diff --git a/app/src/constants.ts b/app/src/constants.ts index 29b3f1308..a0adeaa06 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -70,6 +70,7 @@ export abstract class Constants { public static readonly LOCAL_ZOOM = "local-zoom"; public static readonly LOCAL_SEARCHDATA = "local-searchdata"; public static readonly LOCAL_SEARCHKEYS = "local-searchkeys"; + public static readonly LOCAL_SEARCHASSET = "local-searchasset"; public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobile public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid"; // string public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid"; // string diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index 05702a0b2..021658c42 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -148,6 +148,16 @@ export const getLocalStorage = (cb: () => void) => { window.siyuan.storage = response.data; // 历史数据迁移 const defaultStorage: any = {}; + defaultStorage[Constants.LOCAL_SEARCHASSET] = { + keys: [], + col: "", + row: "", + layout: 0, + method: 0, + types: [".txt", ".md", ".docx", ".xlsx", ".pptx"], + sort: 0, + k: "", + }; defaultStorage[Constants.LOCAL_SEARCHKEYS] = { keys: [], replaceKeys: [], @@ -216,9 +226,10 @@ export const getLocalStorage = (cb: () => void) => { }; defaultStorage[Constants.LOCAL_ZOOM] = 1; - [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_LAYOUTS, Constants.LOCAL_AI, Constants.LOCAL_PLUGINTOPUNPIN].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_LAYOUTS, Constants.LOCAL_AI, + Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET].forEach((key) => { if (typeof response.data[key] === "string") { try { const parseData = JSON.parse(response.data[key]); diff --git a/app/src/search/assets.ts b/app/src/search/assets.ts index b350d17be..efd7bd36f 100644 --- a/app/src/search/assets.ts +++ b/app/src/search/assets.ts @@ -1,3 +1,84 @@ -export const openSearchAsset = () => { +import {Constants} from "../constants"; +import {fetchPost} from "../util/fetch"; +export const openSearchAsset = (element: HTMLElement, isStick: boolean) => { + const localSearch = window.siyuan.storage[Constants.LOCAL_SEARCHASSET] + let methodText = window.siyuan.languages.keyword; + if (localSearch.method === 1) { + methodText = window.siyuan.languages.querySyntax; + } else if (localSearch.method === 2) { + methodText = "SQL"; + } else if (localSearch.method === 3) { + methodText = window.siyuan.languages.regex; + } + const loadingElement = element.nextElementSibling; + loadingElement.classList.remove("fn__none"); + element.innerHTML = `