mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
feat: 目录浏览添加复制直链按钮
This commit is contained in:
@@ -190,6 +190,14 @@
|
|||||||
>
|
>
|
||||||
<i class="fas fa-paper-plane"></i> 发送到下载器
|
<i class="fas fa-paper-plane"></i> 发送到下载器
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="selectedNode.parserUrl"
|
||||||
|
size="small"
|
||||||
|
@click="copyDirectLink(selectedNode)"
|
||||||
|
:loading="copyLinkLoading"
|
||||||
|
>
|
||||||
|
<i class="fas fa-link"></i> 复制直链
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="file-detail-empty">
|
<div v-else class="file-detail-empty">
|
||||||
@@ -258,6 +266,14 @@
|
|||||||
>
|
>
|
||||||
<i class="fas fa-paper-plane"></i> 发送到下载器
|
<i class="fas fa-paper-plane"></i> 发送到下载器
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="selectedNode.parserUrl"
|
||||||
|
size="small"
|
||||||
|
@click="copyDirectLink(selectedNode)"
|
||||||
|
:loading="copyLinkLoading"
|
||||||
|
>
|
||||||
|
<i class="fas fa-link"></i> 复制直链
|
||||||
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="file-detail-empty">
|
<div v-else class="file-detail-empty">
|
||||||
@@ -324,6 +340,14 @@
|
|||||||
>
|
>
|
||||||
发送到下载器
|
发送到下载器
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="selectedFile && selectedFile.parserUrl"
|
||||||
|
@click="copyDirectLink(selectedFile)"
|
||||||
|
style="margin-left: 8px;"
|
||||||
|
:loading="copyLinkLoading"
|
||||||
|
>
|
||||||
|
复制直链
|
||||||
|
</el-button>
|
||||||
</span>
|
</span>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<div v-if="isPreviewing" class="preview-mask">
|
<div v-if="isPreviewing" class="preview-mask">
|
||||||
@@ -391,6 +415,7 @@ export default {
|
|||||||
downloadInfo: null,
|
downloadInfo: null,
|
||||||
downloadLoading: false,
|
downloadLoading: false,
|
||||||
singleSendLoading: false,
|
singleSendLoading: false,
|
||||||
|
copyLinkLoading: false,
|
||||||
treeProps: {
|
treeProps: {
|
||||||
label: 'fileName',
|
label: 'fileName',
|
||||||
children: 'children',
|
children: 'children',
|
||||||
@@ -743,6 +768,32 @@ export default {
|
|||||||
this.fileDialogVisible = false
|
this.fileDialogVisible = false
|
||||||
this.selectedFile = null
|
this.selectedFile = null
|
||||||
},
|
},
|
||||||
|
async copyDirectLink(file) {
|
||||||
|
if (!file?.parserUrl) {
|
||||||
|
this.$message.warning('该文件暂无直链')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const rawUrl = file.parserUrl.startsWith('http') ? file.parserUrl : (window.location.origin + file.parserUrl)
|
||||||
|
const url = this.appendToken(rawUrl)
|
||||||
|
this.copyLinkLoading = true
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(url)
|
||||||
|
this.$message.success('直链已复制到剪贴板')
|
||||||
|
} catch {
|
||||||
|
// fallback
|
||||||
|
const ta = document.createElement('textarea')
|
||||||
|
ta.value = url
|
||||||
|
ta.style.position = 'fixed'
|
||||||
|
ta.style.opacity = '0'
|
||||||
|
document.body.appendChild(ta)
|
||||||
|
ta.select()
|
||||||
|
document.execCommand('copy')
|
||||||
|
document.body.removeChild(ta)
|
||||||
|
this.$message.success('直链已复制到剪贴板')
|
||||||
|
} finally {
|
||||||
|
this.copyLinkLoading = false
|
||||||
|
}
|
||||||
|
},
|
||||||
closePreview() {
|
closePreview() {
|
||||||
this.isPreviewing = false
|
this.isPreviewing = false
|
||||||
this.previewUrl = ''
|
this.previewUrl = ''
|
||||||
|
|||||||
Reference in New Issue
Block a user