@@ -63,7 +63,7 @@
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" @click="handlePlay(scope.row)">播放</el-button>
|
||||
<el-button type="primary" @click="handleUpload(scope.row)">下载至本地</el-button>
|
||||
<el-button type="primary" @click="handleDown(scope.row)">下载至本地</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -88,6 +88,7 @@
|
||||
|
||||
<script setup name="Demo" lang="ts">
|
||||
import { listDemo, getDemo, delDemo, addDemo, updateDemo } from '@/api/fileList/index';
|
||||
import { download } from '@/utils/request';
|
||||
//import { DemoVO, DemoQuery, DemoForm } from '@/api/demo/demo/types';
|
||||
|
||||
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||
@@ -101,6 +102,7 @@ const single = ref(true);
|
||||
const multiple = ref(true);
|
||||
const total = ref(0);
|
||||
const monitorVideoUrl = ref();
|
||||
const downloadUrl = ref();
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const demoFormRef = ref<ElFormInstance>();
|
||||
@@ -202,13 +204,26 @@ const handlePlay = async (row?: any) => {
|
||||
monitorVideoUrl.value = row.videoUrl;
|
||||
dialog.visible = true;
|
||||
};
|
||||
const handleUpload = async (row?: any) => {
|
||||
const handleDown = async (row?: any) => {
|
||||
if (!row || !row.zipUrl) {
|
||||
proxy?.$modal.msgError('下载地址不存在');
|
||||
return;
|
||||
}
|
||||
proxy?.$download.zip(row.zipUrl, row.zipUrl);
|
||||
console.log('点击下载');
|
||||
const fileName = row.videoName || `file_${new Date().getTime()}.zip`;
|
||||
//console.log(row, fileName);
|
||||
|
||||
// 1. 创建隐藏的 a 元素
|
||||
const link = document.createElement('a');
|
||||
link.href = row.zipUrl; // 文件路径
|
||||
link.download = fileName; // 指定下载的文件名
|
||||
link.style.display = 'none';
|
||||
|
||||
// 2. 挂载到 DOM 并模拟点击
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
// 3. 移除元素,保持页面整洁
|
||||
document.body.removeChild(link);
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
|
||||
Reference in New Issue
Block a user