This commit is contained in:
Vanessa 2023-03-22 11:56:58 +08:00
parent b92ac264ca
commit 97882c4304
7 changed files with 45 additions and 45 deletions

View file

@ -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];