|
|
|
|
@ -14,7 +14,7 @@
|
|
|
|
|
<el-dialog title="输入密码" :modal-append-to-body="false" :visible.sync="getPasswordVisible">
|
|
|
|
|
<el-form :model="form" label-width="50px">
|
|
|
|
|
<el-form-item label="密码">
|
|
|
|
|
<el-input v-model="form.secretKey" autocomplete="off"></el-input>
|
|
|
|
|
<el-input v-model="form.providedKey" autocomplete="off"></el-input>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
@ -50,7 +50,7 @@ export default {
|
|
|
|
|
} else {
|
|
|
|
|
this.form = {
|
|
|
|
|
documentId: e.uuid,
|
|
|
|
|
secretKey: ''
|
|
|
|
|
providedKey: ''
|
|
|
|
|
}
|
|
|
|
|
this.getPasswordVisible = true
|
|
|
|
|
this.$message.error('请输入密钥')
|
|
|
|
|
@ -58,14 +58,35 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
downFile1() {
|
|
|
|
|
if (!this.form.secretKey) {
|
|
|
|
|
if (!this.form.providedKey) {
|
|
|
|
|
this.$message.error('请输入密码')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getSecureDocumentAddress(this.form).then((res) => {
|
|
|
|
|
getSecureDocumentAddress(this.form).then(async (res) => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
console.log('下载地址', res.data)
|
|
|
|
|
console.log('下载地址', res)
|
|
|
|
|
let url = res.msg
|
|
|
|
|
let filename = url.split('/').at(-1)?.split('_')[0] + '.' + url.split('/').at(-1)?.split('.').at(-1)
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, {mode: 'cors'});
|
|
|
|
|
if (!response.ok) throw new Error('网络错误');
|
|
|
|
|
|
|
|
|
|
const blob = await response.blob(); // 获取文件数据
|
|
|
|
|
const blobUrl = URL.createObjectURL(blob);
|
|
|
|
|
|
|
|
|
|
const a = document.createElement('a');
|
|
|
|
|
a.href = blobUrl;
|
|
|
|
|
a.download = filename || url.split('/').pop();
|
|
|
|
|
document.body.appendChild(a);
|
|
|
|
|
a.click();
|
|
|
|
|
document.body.removeChild(a);
|
|
|
|
|
|
|
|
|
|
URL.revokeObjectURL(blobUrl); // 释放内存
|
|
|
|
|
this.getPasswordVisible = false
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error('下载失败:', err);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error('密钥错误')
|
|
|
|
|
}
|
|
|
|
|
|