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/11782

Vanessa814a4ec3ac42
diff --git a/app/src/boot/globalEvent/command/global.ts b/app/src/boot/globalEvent/command/global.ts
index 356f57132f..44b9db954e 100644
--- a/app/src/boot/globalEvent/command/global.ts
+++ b/app/src/boot/globalEvent/command/global.ts
@@ -46,7 +46,7 @@ const selectOpenTab = () => {
/// #if MOBILE
if (window.siyuan.mobile.editor?.protyle) {
openDock("file");
- window.siyuan.mobile.files.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);
+ window.siyuan.mobile.docks.file.selectItem(window.siyuan.mobile.editor.protyle.notebookId, window.siyuan.mobile.editor.protyle.path);
}
/// #else
const dockFile = getDockByType("file");
diff --git a/app/src/dialog/processSystem.ts b/app/src/dialog/processSystem.ts
index 972fb8403a..93949e6cdb 100644
--- a/app/src/dialog/processSystem.ts
+++ b/app/src/dialog/processSystem.ts
@@ -71,7 +71,7 @@ export const reloadSync = (
}
}
setNoteBook(() => {
- window.siyuan.mobile.files.init(false);
+ window.siyuan.mobile.docks.file.init(false);
});
/// #else
const allModels = getAllModels();
@@ -215,7 +215,7 @@ export const setDefRefCount = (data: {
let liElement;
/// #if MOBILE
- liElement = window.siyuan.mobile.files.element.querySelector(`li[data-node-id="${data.rootID}"]`);
+ liElement = window.siyuan.mobile.docks.file.element.querySelector(`li[data-node-id="${data.rootID}"]`);
/// #else
liElement = (getDockByType("file").data.file as Files).element.querySelector(`li[data-node-id="${data.rootID}"]`);
/// #endif
diff --git a/app/src/menus/navigation.ts b/app/src/menus/navigation.ts
index 5f1c6fa7a3..2baf073234 100644
--- a/app/src/menus/navigation.ts
+++ b/app/src/menus/navigation.ts
@@ -190,7 +190,7 @@ export const initNavigationMenu = (app: App, liElement: HTMLElement) => {
liElement.parentElement.setAttribute("data-sortmode", sort.toString());
let files;
/// #if MOBILE
- files = window.siyuan.mobile.files;
+ files = window.siyuan.mobile.docks.file;
/// #else
files = (getDockByType("file").data["file"] as Files);
/// #endif
@@ -671,7 +671,7 @@ export const genImportMenu = (notebookId: string, pathString: string) => {
const reloadDocTree = () => {
let files;
/// #if MOBILE
- files = window.siyuan.mobile.files;
+ files = window.siyuan.mobile.docks.file;
/// #else
files = (getDockByType("file").data["file"] as Files);
/// #endif
diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts
index 104ece816f..0c46f3cfde 100644
--- a/app/src/mobile/index.ts
+++ b/app/src/mobile/index.ts
@@ -47,7 +47,16 @@ class App {
backStack: [],
dialogs: [],
blockPanels: [],
- mobile: {},
+ mobile: {
+ docks: {
+ outline: null,
+ file: null,
+ bookmark: null,
+ tag: null,
+ backlink: null,
+ inbox: null,
+ }
+ },
ws: new Model({
app: this,
id: genUUID(),
@@ -149,7 +158,7 @@ const siyuanApp = new App();
// https://github.com/siyuan-note/siyuan/issues/8441
window.reconnectWebSocket = () => {
window.siyuan.ws.send("ping", {});
- window.siyuan.mobile.files.send("ping", {});
+ window.siyuan.mobile.docks.file.send("ping", {});
window.siyuan.mobile.editor.protyle.ws.send("ping", {});
window.siyuan.mobile.popEditor.protyle.ws.send("ping", {});
};
diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts
index 1a99ea29e6..152003abe7 100644
--- a/app/src/mobile/util/initFramework.ts
+++ b/app/src/mobile/util/initFramework.ts
@@ -62,11 +62,6 @@ export const initFramework = (app: App, isStart: boolean) => {
renderSnippet();
initKeyboardToolbar();
const sidebarElement = document.getElementById("sidebar");
- let outline: MobileOutline;
- let backlink: MobileBacklinks;
- let bookmark: MobileBookmarks;
- let inbox: Inbox;
- let tag: MobileTags;
// 不能使用 getEventName,否则点击返回会展开右侧栏
const firstToolbarElement = sidebarElement.querySelector(".toolbar--border");
firstToolbarElement.addEventListener("click", (event: MouseEvent) => {
@@ -99,31 +94,31 @@ export const initFramework = (app: App, isStart: boolean) => {
const tabPanelElement = sidebarElement.lastElementChild.querySelector(`[data-type="${itemType.replace("-tab", "")}"]`);
if (itemType === type) {
if (type === "sidebar-outline-tab") {
- if (!outline) {
- outline = new MobileOutline(app);
+ if (!window.siyuan.mobile.docks.outline) {
+ window.siyuan.mobile.docks.outline = new MobileOutline(app);
} else {
- outline.update();
+ window.siyuan.mobile.docks.outline.update();
}
} else if (type === "sidebar-backlink-tab") {
- if (!backlink) {
- backlink = new MobileBacklinks(app);
+ if (!window.siyuan.mobile.docks.backlink) {
+ window.siyuan.mobile.docks.backlink = new MobileBacklinks(app);
} else {
- backlink.update();
+ window.siyuan.mobile.docks.backlink.update();
}
} else if (type === "sidebar-bookmark-tab") {
- if (!bookmark) {
- bookmark = new MobileBookmarks(app);
+ if (!window.siyuan.mobile.docks.bookmark) {
+ window.siyuan.mobile.docks.bookmark = new MobileBookmarks(app);
} else {
- bookmark.update();
+ window.siyuan.mobile.docks.bookmark.update();
}
} else if (type === "sidebar-tag-tab") {
- if (!tag) {
- tag = new MobileTags(app);
+ if (!window.siyuan.mobile.docks.tag) {
+ window.siyuan.mobile.docks.tag = new MobileTags(app);
} else {
- tag.update();
+ window.siyuan.mobile.docks.tag.update();
}
- } else if (type === "sidebar-inbox-tab" && !inbox) {
- inbox = new Inbox(app, document.querySelector('#sidebar [data-type="sidebar-inbox"]'));
+ } else if (type === "sidebar-inbox-tab" && !window.siyuan.mobile.docks.inbox) {
+ window.siyuan.mobile.docks.inbox = new Inbox(app, document.querySelector('#sidebar [data-type="sidebar-inbox"]'));
} else if (type === "sidebar-plugin-tab") {
if (!custom) {
tabPanelElement.innerHTML = `<div class="b3-list--empty">${window.siyuan.languages.emptyContent}</div>`;
@@ -140,20 +135,20 @@ export const initFramework = (app: App, isStart: boolean) => {
}
});
});
- window.siyuan.mobile.files = new MobileFiles(app);
+ window.siyuan.mobile.docks.files = new MobileFiles(app);
document.getElementById("toolbarFile").addEventListener("click", () => {
hideKeyboardToolbar();
activeBlur();
sidebarElement.style.transform = "translateX(0px)";
const type = sidebarElement.querySelector(".toolbar--border .toolbar__icon--active").getAttribute("data-type");
if (type === "sidebar-outline-tab") {
- outline.update();
+ window.siyuan.mobile.docks.outline.update();
} else if (type === "sidebar-backlink-tab") {
- backlink.update();
+ window.siyuan.mobile.docks.backlink.update();
} else if (type === "sidebar-bookmark-tab") {
- bookmark.update();
+ window.siyuan.mobile.docks.bookmark.update();
} else if (type === "sidebar-tag-tab") {
- tag.update();
+ window.siyuan.mobile.docks.tag.update();
}
});
// 用 touchstart 会导致键盘不收起
diff --git a/app/src/plugin/API.ts b/app/src/plugin/API.ts
index be984db7ea..1c7529178b 100644
--- a/app/src/plugin/API.ts
+++ b/app/src/plugin/API.ts
@@ -166,6 +166,14 @@ openTab = (options: {
};
/// #endif
+const getModelByDockType = (type: TDock | string) => {
+ /// #if MOBILE
+ return window.siyuan.mobile.docks[type];
+ /// #else
+ return getDockByType(type).data[type];
+ /// #endif
+}
+
export const API = {
adaptHotkey: updateHotkeyTip,
confirm: confirmDialog,
@@ -176,7 +184,7 @@ export const API = {
fetchGet,
getFrontend,
getBackend,
- getDockByType,
+ getModelByDockType,
openTab,
openWindow,
openMobileFileById,
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 5c1fd76be3..e00f29a2e4 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -376,7 +376,14 @@ interface ISiyuan {
mobile?: {
editor?: import("../protyle").Protyle
popEditor?: import("../protyle").Protyle
- files?: import("../mobile/dock/MobileFiles").MobileFiles
+ docks?: {
+ outline: import("../mobile/dock/MobileOutline").MobileOutline | null,
+ file: import("../mobile/dock/MobileFiles").MobileFiles | null,
+ bookmark: import("../mobile/dock/MobileBookmarks").MobileBookmarks | null,
+ tag: import("../mobile/dock/MobileTags").MobileTags | null,
+ backlink: import("../mobile/dock/MobileBacklinks").MobileBacklinks | null,
+ inbox: import("../layout/dock/Inbox").Inbox | null,
+ } & { [key: string]: import("../layout/Model").Model | boolean };
},
user?: {
userId: string