mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 16:40:13 +01:00
This commit is contained in:
parent
404da1e018
commit
de3f47037b
9 changed files with 182 additions and 54 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
"apiBaseURLTip": "The base address of the request, such as <code class='fn__code'>https://api.openai.com/v1</code>",
|
"apiBaseURLTip": "The base address of the request, such as <code class='fn__code'>https://api.openai.com/v1</code>",
|
||||||
"skip": "Skip",
|
"skip": "Skip",
|
||||||
"reboot": "Reboot",
|
"reboot": "Reboot",
|
||||||
"saveLayout": "Save Layout",
|
"save": "Save",
|
||||||
"ai": "Artificial Intelligence",
|
"ai": "Artificial Intelligence",
|
||||||
"aiContinueWrite": "Continue writing",
|
"aiContinueWrite": "Continue writing",
|
||||||
"aiTranslate": "Translate",
|
"aiTranslate": "Translate",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"apiBaseURLTip": "La dirección base de la solicitud, como <code class='fn__code'>https://api.openai.com/v1</code>",
|
"apiBaseURLTip": "La dirección base de la solicitud, como <code class='fn__code'>https://api.openai.com/v1</code>",
|
||||||
"skip": "barco",
|
"skip": "barco",
|
||||||
"reboot": "Reiniciar",
|
"reboot": "Reiniciar",
|
||||||
"saveLayout": "Guardar diseño",
|
"save": "Ahorrar",
|
||||||
"ai": "Inteligencia Artificial",
|
"ai": "Inteligencia Artificial",
|
||||||
"aiContinueWrite": "Continuar escribiendo",
|
"aiContinueWrite": "Continuar escribiendo",
|
||||||
"aiTranslate": "Traducir",
|
"aiTranslate": "Traducir",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"apiBaseURLTip": "L'adresse de base de la requête, telle que <code class='fn__code'>https://api.openai.com/v1</code>",
|
"apiBaseURLTip": "L'adresse de base de la requête, telle que <code class='fn__code'>https://api.openai.com/v1</code>",
|
||||||
"skip": "Navire",
|
"skip": "Navire",
|
||||||
"reboot": "Redémarrer",
|
"reboot": "Redémarrer",
|
||||||
"saveLayout": "Enregistrer la mise en page",
|
"save": "Sauvegarder",
|
||||||
"ai": "Intelligence Artificielle",
|
"ai": "Intelligence Artificielle",
|
||||||
"aiContinueWrite": "Continuer à écrire",
|
"aiContinueWrite": "Continuer à écrire",
|
||||||
"aiTranslate": "Traduire",
|
"aiTranslate": "Traduire",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"apiBaseURLTip": "發起請求的基礎地址,如 <code class='fn__code'>https://api.openai.com/v1</code>",
|
"apiBaseURLTip": "發起請求的基礎地址,如 <code class='fn__code'>https://api.openai.com/v1</code>",
|
||||||
"skip": "跳過",
|
"skip": "跳過",
|
||||||
"reboot": "重啟",
|
"reboot": "重啟",
|
||||||
"saveLayout": "保存佈局",
|
"save": "保存",
|
||||||
"ai": "人工智能",
|
"ai": "人工智能",
|
||||||
"aiContinueWrite": "續寫",
|
"aiContinueWrite": "續寫",
|
||||||
"aiTranslate": "翻譯",
|
"aiTranslate": "翻譯",
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
"apiBaseURLTip": "发起请求的基础地址,如 <code class='fn__code'>https://api.openai.com/v1</code>",
|
"apiBaseURLTip": "发起请求的基础地址,如 <code class='fn__code'>https://api.openai.com/v1</code>",
|
||||||
"skip": "跳过",
|
"skip": "跳过",
|
||||||
"reboot": "重启",
|
"reboot": "重启",
|
||||||
"saveLayout": "保存布局",
|
"save": "保存",
|
||||||
"ai": "人工智能",
|
"ai": "人工智能",
|
||||||
"aiContinueWrite": "续写",
|
"aiContinueWrite": "续写",
|
||||||
"aiTranslate": "翻译",
|
"aiTranslate": "翻译",
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,12 @@ import {getContenteditableElement} from "../protyle/wysiwyg/getBlock";
|
||||||
import {blockRender} from "../protyle/markdown/blockRender";
|
import {blockRender} from "../protyle/markdown/blockRender";
|
||||||
import {processRender} from "../protyle/util/processCode";
|
import {processRender} from "../protyle/util/processCode";
|
||||||
import {highlightRender} from "../protyle/markdown/highlightRender";
|
import {highlightRender} from "../protyle/markdown/highlightRender";
|
||||||
|
import {Constants} from "../constants";
|
||||||
|
import {setStorageVal} from "../protyle/util/compatibility";
|
||||||
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
|
import {escapeHtml} from "../util/escape";
|
||||||
|
|
||||||
export const fillContent = (protyle:IProtyle, data:string, elements:Element[]) => {
|
export const fillContent = (protyle: IProtyle, data: string, elements: Element[]) => {
|
||||||
setLastNodeRange(getContenteditableElement(elements[elements.length - 1]), protyle.toolbar.range);
|
setLastNodeRange(getContenteditableElement(elements[elements.length - 1]), protyle.toolbar.range);
|
||||||
protyle.toolbar.range.collapse(true);
|
protyle.toolbar.range.collapse(true);
|
||||||
insertHTML(data, protyle, true, true);
|
insertHTML(data, protyle, true, true);
|
||||||
|
|
@ -23,93 +27,8 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
|
||||||
elements.forEach(item => {
|
elements.forEach(item => {
|
||||||
ids.push(item.getAttribute("data-node-id"));
|
ids.push(item.getAttribute("data-node-id"));
|
||||||
});
|
});
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
const customMenu: IMenu[] = [{
|
||||||
icon: "iconSparkles",
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.ai,
|
|
||||||
type: "submenu",
|
|
||||||
submenu: [{
|
|
||||||
label: window.siyuan.languages.aiContinueWrite,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Continue writing"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate,
|
|
||||||
type: "submenu",
|
|
||||||
submenu: [{
|
|
||||||
label: window.siyuan.languages.aiTranslate_zh_CN,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [zh_CN]"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate_ja_JP,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [ja_JP]"}, (response) => {
|
|
||||||
focusByRange(protyle.toolbar.range);
|
|
||||||
insertHTML(response.data, protyle, true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate_ko_KR,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [ko_KR]"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate_en_US,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [en_US]"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate_es_ES,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [es_ES]"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate_fr_FR,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [fr_FR]"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiTranslate_de_DE,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Translate as follows to [de_DE]"}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiExtractSummary,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: window.siyuan.languages.aiExtractSummary}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiBrainStorm,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: window.siyuan.languages.aiBrainStorm}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
label: window.siyuan.languages.aiFixGrammarSpell,
|
|
||||||
click() {
|
|
||||||
fetchPost("/api/ai/chatGPTWithAction", {ids, action: window.siyuan.languages.aiFixGrammarSpell}, (response) => {
|
|
||||||
fillContent(protyle, response.data, elements);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
label: window.siyuan.languages.aiCustomAction,
|
label: window.siyuan.languages.aiCustomAction,
|
||||||
click() {
|
click() {
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
|
|
@ -144,6 +63,213 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.save,
|
||||||
|
click() {
|
||||||
|
const dialog = new Dialog({
|
||||||
|
title: window.siyuan.languages.save,
|
||||||
|
content: `<div class="b3-dialog__content">
|
||||||
|
<input class="b3-text-field fn__size200" value="" placeholder="${window.siyuan.languages.memo}">
|
||||||
|
<div class="fn__hr"></div>
|
||||||
|
<textarea class="b3-text-field fn__block" placeholder="${window.siyuan.languages.aiCustomAction}"></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="b3-dialog__action">
|
||||||
|
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||||
|
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||||
|
</div>`,
|
||||||
|
width: isMobile() ? "80vw" : "520px",
|
||||||
|
});
|
||||||
|
const inputElement = dialog.element.querySelector("input");
|
||||||
|
const btnsElement = dialog.element.querySelectorAll(".b3-button");
|
||||||
|
dialog.bindInput(inputElement, () => {
|
||||||
|
(btnsElement[1] as HTMLButtonElement).click();
|
||||||
|
});
|
||||||
|
inputElement.focus();
|
||||||
|
btnsElement[0].addEventListener("click", () => {
|
||||||
|
dialog.destroy();
|
||||||
|
});
|
||||||
|
btnsElement[1].addEventListener("click", () => {
|
||||||
|
window.siyuan.storage[Constants.LOCAL_AI].push({
|
||||||
|
name: inputElement.value,
|
||||||
|
memo: dialog.element.querySelector("textarea").value,
|
||||||
|
})
|
||||||
|
setStorageVal(Constants.LOCAL_AI, window.siyuan.storage[Constants.LOCAL_AI]);
|
||||||
|
dialog.destroy();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
window.siyuan.storage[Constants.LOCAL_AI].forEach((item: { name: string, memo: string }) => {
|
||||||
|
customMenu.push({
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
action: "iconCloseRound",
|
||||||
|
label: escapeHtml(item.name),
|
||||||
|
bind: (element) => {
|
||||||
|
element.addEventListener("click", (event) => {
|
||||||
|
if (hasClosestByClassName(event.target as Element, "b3-menu__action")) {
|
||||||
|
window.siyuan.storage[Constants.LOCAL_AI].find((subItem: {
|
||||||
|
name: string,
|
||||||
|
memo: string
|
||||||
|
}, index: number) => {
|
||||||
|
if (element.querySelector(".b3-menu__label").textContent.trim() === subItem.name) {
|
||||||
|
window.siyuan.storage[Constants.LOCAL_AI].splice(index, 1);
|
||||||
|
setStorageVal(Constants.LOCAL_AI, window.siyuan.storage[Constants.LOCAL_AI]);
|
||||||
|
element.remove();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: item.memo,
|
||||||
|
}, (response) => {
|
||||||
|
let respContent = "";
|
||||||
|
if (response.data && "" !== response.data) {
|
||||||
|
respContent = "\n\n" + response.data;
|
||||||
|
}
|
||||||
|
fillContent(protyle, `${item.memo}${respContent}`, elements);
|
||||||
|
});
|
||||||
|
window.siyuan.menus.menu.remove();
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
icon: "iconSparkles",
|
||||||
|
label: window.siyuan.languages.ai,
|
||||||
|
type: "submenu",
|
||||||
|
submenu: [{
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiContinueWrite,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {ids, action: "Continue writing"}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate,
|
||||||
|
type: "submenu",
|
||||||
|
submenu: [{
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_zh_CN,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [zh_CN]"
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_ja_JP,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [ja_JP]"
|
||||||
|
}, (response) => {
|
||||||
|
focusByRange(protyle.toolbar.range);
|
||||||
|
insertHTML(response.data, protyle, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_ko_KR,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [ko_KR]"
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_en_US,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [en_US]"
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_es_ES,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [es_ES]"
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_fr_FR,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [fr_FR]"
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiTranslate_de_DE,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: "Translate as follows to [de_DE]"
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiExtractSummary,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: window.siyuan.languages.aiExtractSummary
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiBrainStorm,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: window.siyuan.languages.aiBrainStorm
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.aiFixGrammarSpell,
|
||||||
|
click() {
|
||||||
|
fetchPost("/api/ai/chatGPTWithAction", {
|
||||||
|
ids,
|
||||||
|
action: window.siyuan.languages.aiFixGrammarSpell
|
||||||
|
}, (response) => {
|
||||||
|
fillContent(protyle, response.data, elements);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
iconHTML: Constants.ZWSP,
|
||||||
|
label: window.siyuan.languages.custom,
|
||||||
|
type: "submenu",
|
||||||
|
submenu: customMenu
|
||||||
}]
|
}]
|
||||||
}).element);
|
}).element);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ export abstract class Constants {
|
||||||
public static readonly LOCAL_BAZAAR = "local-bazaar";
|
public static readonly LOCAL_BAZAAR = "local-bazaar";
|
||||||
public static readonly LOCAL_PDFTHEME = "local-pdftheme";
|
public static readonly LOCAL_PDFTHEME = "local-pdftheme";
|
||||||
public static readonly LOCAL_LAYOUTS = "local-layouts";
|
public static readonly LOCAL_LAYOUTS = "local-layouts";
|
||||||
|
public static readonly LOCAL_AI = "local-ai";
|
||||||
|
|
||||||
// timeout
|
// timeout
|
||||||
public static readonly TIMEOUT_DBLCLICK = 190;
|
public static readonly TIMEOUT_DBLCLICK = 190;
|
||||||
|
|
|
||||||
|
|
@ -105,10 +105,10 @@ export const workspaceMenu = (rect: DOMRect) => {
|
||||||
/// #endif
|
/// #endif
|
||||||
const layoutSubMenu: IMenu[] = [{
|
const layoutSubMenu: IMenu[] = [{
|
||||||
iconHTML: Constants.ZWSP,
|
iconHTML: Constants.ZWSP,
|
||||||
label: window.siyuan.languages.saveLayout,
|
label: window.siyuan.languages.save,
|
||||||
click() {
|
click() {
|
||||||
const saveDialog = new Dialog({
|
const saveDialog = new Dialog({
|
||||||
title: window.siyuan.languages.saveLayout,
|
title: window.siyuan.languages.save,
|
||||||
content: `<div class="b3-dialog__content">
|
content: `<div class="b3-dialog__content">
|
||||||
<input class="b3-text-field fn__block" placeholder="${window.siyuan.languages.memo}">
|
<input class="b3-text-field fn__block" placeholder="${window.siyuan.languages.memo}">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -156,6 +156,7 @@ export const getLocalStorage = (cb: () => void) => {
|
||||||
};
|
};
|
||||||
defaultStorage[Constants.LOCAL_PDFTHEME] = {light: "light", dark: "dark", annoColor: "var(--b3-pdf-background1)"};
|
defaultStorage[Constants.LOCAL_PDFTHEME] = {light: "light", dark: "dark", annoColor: "var(--b3-pdf-background1)"};
|
||||||
defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}}
|
defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}}
|
||||||
|
defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""}
|
||||||
defaultStorage[Constants.LOCAL_BAZAAR] = {
|
defaultStorage[Constants.LOCAL_BAZAAR] = {
|
||||||
theme: "0",
|
theme: "0",
|
||||||
template: "0",
|
template: "0",
|
||||||
|
|
@ -209,7 +210,7 @@ export const getLocalStorage = (cb: () => void) => {
|
||||||
|
|
||||||
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, Constants.LOCAL_EXPORTWORD,
|
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, Constants.LOCAL_EXPORTWORD,
|
||||||
Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHDATA,
|
Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHDATA,
|
||||||
Constants.LOCAL_ZOOM, Constants.LOCAL_SEARCHKEY, Constants.LOCAL_LAYOUTS].forEach((key) => {
|
Constants.LOCAL_ZOOM, Constants.LOCAL_SEARCHKEY, Constants.LOCAL_LAYOUTS, Constants.LOCAL_AI].forEach((key) => {
|
||||||
if (typeof response.data[key] === "string") {
|
if (typeof response.data[key] === "string") {
|
||||||
try {
|
try {
|
||||||
window.siyuan.storage[key] = Object.assign(defaultStorage[key], JSON.parse(response.data[key]));
|
window.siyuan.storage[key] = Object.assign(defaultStorage[key], JSON.parse(response.data[key]));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue