mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-23 01:50:12 +01:00
This commit is contained in:
parent
8aa4dac91f
commit
3f5dc6432f
2 changed files with 5 additions and 4 deletions
|
|
@ -46,7 +46,7 @@ export const toolbarSearchEvent = () => {
|
||||||
const initToolbarSearch = () => {
|
const initToolbarSearch = () => {
|
||||||
const inputElement = document.getElementById("toolbarSearch") as HTMLInputElement;
|
const inputElement = document.getElementById("toolbarSearch") as HTMLInputElement;
|
||||||
inputElement.focus();
|
inputElement.focus();
|
||||||
inputElement.value = window.siyuan.storage[Constants.LOCAL_SEARCHEKEY];
|
inputElement.value = window.siyuan.storage[Constants.LOCAL_SEARCHEKEY] || "";
|
||||||
inputElement.addEventListener("compositionend", (event: InputEvent) => {
|
inputElement.addEventListener("compositionend", (event: InputEvent) => {
|
||||||
if (event && event.isComposing) {
|
if (event && event.isComposing) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ export const hotKey2Electron = (key: string) => {
|
||||||
return electronKey + key.substr(key.length - 1);
|
return electronKey + key.substr(key.length - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getLocalStorage = (cb:()=>void) => {
|
export const getLocalStorage = (cb: () => void) => {
|
||||||
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
|
fetchPost("/api/storage/getLocalStorage", undefined, (response) => {
|
||||||
window.siyuan.storage = response.data;
|
window.siyuan.storage = response.data;
|
||||||
// 历史数据迁移
|
// 历史数据迁移
|
||||||
|
|
@ -204,15 +204,16 @@ export const getLocalStorage = (cb:()=>void) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
defaultStorage[Constants.LOCAL_ZOOM] = 1;
|
defaultStorage[Constants.LOCAL_ZOOM] = 1;
|
||||||
|
defaultStorage[Constants.LOCAL_SEARCHEKEY] = "";
|
||||||
|
|
||||||
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHEKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, Constants.LOCAL_EXPORTWORD,
|
[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_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_SEARCHEDATA,
|
||||||
Constants.LOCAL_ZOOM,].forEach((key) => {
|
Constants.LOCAL_ZOOM, Constants.LOCAL_SEARCHEKEY].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]));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.siyuan.storage[key] = defaultStorage[key];
|
window.siyuan.storage[key] = key === Constants.LOCAL_SEARCHEKEY ? (response.data[key] || "") : defaultStorage[key];
|
||||||
}
|
}
|
||||||
} else if (typeof response.data[key] === "undefined") {
|
} else if (typeof response.data[key] === "undefined") {
|
||||||
window.siyuan.storage[key] = defaultStorage[key];
|
window.siyuan.storage[key] = defaultStorage[key];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue