Vanessa 2024-04-25 20:35:09 +08:00
parent 07e572f46c
commit 52cdc67f19
9 changed files with 64 additions and 33 deletions

View file

@ -1,4 +1,5 @@
{ {
"currentNotebook": "Current Notebook",
"containerBlockTip1": "Enabling container blocks will result in duplicate search results", "containerBlockTip1": "Enabling container blocks will result in duplicate search results",
"containerBlockTip2": "Enabling document blocks currently only supports searching for document titles", "containerBlockTip2": "Enabling document blocks currently only supports searching for document titles",
"copyAsPNG": "Copy as PNG", "copyAsPNG": "Copy as PNG",

View file

@ -1,4 +1,5 @@
{ {
"currentNotebook": "Cuaderno actual",
"containerBlockTip1": "Habilitar bloques de contenedores generará resultados de búsqueda duplicados", "containerBlockTip1": "Habilitar bloques de contenedores generará resultados de búsqueda duplicados",
"containerBlockTip2": "Habilitar bloques de documentos actualmente solo admite la búsqueda de títulos de documentos", "containerBlockTip2": "Habilitar bloques de documentos actualmente solo admite la búsqueda de títulos de documentos",
"copyAsPNG": "Copiar como PNG", "copyAsPNG": "Copiar como PNG",

View file

@ -1,4 +1,5 @@
{ {
"currentNotebook": "Carnet actuel",
"containerBlockTip1": "L'activation des blocs de conteneurs entraînera des résultats de recherche en double", "containerBlockTip1": "L'activation des blocs de conteneurs entraînera des résultats de recherche en double",
"containerBlockTip2": "L'activation des blocs de documents ne prend actuellement en charge que la recherche de titres de documents", "containerBlockTip2": "L'activation des blocs de documents ne prend actuellement en charge que la recherche de titres de documents",
"copyAsPNG": "Copier en tant PNG", "copyAsPNG": "Copier en tant PNG",

View file

@ -1,4 +1,5 @@
{ {
"currentNotebook": "目前筆記本",
"containerBlockTip1": "啟用容器區塊後會導致搜尋結果重複", "containerBlockTip1": "啟用容器區塊後會導致搜尋結果重複",
"containerBlockTip2": "啟用文件區塊目前僅支援搜尋文件名稱", "containerBlockTip2": "啟用文件區塊目前僅支援搜尋文件名稱",
"copyAsPNG": "複製為 PNG", "copyAsPNG": "複製為 PNG",

View file

@ -1,4 +1,5 @@
{ {
"currentNotebook": "当前笔记本",
"containerBlockTip1": "启用容器块后会导致搜索结果重复", "containerBlockTip1": "启用容器块后会导致搜索结果重复",
"containerBlockTip2": "启用文档块目前仅支持搜索文档名", "containerBlockTip2": "启用文档块目前仅支持搜索文档名",
"copyAsPNG": "复制为 PNG", "copyAsPNG": "复制为 PNG",

View file

@ -1,4 +1,5 @@
import {fetchPost} from "../util/fetch"; import {fetchPost} from "../util/fetch";
import {genNotebookOption} from "../menus/onGetnotebookconf";
export const fileTree = { export const fileTree = {
element: undefined as Element, element: undefined as Element,
@ -51,22 +52,6 @@ export const fileTree = {
<span class="fn__space"></span> <span class="fn__space"></span>
<input class="b3-switch fn__flex-center" id="useSingleLineSave" type="checkbox"${window.siyuan.config.fileTree.useSingleLineSave ? " checked" : ""}/> <input class="b3-switch fn__flex-center" id="useSingleLineSave" type="checkbox"${window.siyuan.config.fileTree.useSingleLineSave ? " checked" : ""}/>
</label> </label>
<div class="fn__flex b3-label config__item">
<div class="fn__flex-1">
${window.siyuan.languages.fileTree12}
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
</div>
<span class="fn__space"></span>
<input class="b3-text-field fn__flex-center fn__size200" id="docCreateSavePath" value="">
</div>
<div class="b3-label fn__flex config__item">
<div class="fn__flex-1">
${window.siyuan.languages.fileTree5}
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
</div>
<span class="fn__space"></span>
<input class="b3-text-field fn__flex-center fn__size200" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}">
</div>
<div class="fn__flex b3-label config__item"> <div class="fn__flex b3-label config__item">
<div class="fn__flex-1"> <div class="fn__flex-1">
${window.siyuan.languages.fileTree16} ${window.siyuan.languages.fileTree16}
@ -82,6 +67,26 @@ export const fileTree = {
</div> </div>
<span class="fn__space"></span> <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}"> <input class="b3-text-field fn__flex-center fn__size200" id="maxOpenTabCount" type="number" min="1" max="32" value="${window.siyuan.config.fileTree.maxOpenTabCount}">
</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>
</div>`; </div>`;
}, },
_send() { _send() {
@ -100,7 +105,9 @@ export const fileTree = {
sort: window.siyuan.config.fileTree.sort, sort: window.siyuan.config.fileTree.sort,
alwaysSelectOpenedFile: (fileTree.element.querySelector("#alwaysSelectOpenedFile") as HTMLInputElement).checked, alwaysSelectOpenedFile: (fileTree.element.querySelector("#alwaysSelectOpenedFile") as HTMLInputElement).checked,
refCreateSavePath: (fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value, refCreateSavePath: (fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value,
refCreateSaveBox: (fileTree.element.querySelector("#refCreateSaveBox") as HTMLInputElement).value,
docCreateSavePath: (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value, docCreateSavePath: (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value,
docCreateSaveBox: (fileTree.element.querySelector("#docCreateSaveBox") as HTMLInputElement).value,
openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked, openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,
closeTabsOnStart: (fileTree.element.querySelector("#closeTabsOnStart") as HTMLInputElement).checked, closeTabsOnStart: (fileTree.element.querySelector("#closeTabsOnStart") as HTMLInputElement).checked,
allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked, allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,
@ -115,7 +122,7 @@ export const fileTree = {
bindEvent: () => { bindEvent: () => {
(fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.docCreateSavePath; (fileTree.element.querySelector("#docCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.docCreateSavePath;
(fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.refCreateSavePath; (fileTree.element.querySelector("#refCreateSavePath") as HTMLInputElement).value = window.siyuan.config.fileTree.refCreateSavePath;
fileTree.element.querySelectorAll("input").forEach((item) => { fileTree.element.querySelectorAll("input, select").forEach((item) => {
item.addEventListener("change", () => { item.addEventListener("change", () => {
fileTree._send(); fileTree._send();
}); });

View file

@ -14,32 +14,47 @@ declare interface INotebookConf {
refCreateSavePath: string refCreateSavePath: string
docCreateSavePath: string docCreateSavePath: string
dailyNoteSavePath: string dailyNoteSavePath: string
refCreateSaveBox: string;
docCreateSaveBox: string;
dailyNoteTemplatePath: string dailyNoteTemplatePath: string
} }
} }
export const genNotebookOption = (id: string) => {
let html = `<option value="">${window.siyuan.languages.currentNotebook}</option>`;
window.siyuan.notebooks.forEach((item) => {
html += `<option value="${item.id}" ${id === item.id ? "selected" : ""}>${item.name}</option>`;
});
return html;
}
export const onGetnotebookconf = (data: INotebookConf) => { export const onGetnotebookconf = (data: INotebookConf) => {
const titleHTML = `<div class="fn__flex">${escapeHtml(data.name)} const titleHTML = `<div class="fn__flex">${escapeHtml(data.name)}
<div class="fn__space"></div> <div class="fn__space"></div>
<button class="b3-button b3-button--small">${window.siyuan.languages.copy} ID</button></div>`; <button class="b3-button b3-button--small">${window.siyuan.languages.copy} ID</button></div>`;
const contentHTML = `<div class="b3-dialog__content" style="background-color: var(--b3-theme-background);"> const contentHTML = `<div class="b3-dialog__content" style="background-color: var(--b3-theme-background);">
<div class="b3-label"> <div class="b3-label config__item">
${window.siyuan.languages.fileTree12} ${window.siyuan.languages.fileTree12}
<div class="fn__hr"></div>
<div class="b3-label__text">${window.siyuan.languages.fileTree13}</div> <div class="b3-label__text">${window.siyuan.languages.fileTree13}</div>
<div class="fn__hr"></div> <span class="fn__hr"></span>
<input class="b3-text-field fn__flex-center fn__block" id="docCreateSavePath" value=""> <div class="fn__flex">
<select style="min-width: 200px" class="b3-select" id="docCreateSaveBox">${genNotebookOption(data.conf.docCreateSaveBox)}</select>
<div class="fn__space"></div>
<input class="b3-text-field fn__flex-1" id="docCreateSavePath" value="">
</div>
</div> </div>
<div class="b3-label"> <div class="b3-label config__item">
${window.siyuan.languages.fileTree5} ${window.siyuan.languages.fileTree5}
<div class="fn__hr"></div>
<div class="b3-label__text">${window.siyuan.languages.fileTree6}</div> <div class="b3-label__text">${window.siyuan.languages.fileTree6}</div>
<div class="fn__hr"></div> <span class="fn__hr"></span>
<input class="b3-text-field fn__flex-center fn__block" id="refCreateSavePath" value="${window.siyuan.config.fileTree.refCreateSavePath}"> <div class="fn__flex">
<select style="min-width: 200px" class="b3-select" id="refCreateSaveBox">${genNotebookOption(data.conf.refCreateSaveBox)}</select>
<div class="fn__space"></div>
<input class="b3-text-field fn__flex-1" id="refCreateSavePath" value="">
</div>
</div> </div>
<div class="b3-label"> <div class="b3-label">
${window.siyuan.languages.fileTree11} ${window.siyuan.languages.fileTree11}
<div class="fn__hr"></div>
<div class="b3-label__text">${window.siyuan.languages.fileTree14}</div> <div class="b3-label__text">${window.siyuan.languages.fileTree14}</div>
<div class="fn__hr"></div> <div class="fn__hr"></div>
<input class="b3-text-field fn__flex-center fn__block" id="dailyNoteSavePath" value=""> <input class="b3-text-field fn__flex-center fn__block" id="dailyNoteSavePath" value="">
@ -81,12 +96,14 @@ const bindSettingEvent = (contentElement: Element, data: INotebookConf) => {
refCreateSavePathElement.value = data.conf.refCreateSavePath; refCreateSavePathElement.value = data.conf.refCreateSavePath;
const dailyNoteTemplatePathElement = contentElement.querySelector("#dailyNoteTemplatePath") as HTMLInputElement; const dailyNoteTemplatePathElement = contentElement.querySelector("#dailyNoteTemplatePath") as HTMLInputElement;
dailyNoteTemplatePathElement.value = data.conf.dailyNoteTemplatePath; dailyNoteTemplatePathElement.value = data.conf.dailyNoteTemplatePath;
contentElement.querySelectorAll("input").forEach((item) => { contentElement.querySelectorAll("input, select").forEach((item) => {
item.addEventListener("change", () => { item.addEventListener("change", () => {
fetchPost("/api/notebook/setNotebookConf", { fetchPost("/api/notebook/setNotebookConf", {
notebook: data.box, notebook: data.box,
conf: { conf: {
refCreateSavePath: refCreateSavePathElement.value, refCreateSavePath: refCreateSavePathElement.value,
refCreateSaveBox: (contentElement.querySelector("#refCreateSaveBox") as HTMLInputElement).value,
docCreateSaveBox: (contentElement.querySelector("#docCreateSaveBox") as HTMLInputElement).value,
docCreateSavePath: docCreateSavePathElement.value, docCreateSavePath: docCreateSavePathElement.value,
dailyNoteSavePath: dailyNoteSavePathElement.value, dailyNoteSavePath: dailyNoteSavePathElement.value,
dailyNoteTemplatePath: dailyNoteTemplatePathElement.value, dailyNoteTemplatePath: dailyNoteTemplatePathElement.value,

View file

@ -536,6 +536,8 @@ declare namespace Config {
* The storage path of the new document created using block references * The storage path of the new document created using block references
*/ */
refCreateSavePath: string; refCreateSavePath: string;
refCreateSaveBox: string;
docCreateSaveBox: string;
/** /**
* Close the secondary confirmation when deleting a document * Close the secondary confirmation when deleting a document
*/ */

View file

@ -95,7 +95,7 @@ export const newFile = (optios: {
if ((data.data.path.indexOf("/") > -1 && optios.useSavePath) || optios.name) { if ((data.data.path.indexOf("/") > -1 && optios.useSavePath) || optios.name) {
if (data.data.path.startsWith("/") || optios.currentPath === "/") { if (data.data.path.startsWith("/") || optios.currentPath === "/") {
fetchPost("/api/filetree/createDocWithMd", { fetchPost("/api/filetree/createDocWithMd", {
notebook: optios.notebookId, notebook: data.data.box,
path: pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")), path: pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
// 根目录时无法确定 parentID // 根目录时无法确定 parentID
markdown: "" markdown: ""
@ -112,11 +112,11 @@ export const newFile = (optios: {
}); });
} else { } else {
fetchPost("/api/filetree/getHPathByPath", { fetchPost("/api/filetree/getHPathByPath", {
notebook: optios.notebookId, notebook: data.data.box,
path: optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy" path: optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy"
}, (responseHPath) => { }, (responseHPath) => {
fetchPost("/api/filetree/createDocWithMd", { fetchPost("/api/filetree/createDocWithMd", {
notebook: optios.notebookId, notebook: data.data.box,
path: pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")), path: pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
parentID: getDisplayName(optios.currentPath, true, true), parentID: getDisplayName(optios.currentPath, true, true),
markdown: "" markdown: ""
@ -144,7 +144,7 @@ export const newFile = (optios: {
optios.paths[optios.paths.indexOf(undefined)] = newPath; optios.paths[optios.paths.indexOf(undefined)] = newPath;
} }
fetchPost("/api/filetree/createDoc", { fetchPost("/api/filetree/createDoc", {
notebook: optios.notebookId, notebook: data.data.box,
path: newPath, path: newPath,
title, title,
md: "", md: "",
@ -169,7 +169,7 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
cb(getDisplayName(data.data.path, false, true)); cb(getDisplayName(data.data.path, false, true));
} else { } else {
fetchPost("/api/filetree/getHPathByPath", { fetchPost("/api/filetree/getHPathByPath", {
notebook: notebookId, notebook: data.data.box,
path: pathString path: pathString
}, (response) => { }, (response) => {
cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true)); cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true));
@ -177,7 +177,7 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
} }
} else { } else {
fetchPost("/api/filetree/getHPathByPath", { fetchPost("/api/filetree/getHPathByPath", {
notebook: notebookId, notebook: data.data.box,
path: pathString path: pathString
}, (response) => { }, (response) => {
cb(getDisplayName(response.data, false, true)); cb(getDisplayName(response.data, false, true));