feat: 获取文件列表按时间排序近到远
This commit is contained in:
@@ -2,6 +2,7 @@ package ssh
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"be.ems/src/framework/cmd"
|
"be.ems/src/framework/cmd"
|
||||||
@@ -99,5 +100,10 @@ func FileList(sshClient *ConnSSH, path, search string) ([]FileListRow, error) {
|
|||||||
FileName: fileName,
|
FileName: fileName,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按时间排序
|
||||||
|
sort.Slice(rows, func(i, j int) bool {
|
||||||
|
return rows[i].ModifiedTime > rows[j].ModifiedTime
|
||||||
|
})
|
||||||
return rows, nil
|
return rows, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package file
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FileListRow 文件列表行数据
|
// 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
|
return rows, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user