Преглед на файлове

:art: https://github.com/siyuan-note/siyuan/issues/6766

Vanessa преди 2 години
родител
ревизия
67d95f8a78

+ 1 - 1
app/appearance/langs/en_US.json

@@ -1,4 +1,5 @@
 {
 {
+  "group": "Group",
   "noGroupBy": "No grouping",
   "noGroupBy": "No grouping",
   "groupByDoc": "Group by document",
   "groupByDoc": "Group by document",
   "leftRightLayout": "Left and right layout",
   "leftRightLayout": "Left and right layout",
@@ -6,7 +7,6 @@
   "keyword": "Keyword",
   "keyword": "Keyword",
   "searchMethod": "Search Method",
   "searchMethod": "Search Method",
   "regex": "Regex",
   "regex": "Regex",
-  "groupBy": "Grouping and Layout",
   "keywordsLimit": "Keywords Limit",
   "keywordsLimit": "Keywords Limit",
   "exportAsImage": "Export as image",
   "exportAsImage": "Export as image",
   "exportBySiYuan": "Export by SiYuan",
   "exportBySiYuan": "Export by SiYuan",

+ 1 - 1
app/appearance/langs/es_ES.json

@@ -1,4 +1,5 @@
 {
 {
+  "grupo": "Grupo",
   "noGroupBy": "Sin agrupar",
   "noGroupBy": "Sin agrupar",
   "groupByDoc": "Agrupar por documento",
   "groupByDoc": "Agrupar por documento",
   "leftRightLayout": "Disposición izquierda y derecha",
   "leftRightLayout": "Disposición izquierda y derecha",
@@ -6,7 +7,6 @@
   "keyword": "Palabra clave",
   "keyword": "Palabra clave",
   "searchMethod": "método de búsqueda",
   "searchMethod": "método de búsqueda",
   "regex": "Regex",
   "regex": "Regex",
-  "groupBy": "Agrupación y diseño",
   "keywordsLimit": "Límite de palabras clave",
   "keywordsLimit": "Límite de palabras clave",
   "exportAsImage": "Exportar como imagen",
   "exportAsImage": "Exportar como imagen",
   "exportBySiYuan": "Exportar por SiYuan",
   "exportBySiYuan": "Exportar por SiYuan",

+ 1 - 1
app/appearance/langs/fr_FR.json

@@ -1,4 +1,5 @@
 {
 {
+  "groupe": "Groupe",
   "noGroupBy": "Aucun regroupement",
   "noGroupBy": "Aucun regroupement",
   "groupByDoc": "Regrouper par document",
   "groupByDoc": "Regrouper par document",
   "leftRightLayout": "Disposition gauche et droite",
   "leftRightLayout": "Disposition gauche et droite",
@@ -6,7 +7,6 @@
   "keyword": "Mot-clé",
   "keyword": "Mot-clé",
   "searchMethod": "méthode de recherche",
   "searchMethod": "méthode de recherche",
   "regex": "Regex",
   "regex": "Regex",
-  "groupBy": "Regroupement et mise en page",
   "keywordsLimit": "Limite de mots clés",
   "keywordsLimit": "Limite de mots clés",
   "exportAsImage": "Exporter en tant qu'image",
   "exportAsImage": "Exporter en tant qu'image",
   "exportBySiYuan": "Exporter par SiYuan",
   "exportBySiYuan": "Exporter par SiYuan",

+ 1 - 1
app/appearance/langs/zh_CHT.json

@@ -1,4 +1,5 @@
 {
 {
+  "group": "分組",
   "noGroupBy": "不分組",
   "noGroupBy": "不分組",
   "groupByDoc": "按文檔分組",
   "groupByDoc": "按文檔分組",
   "leftRightLayout": "左右佈局",
   "leftRightLayout": "左右佈局",
@@ -6,7 +7,6 @@
   "keyword": "關鍵字",
   "keyword": "關鍵字",
   "searchMethod":"搜索方式",
   "searchMethod":"搜索方式",
   "regex":"正則表達式",
   "regex":"正則表達式",
-  "groupBy": "分組及佈局",
   "keywordsLimit": "關鍵字數量限制",
   "keywordsLimit": "關鍵字數量限制",
   "exportAsImage": "導出為圖片",
   "exportAsImage": "導出為圖片",
   "exportBySiYuan": "由思源筆記導出",
   "exportBySiYuan": "由思源筆記導出",

+ 1 - 1
app/appearance/langs/zh_CN.json

@@ -1,4 +1,5 @@
 {
 {
+  "group": "分组",
   "noGroupBy": "不分组",
   "noGroupBy": "不分组",
   "groupByDoc": "按文档分组",
   "groupByDoc": "按文档分组",
   "leftRightLayout": "左右布局",
   "leftRightLayout": "左右布局",
@@ -6,7 +7,6 @@
   "keyword": "关键字",
   "keyword": "关键字",
   "searchMethod":"搜索方式",
   "searchMethod":"搜索方式",
   "regex":"正则表达式",
   "regex":"正则表达式",
-  "groupBy": "分组及布局",
   "keywordsLimit": "关键字数量限制",
   "keywordsLimit": "关键字数量限制",
   "exportAsImage": "导出为图片",
   "exportAsImage": "导出为图片",
   "exportBySiYuan": "由思源笔记导出",
   "exportBySiYuan": "由思源笔记导出",

+ 1 - 0
app/src/search/spread.ts

@@ -105,6 +105,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
         replaceList: localData.replaceList || [],
         replaceList: localData.replaceList || [],
         group: localData.group || 0,
         group: localData.group || 0,
         layout: localData.layout || 0,
         layout: localData.layout || 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, () => {
         dialog.destroy();
         dialog.destroy();

+ 94 - 33
app/src/search/util.ts

@@ -68,6 +68,7 @@ export const openGlobalSearch = (text: string, replace: boolean) => {
                     replaceList: [],
                     replaceList: [],
                     group: localData.group || 0,
                     group: localData.group || 0,
                     layout: localData.layout || 0,
                     layout: localData.layout || 0,
+                    sort: localData.sort || 0,
                     types: localData.types
                     types: localData.types
                 }
                 }
             });
             });
@@ -118,8 +119,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
                 <svg><use xlink:href="#iconFilter"></use></svg>
                 <svg><use xlink:href="#iconFilter"></use></svg>
             </span>
             </span>
             <span class="fn__space"></span>
             <span class="fn__space"></span>
-            <span id="searchGroup" aria-label="${window.siyuan.languages.groupBy}" class="block__icon b3-tooltips b3-tooltips__w">
-                <svg><use xlink:href="#iconFiles"></use></svg>
+            <span id="searchMore" aria-label="${window.siyuan.languages.more}" class="block__icon b3-tooltips b3-tooltips__w">
+                <svg><use xlink:href="#iconMore"></use></svg>
             </span>
             </span>
             <span class="fn__space"></span>
             <span class="fn__space"></span>
             <span id="searchRefresh" aria-label="${window.siyuan.languages.refresh}" class="${closeCB ? "fn__none " : ""}block__icon b3-tooltips b3-tooltips__w">
             <span id="searchRefresh" aria-label="${window.siyuan.languages.refresh}" class="${closeCB ? "fn__none " : ""}block__icon b3-tooltips b3-tooltips__w">
@@ -321,8 +322,8 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
                 event.stopPropagation();
                 event.stopPropagation();
                 event.preventDefault();
                 event.preventDefault();
                 break;
                 break;
-            } else if (target.id === "searchGroup") {
-                addConfigGroupMenu(config, edit, element);
+            } else if (target.id === "searchMore") {
+                addConfigMoreMenu(config, edit, element);
                 window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true);
                 window.siyuan.menus.menu.popup({x: event.clientX - 16, y: event.clientY - 16}, true);
                 event.stopPropagation();
                 event.stopPropagation();
                 event.preventDefault();
                 event.preventDefault();
@@ -552,50 +553,109 @@ export const genSearch = (config: ISearchOption, element: Element, closeCB?: ()
     return edit;
     return edit;
 };
 };
 
 
-const addConfigGroupMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
+const addConfigMoreMenu = (config: ISearchOption, edit: Protyle, element: Element) => {
     window.siyuan.menus.menu.remove();
     window.siyuan.menus.menu.remove();
-    window.siyuan.menus.menu.append(new MenuItem({
-        label: window.siyuan.languages.noGroupBy,
-        current: config.group === 0,
+    const sortMenu = [{
+        label: window.siyuan.languages.type,
+        current: config.sort === 0,
         click() {
         click() {
-            element.querySelector("#searchCollapse").parentElement.classList.add("fn__none");
             config.group = 0;
             config.group = 0;
             inputEvent(element, config, undefined, edit);
             inputEvent(element, config, undefined, edit);
         }
         }
-    }).element);
-    window.siyuan.menus.menu.append(new MenuItem({
-        label: window.siyuan.languages.groupByDoc,
-        current: config.group === 1,
+    }, {
+        label: window.siyuan.languages.createdASC,
+        current: config.sort === 1,
         click() {
         click() {
-            element.querySelector("#searchCollapse").parentElement.classList.remove("fn__none");
             config.group = 1;
             config.group = 1;
             inputEvent(element, config, undefined, edit);
             inputEvent(element, config, undefined, edit);
         }
         }
+    }, {
+        label: window.siyuan.languages.createdDESC,
+        current: config.sort === 2,
+        click() {
+            config.group = 2;
+            inputEvent(element, config, undefined, edit);
+        }
+    }, {
+        label: window.siyuan.languages.modifiedASC,
+        current: config.sort === 3,
+        click() {
+            config.group = 3;
+            inputEvent(element, config, undefined, edit);
+        }
+    }, {
+        label: window.siyuan.languages.modifiedDESC,
+        current: config.sort === 4,
+        click() {
+            config.group = 4;
+            inputEvent(element, config, undefined, edit);
+        }
+    }]
+    if (config.group === 1) {
+        sortMenu.push({
+            label: window.siyuan.languages.context,
+            current: config.sort === 5,
+            click() {
+                config.sort = 5;
+                inputEvent(element, config, undefined, edit);
+            }
+        })
+    }
+    window.siyuan.menus.menu.append(new MenuItem({
+        label: window.siyuan.languages.sort,
+        type: "submenu",
+        submenu: sortMenu,
     }).element);
     }).element);
-    window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
     window.siyuan.menus.menu.append(new MenuItem({
     window.siyuan.menus.menu.append(new MenuItem({
-        label: window.siyuan.languages.topBottomLayout,
-        current: config.layout === 0,
-        click() {
-            element.querySelector(".search__layout").classList.remove("search__layout--row");
-            setPadding(edit.protyle);
-            config.layout = 0;
-            if (!element.parentElement.getAttribute("data-id")) {
-                localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+        label: window.siyuan.languages.group,
+        type: "submenu",
+        submenu: [{
+            label: window.siyuan.languages.noGroupBy,
+            current: config.group === 0,
+            click() {
+                element.querySelector("#searchCollapse").parentElement.classList.add("fn__none");
+                config.group = 0;
+                if (config.sort === 5) {
+                    config.sort = 0;
+                }
+                inputEvent(element, config, undefined, edit);
             }
             }
-        }
+        }, {
+            label: window.siyuan.languages.groupByDoc,
+            current: config.group === 1,
+            click() {
+                element.querySelector("#searchCollapse").parentElement.classList.remove("fn__none");
+                config.group = 1;
+                inputEvent(element, config, undefined, edit);
+            }
+        }]
     }).element);
     }).element);
     window.siyuan.menus.menu.append(new MenuItem({
     window.siyuan.menus.menu.append(new MenuItem({
-        label: window.siyuan.languages.leftRightLayout,
-        current: config.layout === 1,
-        click() {
-            element.querySelector(".search__layout").classList.add("search__layout--row");
-            setPadding(edit.protyle);
-            config.layout = 1;
-            if (!element.parentElement.getAttribute("data-id")) {
-                localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+        label: window.siyuan.languages.layout,
+        type: "submenu",
+        submenu: [{
+            label: window.siyuan.languages.topBottomLayout,
+            current: config.layout === 0,
+            click() {
+                element.querySelector(".search__layout").classList.remove("search__layout--row");
+                setPadding(edit.protyle);
+                config.layout = 0;
+                if (!element.parentElement.getAttribute("data-id")) {
+                    localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+                }
             }
             }
-        }
+        }, {
+            label: window.siyuan.languages.leftRightLayout,
+            current: config.layout === 1,
+            click() {
+                element.querySelector(".search__layout").classList.add("search__layout--row");
+                setPadding(edit.protyle);
+                config.layout = 1;
+                if (!element.parentElement.getAttribute("data-id")) {
+                    localStorage.setItem(Constants.LOCAL_SEARCHEDATA, JSON.stringify(config));
+                }
+            }
+        }]
     }).element);
     }).element);
 };
 };
 
 
@@ -878,6 +938,7 @@ const inputEvent = (element: Element, config: ISearchOption, inputTimeout: numbe
                 types: config.types,
                 types: config.types,
                 paths: config.idPath || [],
                 paths: config.idPath || [],
                 groupBy: config.group,
                 groupBy: config.group,
+                orderBy: config.sort,
             }, (response) => {
             }, (response) => {
                 onSearch(response.data.blocks, edit, element);
                 onSearch(response.data.blocks, edit, element);
                 element.querySelector("#searchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);
                 element.querySelector("#searchResult").innerHTML = window.siyuan.languages.findInDoc.replace("${x}", response.data.matchedRootCount).replace("${y}", response.data.matchedBlockCount);

+ 1 - 0
app/src/types/index.d.ts

@@ -34,6 +34,7 @@ interface Window {
 }
 }
 
 
 interface ISearchOption {
 interface ISearchOption {
+    sort: number,  //  0:按块类型(默认),1:按创建时间升序,2:按创建时间降序,3:按更新时间升序,4:按更新时间降序,5:按内容顺序(仅在按文档分组时)
     group: number,  // 0:不分组,1:按文档分组
     group: number,  // 0:不分组,1:按文档分组
     layout: number  // 0:上下,1:左右
     layout: number  // 0:上下,1:左右
     hasReplace: boolean,
     hasReplace: boolean,