Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/17354

Vanessaa0add9a0a442
diff --git a/app/src/layout/getAll.ts b/app/src/layout/getAll.ts
index d104e9b925..bbe0d4bae4 100644
--- a/app/src/layout/getAll.ts
+++ b/app/src/layout/getAll.ts
@@ -123,13 +123,45 @@ export const getAllWnds = (layout: Layout, wnds: Wnd[]) => {
}
};
-export const getAllTabs = () => {
+export const getAllTabs = (type?: TTab | string) => {
const tabs: Tab[] = [];
const getTabs = (layout: Layout) => {
for (let i = 0; i < layout.children.length; i++) {
const item = layout.children[i];
if (item instanceof Tab) {
- tabs.push(item);
+ if (type) {
+ if (item.model) {
+ if (item.model instanceof Search && type === "Search") {
+ tabs.push(item);
+ } else if (item.model instanceof Asset && type === "Asset") {
+ tabs.push(item);
+ } else if (item.model instanceof Editor && type === "Editor") {
+ tabs.push(item);
+ } else if (item.model instanceof Graph && type === "Graph") {
+ tabs.push(item);
+ } else if (item.model instanceof Backlink && type === "Backlink") {
+ tabs.push(item);
+ } else if (item.model instanceof Outline && type === "Outline") {
+ tabs.push(item);
+ }
+ } else {
+ const initData = item?.headElement?.getAttribute("data-initdata");
+ if (initData) {
+ try {
+ const initObj = JSON.parse(initData);
+ if (initObj.instance === "Custom" && initObj.customModelType === type) {
+ tabs.push(item);
+ } else if (initObj.instance === type) {
+ tabs.push(item);
+ }
+ } catch (e) {
+ console.log(`getAllTabs(${type}) error:`, e);
+ }
+ }
+ }
+ } else {
+ tabs.push(item);
+ }
} else {
getTabs(item as Layout);
}
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 5ccb9e6450..9224c9cf05 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -2,6 +2,7 @@ type TPluginDockPosition = "LeftTop" | "LeftBottom" | "RightTop" | "RightBottom"
type TDockPosition = "Left" | "Right" | "Bottom"
type TWS = "main" | "filetree" | "protyle"
type TDock = "file" | "outline" | "inbox" | "bookmark" | "tag" | "graph" | "globalGraph" | "backlink"
+type TTab = "Outline" | "Graph" | "Backlink" | "Asset" | "Editor" | "Search" | "siyuan-card"
type TOperation =
"insert"
| "update"