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