From 6f8c1176f508e785219d9133b54e4fc5006eb2fd Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 16 Feb 2024 22:30:17 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/10237 --- app/src/layout/Wnd.ts | 12 +++++++----- app/src/layout/util.ts | 6 +++--- app/src/protyle/wysiwyg/index.ts | 2 +- app/src/util/assets.ts | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 49d293b32..abab03063 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -696,7 +696,7 @@ export class Wnd { model.send("closews", {}); } - private removeTabAction = (id: string, closeAll = false, animate = true) => { + private removeTabAction = (id: string, closeAll = false, animate = true, isSaveLayout = true) => { clearCounter(); this.children.find((item, index) => { if (item.id === id) { @@ -792,7 +792,9 @@ export class Wnd { setTitle(window.siyuan.languages.siyuanNote); } } - saveLayout(); + if (isSaveLayout) { + saveLayout(); + } /// #if !BROWSER webFrame.clearCache(); ipcRenderer.send(Constants.SIYUAN_CMD, "clearCache"); @@ -800,7 +802,7 @@ export class Wnd { /// #endif }; - public removeTab(id: string, closeAll = false, animate = true) { + public removeTab(id: string, closeAll = false, animate = true, isSaveLayout = true) { for (let index = 0; index < this.children.length; index++) { const item = this.children[index]; if (item.id === id) { @@ -809,9 +811,9 @@ export class Wnd { showMessage(window.siyuan.languages.uploading); return; } - this.removeTabAction(id, closeAll, animate); + this.removeTabAction(id, closeAll, animate, isSaveLayout); } else { - this.removeTabAction(id, closeAll, animate); + this.removeTabAction(id, closeAll, animate, isSaveLayout); } return; } diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts index a2f3a2a0a..d54279dbc 100644 --- a/app/src/layout/util.ts +++ b/app/src/layout/util.ts @@ -428,7 +428,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => { if (!sessionStorage.getItem(Constants.LOCAL_SESSION_FIRSTLOAD)) { getAllTabs().forEach(item => { if (item.headElement && !item.headElement.classList.contains("item--pin")) { - item.parent.removeTab(item.id, false, false); + item.parent.removeTab(item.id, false, false, false); } }); sessionStorage.setItem(Constants.LOCAL_SESSION_FIRSTLOAD, "true"); @@ -437,7 +437,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => { if (isStart) { getAllTabs().forEach(item => { if (item.headElement && !item.headElement.classList.contains("item--pin")) { - item.parent.removeTab(item.id, false, false); + item.parent.removeTab(item.id, false, false, false); } }); } @@ -460,7 +460,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => { const tabId = item.getAttribute("data-id"); const tab = getInstanceById(tabId) as Tab; if (tab) { - tab.parent.removeTab(tabId, false, false); + tab.parent.removeTab(tabId, false, false, false); } } } diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 17644add4..ba7c7d3ea 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -2398,7 +2398,7 @@ export class WYSIWYG { // 选中后,在选中的文字上点击需等待 range 更新 let newRange = getEditorRange(this.element); // https://github.com/siyuan-note/siyuan/issues/10357 - const attrElement = hasClosestByClassName(newRange.endContainer, "protyle-attr") + const attrElement = hasClosestByClassName(newRange.endContainer, "protyle-attr"); if (attrElement) { newRange = setLastNodeRange(attrElement.previousElementSibling, newRange, false); } diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts index 848b89f9c..cf1ca75b8 100644 --- a/app/src/util/assets.ts +++ b/app/src/util/assets.ts @@ -40,7 +40,7 @@ export const loadAssets = (data: IAppearance) => { const defaultThemeAddress = `/appearance/themes/${data.mode === 1 ? "midnight" : "daylight"}/theme.css?v=${Constants.SIYUAN_VERSION}`; if (defaultStyleElement) { if (!defaultStyleElement.getAttribute("href").startsWith(defaultThemeAddress)) { - defaultStyleElement.setAttribute("href", defaultThemeAddress) + defaultStyleElement.setAttribute("href", defaultThemeAddress); } } else { addStyle(defaultThemeAddress, "themeDefaultStyle"); @@ -50,7 +50,7 @@ export const loadAssets = (data: IAppearance) => { const themeAddress = `/appearance/themes/${data.mode === 1 ? data.themeDark : data.themeLight}/theme.css?v=${data.themeVer}`; if (styleElement) { if (!styleElement.getAttribute("href").startsWith(themeAddress)) { - styleElement.setAttribute("href", themeAddress) + styleElement.setAttribute("href", themeAddress); } } else { addStyle(themeAddress, "themeStyle");