diff --git a/app/src/boot/globalEvent/keydown.ts b/app/src/boot/globalEvent/keydown.ts index 5ca1a3b91..f05e177a3 100644 --- a/app/src/boot/globalEvent/keydown.ts +++ b/app/src/boot/globalEvent/keydown.ts @@ -287,7 +287,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => { event.preventDefault(); return true; } - if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event)) { + if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.quickMakeCard.custom, event) && !window.siyuan.config.readonly) { if (protyle.title?.editElement.contains(range.startContainer)) { quickMakeCard(protyle, [protyle.title.element]); } else { @@ -316,7 +316,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => { event.preventDefault(); return true; } - if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) { + if (!isFileFocus && matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) { fetchPost("/api/riff/getTreeRiffDueCards", {rootID: protyle.block.rootID}, (response) => { openCardByData(app, response.data, "doc", protyle.block.rootID, protyle.title?.editElement.textContent || window.siyuan.languages.untitled); }); @@ -593,7 +593,7 @@ const fileTreeKeydown = (app: App, event: KeyboardEvent) => { const pathString = liElements[0].getAttribute("data-path"); const isFile = liElements[0].getAttribute("data-type") === "navigation-file"; - if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event)) { + if (matchHotKey(window.siyuan.config.keymap.editor.general.spaceRepetition.custom, event) && !window.siyuan.config.readonly) { if (isFile) { const id = liElements[0].getAttribute("data-node-id"); fetchPost("/api/riff/getTreeRiffDueCards", {rootID: id}, (response) => { diff --git a/app/src/card/openCard.ts b/app/src/card/openCard.ts index 804a3403a..b10998479 100644 --- a/app/src/card/openCard.ts +++ b/app/src/card/openCard.ts @@ -672,6 +672,9 @@ const emitEvent = (app: App, card: ICard, type: string) => { }; export const openCard = (app: App) => { + if (window.siyuan.config.readonly) { + return + } fetchPost("/api/riff/getRiffDueCards", {deckID: ""}, (cardsResponse) => { openCardByData(app, cardsResponse.data, "all"); }); diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 102acc26f..851b2c65e 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -310,12 +310,10 @@ export const editor = { if (fontFamilyElement.tagName === "SELECT") { let fontFamilyHTML = ``; fetchPost("/api/system/getSysFonts", {}, (response) => { - if (response.code === 0) { - response.data.forEach((item: string) => { - fontFamilyHTML += ``; - }); - fontFamilyElement.innerHTML = fontFamilyHTML; - } + response.data.forEach((item: string) => { + fontFamilyHTML += ``; + }); + fontFamilyElement.innerHTML = fontFamilyHTML; }); } editor.element.querySelector("#clearHistory").addEventListener("click", () => { diff --git a/app/src/index.ts b/app/src/index.ts index c666a0cc1..0bcd88cf5 100644 --- a/app/src/index.ts +++ b/app/src/index.ts @@ -38,8 +38,6 @@ export class App { registerServiceWorker(`${Constants.SERVICE_WORKER_PATH}?v=${Constants.SIYUAN_VERSION}`); /// #endif addBaseURL(); - addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"), - addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"), this.appId = Constants.SIYUAN_APPID; window.siyuan = { @@ -160,40 +158,24 @@ export class App { }; fetchPost("/api/system/getConf", {}, async (response) => { + addScriptSync(`${Constants.PROTYLE_CDN}/js/lute/lute.min.js?v=${Constants.SIYUAN_VERSION}`, "protyleLuteScript"); + addScript(`${Constants.PROTYLE_CDN}/js/protyle-html.js?v=${Constants.SIYUAN_VERSION}`, "protyleWcHtmlScript"); window.siyuan.config = response.data.conf; - - const promises = [ - loadPlugins(this), - new Promise(resolve => getLocalStorage(resolve)), - new Promise(resolve => fetchGet( - `/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, - (lauguages: IObject) => { - window.siyuan.languages = lauguages; - resolve(); - }, - )), - ]; - - if (!window.siyuan.config.readonly) { - promises.push(new Promise(resolve => { + await loadPlugins(this); + getLocalStorage(() => { + fetchGet(`/appearance/langs/${window.siyuan.config.appearance.lang}.json?v=${Constants.SIYUAN_VERSION}`, (lauguages: IObject) => { + window.siyuan.languages = lauguages; + window.siyuan.menus = new Menus(this); + bootSync(); fetchPost("/api/setting/getCloudUser", {}, userResponse => { window.siyuan.user = userResponse.data; - resolve(); + onGetConfig(response.data.start, this); + account.onSetaccount(); + setTitle(window.siyuan.languages.siyuanNote); + initMessage(); }); - })); - } - - await Promise.all(promises); - - if (!window.siyuan.config.readonly) { - bootSync(); - } - - window.siyuan.menus = new Menus(this); - onGetConfig(response.data.start, this); - account.onSetaccount(); - setTitle(window.siyuan.languages.siyuanNote); - initMessage(); + }); + }); }); setNoteBook(); initBlockPopover(this); diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index a2fd12273..64d18dae6 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -67,7 +67,7 @@ export class Wnd {