From 1088cf163b492949cfc29df318852cd752bbbd48 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 3 Mar 2025 22:21:55 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/14266 --- app/src/config/fileTree.ts | 5 +- app/src/mobile/menu/index.ts | 9 ++++ app/src/mobile/settings/fileTree.ts | 81 +++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 app/src/mobile/settings/fileTree.ts diff --git a/app/src/config/fileTree.ts b/app/src/config/fileTree.ts index 12461f93d..4822f4028 100644 --- a/app/src/config/fileTree.ts +++ b/app/src/config/fileTree.ts @@ -116,7 +116,7 @@ export const fileTree = { maxListCount: parseInt((fileTree.element.querySelector("#maxListCount") as HTMLInputElement).value), maxOpenTabCount: inputMaxOpenTabCount, }, response => { - fileTree.onSetfiletree(response.data); + window.siyuan.config.fileTree = response.data; }); }, bindEvent: () => { @@ -127,8 +127,5 @@ export const fileTree = { fileTree._send(); }); }); - }, - onSetfiletree: (fileTree: Config.IFileTree) => { - window.siyuan.config.fileTree = fileTree; } }; diff --git a/app/src/mobile/menu/index.ts b/app/src/mobile/menu/index.ts index da6684c27..416d2d275 100644 --- a/app/src/mobile/menu/index.ts +++ b/app/src/mobile/menu/index.ts @@ -28,6 +28,7 @@ import {newFile} from "../../util/newFile"; import {afterLoadPlugin} from "../../plugin/loader"; import {commandPanel} from "../../boot/globalEvent/command/panel"; import {openTopBarMenu} from "../../plugin/openTopBarMenu"; +import {initFileTree} from "../settings/fileTree"; export const popMenu = () => { activeBlur(); @@ -103,6 +104,9 @@ export const initRightMenu = (app: App) => { + @@ -177,6 +181,11 @@ export const initRightMenu = (app: App) => { event.preventDefault(); event.stopPropagation(); break; + } else if (target.id === "menuFileTree") { + initFileTree(); + event.preventDefault(); + event.stopPropagation(); + break; } else if (target.id === "menuSafeQuit") { event.preventDefault(); event.stopPropagation(); diff --git a/app/src/mobile/settings/fileTree.ts b/app/src/mobile/settings/fileTree.ts new file mode 100644 index 000000000..7dc32c7e7 --- /dev/null +++ b/app/src/mobile/settings/fileTree.ts @@ -0,0 +1,81 @@ +import {openModel} from "../menu/model"; +import {fetchPost} from "../../util/fetch"; +import {genNotebookOption} from "../../menus/onGetnotebookconf"; + +export const initFileTree = () => { + openModel({ + title: window.siyuan.languages.editor, + icon: "iconEdit", + html: ` + + +
+ ${window.siyuan.languages.fileTree16} + + +
${window.siyuan.languages.fileTree17}
+
+
+ ${window.siyuan.languages.fileTree12} + + + + +
${window.siyuan.languages.fileTree13}
+
+
+ ${window.siyuan.languages.fileTree5} + + + + +
${window.siyuan.languages.fileTree6}
+
`, + bindEvent(modelMainElement: HTMLElement) { + (modelMainElement.querySelector("#docCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.docCreateSavePath; + (modelMainElement.querySelector("#refCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.refCreateSavePath; + modelMainElement.querySelectorAll("input, select").forEach((item) => { + item.addEventListener("change", () => { + fetchPost("/api/setting/setFiletree", { + sort: window.siyuan.config.fileTree.sort, + alwaysSelectOpenedFile: window.siyuan.config.fileTree.alwaysSelectOpenedFile, + refCreateSavePath: (modelMainElement.querySelector("#refCreateSavePath") as HTMLInputElement).value, + refCreateSaveBox: (modelMainElement.querySelector("#refCreateSaveBox") as HTMLInputElement).value, + docCreateSavePath: (modelMainElement.querySelector("#docCreateSavePath") as HTMLInputElement).value, + docCreateSaveBox: (modelMainElement.querySelector("#docCreateSaveBox") as HTMLInputElement).value, + openFilesUseCurrentTab: window.siyuan.config.fileTree.openFilesUseCurrentTab, + closeTabsOnStart: window.siyuan.config.fileTree.closeTabsOnStart, + allowCreateDeeper: (modelMainElement.querySelector("#allowCreateDeeper") as HTMLInputElement).checked, + removeDocWithoutConfirm: (modelMainElement.querySelector("#removeDocWithoutConfirm") as HTMLInputElement).checked, + useSingleLineSave: (modelMainElement.querySelector("#useSingleLineSave") as HTMLInputElement).checked, + maxListCount: parseInt((modelMainElement.querySelector("#maxListCount") as HTMLInputElement).value), + maxOpenTabCount: window.siyuan.config.fileTree.maxOpenTabCount, + }, response => { + window.siyuan.config.fileTree = response.data; + }); + }); + }); + } + }); +};