Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 2 gadi atpakaļ
vecāks
revīzija
a3c7ed10ed

+ 4 - 0
app/appearance/langs/en_US.json

@@ -426,6 +426,10 @@
   "refCountDESC": "Ref Count DESC",
   "createdASC": "Created Time ASC",
   "createdDESC": "Created Time DESC",
+  "docSizeASC": "Document Size ASC",
+  "docSizeDESC": "Document Size DESC",
+  "subDocCountASC": "Sub-docs Count ASC ",
+  "subDocCountDESC": "Sub-docs Count DESC",
   "sort": "Sort",
   "enterFullscreen": "Enter Full Screen",
   "exitFullscreen": "Exit Full Screen",

+ 4 - 0
app/appearance/langs/es_ES.json

@@ -426,6 +426,10 @@
   "refCountDESC": "Número de referencia DESC",
   "createdASC": "Tiempo de Creación ASC",
   "createdDESC": "Tiempo de creación DESC",
+  "docSizeASC": "Tamaño del Documento Ascendente",
+  "docSizeDESC": "Tamaño del Documento Descendente",
+  "subDocCountASC": "Recuento de subdocumentos ASC",
+  "subDocCountDESC": "Recuento de subdocs DESC",
   "sort": "Ordenar",
   "enterFullscreen": "Entrar en pantalla completa",
   "exitFullscreen": "Salir de pantalla completa",

+ 4 - 0
app/appearance/langs/fr_FR.json

@@ -426,6 +426,10 @@
   "refCountDESC": "Comte Rec décroissant",
   "createdASC": "Temps créé croissant",
   "createdDESC": "Temps créé décroissant",
+  "docSizeASC": "Taille du document croissante",
+  "docSizeDESC": "Taille du document décroissante",
+  "subDocCountASC": "Nombre de sous-documents ASC ",
+  "subDocCountDESC": "Nombre de sous-documents DESC",
   "sort": "Tri",
   "enterFullscreen": "plein écran",
   "exitFullscreen": "Quitter le plein écran",

+ 4 - 0
app/appearance/langs/zh_CHT.json

@@ -426,6 +426,10 @@
   "refCountDESC": "引用數降冪",
   "createdASC": "創建時間昇冪",
   "createdDESC": "創建時間降冪",
+  "docSizeASC": "文檔大小升序",
+  "docSizeDESC": "文檔大小降序",
+  "subDocCountASC": "子文檔數升序",
+  "subDocCountDESC": "子文檔數降序",
   "sort": "排序",
   "enterFullscreen": "進入全螢幕",
   "exitFullscreen": "退出全螢幕",

+ 4 - 0
app/appearance/langs/zh_CN.json

@@ -426,6 +426,10 @@
   "refCountDESC": "引用数降序",
   "createdASC": "创建时间升序",
   "createdDESC": "创建时间降序",
+  "docSizeASC": "文档大小升序",
+  "docSizeDESC": "文档大小降序",
+  "subDocCountASC": "子文档数升序",
+  "subDocCountDESC": "子文档数降序",
   "sort": "排序",
   "enterFullscreen": "进入全屏幕",
   "exitFullscreen": "退出全屏幕",

+ 25 - 1
app/src/layout/dock/Files.ts

@@ -918,7 +918,7 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
                     click: () => {
                         clickEvent(1);
                     }
-                }, {type: "separator"}, {
+                }, {
                     icon: window.siyuan.config.fileTree.sort === 4 ? "iconSelect" : undefined,
                     label: window.siyuan.languages.fileNameNatASC,
                     click: () => {
@@ -966,6 +966,30 @@ class="b3-list-item b3-list-item--hide-action" data-path="${item.path}">
                     click: () => {
                         clickEvent(8);
                     }
+                }, {type: "separator"}, {
+                    icon: window.siyuan.config.fileTree.sort === 11 ? "iconSelect" : undefined,
+                    label: window.siyuan.languages.docSizeASC,
+                    click: () => {
+                        clickEvent(11);
+                    }
+                }, {
+                    icon: window.siyuan.config.fileTree.sort === 12 ? "iconSelect" : undefined,
+                    label: window.siyuan.languages.docSizeDESC,
+                    click: () => {
+                        clickEvent(12);
+                    }
+                }, {type: "separator"}, {
+                    icon: window.siyuan.config.fileTree.sort === 13 ? "iconSelect" : undefined,
+                    label: window.siyuan.languages.subDocCountASC,
+                    click: () => {
+                        clickEvent(13);
+                    }
+                }, {
+                    icon: window.siyuan.config.fileTree.sort === 14 ? "iconSelect" : undefined,
+                    label: window.siyuan.languages.subDocCountDESC,
+                    click: () => {
+                        clickEvent(14);
+                    }
                 }, {type: "separator"}, {
                     icon: window.siyuan.config.fileTree.sort === 6 ? "iconSelect" : undefined,
                     label: window.siyuan.languages.customSort,

+ 29 - 4
app/src/mobile/util/MobileFiles.ts

@@ -243,9 +243,6 @@ export class MobileFiles extends Model {
                 clickEvent(1);
             }
         }).element);
-        window.siyuan.menus.menu.append(new MenuItem({
-            type: "separator"
-        }).element);
         window.siyuan.menus.menu.append(new MenuItem({
             icon: window.siyuan.config.fileTree.sort === 4 ? "iconSelect" : undefined,
             label: window.siyuan.languages.fileNameNatASC,
@@ -305,6 +302,34 @@ export class MobileFiles extends Model {
                 clickEvent(8);
             }
         }).element);
+        window.siyuan.menus.menu.append(new MenuItem({
+            icon: window.siyuan.config.fileTree.sort === 11 ? "iconSelect" : undefined,
+            label: window.siyuan.languages.docSizeASC,
+            click: () => {
+                clickEvent(11);
+            }
+        }).element);
+        window.siyuan.menus.menu.append(new MenuItem({
+            icon: window.siyuan.config.fileTree.sort === 12 ? "iconSelect" : undefined,
+            label: window.siyuan.languages.docSizeDESC,
+            click: () => {
+                clickEvent(12);
+            }
+        }).element);
+        window.siyuan.menus.menu.append(new MenuItem({
+            icon: window.siyuan.config.fileTree.sort === 13 ? "iconSelect" : undefined,
+            label: window.siyuan.languages.subDocCountASC,
+            click: () => {
+                clickEvent(13);
+            }
+        }).element);
+        window.siyuan.menus.menu.append(new MenuItem({
+            icon: window.siyuan.config.fileTree.sort === 14 ? "iconSelect" : undefined,
+            label: window.siyuan.languages.subDocCountDESC,
+            click: () => {
+                clickEvent(14);
+            }
+        }).element);
         window.siyuan.menus.menu.append(new MenuItem({
             icon: window.siyuan.config.fileTree.sort === 6 ? "iconSelect" : undefined,
             label: window.siyuan.languages.customSort,
@@ -526,7 +551,7 @@ export class MobileFiles extends Model {
         if (liElement) {
             liElement.remove();
         }
-        setNoteBook((notebooks: INotebook[])=> {
+        setNoteBook((notebooks: INotebook[]) => {
             const html = this.genNotebook(data.data.box);
             if (this.element.childElementCount === 0) {
                 this.element.innerHTML = html;

+ 8 - 0
kernel/model/file.go

@@ -361,6 +361,14 @@ func ListDocTree(boxID, path string, sortMode int) (ret []*File, totals int, err
 		sort.Slice(docs, func(i, j int) bool { return docs[i].CTime < docs[j].CTime })
 	case util.SortModeCreatedDESC:
 		sort.Slice(docs, func(i, j int) bool { return docs[i].CTime > docs[j].CTime })
+	case util.SortModeSizeASC:
+		sort.Slice(docs, func(i, j int) bool { return docs[i].Size < docs[j].Size })
+	case util.SortModeSizeDESC:
+		sort.Slice(docs, func(i, j int) bool { return docs[i].Size > docs[j].Size })
+	case util.SortModeSubDocCountASC:
+		sort.Slice(docs, func(i, j int) bool { return docs[i].SubFileCount < docs[j].SubFileCount })
+	case util.SortModeSubDocCountDESC:
+		sort.Slice(docs, func(i, j int) bool { return docs[i].SubFileCount > docs[j].SubFileCount })
 	}
 
 	if util.SortModeCustom != sortMode {

+ 17 - 13
kernel/util/sort.go

@@ -39,13 +39,13 @@ func PinYinCompare(str1, str2 string) bool {
 	return true
 }
 
-//UTF82GBK : transform UTF8 rune into GBK byte array
+// UTF82GBK transform UTF8 rune into GBK byte array.
 func UTF82GBK(src string) ([]byte, error) {
 	GB18030 := simplifiedchinese.All[0]
 	return io.ReadAll(transform.NewReader(bytes.NewReader([]byte(src)), GB18030.NewEncoder()))
 }
 
-//GBK2UTF8 : transform  GBK byte array into UTF8 string
+// GBK2UTF8 transform GBK byte array into UTF8 string.
 func GBK2UTF8(src []byte) (string, error) {
 	GB18030 := simplifiedchinese.All[0]
 	bytes, err := io.ReadAll(transform.NewReader(bytes.NewReader(src), GB18030.NewDecoder()))
@@ -53,15 +53,19 @@ func GBK2UTF8(src []byte) (string, error) {
 }
 
 const (
-	SortModeNameASC      = iota // 0:文件名字母升序
-	SortModeNameDESC            // 1:文件名字母降序
-	SortModeUpdatedASC          // 2:文件更新时间升序
-	SortModeUpdatedDESC         // 3:文件更新时间降序
-	SortModeAlphanumASC         // 4:文件名自然数升序
-	SortModeAlphanumDESC        // 5:文件名自然数降序
-	SortModeCustom              // 6:自定义排序
-	SortModeRefCountASC         // 7:引用数升序
-	SortModeRefCountDESC        // 8:引用数降序
-	SortModeCreatedASC          // 9:文件创建时间升序
-	SortModeCreatedDESC         // 10:文件创建时间降序
+	SortModeNameASC         = iota // 0:文件名字母升序
+	SortModeNameDESC               // 1:文件名字母降序
+	SortModeUpdatedASC             // 2:文件更新时间升序
+	SortModeUpdatedDESC            // 3:文件更新时间降序
+	SortModeAlphanumASC            // 4:文件名自然数升序
+	SortModeAlphanumDESC           // 5:文件名自然数降序
+	SortModeCustom                 // 6:自定义排序
+	SortModeRefCountASC            // 7:引用数升序
+	SortModeRefCountDESC           // 8:引用数降序
+	SortModeCreatedASC             // 9:文件创建时间升序
+	SortModeCreatedDESC            // 10:文件创建时间降序
+	SortModeSizeASC                // 11:文件大小升序
+	SortModeSizeDESC               // 12:文件大小降序
+	SortModeSubDocCountASC         // 13:子文档数升序
+	SortModeSubDocCountDESC        // 14:子文档数降序
 )