修改文件分享展示界面

This commit is contained in:
jmal 2020-05-20 17:46:52 +08:00
parent 4d940656ff
commit 8c994f3138
3 changed files with 68 additions and 108 deletions

View File

@ -51,32 +51,34 @@
/*min-height: calc(100vh - 50px);*/ /*min-height: calc(100vh - 50px);*/
} }
.share-empty { .share-empty {
height: 30%; /*height: 30%;*/
width: 50%; /*width: 50%;*/
color: #6e6e6e; color: #6e6e6e;
position: absolute; margin: 20%;
top: 50%; /*left: 50%;*/
left: 50%; /*position: absolute;*/
margin: -15% 0 0 -25%; /*top: 50%;*/
} /*left: 50%;*/
.share-empty-icon { /*margin: -15% 0 0 -25%;*/
width: 268px; }
margin: 0 auto; .share-empty-icon {
img { width: 268px;
width: 100%; margin: 0 auto;
} img {
} width: 100%;
.share-empty-status { }
text-align: center; }
padding-top: 40px; .share-empty-status {
font-size: 18px; text-align: center;
line-height: 28px; padding-top: 40px;
} font-size: 18px;
.share-empty-text { line-height: 28px;
padding-top: 20px; }
font-size: 16px; .share-empty-text {
text-align: center; padding-top: 20px;
line-height: 28px; font-size: 16px;
} text-align: center;
line-height: 28px;
}
</style> </style>

View File

@ -232,7 +232,6 @@
import 'vant/lib/checkbox/style'; import 'vant/lib/checkbox/style';
import 'vant/lib/checkbox-group/style'; import 'vant/lib/checkbox-group/style';
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { getPath, getPathList, setPath, removePath } from '@/utils/path'
import { strlen, substring10, formatTime, formatSize } 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/file-api' import api from '@/api/file-api'
@ -256,9 +255,7 @@
newFolderName: '新建文件夹', newFolderName: '新建文件夹',
renameFileName: '', renameFileName: '',
searchFileName: '', searchFileName: '',
pathList: [ pathList: [],
{ 'folder': '', index: 0 },
],
fileList: [], fileList: [],
pagination: { pagination: {
fileId: false, fileId: false,
@ -330,7 +327,7 @@
dragLoop: null, dragLoop: null,
positionX:0, positionX:0,
positionY:0, positionY:0,
grid: true, grid: false,
vmode: 'list', vmode: 'list',
gridColumnNum: -1, gridColumnNum: -1,
gridHoverItemIndex: -1, gridHoverItemIndex: -1,
@ -353,11 +350,6 @@
}, },
created() { created() {
this.getFileList() this.getFileList()
// if(this.$route.query.f){
// this.accessShareOpenDir(this.$route.query.f)
// }else{
// this.getFileList()
// }
}, },
mounted() { mounted() {
Bus.$on('fileSuccess', () => { Bus.$on('fileSuccess', () => {
@ -388,27 +380,8 @@
this.grid = true this.grid = true
} }
} }
// 加载url上的path
if(this.$route.query.path){
const path = decodeURI(this.$route.query.path)
this.pathList.splice(1,1)
path.split('/').forEach((pathName,index)=>{
if(index > 0){
const item = {}
item['folder'] = pathName
item['index'] = index
this.pathList.push(item)
}
})
const item = {}
item['folder'] = '+'
item['index'] = this.pathList.length
this.pathList.push(item)
}
}, },
destroyed() { destroyed() {
removePath()
window.removeEventListener('popstate', this.goBack, false); window.removeEventListener('popstate', this.goBack, false);
}, },
directives: { directives: {
@ -499,15 +472,15 @@
}, },
handleLink(item, index) { handleLink(item, index) {
if(index === 0){ if(index === 0){
this.pathList = [ this.pathList.splice(this.pathList.findIndex((v,i) => i === index + 1), this.pathList.length - (index + 1))
{ 'folder': '', index: 0 }, this.getFileList(null,true);
], this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}`)
this.getFileList();
} }
if(item && item.search){ if(item && item.fileId){
this.accessShareOpenDir(item.fileId) this.accessShareOpenDir(item.fileId)
this.pathList.splice(this.pathList.findIndex(v => v.index === index + 2), this.pathList.length - (index + 2)) this.pathList.splice(this.pathList.findIndex((v,i) => i === index + 1), this.pathList.length - (index + 1))
} }
console.log(this.pathList)
}, },
// 切换布局 // 切换布局
changeVmode(){ changeVmode(){
@ -517,10 +490,7 @@
this.vmode = 'grid' this.vmode = 'grid'
} }
let f = '' let f = ''
if(this.$route.query.f){ this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}`)
f = this.$route.query.f
}
this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}&f=${f}`)
}, },
accessShareOpenDir(fileId) { accessShareOpenDir(fileId) {
this.tableLoading = true this.tableLoading = true
@ -530,28 +500,20 @@
pageIndex: this.pagination.pageIndex, pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize pageSize: this.pagination.pageSize
}).then(res => { }).then(res => {
this.isLoading = false
this.fileList = res.data this.fileList = res.data
this.clientHeight = document.documentElement.clientHeight - 265 this.clientHeight = document.documentElement.clientHeight - 265
this.listModeSearch = true this.listModeSearch = true
this.pagination.fileId = fileId this.pagination.fileId = fileId
this.pagination['total'] = res.count this.pagination['total'] = res.count
this.$nextTick(()=>{ this.$nextTick(()=>{
this.containerResize()
this.tableLoading = false this.tableLoading = false
this.linkFailed = false
// const path = this.fileList[0].path
// console.log(path)
// path.split('/').forEach((pathName,index)=>{
// if(index > 0){
// const item = {}
// item['folder'] = pathName
// item['index'] = index
// this.pathList.push(item)
// }
// })
}) })
}).catch(e => {}) }).catch(e => {})
}, },
getFileList(pagination) { getFileList(pagination,overload) {
this.tableLoading = true this.tableLoading = true
api.accessShare({ api.accessShare({
share:this.shareId, share:this.shareId,
@ -585,14 +547,12 @@
this.linkFailed = false this.linkFailed = false
if(!pagination){ if(!pagination){
// 打开文件夹 // 打开文件夹
const item1 = {} const item = {}
item1['folder'] = this.currentDirName item['folder'] = this.currentDirName
item1['index'] = this.pathList.length - 1 item['index'] = this.pathList.length
const item2 = {} if(!overload){
item2['folder'] = '+' this.pathList.push(item)
item2['index'] = this.pathList.length }
this.pathList[this.pathList.length - 1] = item1
this.pathList.push(item2)
} }
}) })
} }
@ -875,8 +835,16 @@
} else { } else {
fileIds.push(this.rowContextData.id) fileIds.push(this.rowContextData.id)
} }
console.log("fileIds",fileIds)
window.open(process.env.VUE_APP_BASE_FILE_API + `/public/s/download?&share=${this.shareId}&fileIds=${fileIds}`, '_self') if(process.env.NODE_ENV !== 'development'){
let host = window.location.host
if(window.location.port.length > 0){
host = window.location.host.substring(0,window.location.host.length - window.location.port.length - 1)
}
window.open(`http://${host}:10010/public/s/download?&share=${this.shareId}&fileIds=${fileIds}`,'_self')
}else{
window.open(process.env.VUE_APP_BASE_FILE_API + `/public/s/download?&share=${this.shareId}&fileIds=${fileIds}`, '_self')
}
} else { } else {
this.$message({ this.$message({
message: '所选文件为空', message: '所选文件为空',
@ -888,29 +856,19 @@
fileClick(row) { fileClick(row) {
if (row.isFolder) { if (row.isFolder) {
// 打开文件夹 // 打开文件夹
const item1 = {} const item = {}
item1['folder'] = row.name item['folder'] = row.name
item1['search'] = true item['fileId'] = row.id
item1['fileId'] = row.id item['index'] = this.pathList.length
item1['index'] = this.pathList.length - 1 this.pathList.push(item)
const item2 = {}
item2['folder'] = '+'
item2['index'] = this.pathList.length
this.pathList[this.pathList.length - 1] = item1
this.pathList.push(item2)
this.pagination.pageIndex = 1 this.pagination.pageIndex = 1
this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}&f=${row.id}`) this.$router.push(`/s?s=${this.shareId}&vmode=${this.vmode}`)
this.accessShareOpenDir(row.id) this.accessShareOpenDir(row.id)
} else { } else {
if(row.contentType.includes('text')){ // 打开文件
let routeData = this.$router.resolve({path: '/public/articles/article',query: {mark: row.id}}) const fileIds = [row.id]
window.open(routeData.href, '_blank'); const url = process.env.VUE_APP_BASE_FILE_API + '/public/s/preview/' + row.name + '?fileIds=' + fileIds
}else{ window.open(url, '_blank')
// 打开文件
const fileIds = [row.id]
const url = process.env.VUE_APP_BASE_FILE_API + '/public/s/preview/' + row.name + '?fileIds=' + fileIds
window.open(url, '_blank')
}
} }
} }
} }

View File

@ -146,7 +146,7 @@
<!--</el-pagination>--> <!--</el-pagination>-->
<empty-file <empty-file
v-if="fileList.length < 1 && !tableLoading" v-if="fileList.length < 1 && !tableLoading"
emptyStatus="您还没有分享历史哦~" emptyStatus="还没有分享历史哦~"
:emptyShare="true" :emptyShare="true"
> >
</empty-file> </empty-file>