feat: 获取文件列表按时间排序近到远

This commit is contained in:
TsMask committed 2025-06-26 20:43:43 +08:00
1 parent a44854d4b5
commit e4c6a7c37a
2 files changed
+11

No files matched your search

+6
View File
@@ -2,6 +2,7 @@ package ssh
import (
"fmt"
"sort"
"strings"
"be.ems/src/framework/logger"
@@ -99,5 +100,10 @@ func FileList(sshClient *ConnSSH, path, search string) ([]FileListRow, error) {
FileName: fileName,
})
}
// 按时间排序
sort.Slice(rows, func(i, j int) bool {
return rows[i].ModifiedTime > rows[j].ModifiedTime
})
return rows, nil
}
+5
View File
@@ -3,6 +3,7 @@ package file
import (
"os"
"path/filepath"
"sort"
)
// FileListRow 文件列表行数据
@@ -74,5 +75,9 @@ func FileList(path, search string) ([]FileListRow, error) {
})
}
// 按时间排序
sort.Slice(rows, func(i, j int) bool {
return rows[i].ModifiedTime > rows[j].ModifiedTime
})
return rows, nil
}