2022-05-26 15:18:53 +08:00
|
|
|
import {fetchPost} from "../util/fetch";
|
2024-04-25 20:35:09 +08:00
|
|
|
import {genNotebookOption} from "../menus/onGetnotebookconf";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
|
|
|
export const fileTree = {
|
|
|
|
element: undefined as Element,
|
|
|
|
genHTML: () => {
|
|
|
|
return `<label class="fn__flex b3-label">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.selectOpen}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree2}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-switch fn__flex-center" id="alwaysSelectOpenedFile" type="checkbox"${window.siyuan.config.fileTree.alwaysSelectOpenedFile ? " checked" : ""}/>
|
|
|
|
</label>
|
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree7}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree8}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-switch fn__flex-center" id="openFilesUseCurrentTab" type="checkbox"${window.siyuan.config.fileTree.openFilesUseCurrentTab ? " checked" : ""}/>
|
|
|
|
</label>
|
2022-07-14 11:11:54 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree9}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree10}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-switch fn__flex-center" id="closeTabsOnStart" type="checkbox"${window.siyuan.config.fileTree.closeTabsOnStart ? " checked" : ""}/>
|
|
|
|
</label>
|
2022-05-26 15:18:53 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree18}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree19}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-switch fn__flex-center" id="allowCreateDeeper" type="checkbox"${window.siyuan.config.fileTree.allowCreateDeeper ? " checked" : ""}/>
|
|
|
|
</label>
|
2022-06-18 23:34:14 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree3}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree4}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-switch fn__flex-center" id="removeDocWithoutConfirm" type="checkbox"${window.siyuan.config.fileTree.removeDocWithoutConfirm ? " checked" : ""}/>
|
|
|
|
</label>
|
2023-07-09 22:24:32 +08:00
|
|
|
<label class="fn__flex b3-label">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree20}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree21}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-switch fn__flex-center" id="useSingleLineSave" type="checkbox"${window.siyuan.config.fileTree.useSingleLineSave ? " checked" : ""}/>
|
|
|
|
</label>
|
2025-08-24 10:49:13 +08:00
|
|
|
<div class="fn__flex b3-label config__item">
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree22}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree23}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="largeFileWarningSize" type="number" min="2" max="10240" value="${window.siyuan.config.fileTree.largeFileWarningSize}">
|
|
|
|
</div>
|
2023-12-19 12:20:25 +08:00
|
|
|
<div class="fn__flex b3-label config__item">
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.fileTree16}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree17}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="maxListCount" type="number" min="1" max="10240" value="${window.siyuan.config.fileTree.maxListCount}">
|
2023-12-19 12:20:25 +08:00
|
|
|
</div>
|
|
|
|
<div class="fn__flex b3-label config__item">
|
2022-06-23 11:43:46 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
${window.siyuan.languages.tabLimit}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.tabLimit1}</div>
|
|
|
|
</div>
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="maxOpenTabCount" type="number" min="1" max="32" value="${window.siyuan.config.fileTree.maxOpenTabCount}">
|
2024-04-25 20:35:09 +08:00
|
|
|
</div>
|
|
|
|
<div class="b3-label config__item">
|
|
|
|
${window.siyuan.languages.fileTree12}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
|
|
|
|
<span class="fn__hr"></span>
|
|
|
|
<div class="fn__flex">
|
|
|
|
<select style="min-width: 200px" class="b3-select" id="docCreateSaveBox">${genNotebookOption(window.siyuan.config.fileTree.docCreateSaveBox)}</select>
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
<input class="b3-text-field fn__flex-1" id="docCreateSavePath" value="">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="b3-label config__item">
|
|
|
|
${window.siyuan.languages.fileTree5}
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
|
|
|
|
<span class="fn__hr"></span>
|
|
|
|
<div class="fn__flex">
|
|
|
|
<select style="min-width: 200px" class="b3-select" id="refCreateSaveBox">${genNotebookOption(window.siyuan.config.fileTree.refCreateSaveBox)}</select>
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
<input class="b3-text-field fn__flex-1" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}">
|
|
|
|
</div>
|
2023-12-19 12:20:25 +08:00
|
|
|
</div>`;
|
2022-05-26 15:18:53 +08:00
|
|
|
},
|
|
|
|
_send() {
|
2022-10-22 17:49:00 +08:00
|
|
|
// 限制页签最大打开数量为 `32` https://github.com/siyuan-note/siyuan/issues/6303
|
2022-10-22 17:48:46 +08:00
|
|
|
let inputMaxOpenTabCount = parseInt((fileTree.element.querySelector("#maxOpenTabCount") as HTMLInputElement).value);
|
|
|
|
if (32 < inputMaxOpenTabCount) {
|
|
|
|
inputMaxOpenTabCount = 32;
|
|
|
|
(fileTree.element.querySelector("#maxOpenTabCount") as HTMLInputElement).value = "32";
|
|
|
|
}
|
|
|
|
if (1 > inputMaxOpenTabCount) {
|
|
|
|
inputMaxOpenTabCount = 1;
|
|
|
|
(fileTree.element.querySelector("#maxOpenTabCount") as HTMLInputElement).value = "1";
|
|
|
|
}
|
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
fetchPost("/api/setting/setFiletree", {
|
|
|
|
sort: window.siyuan.config.fileTree.sort,
|
|
|
|
alwaysSelectOpenedFile: (fileTree.element.querySelector("#alwaysSelectOpenedFile") as HTMLInputElement).checked,
|
|
|
|
refCreateSavePath: (fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value,
|
2024-04-25 20:35:09 +08:00
|
|
|
refCreateSaveBox: (fileTree.element.querySelector("#refCreateSaveBox") as HTMLInputElement).value,
|
2023-02-03 20:47:43 +08:00
|
|
|
docCreateSavePath: (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value,
|
2024-04-25 20:35:09 +08:00
|
|
|
docCreateSaveBox: (fileTree.element.querySelector("#docCreateSaveBox") as HTMLInputElement).value,
|
2022-05-26 15:18:53 +08:00
|
|
|
openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,
|
2022-07-14 11:11:54 +08:00
|
|
|
closeTabsOnStart: (fileTree.element.querySelector("#closeTabsOnStart") as HTMLInputElement).checked,
|
2022-05-26 15:18:53 +08:00
|
|
|
allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,
|
2022-06-18 23:34:14 +08:00
|
|
|
removeDocWithoutConfirm: (fileTree.element.querySelector("#removeDocWithoutConfirm") as HTMLInputElement).checked,
|
2023-07-09 22:24:32 +08:00
|
|
|
useSingleLineSave: (fileTree.element.querySelector("#useSingleLineSave") as HTMLInputElement).checked,
|
2025-08-24 10:49:13 +08:00
|
|
|
largeFileWarningSize: parseInt((fileTree.element.querySelector("#largeFileWarningSize") as HTMLInputElement).value),
|
2022-05-26 15:18:53 +08:00
|
|
|
maxListCount: parseInt((fileTree.element.querySelector("#maxListCount") as HTMLInputElement).value),
|
2022-10-22 17:48:46 +08:00
|
|
|
maxOpenTabCount: inputMaxOpenTabCount,
|
2022-05-26 15:18:53 +08:00
|
|
|
}, response => {
|
2025-03-03 22:21:55 +08:00
|
|
|
window.siyuan.config.fileTree = response.data;
|
2022-05-26 15:18:53 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
bindEvent: () => {
|
2023-02-03 20:47:43 +08:00
|
|
|
(fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.docCreateSavePath;
|
2022-05-26 15:18:53 +08:00
|
|
|
(fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.refCreateSavePath;
|
2024-04-25 20:35:09 +08:00
|
|
|
fileTree.element.querySelectorAll("input, select").forEach((item) => {
|
2022-05-26 15:18:53 +08:00
|
|
|
item.addEventListener("change", () => {
|
|
|
|
fileTree._send();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|