mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
This commit is contained in:
parent
ec00af7334
commit
0153d9b8d7
4 changed files with 19 additions and 43 deletions
|
|
@ -59,7 +59,7 @@ export abstract class Constants {
|
||||||
|
|
||||||
// localstorage
|
// localstorage
|
||||||
public static readonly LOCAL_SEARCHEDATA = "local-searchedata";
|
public static readonly LOCAL_SEARCHEDATA = "local-searchedata";
|
||||||
public static readonly LOCAL_SEARCHEKEYS = "local-searchekeys"; // "keys","col", "row", "replaceKeys"
|
public static readonly LOCAL_SEARCHEKEYS = "local-searchekeys"; // "keys", "col", "row", "replaceKeys", "layout"
|
||||||
public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobile
|
public static readonly LOCAL_DOCINFO = "local-docinfo"; // only mobile
|
||||||
public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid";
|
public static readonly LOCAL_DAILYNOTEID = "local-dailynoteid";
|
||||||
public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid";
|
public static readonly LOCAL_HISTORYNOTEID = "local-historynoteid";
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
|
||||||
hPath,
|
hPath,
|
||||||
idPath,
|
idPath,
|
||||||
group: localData.group || 0,
|
group: localData.group || 0,
|
||||||
layout: localData.layout || 0,
|
|
||||||
sort: localData.sort || 0,
|
sort: localData.sort || 0,
|
||||||
types: localData.types
|
types: localData.types
|
||||||
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
|
}, dialog.element.querySelector(".b3-dialog__container").lastElementChild, () => {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ export const openGlobalSearch = (text: string, replace: boolean) => {
|
||||||
hPath: "",
|
hPath: "",
|
||||||
idPath: [],
|
idPath: [],
|
||||||
group: localData.group || 0,
|
group: localData.group || 0,
|
||||||
layout: localData.layout || 0,
|
|
||||||
sort: localData.sort || 0,
|
sort: localData.sort || 0,
|
||||||
types: localData.types
|
types: localData.types
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +109,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
enableIncludeChild = true;
|
enableIncludeChild = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
|
||||||
element.innerHTML = `<div class="fn__flex-column" style="height: 100%;${closeCB ? "border-radius: 4px;overflow: hidden;" : ""}">
|
element.innerHTML = `<div class="fn__flex-column" style="height: 100%;${closeCB ? "border-radius: 4px;overflow: hidden;" : ""}">
|
||||||
<div class="b3-form__icon search__header">
|
<div class="b3-form__icon search__header">
|
||||||
<span class="fn__a" id="searchHistoryBtn">
|
<span class="fn__a" id="searchHistoryBtn">
|
||||||
|
|
@ -181,7 +181,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="search__layout${config.layout === 1 ? " search__layout--row" : ""}">
|
<div class="search__layout${data.layout === 1 ? " search__layout--row" : ""}">
|
||||||
<div id="searchList" class="fn__flex-1 search__list b3-list b3-list--background"></div>
|
<div id="searchList" class="fn__flex-1 search__list b3-list b3-list--background"></div>
|
||||||
<div class="search__drag"></div>
|
<div class="search__drag"></div>
|
||||||
<div id="searchPreview" class="fn__flex-1 search__preview"></div>
|
<div id="searchPreview" class="fn__flex-1 search__preview"></div>
|
||||||
|
|
@ -202,9 +202,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
breadcrumbDocName: true
|
breadcrumbDocName: true
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (data.layout === 1) {
|
||||||
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
|
|
||||||
if (config.layout === 1) {
|
|
||||||
if (data.col) {
|
if (data.col) {
|
||||||
edit.protyle.element.style.width = data.col;
|
edit.protyle.element.style.width = data.col;
|
||||||
edit.protyle.element.classList.remove("fn__flex-1");
|
edit.protyle.element.classList.remove("fn__flex-1");
|
||||||
|
|
@ -227,7 +225,7 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
|
||||||
const documentSelf = document;
|
const documentSelf = document;
|
||||||
const nextElement = dragElement.nextElementSibling as HTMLElement;
|
const nextElement = dragElement.nextElementSibling as HTMLElement;
|
||||||
const previousElement = dragElement.previousElementSibling as HTMLElement;
|
const previousElement = dragElement.previousElementSibling as HTMLElement;
|
||||||
const direction = config.layout === 1 ? "lr" : "tb";
|
const direction = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}").layout === 1 ? "lr" : "tb";
|
||||||
const x = event[direction === "lr" ? "clientX" : "clientY"];
|
const x = event[direction === "lr" ? "clientX" : "clientY"];
|
||||||
const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
|
const previousSize = direction === "lr" ? previousElement.clientWidth : previousElement.clientHeight;
|
||||||
const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
|
const nextSize = direction === "lr" ? nextElement.clientWidth : nextElement.clientHeight;
|
||||||
|
|
@ -706,40 +704,44 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}).element);
|
}).element);
|
||||||
|
const localData = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}")
|
||||||
|
if (typeof localData.layout === "undefined") {
|
||||||
|
localData.layout = 0;
|
||||||
|
}
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.layout,
|
label: window.siyuan.languages.layout,
|
||||||
type: "submenu",
|
type: "submenu",
|
||||||
submenu: [{
|
submenu: [{
|
||||||
label: window.siyuan.languages.topBottomLayout,
|
label: window.siyuan.languages.topBottomLayout,
|
||||||
current: config.layout === 0,
|
current: localData.layout === 0,
|
||||||
click() {
|
click() {
|
||||||
element.querySelector(".search__layout").classList.remove("search__layout--row");
|
element.querySelector(".search__layout").classList.remove("search__layout--row");
|
||||||
edit.protyle.element.style.width = "";
|
edit.protyle.element.style.width = "";
|
||||||
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
|
if (localData.row) {
|
||||||
if (data.row) {
|
edit.protyle.element.style.height = localData.row;
|
||||||
edit.protyle.element.style.height = data.row;
|
|
||||||
edit.protyle.element.classList.remove("fn__flex-1");
|
edit.protyle.element.classList.remove("fn__flex-1");
|
||||||
} else {
|
} else {
|
||||||
edit.protyle.element.classList.add("fn__flex-1");
|
edit.protyle.element.classList.add("fn__flex-1");
|
||||||
}
|
}
|
||||||
setPadding(edit.protyle);
|
setPadding(edit.protyle);
|
||||||
config.layout = 0;
|
localData.layout = 0;
|
||||||
|
localStorage.setItem(Constants.LOCAL_SEARCHEKEYS, JSON.stringify(localData));
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
label: window.siyuan.languages.leftRightLayout,
|
label: window.siyuan.languages.leftRightLayout,
|
||||||
current: config.layout === 1,
|
current: localData.layout === 1,
|
||||||
click() {
|
click() {
|
||||||
element.querySelector(".search__layout").classList.add("search__layout--row");
|
element.querySelector(".search__layout").classList.add("search__layout--row");
|
||||||
edit.protyle.element.style.height = "";
|
edit.protyle.element.style.height = "";
|
||||||
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
|
if (localData.col) {
|
||||||
if (data.col) {
|
edit.protyle.element.style.width = localData.col;
|
||||||
edit.protyle.element.style.width = data.col;
|
|
||||||
edit.protyle.element.classList.remove("fn__flex-1");
|
edit.protyle.element.classList.remove("fn__flex-1");
|
||||||
} else {
|
} else {
|
||||||
edit.protyle.element.classList.add("fn__flex-1");
|
edit.protyle.element.classList.add("fn__flex-1");
|
||||||
}
|
}
|
||||||
setPadding(edit.protyle);
|
setPadding(edit.protyle);
|
||||||
config.layout = 1;
|
localData.layout = 1;
|
||||||
|
localStorage.setItem(Constants.LOCAL_SEARCHEKEYS, JSON.stringify(localData));
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}).element);
|
}).element);
|
||||||
|
|
@ -814,7 +816,6 @@ const addConfigMoreMenu = async (config: ISearchOption, edit: Protyle, element:
|
||||||
updateConfig(element, {
|
updateConfig(element, {
|
||||||
sort: 0,
|
sort: 0,
|
||||||
group: 0,
|
group: 0,
|
||||||
layout: 0,
|
|
||||||
hasReplace: false,
|
hasReplace: false,
|
||||||
method: 0,
|
method: 0,
|
||||||
hPath: "",
|
hPath: "",
|
||||||
|
|
@ -847,29 +848,6 @@ const updateConfig = (element: Element, item: ISearchOption, config: ISearchOpti
|
||||||
item.hPath = config.hPath;
|
item.hPath = config.hPath;
|
||||||
item.idPath = config.idPath.join(",").split(",");
|
item.idPath = config.idPath.join(",").split(",");
|
||||||
}
|
}
|
||||||
if (config.layout !== item.layout) {
|
|
||||||
const data = JSON.parse(localStorage.getItem(Constants.LOCAL_SEARCHEKEYS) || "{}");
|
|
||||||
if (item.layout === 0) {
|
|
||||||
element.querySelector(".search__layout").classList.remove("search__layout--row");
|
|
||||||
if (data.row) {
|
|
||||||
edit.protyle.element.classList.remove("fn__flex-1");
|
|
||||||
edit.protyle.element.style.height = data.row;
|
|
||||||
edit.protyle.element.style.width = "";
|
|
||||||
} else {
|
|
||||||
edit.protyle.element.classList.add("fn__flex-1");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
element.querySelector(".search__layout").classList.add("search__layout--row");
|
|
||||||
if (data.col) {
|
|
||||||
edit.protyle.element.style.width = data.col;
|
|
||||||
edit.protyle.element.classList.remove("fn__flex-1");
|
|
||||||
edit.protyle.element.style.height = "";
|
|
||||||
} else {
|
|
||||||
edit.protyle.element.classList.add("fn__flex-1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setPadding(edit.protyle);
|
|
||||||
}
|
|
||||||
if (config.hasReplace !== item.hasReplace) {
|
if (config.hasReplace !== item.hasReplace) {
|
||||||
if (item.hasReplace) {
|
if (item.hasReplace) {
|
||||||
element.querySelector("#replaceHistoryBtn").parentElement.classList.remove("fn__none");
|
element.querySelector("#replaceHistoryBtn").parentElement.classList.remove("fn__none");
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -61,7 +61,6 @@ interface ISearchOption {
|
||||||
name?: string
|
name?: string
|
||||||
sort: number, // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序
|
sort: number, // 0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时),6:按相关度升序,7:按相关度降序
|
||||||
group: number, // 0:不分组,1:按文档分组
|
group: number, // 0:不分组,1:按文档分组
|
||||||
layout: number // 0:上下,1:左右
|
|
||||||
hasReplace: boolean,
|
hasReplace: boolean,
|
||||||
method: number // 0:文本,1:查询语法,2:SQL,3:正则表达式
|
method: number // 0:文本,1:查询语法,2:SQL,3:正则表达式
|
||||||
hPath: string
|
hPath: string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue