perf: 非分享界面添加复制下载链接的选项

This commit is contained in:
jmal 2023-08-28 18:29:56 +08:00
parent a3fe98f489
commit d9b33ef28c
2 changed files with 37 additions and 6 deletions

View File

@ -258,6 +258,7 @@
v-if="
item.operation === 'unFavorite' || item.operation === 'favorite'
"
class="menu-option"
@click="menusOperations(item.operation)"
@mouseover.prevent.stop="
menuFavoriteOver(index, rowContextData.isFavorite)
@ -870,6 +871,7 @@ import EditElement from "@/views/markdown/EditElement";
import OfficePreview from "@/components/preview/OfficePreview";
import ShareDialog from "@/components/ShareDialog/index.vue";
import {getUsername} from "@/api/user";
import Clipboard from "clipboard";
export default {
name: "ShowFile",
@ -2690,7 +2692,8 @@ export default {
id: row.id,
currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize
pageSize: this.pagination.pageSize,
folder: this.$route.query.folder
})
.then(res => {
this.loadData(res, onLoad);
@ -2709,7 +2712,8 @@ export default {
id: row.mountFileId || row.id,
currentDirectory: encodeURI(this.$route.query.path),
pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize
pageSize: this.pagination.pageSize,
folder: this.$route.query.folder
})
.then(res => {
this.loadData(res, onLoad);
@ -3191,13 +3195,17 @@ export default {
if (!row.isFolder) {
this.menus.splice(-2, 0, { iconClass: "duplicate", label: "创建副本", operation: "duplicate" })
}
if (row.isShare && !row.shareBase) {
if ((row.isShare && !row.shareBase) || row.ossFolder) {
// 删除分享选项
let index = this.menus.findIndex(item => item.operation === "share")
if (index > -1) {
this.menus.splice(index, 1)
}
}
if (row.isShare && !row.isPrivacy) {
// 添加复制下载链接选项
this.menus.splice(-2, 0, { iconClass: "menu-fuzhi", label: "复制下载链接", operation: "copyDownloadLink" })
}
}
this.preliminaryRowData(row);
},
@ -3449,6 +3457,10 @@ export default {
// 下载
this.downloadFile();
break;
case "copyDownloadLink":
// 复制下载链接
this.copyDownloadLink(this.rowContextData)
break;
case "remove":
// 删除
this.deleteFile();
@ -3771,6 +3783,25 @@ export default {
});
}
},
// 复制下载链接
copyDownloadLink(row) {
let url = window.location.origin + fileConfig.previewUrl(this.$store.getters.name, row, undefined, undefined)
let clipboard = new Clipboard('.newFileMenu', {
text: function () {
return url
}
})
clipboard.on('success', e => {
this.$message({message: '复制成功', type: 'success', duration: 1000});
// 释放内存
clipboard.destroy()
})
clipboard.on('error', e => {
// 不支持复制
this.$message({message: '该浏览器不支持自动复制', type: 'warning', duration: 1000});
clipboard.destroy()
})
},
// 收藏/取消收藏
favoriteOperating(isFavorite) {
const fileIds = this.getSelectIdList();

View File

@ -356,12 +356,12 @@ export default {
singleMenus: [
{iconClass: 'menu-open', label: '打开', operation: 'open'},
{iconClass: 'menu-download', label: '下载', operation: 'download'},
{iconClass: 'menu-fuzhi', label: '复制下载连接', operation: 'copyDownloadUrl'},
{iconClass: 'menu-fuzhi', label: '复制下载链接', operation: 'copyDownloadUrl'},
],
singleMenusEdit: [
{iconClass: 'menu-open', label: '打开', operation: 'open'},
{iconClass: 'menu-download', label: '下载', operation: 'download'},
{iconClass: 'menu-fuzhi', label: '复制下载连接', operation: 'copyDownloadUrl'},
{iconClass: 'menu-fuzhi', label: '复制下载链接', operation: 'copyDownloadUrl'},
],
multipleMenus: [
{iconClass: 'menu-download', label: '下载', operation: 'download'},
@ -1042,7 +1042,7 @@ export default {
});
}
},
// 复制下载连接
// 复制下载链接
copyDownloadLink(url) {
let clipboard = new Clipboard('.menu-option', {
text: function () {