1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-07 08:50:23 +08:00

finish file download

This commit is contained in:
源文雨
2023-03-16 14:40:46 +08:00
parent aef99827ce
commit f1bd3c15b1

View File

@@ -1,7 +1,7 @@
<template>
<PageWrapper :title="t('routes.filelist.file')">
<template #headerContent>
<a-button type="primary"> 下载试卷 </a-button>
<a-button type="primary" @click="downloadDocx"> 下载试卷 </a-button>
</template>
<div ref="chartRef" :style="{ height, width }"></div>
<div class="docxWrap" :style="{ width }">
@@ -20,13 +20,17 @@
import { useGo } from '/@/hooks/web/usePage'
import { PageEnum } from '/@/enums/pageEnum'
import { useI18n } from '/@/hooks/web/useI18n'
import { downloadByData } from '/@/utils/file/download'
import axios from 'axios'
const { t } = useI18n()
let docxRef = ref(null)
let docxBlob: Blob | null = null
function loadDocx(file: Blob) {
docxBlob = file
renderAsync(file, docxRef.value as unknown as HTMLElement, undefined, {
className: 'docx', // 默认和文档样式类的类名/前缀
inWrapper: false, // 启用围绕文档内容渲染包装器
@@ -41,6 +45,10 @@
})
}
function downloadDocx() {
downloadByData(docxBlob as BlobPart, 'testName.docx')
}
export default defineComponent({
name: 'PaperAnalyzeTab',
components: { PageWrapper },
@@ -198,6 +206,7 @@
t,
chartRef,
docxRef,
downloadDocx,
}
},
})