Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/5189

Vanessa56dc05740ae5
diff --git a/app/src/layout/util.ts b/app/src/layout/util.ts
index d98a744781..0e2117afd1 100644
--- a/app/src/layout/util.ts
+++ b/app/src/layout/util.ts
@@ -181,7 +181,10 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
child.element.classList.remove("fn__flex-1");
child.element.style.height = json.height;
}
- } else if (json.instance === "Tab") {
+ } else if (json.instance === "Tab" && (
+ (window.siyuan.config.fileTree.closeTabsOnStart && json.pin) ||
+ !window.siyuan.config.fileTree.closeTabsOnStart)
+ ) {
if (!json.title) {
child = newCenterEmptyTab();
} else {
@@ -205,14 +208,14 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
child.headElement.setAttribute("data-init-active", "true");
}
(layout as Wnd).addTab(child);
- } else if (json.instance === "Editor" && json.blockId) {
+ } else if (json.instance === "Editor" && json.blockId && layout) {
(layout as Tab).addModel(new Editor({
tab: (layout as Tab),
blockId: json.blockId,
mode: json.mode,
action: [json.action]
}));
- } else if (json.instance === "Asset") {
+ } else if (json.instance === "Asset" && layout) {
(layout as Tab).addModel(new Asset({
tab: (layout as Tab),
path: json.path,
@@ -230,22 +233,22 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
(layout as Tab).addModel(new Files({
tab: (layout as Tab),
}));
- } else if (json.instance === "Graph") {
+ } else if (json.instance === "Graph" && layout) {
(layout as Tab).addModel(new Graph({
tab: (layout as Tab),
blockId: json.blockId,
rootId: json.rootId,
type: json.type
}));
- } else if (json.instance === "Outline") {
+ } else if (json.instance === "Outline" && layout) {
(layout as Tab).addModel(new Outline({
tab: (layout as Tab),
blockId: json.blockId,
type: json.type
}));
- } else if (json.instance === "Tag") {
+ } else if (json.instance === "Tag" && layout) {
(layout as Tab).addModel(new Tag((layout as Tab)));
- } else if (json.instance === "Search") {
+ } else if (json.instance === "Search" && layout) {
(layout as Tab).addModel(new Search({
tab: (layout as Tab),
text: json.text
@@ -272,6 +275,10 @@ const JSONToCenter = (json: any, layout?: Layout | Wnd | Tab | Model) => {
export const JSONToLayout = () => {
JSONToCenter(window.siyuan.config.uiLayout.layout);
JSONToDock(window.siyuan.config.uiLayout);
+ // 启动时不打开页签且没有钉住的页签,需要添加空白页
+ if (window.siyuan.layout.centerLayout.children[0].children.length === 0) {
+ (window.siyuan.layout.centerLayout.children[0] as Wnd).addTab(newCenterEmptyTab());
+ }
setTimeout(() => {
getAllModels().editor.find(item => {
if (item.headElement.classList.contains("item--focus")) {