feat: 获取文件列表按时间排序近到远
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user