修改pc端path显示;提取公共组件
This commit is contained in:
parent
d98e7b55cf
commit
2a7a27e8e4
@ -176,10 +176,7 @@
|
|||||||
header-align="center"
|
header-align="center"
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span v-if="scope.row.size < 1024">{{ scope.row.size }}B</span>
|
<span>{{formatSize(scope.row.size)}}</span>
|
||||||
<span v-if="scope.row.size >= 1024 && scope.row.size < 1024*1024">{{ (scope.row.size/1024).toFixed(2) }}K</span>
|
|
||||||
<span v-if="scope.row.size >= 1024*1024 && scope.row.size < 1024*1024*1024">{{ (scope.row.size/(1024*1024)).toFixed(2) }}M</span>
|
|
||||||
<span v-if="scope.row.size >= 1024*1024*1024 && scope.row.size < 1024*1024*1024*1024">{{ (scope.row.size/(1024*1024*1024)).toFixed(2) }}G</span>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
@ -196,13 +193,7 @@
|
|||||||
header-align="left"
|
header-align="left"
|
||||||
>
|
>
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span v-if="scope.row.agoTime < 1000*10"> 刚刚</span>
|
<span> {{formatTime(scope.row.agoTime)}}</span>
|
||||||
<span v-if="scope.row.agoTime >= 1000*10 && scope.row.agoTime < 1000*60"> {{ (scope.row.agoTime/1000).toFixed(0) }} 秒钟前</span>
|
|
||||||
<span v-if="scope.row.agoTime >= 1000*60 && scope.row.agoTime < 1000*60*60"> {{ (scope.row.agoTime/(1000*60)).toFixed(0) }} 分钟前</span>
|
|
||||||
<span v-if="scope.row.agoTime >= 1000*60*60 && scope.row.agoTime < 1000*60*60*24"> {{ (scope.row.agoTime/(1000*60*60)).toFixed(0) }} 小时前</span>
|
|
||||||
<span v-if="scope.row.agoTime >= 1000*60*60*24 && scope.row.agoTime < 1000*60*60*24*30"> {{ (scope.row.agoTime/(1000*60*60*24)).toFixed(0) }} 天前</span>
|
|
||||||
<span v-if="scope.row.agoTime >= 1000*60*60*24*30 && scope.row.agoTime < 1000*60*60*24*30*12">{{ (scope.row.agoTime/(1000*60*60*24)).toFixed(0) }} 个月前</span>
|
|
||||||
<span v-if="scope.row.agoTime >= 1000*60*60*24*30*12"> {{ (scope.row.agoTime/(1000*60*60*24*30*12)).toFixed(0) }} 年前</span>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</template>
|
</template>
|
||||||
@ -224,8 +215,8 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
// import defaultSettings from '@/settings'
|
// import defaultSettings from '@/settings'
|
||||||
import { getPath, getPathList, setPath, removePath } from '@/utils/path'
|
// import { getPath, getPathList, setPath, removePath } from '@/utils/path'
|
||||||
import { strlen, substring10 } from '@/utils/number'
|
import { strlen, substring10, formatTime, formatSize } from '@/utils/number'
|
||||||
import Bus from '@/assets/js/bus'
|
import Bus from '@/assets/js/bus'
|
||||||
import api from '@/api/upload-api'
|
import api from '@/api/upload-api'
|
||||||
import BreadcrumbFilePath from "../../components/Breadcrumb/BreadcrumbFilePath";
|
import BreadcrumbFilePath from "../../components/Breadcrumb/BreadcrumbFilePath";
|
||||||
@ -239,7 +230,7 @@ export default {
|
|||||||
imageUrl: process.env.VUE_APP_BASE_API + '/view/thumbnail?jmal-token=' + this.$store.state.user.token + '&id=',
|
imageUrl: process.env.VUE_APP_BASE_API + '/view/thumbnail?jmal-token=' + this.$store.state.user.token + '&id=',
|
||||||
// imageUrl: 'http://localhost:8088/view?username=' + this.$store.state.user.name + '&id=',
|
// imageUrl: 'http://localhost:8088/view?username=' + this.$store.state.user.name + '&id=',
|
||||||
fileMenuActive: '',
|
fileMenuActive: '',
|
||||||
path: getPath(),
|
path: this.$route.query.path,
|
||||||
showNewFolder: false,
|
showNewFolder: false,
|
||||||
isShowNewFolder: false,
|
isShowNewFolder: false,
|
||||||
listModeSearch: false,
|
listModeSearch: false,
|
||||||
@ -334,18 +325,9 @@ export default {
|
|||||||
this.preliminaryRowData()
|
this.preliminaryRowData()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 加载路径
|
if (window.history && window.history.pushState) {
|
||||||
const pathList = getPathList()
|
history.pushState(null, null, document.URL);
|
||||||
if (pathList && pathList !== 'undefined') {
|
window.addEventListener('popstate', this.goBack, false);
|
||||||
const res = JSON.parse(pathList)
|
|
||||||
const list = []
|
|
||||||
res.forEach(function(element) {
|
|
||||||
const item0 = {}
|
|
||||||
item0['folder'] = element.folder + ''
|
|
||||||
item0['index'] = element.index
|
|
||||||
list.push(item0)
|
|
||||||
})
|
|
||||||
this.pathList = list
|
|
||||||
}
|
}
|
||||||
const that = this
|
const that = this
|
||||||
window.onresize = function temp() {
|
window.onresize = function temp() {
|
||||||
@ -353,7 +335,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
removePath()
|
// removePath()
|
||||||
|
window.removeEventListener('popstate', this.goBack, false);
|
||||||
},
|
},
|
||||||
directives: {
|
directives: {
|
||||||
// 注册一个局部的自定义指令 v-focus
|
// 注册一个局部的自定义指令 v-focus
|
||||||
@ -377,6 +360,14 @@ export default {
|
|||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
},
|
},
|
||||||
|
// 格式化最近时间
|
||||||
|
formatTime(time) {
|
||||||
|
return formatTime(time)
|
||||||
|
},
|
||||||
|
// 格式化文件大小
|
||||||
|
formatSize(size) {
|
||||||
|
return formatSize(size)
|
||||||
|
},
|
||||||
upload() {
|
upload() {
|
||||||
console.log('user', this.$store.state.user);
|
console.log('user', this.$store.state.user);
|
||||||
// 打开文件选择框
|
// 打开文件选择框
|
||||||
@ -388,17 +379,29 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
uploadFolder() {
|
uploadFolder() {
|
||||||
// 打开文件夹选择框
|
if(window.uploader.supportDirectory){
|
||||||
console.log('selectFolder')
|
// 打开文件夹选择框
|
||||||
Bus.$emit('uploadFolder', {
|
console.log('selectFolder')
|
||||||
// 传入的参数
|
Bus.$emit('uploadFolder', {
|
||||||
currentDirectory: this.path,
|
// 传入的参数
|
||||||
username: this.$store.state.user.name,
|
currentDirectory: this.path,
|
||||||
userId: this.$store.state.user.userId
|
username: this.$store.state.user.name,
|
||||||
})
|
userId: this.$store.state.user.userId
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
this.$message({
|
||||||
|
message: '该浏览器不支持上传文件夹',
|
||||||
|
type: 'warning'
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleLink(item, index) {
|
// 浏览器的返回事件
|
||||||
if(item.search){
|
goBack(){
|
||||||
|
const linkIndex = this.pathList.length-3
|
||||||
|
this.handleLink(this.pathList[linkIndex],linkIndex)
|
||||||
|
},
|
||||||
|
handleLink(item, index, unPushLink) {
|
||||||
|
if(item && item.search){
|
||||||
if(item.searchKey){
|
if(item.searchKey){
|
||||||
this.searchFileByKeyWord(item.searchKey)
|
this.searchFileByKeyWord(item.searchKey)
|
||||||
} else if(item.row){
|
} else if(item.row){
|
||||||
@ -415,7 +418,14 @@ export default {
|
|||||||
this.path += '/' + this.pathList[number].folder
|
this.path += '/' + this.pathList[number].folder
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setPath(this.path, this.pathList)
|
if(!unPushLink){
|
||||||
|
if (!this.$route.query.path){
|
||||||
|
this.$router.push(`/_m`)
|
||||||
|
} else {
|
||||||
|
this.$router.push(`?path=${this.path}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// setPath(this.path, this.pathList)
|
||||||
this.pagination.pageIndex = 1
|
this.pagination.pageIndex = 1
|
||||||
this.getFileList()
|
this.getFileList()
|
||||||
}
|
}
|
||||||
@ -502,12 +512,12 @@ export default {
|
|||||||
item2['index'] = 2
|
item2['index'] = 2
|
||||||
this.pathList.push(item1)
|
this.pathList.push(item1)
|
||||||
this.pathList.push(item2)
|
this.pathList.push(item2)
|
||||||
|
this.$router.push(`?search-file=${key}`)
|
||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
api.searchFile({
|
api.searchFile({
|
||||||
userId: this.$store.state.user.userId,
|
userId: this.$store.state.user.userId,
|
||||||
keyword: key,
|
keyword: key,
|
||||||
currentDirectory: getPath(),
|
currentDirectory: this.$route.query.path,
|
||||||
pageIndex: this.pagination.pageIndex,
|
pageIndex: this.pagination.pageIndex,
|
||||||
pageSize: this.pagination.pageSize
|
pageSize: this.pagination.pageSize
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -527,7 +537,7 @@ export default {
|
|||||||
api.searchFileAndOpenDir({
|
api.searchFileAndOpenDir({
|
||||||
userId: this.$store.state.user.userId,
|
userId: this.$store.state.user.userId,
|
||||||
id: row.id,
|
id: row.id,
|
||||||
currentDirectory: getPath(),
|
currentDirectory: this.$route.query.path,
|
||||||
pageIndex: this.pagination.pageIndex,
|
pageIndex: this.pagination.pageIndex,
|
||||||
pageSize: this.pagination.pageSize
|
pageSize: this.pagination.pageSize
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -543,7 +553,7 @@ export default {
|
|||||||
this.tableLoading = true
|
this.tableLoading = true
|
||||||
api.fileList({
|
api.fileList({
|
||||||
userId: this.$store.state.user.userId,
|
userId: this.$store.state.user.userId,
|
||||||
currentDirectory: getPath(),
|
currentDirectory: this.$route.query.path,
|
||||||
pageIndex: this.pagination.pageIndex,
|
pageIndex: this.pagination.pageIndex,
|
||||||
pageSize: this.pagination.pageSize
|
pageSize: this.pagination.pageSize
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
@ -1017,9 +1027,14 @@ export default {
|
|||||||
this.pathList[this.pathList.length - 1] = item1
|
this.pathList[this.pathList.length - 1] = item1
|
||||||
this.pathList.push(item2)
|
this.pathList.push(item2)
|
||||||
this.pagination.pageIndex = 1
|
this.pagination.pageIndex = 1
|
||||||
|
this.$router.push(`?search-file=${row.id}`)
|
||||||
this.searchFileAndOpenDir(row)
|
this.searchFileAndOpenDir(row)
|
||||||
} else {
|
} else {
|
||||||
this.path += '/' + row.name
|
if(this.path){
|
||||||
|
this.path += '/' + row.name
|
||||||
|
} else {
|
||||||
|
this.path = '/' + row.name
|
||||||
|
}
|
||||||
const item1 = {}
|
const item1 = {}
|
||||||
item1['folder'] = row.name
|
item1['folder'] = row.name
|
||||||
item1['index'] = this.pathList.length - 1
|
item1['index'] = this.pathList.length - 1
|
||||||
@ -1028,8 +1043,10 @@ export default {
|
|||||||
item2['index'] = this.pathList.length
|
item2['index'] = this.pathList.length
|
||||||
this.pathList[this.pathList.length - 1] = item1
|
this.pathList[this.pathList.length - 1] = item1
|
||||||
this.pathList.push(item2)
|
this.pathList.push(item2)
|
||||||
setPath(this.path, this.pathList)
|
// setPath(this.path, this.pathList)
|
||||||
this.pagination.pageIndex = 1
|
this.pagination.pageIndex = 1
|
||||||
|
console.log(this.path)
|
||||||
|
this.$router.push(`?path=${this.path}`)
|
||||||
this.getFileList()
|
this.getFileList()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user