diff --git a/package.json b/package.json index 18041b5..7e50815 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "jspdf": "^2.5.1", "less-loader": "^6.1.0", "lib-flexible": "^0.3.2", + "moment": "^2.29.4", "monaco-editor": "^0.23.0", "monaco-editor-vue": "^1.0.10", "monaco-editor-webpack-plugin": "^3.0.1", diff --git a/src/api/file-api.js b/src/api/file-api.js index 9f567eb..1af1c03 100644 --- a/src/api/file-api.js +++ b/src/api/file-api.js @@ -196,6 +196,14 @@ export default { params }) }, + // 获取分享信息 + getShare: function(params) { + return request({ + url: '/get/share', + method: 'get', + params + }) + }, // 访问分享链接里的文件夹 accessShareOpenDir: function(params) { return request({ diff --git a/src/components/ShareDialog/index.vue b/src/components/ShareDialog/index.vue new file mode 100644 index 0000000..f9b218e --- /dev/null +++ b/src/components/ShareDialog/index.vue @@ -0,0 +1,384 @@ + + + + + + + + + + + {{ file.name }} + + + + + + + + + + + + + + 到期时间 +   + + + + + + + + + + + + + + + + + + + 提取码 + + + + + + + + + + + + + + diff --git a/src/components/ShowFile/ShowFile.vue b/src/components/ShowFile/ShowFile.vue index 71e909c..7d57568 100644 --- a/src/components/ShowFile/ShowFile.vue +++ b/src/components/ShowFile/ShowFile.vue @@ -489,18 +489,7 @@ - - - - - - - - + { - this.shareDialog = true - // 这3行代码是为了让vue刷新数据 - const isFavorite = this.rowContextData.isFavorite - this.rowContextData.isFavorite = !isFavorite - this.rowContextData.isFavorite = isFavorite - if (res.data) { - let shareId = res.data - this.shareLink = window.location.origin + '/s?s=' + shareId - this.generateShareLinkLoading = false - this.rowContextData.shareId = shareId - } - this.rowContextData.isShare = true - }).catch(() => { - this.shareDialog = false - this.generateShareLinkLoading = false - }) + this.shareDialogObject = row + this.shareDialogObject.fileId = row.id + this.shareDialogObject.shareId = undefined + this.shareDialogVisible = true + // this.shareFileName = row.name + // api.generate({ + // userId: row.userId, + // fileId: row.id, + // isFolder: row.isFolder + // }).then(res => { + // this.shareDialog = true + // // 这3行代码是为了让vue刷新数据 + // const isFavorite = this.rowContextData.isFavorite + // this.rowContextData.isFavorite = !isFavorite + // this.rowContextData.isFavorite = isFavorite + // if (res.data) { + // let shareId = res.data + // this.shareLink = window.location.origin + '/s?s=' + shareId + // this.generateShareLinkLoading = false + // this.rowContextData.shareId = shareId + // } + // this.rowContextData.isShare = true + // }).catch(() => { + // this.shareDialog = false + // this.generateShareLinkLoading = false + // }) }, - // 复制分享链接 - copyShareLink() { - var clipboard = new Clipboard('.tag-share-link') - clipboard.on('success', e => { - this.$message({ - message: '复制成功', - type: 'success', - duration: 1000 - }); - this.shareDialog = false - // 释放内存 - clipboard.destroy() - }) - clipboard.on('error', e => { - // 不支持复制 - this.$message({ - message: '该浏览器不支持自动复制', - type: 'warning', - duration: 1000 - }); - // 释放内存 - clipboard.destroy() - }) + shareSuccess(shareId) { + console.log('shareSuccess', shareId) + // 这3行代码是为了让vue刷新数据 + const isFavorite = this.rowContextData.isFavorite + this.rowContextData.isFavorite = !isFavorite + this.rowContextData.isFavorite = isFavorite + this.rowContextData.shareId = shareId + this.rowContextData.isShare = true }, downloadFile() { let totalSize = 0 @@ -3284,6 +3264,12 @@ export default { .drawer-icon { text-align: center; + >>> .icon-favorite { + display: none; + } + >>> .icon-share { + display: none; + } } .drawer-icon-font >>> .svg-icon { diff --git a/src/views/share/index.vue b/src/views/share/index.vue index 68f48b3..eacf34d 100644 --- a/src/views/share/index.vue +++ b/src/views/share/index.vue @@ -1,14 +1,6 @@ - - - - - - - + - + {{scope.row.createDate}} - + + + {{scope.row.isPrivacy ? '私密':'公开'}} + + + + - - - - - - - - - - - 0) { this.sumFileAndFolder = this.getShowSumFileAndFolder(row) itemIcon.label = '已选中' @@ -351,6 +353,8 @@ itemSize.sortable = false itemDate.label = '' itemDate.sortable = false + itemIsPrivacy.label = '' + itemIsPrivacy.sortable = false } else { itemIcon.label = '' itemName.label = '分享文件' @@ -359,6 +363,8 @@ itemSize.sortable = 'custom' itemDate.label = '过期时间' itemDate.sortable = 'custom' + itemIsPrivacy.label = '分享形式' + itemIsPrivacy.sortable = 'custom' } }, // 统计文件和文件夹 @@ -397,21 +403,10 @@ tableRowClassName({ row, rowIndex }) { row.index = rowIndex }, - // 选择某行预备数据 - preliminaryRowData(row) { - if (row) { - this.selectRowData[0] = row - this.rowContextData = row - } - const isFavorite = this.selectRowData[0].isFavorite - this.highlightFavorite(isFavorite, false) - }, // 单元格hover进入时时间 cellMouseEnter(row) { - if(this.editingIndex === -1){ - if (this.indexList.length < 1) { - this.cellMouseIndex = row.index - } + if (this.indexList.length < 1) { + this.cellMouseIndex = row.index } }, // 单元格hover退出时时间 @@ -421,27 +416,19 @@ // 单元格点击事件 cellClick(row, column) { clearTimeout(this.Loop); - if(this.editingIndex === -1) { - const columnIndex = column.index - if (columnIndex === 0) { - // 点击选中 - this.$refs.fileListTable.toggleRowSelection(row) - } - if (columnIndex === 2) { - if (this.indexList.length < 1) { - if (row.index !== this.editingIndex) { - this.fileClick(row) - this.editingIndex = -1 - } - } - } - if (columnIndex === 4) { - // // 单个操作 - } - if (this.indexList.length > 0 && columnIndex > 0) { - this.$refs.fileListTable.toggleRowSelection(row) + const columnIndex = column.index + if (columnIndex === 0) { + // 点击选中 + this.$refs.fileListTable.toggleRowSelection(row) + } + if (columnIndex === 2) { + if (this.indexList.length < 1) { + this.fileClick(row) } } + if (this.indexList.length > 0 && columnIndex > 0) { + this.$refs.fileListTable.toggleRowSelection(row) + } }, // 取消分享 cancelShare(row) { @@ -466,34 +453,16 @@ }, // 点击文件或文件夹 fileClick(row) { - this.shareDialog = true - this.shareFileName = row.fileName - this.shareLink = window.location.origin+'/s?s='+row.id - this.generateShareLinkLoading = false + this.shareDialogObject = row + this.shareDialogObject.name = row.fileName + this.shareDialogObject.shareId = row.id + this.shareDialogVisible = true }, - // 复制分享链接 - copyShareLink() { - var clipboard = new Clipboard('.tag-share-link') - clipboard.on('success', e => { - this.$message({ - message: '复制成功', - type: 'success', - duration: 1000 - }); - this.shareDialog = false - // 释放内存 - clipboard.destroy() - }) - clipboard.on('error', e => { - // 不支持复制 - this.$message({ - message: '该浏览器不支持自动复制', - type: 'warning', - duration: 1000 - }); - // 释放内存 - clipboard.destroy() - }) + onUpdateExpireData(shareId, expireDate) { + let index = this.fileList.findIndex(item => item.id === shareId) + let share = this.fileList[index] + share.expireDate = expireDate + this.fileList.splice(index, 1, share) }, } }