This commit is contained in:
Vanessa 2023-12-20 16:45:06 +08:00
parent 5ff968412a
commit ffc9164e08
4 changed files with 11 additions and 7 deletions

View file

@ -403,7 +403,7 @@ export class Wnd {
} }
} }
public switchTab(target: HTMLElement, pushBack = false, update = true, resize = true) { public switchTab(target: HTMLElement, pushBack = false, update = true, resize = true, isSaveLayout = true) {
let currentTab: Tab; let currentTab: Tab;
this.children.forEach((item) => { this.children.forEach((item) => {
if (target === item.headElement) { if (target === item.headElement) {
@ -431,7 +431,9 @@ export class Wnd {
if (initData) { if (initData) {
currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData))); currentTab.addModel(newModelByInitData(this.app, currentTab, JSON.parse(initData)));
currentTab.headElement.removeAttribute("data-initdata"); currentTab.headElement.removeAttribute("data-initdata");
saveLayout(); if (isSaveLayout) {
saveLayout();
}
return; return;
} }
} }
@ -492,7 +494,9 @@ export class Wnd {
resize, resize,
}); });
} }
saveLayout(); if (isSaveLayout) {
saveLayout();
}
} }
public addTab(tab: Tab, keepCursor = false, isSaveLayout = true) { public addTab(tab: Tab, keepCursor = false, isSaveLayout = true) {

View file

@ -365,8 +365,8 @@ export class Dock {
if ((type === "graph" || type === "globalGraph") && this.layout.element.querySelector(".fullscreen")) { if ((type === "graph" || type === "globalGraph") && this.layout.element.querySelector(".fullscreen")) {
document.getElementById("drag")?.classList.remove("fn__hidden"); document.getElementById("drag")?.classList.remove("fn__hidden");
} }
// 关闭 dock 后设置光标 // 关闭 dock 后设置光标,初始化的时候不能设置,否则关闭文档树且多页签时会请求两次 getDoc
if (!document.querySelector(".layout__center .layout__wnd--active")) { if (saveLayout && !document.querySelector(".layout__center .layout__wnd--active")) {
const currentElement = document.querySelector(".layout__center ul.layout-tab-bar .item--focus"); const currentElement = document.querySelector(".layout__center ul.layout-tab-bar .item--focus");
if (currentElement) { if (currentElement) {
getAllTabs().find(item => { getAllTabs().find(item => {

View file

@ -474,7 +474,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => { document.querySelectorAll('li[data-type="tab-header"][data-init-active="true"]').forEach((item: HTMLElement) => {
item.removeAttribute("data-init-active"); item.removeAttribute("data-init-active");
const tab = getInstanceById(item.getAttribute("data-id")) as Tab; const tab = getInstanceById(item.getAttribute("data-id")) as Tab;
tab.parent.switchTab(item, false, false); tab.parent.switchTab(item, false, false, true, false);
}); });
} }
resizeTopBar(); resizeTopBar();

View file

@ -247,7 +247,7 @@ const setHTML = (options: {
onGet({data: getResponse, protyle, action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]}); onGet({data: getResponse, protyle, action: [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]});
}); });
} }
if (options.scrollAttr && !protyle.scroll.element.classList.contains("fn__none")) { if (options.scrollAttr && !protyle.scroll.element.classList.contains("fn__none") && !protyle.element.classList.contains("fn__none")) {
// 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index // 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId); protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
// https://github.com/siyuan-note/siyuan/issues/8224 // https://github.com/siyuan-note/siyuan/issues/8224