diff --git a/nezha-fronted/src/components/cli/fileDirectory.vue b/nezha-fronted/src/components/cli/fileDirectory.vue index 38ce8eebf..c99651188 100644 --- a/nezha-fronted/src/components/cli/fileDirectory.vue +++ b/nezha-fronted/src/components/cli/fileDirectory.vue @@ -33,47 +33,47 @@
-
+
{{$t('overall.name')}}
+ }" @click.stop="orderBy('nameOrderType','asc' , 'name')">
+ }" @click.stop="orderBy('nameOrderType','desc', 'name')">
-
+
{{$t('backup.size')}}
+ }" @click.stop="orderBy('sizeOrderType','asc' , 'size')">
+ }" @click.stop="orderBy('sizeOrderType','desc', 'size')">
-
+
{{$t('issue.createTime')}}
+ }" @click.stop="orderBy('dateOrderType','asc', 'cts')">
+ }" @click.stop="orderBy('dateOrderType','desc', 'cts')">
@@ -81,15 +81,24 @@ {{$t('overall.option')}} -
+
- + ..
-
+
@@ -389,10 +398,24 @@ export default { if (res.code === 200) { this.fileDirectoryLoading = false this.fileDirectory = res.data.path + res.data.list.forEach(item => { + if (item.name[0] === '.') { + item.isHide = true + } + }) this.fileList = res.data.list this.oldFileList = res.data.list this.editPath = '' this.breadcrumb = res.data.path.split('/').filter(item => item) + if (this.nameOrderType) { + this.orderBy('nameOrderType',this.nameOrderType , 'name') + } + if (this.sizeOrderType) { + this.orderBy('sizeOrderType',this.sizeOrderType , 'size') + } + if (this.dateOrderType) { + this.orderBy('dateOrderType',this.dateOrderType , 'cts') + } } else { this.$message.error(res.msg) this.editPath = '' @@ -531,16 +554,41 @@ export default { } return '-' }, - orderBy (key, orderType, order) { + orderBy (key, type, order) { + let orderType = type + if (!orderType) { + orderType = this[key] === 'asc' ? 'desc' : 'asc' + } + this.sizeOrderType = 0 + this.dateOrderType = 0 + this.nameOrderType = 0 if (this[key] == orderType) { this[key] = 0 this.fileList = this.oldFileList } else if (orderType == 'nameOrderType') { this[key] = orderType - this.fileList = this.$loadsh.orderBy(this.oldFileList, [user => user.name.toLowerCase()], [orderType]) + let isDirArr = this.oldFileList.filter(item => item.isDir) + let isRegArr = this.oldFileList.filter(item => !item.isDir) + isDirArr = this.$loadsh.orderBy(isDirArr, [user => user.name.toLowerCase()], [orderType]) + isRegArr = this.$loadsh.orderBy(isRegArr, [user => user.name.toLowerCase()], [orderType]) + this.fileList = [] + if (orderType === 'asc') { + this.fileList = this.fileList.concat(isDirArr, isRegArr) + } else { + this.fileList = this.fileList.concat(isRegArr, isDirArr) + } } else { this[key] = orderType - this.fileList = this.$loadsh.orderBy(this.oldFileList, order, orderType) + let isDirArr = this.oldFileList.filter(item => item.isDir) + let isRegArr = this.oldFileList.filter(item => !item.isDir) + isDirArr = this.$loadsh.orderBy(isDirArr, order, orderType) + isRegArr = this.$loadsh.orderBy(isRegArr, order, orderType) + this.fileList = [] + if (orderType === 'asc') { + this.fileList = this.fileList.concat(isDirArr, isRegArr) + } else { + this.fileList = this.fileList.concat(isRegArr, isDirArr) + } } }, tableOperation ([command, row, param]) {