Vanessa 2023-05-15 13:54:30 +08:00
parent dc1941da3c
commit 15141dde1f
11 changed files with 44 additions and 32 deletions

View file

@ -1,4 +1,5 @@
{
"cloudConfigTip": "Please configure in [Settings - Cloud]",
"confirmUninstall": "Are you sure you want to uninstall ${name}?",
"scrollGetMore": "Don't panic... scroll up and down to load more",
"flashcardNewCard": "New",

View file

@ -1,4 +1,5 @@
{
"cloudConfigTip": "Configure en [Configuración - Nube]",
"confirmUninstall": "¿Está seguro de que desea desinstalar ${name}?",
"scrollGetMore": "No se asuste... desplácese hacia arriba y hacia abajo para cargar más",
"flashcardNewCard": "Nueva Tarjeta",

View file

@ -1,4 +1,5 @@
{
"cloudConfigTip": "Veuillez configurer dans [Paramètres - Cloud]",
"confirmUninstall": "Êtes-vous sûr de vouloir désinstaller ${name} ?",
"scrollGetMore": "Ne paniquez pas... faites défiler de haut en bas pour en charger plus",
"flashcardNewCard": "Nouvelle carte",

View file

@ -1,4 +1,5 @@
{
"cloudConfigTip": "請在 [設置 - 雲端] 中進行配置",
"confirmUninstall": "確定卸載 ${name} ",
"scrollGetMore": "不要驚慌...上下滾動即可加載更多內容",
"flashcardNewCard": "新卡",

View file

@ -1,4 +1,5 @@
{
"cloudConfigTip": "请在 [设置 - 云端] 中进行配置",
"confirmUninstall": "确定卸载 ${name} ",
"scrollGetMore": "不要惊慌...上下滚动即可加载更多内容",
"flashcardNewCard": "新卡",

View file

@ -593,7 +593,7 @@ export const globalShortcut = (app: App) => {
if (!isTabWindow && matchHotKey(window.siyuan.config.keymap.general.syncNow.custom, event)) {
event.preventDefault();
syncGuide(document.querySelector("#barSync"));
syncGuide(app);
return;
}
if (matchHotKey(window.siyuan.config.keymap.general.editMode.custom, event)) {

View file

@ -362,22 +362,16 @@ ${window.siyuan.languages.account9}
_afterLogin(userResponse: IWebSocketData, element: Element) {
window.siyuan.user = userResponse.data;
processSync();
if (element.classList.contains("account") && !needSubscribe("")) {
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement) {
window.siyuan.dialogs.find((item) => {
if (item.element.isSameNode(dialogElement)) {
item.destroy();
return true;
}
});
syncGuide();
return;
}
}
element.innerHTML = account.genHTML();
account.bindEvent(element);
account.onSetaccount();
if (element.getAttribute("data-action") === "go-repos") {
const dialogElement = hasClosestByClassName(element, "b3-dialog--open");
if (dialogElement) {
dialogElement.querySelector('.b3-tab-bar [data-name="repos"]').dispatchEvent(new CustomEvent("click"));
element.removeAttribute("data-action");
}
}
},
onSetaccount() {
if (repos.element) {

View file

@ -73,7 +73,7 @@ export const initBar = (app: App) => {
event.stopPropagation();
break;
} else if (target.id === "barSync") {
syncGuide(target);
syncGuide(app);
event.stopPropagation();
break;
} else if (target.id === "barWorkspace") {

View file

@ -74,7 +74,7 @@ class App {
window.siyuan.user = userResponse.data;
fetchPost("/api/system/getEmojiConf", {}, emojiResponse => {
window.siyuan.emojis = emojiResponse.data as IEmoji[];
initFramework();
initFramework(siyuanApp);
initRightMenu();
loadPlugins(siyuanApp);
openChangelog();

View file

@ -18,8 +18,9 @@ import {MobileTags} from "../dock/MobileTags";
import {activeBlur, hideKeyboardToolbar, initKeyboardToolbar} from "./keyboardToolbar";
import {syncGuide} from "../../sync/syncGuide";
import {Inbox} from "../../layout/dock/Inbox";
import {App} from "../../index";
export const initFramework = () => {
export const initFramework = (app: App) => {
setInlineStyle();
renderSnippet();
initKeyboardToolbar();
@ -122,7 +123,7 @@ export const initFramework = () => {
fetchPost("/api/setting/setEditor", window.siyuan.config.editor);
});
document.getElementById("toolbarSync").addEventListener(getEventName(), () => {
syncGuide();
syncGuide(app);
});
if (navigator.userAgent.indexOf("iPhone") > -1 && !window.siyuan.config.readonly && !window.siyuan.config.editor.readOnly) {
// 不知道为什么 iPhone 中如果是编辑状态,点击文档后无法点击标题

View file

@ -4,8 +4,9 @@ import {fetchPost} from "../util/fetch";
import {Dialog} from "../dialog";
import {confirmDialog} from "../dialog/confirmDialog";
import {isMobile} from "../util/functions";
import {account} from "../config/account";
import {processSync} from "../dialog/processSystem";
import {openSetting} from "../config";
import {App} from "../index";
export const addCloudName = (cloudPanelElement: Element) => {
const dialog = new Dialog({
@ -82,7 +83,15 @@ export const getSyncCloudList = (cloudPanelElement: Element, reload = false, cb?
fetchPost("/api/sync/listCloudSyncDir", {}, (response) => {
let syncListHTML = `<div class="fn__hr"></div><ul><li style="padding: 0 16px" class="b3-list--empty">${window.siyuan.languages.emptyCloudSyncList}</li></ul>`;
if (response.code === 1) {
syncListHTML = `<div class="fn__hr"></div><ul><li style="padding: 0 16px" class="b3-list--empty ft__error">${response.msg}</li></ul>`;
syncListHTML = `<div class="fn__hr"></div>
<ul>
<li class="b3-list--empty ft__error">
${response.msg}
</li>
<li class="b3-list--empty">
${window.siyuan.languages.cloudConfigTip}
</li>
</ul>`;
} else if (response.code !== 1) {
syncListHTML = '<div class="fn__hr"></div><ul class="b3-list b3-list--background fn__flex-1" style="overflow: auto;">';
response.data.syncDirs.forEach((item: { hSize: string, cloudName: string, updated: string }) => {
@ -131,25 +140,28 @@ export const getSyncCloudList = (cloudPanelElement: Element, reload = false, cb?
});
};
export const syncGuide = (element?: Element) => {
export const syncGuide = (app?: App) => {
if (window.siyuan.config.readonly) {
return;
}
if (element && element.classList.contains("toolbar__item--active")) {
return;
}
if (isMobile()) {
if (0 === window.siyuan.config.sync.provider && needSubscribe()) {
return;
}
} else if (0 === window.siyuan.config.sync.provider && needSubscribe("")) {
const dialog = new Dialog({
title: window.siyuan.languages.account,
content: `<div class="account" style="background-color: var(--b3-theme-background)">${account.genHTML()}</div>`,
width: "80vw",
});
account.bindEvent(dialog.element.querySelector(".account"));
return;
} else {
if (document.querySelector("#barSync")?.classList.contains("toolbar__item--active")) {
return;
}
if (0 === window.siyuan.config.sync.provider && needSubscribe("") && app) {
const dialogSetting = openSetting(app);
if (window.siyuan.user) {
dialogSetting.element.querySelector('.b3-tab-bar [data-name="repos"]').dispatchEvent(new CustomEvent("click"));
} else {
dialogSetting.element.querySelector('.b3-tab-bar [data-name="account"]').dispatchEvent(new CustomEvent("click"));
dialogSetting.element.querySelector('.config__tab-container[data-name="account"]').setAttribute("data-action", "go-repos");
}
return;
}
}
if (!window.siyuan.config.repo.key) {
setKey();