mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 17:40:13 +01:00
💄
This commit is contained in:
parent
b92ac264ca
commit
97882c4304
7 changed files with 45 additions and 45 deletions
|
|
@ -9,21 +9,13 @@ export const ai = {
|
|||
</div>
|
||||
<div class="fn__flex-1">
|
||||
<div data-type="openai">
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiKey}
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiKeyTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" id="apiKey" value="${window.siyuan.config.ai.openAI.apiKey}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiTimeout}
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiTimeoutTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" type="number" step="1" min="5" max="600" id="apiTimeout" value="${window.siyuan.config.ai.openAI.apiTimeout}"/>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" type="number" step="1" min="5" max="600" id="apiTimeout" value="${window.siyuan.config.ai.openAI.apiTimeout}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
|
|
@ -31,23 +23,31 @@ export const ai = {
|
|||
<div class="b3-label__text">${window.siyuan.languages.apiMaxTokensTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" type="number" step="1" min="0" id="apiMaxTokens" max="4096" value="${window.siyuan.config.ai.openAI.apiMaxTokens}"/>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" type="number" step="1" min="0" id="apiMaxTokens" max="4096" value="${window.siyuan.config.ai.openAI.apiMaxTokens}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiKey}
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiKeyTip}</div>
|
||||
<div class="fn__hr"></div>
|
||||
<input class="b3-text-field fn__block" id="apiKey" value="${window.siyuan.config.ai.openAI.apiKey}"/>
|
||||
</div>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiProxy}
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiProxyTip}</div>
|
||||
<span class="fn__hr"></span>
|
||||
<input class="b3-text-field fn__block" id="apiProxy" value="${window.siyuan.config.ai.openAI.apiProxy}"/>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" id="apiProxy" value="${window.siyuan.config.ai.openAI.apiProxy}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.apiBaseURL}
|
||||
<div class="b3-label__text">${window.siyuan.languages.apiBaseURLTip}</div>
|
||||
<span class="fn__hr"></span>
|
||||
<input class="b3-text-field fn__block" id="apiBaseURL" value="${window.siyuan.config.ai.openAI.apiBaseURL}"/>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" id="apiBaseURL" value="${window.siyuan.config.ai.openAI.apiBaseURL}"/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export const flashcard = {
|
|||
<div class="b3-label__text">${window.siyuan.languages.flashcardNewCardLimitTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" id="newCardLimit" step="1" min="1" type="number"${window.siyuan.config.flashcard.newCardLimit ? " checked" : "" } value="${window.siyuan.config.flashcard.newCardLimit}"/>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" id="newCardLimit" step="1" min="1" type="number"${window.siyuan.config.flashcard.newCardLimit ? " checked" : "" } value="${window.siyuan.config.flashcard.newCardLimit}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
|
|
@ -17,7 +17,7 @@ export const flashcard = {
|
|||
<div class="b3-label__text">${window.siyuan.languages.flashcardReviewCardLimitTip}</div>
|
||||
</div>
|
||||
<span class="fn__space"></span>
|
||||
<input class="b3-text-field fn__flex-center" id="reviewCardLimit" step="1" min="1" type="number"${window.siyuan.config.flashcard.reviewCardLimit ? " checked" : ""} value="${window.siyuan.config.flashcard.reviewCardLimit}"/>
|
||||
<input class="b3-text-field fn__flex-center fn__size200" id="reviewCardLimit" step="1" min="1" type="number"${window.siyuan.config.flashcard.reviewCardLimit ? " checked" : ""} value="${window.siyuan.config.flashcard.reviewCardLimit}"/>
|
||||
</label>
|
||||
<label class="fn__flex b3-label">
|
||||
<div class="fn__flex-1">
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ export abstract class Constants {
|
|||
|
||||
// localstorage
|
||||
public static readonly LOCAL_ZOOM = "local-zoom";
|
||||
public static readonly LOCAL_SEARCHEDATA = "local-searchedata";
|
||||
public static readonly LOCAL_SEARCHEKEYS = "local-searchekeys";
|
||||
public static readonly LOCAL_SEARCHDATA = "local-searchdata";
|
||||
public static readonly LOCAL_SEARCHKEYS = "local-searchkeys";
|
||||
public static readonly LOCAL_SEARCHKEY = "local-searchkey"; // only mobile
|
||||
public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobile
|
||||
public static readonly LOCAL_SEARCHEKEY = "local-searchkey"; // only mobile
|
||||
public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid"; // string
|
||||
public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid"; // string
|
||||
public static readonly LOCAL_CODELANG = "local-codelang"; // string
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ export const toolbarSearchEvent = () => {
|
|||
onRecentBlocks(response.data.blocks, response.data.matchedRootCount,response.data.matchedBlockCount);
|
||||
});
|
||||
}
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHEKEY] = inputElement.value;
|
||||
setStorageVal(Constants.LOCAL_SEARCHEKEY, window.siyuan.storage[Constants.LOCAL_SEARCHEKEY]);
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHKEY] = inputElement.value;
|
||||
setStorageVal(Constants.LOCAL_SEARCHKEY, window.siyuan.storage[Constants.LOCAL_SEARCHKEY]);
|
||||
}, Constants.TIMEOUT_SEARCH);
|
||||
};
|
||||
|
||||
const initToolbarSearch = () => {
|
||||
const inputElement = document.getElementById("toolbarSearch") as HTMLInputElement;
|
||||
inputElement.focus();
|
||||
inputElement.value = window.siyuan.storage[Constants.LOCAL_SEARCHEKEY] || "";
|
||||
inputElement.value = window.siyuan.storage[Constants.LOCAL_SEARCHKEY] || "";
|
||||
inputElement.addEventListener("compositionend", (event: InputEvent) => {
|
||||
if (event && event.isComposing) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ export const getLocalStorage = (cb: () => void) => {
|
|||
window.siyuan.storage = response.data;
|
||||
// 历史数据迁移
|
||||
const defaultStorage: any = {};
|
||||
defaultStorage[Constants.LOCAL_SEARCHEKEYS] = {
|
||||
defaultStorage[Constants.LOCAL_SEARCHKEYS] = {
|
||||
keys: [],
|
||||
replaceKeys: [],
|
||||
col: "",
|
||||
|
|
@ -180,7 +180,7 @@ export const getLocalStorage = (cb: () => void) => {
|
|||
action: []
|
||||
};
|
||||
defaultStorage[Constants.LOCAL_FONTSTYLES] = [];
|
||||
defaultStorage[Constants.LOCAL_SEARCHEDATA] = {
|
||||
defaultStorage[Constants.LOCAL_SEARCHDATA] = {
|
||||
sort: 0,
|
||||
group: 0,
|
||||
hasReplace: false,
|
||||
|
|
@ -205,16 +205,16 @@ export const getLocalStorage = (cb: () => void) => {
|
|||
}
|
||||
};
|
||||
defaultStorage[Constants.LOCAL_ZOOM] = 1;
|
||||
defaultStorage[Constants.LOCAL_SEARCHEKEY] = "";
|
||||
defaultStorage[Constants.LOCAL_SEARCHKEY] = "";
|
||||
|
||||
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHEKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, Constants.LOCAL_EXPORTWORD,
|
||||
Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHEDATA,
|
||||
Constants.LOCAL_ZOOM, Constants.LOCAL_SEARCHEKEY, Constants.LOCAL_LAYOUTS].forEach((key) => {
|
||||
[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_ZOOM, Constants.LOCAL_SEARCHKEY, Constants.LOCAL_LAYOUTS].forEach((key) => {
|
||||
if (typeof response.data[key] === "string") {
|
||||
try {
|
||||
window.siyuan.storage[key] = Object.assign(defaultStorage[key], JSON.parse(response.data[key]));
|
||||
} catch (e) {
|
||||
window.siyuan.storage[key] = key === Constants.LOCAL_SEARCHEKEY ? (response.data[key] || "") : defaultStorage[key];
|
||||
window.siyuan.storage[key] = key === Constants.LOCAL_SEARCHKEY ? (response.data[key] || "") : defaultStorage[key];
|
||||
}
|
||||
} else if (typeof response.data[key] === "undefined") {
|
||||
window.siyuan.storage[key] = defaultStorage[key];
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
|||
if (exitDialog) {
|
||||
return;
|
||||
}
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHEDATA];
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||
let hPath = "";
|
||||
let idPath: string[] = [];
|
||||
if (notebookId) {
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
|||
import {setStorageVal} from "../protyle/util/compatibility";
|
||||
|
||||
const saveKeyList = (type: "keys" | "replaceKeys", value: string) => {
|
||||
let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS][type];
|
||||
let list: string[] = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][type];
|
||||
list.splice(0, 0, value);
|
||||
list = Array.from(new Set(list));
|
||||
if (list.length > window.siyuan.config.search.limit) {
|
||||
list.splice(window.siyuan.config.search.limit, list.length - window.siyuan.config.search.limit);
|
||||
}
|
||||
// new Set 后需重新赋值
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS][type] = list;
|
||||
setStorageVal(Constants.LOCAL_SEARCHEKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS]);
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][type] = list;
|
||||
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
|
||||
};
|
||||
|
||||
export const openGlobalSearch = (text: string, replace: boolean) => {
|
||||
|
|
@ -53,7 +53,7 @@ export const openGlobalSearch = (text: string, replace: boolean) => {
|
|||
icon: "iconSearch",
|
||||
title: window.siyuan.languages.search,
|
||||
callback(tab) {
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHEDATA];
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHDATA];
|
||||
const asset = new Search({
|
||||
tab,
|
||||
config: {
|
||||
|
|
@ -95,7 +95,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||
enableIncludeChild = true;
|
||||
}
|
||||
});
|
||||
const data = window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS];
|
||||
const data = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
|
||||
element.innerHTML = `<div class="fn__flex-column" style="height: 100%;${closeCB ? "border-radius: 4px;overflow: hidden;" : ""}">
|
||||
<div class="b3-form__icon search__header">
|
||||
<span class="fn__a" id="searchHistoryBtn">
|
||||
|
|
@ -228,7 +228,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||
const documentSelf = document;
|
||||
const nextElement = dragElement.nextElementSibling as HTMLElement;
|
||||
const previousElement = dragElement.previousElementSibling as HTMLElement;
|
||||
const direction = window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS][closeCB ? "layout" : "layoutTab"] === 1 ? "lr" : "tb";
|
||||
const direction = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][closeCB ? "layout" : "layoutTab"] === 1 ? "lr" : "tb";
|
||||
const x = event[direction === "lr" ? "clientX" : "clientY"];
|
||||
const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
|
||||
const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
|
||||
|
|
@ -253,8 +253,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||
documentSelf.ondragstart = null;
|
||||
documentSelf.onselectstart = null;
|
||||
documentSelf.onselect = null;
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS][direction === "lr" ? (closeCB ? "col" : "colTab") : (closeCB ? "row" : "rowTab")] = nextElement[direction === "lr" ? "clientWidth" : "clientHeight"] + "px";
|
||||
setStorageVal(Constants.LOCAL_SEARCHEKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS]);
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHKEYS][direction === "lr" ? (closeCB ? "col" : "colTab") : (closeCB ? "row" : "rowTab")] = nextElement[direction === "lr" ? "clientWidth" : "clientHeight"] + "px";
|
||||
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
|
||||
if (direction === "lr") {
|
||||
setPadding(edit.protyle);
|
||||
}
|
||||
|
|
@ -405,7 +405,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||
event.preventDefault();
|
||||
break;
|
||||
} else if (target.id === "searchHistoryBtn") {
|
||||
const list = window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS];
|
||||
const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
|
||||
if (!list.keys || list.keys.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -425,7 +425,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
|||
event.preventDefault();
|
||||
return;
|
||||
} else if (target.id === "replaceHistoryBtn") {
|
||||
const list = window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS];
|
||||
const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
|
||||
if (!list.replaceKeys || list.replaceKeys.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -714,7 +714,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||
}
|
||||
}]
|
||||
}).element);
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS];
|
||||
const localData = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
|
||||
const isPopover = hasClosestByClassName(element, "b3-dialog__container");
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.layout,
|
||||
|
|
@ -737,7 +737,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||
} else {
|
||||
localData.layoutTab = 0;
|
||||
}
|
||||
setStorageVal(Constants.LOCAL_SEARCHEKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS]);
|
||||
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.leftRightLayout,
|
||||
|
|
@ -757,7 +757,7 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
|||
} else {
|
||||
localData.layoutTab = 1;
|
||||
}
|
||||
setStorageVal(Constants.LOCAL_SEARCHEKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHEKEYS]);
|
||||
setStorageVal(Constants.LOCAL_SEARCHKEYS, window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]);
|
||||
}
|
||||
}]
|
||||
}).element);
|
||||
|
|
@ -930,8 +930,8 @@ const updateConfig = (element: Element, item: ISearchOption, config: ISearchOpti
|
|||
}
|
||||
element.querySelector("#searchSyntaxCheck").setAttribute("aria-label", methodTip);
|
||||
Object.assign(config, item);
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHEDATA] = Object.assign({}, config);
|
||||
setStorageVal(Constants.LOCAL_SEARCHEDATA, window.siyuan.storage[Constants.LOCAL_SEARCHEDATA]);
|
||||
window.siyuan.storage[Constants.LOCAL_SEARCHDATA] = Object.assign({}, config);
|
||||
setStorageVal(Constants.LOCAL_SEARCHDATA, window.siyuan.storage[Constants.LOCAL_SEARCHDATA]);
|
||||
inputEvent(element, config, undefined, edit);
|
||||
window.siyuan.menus.menu.remove();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue