修改文件预览
This commit is contained in:
@@ -1,11 +1,19 @@
|
||||
<template>
|
||||
<div style="overflow: auto; height: 100vh">
|
||||
<vue-office-docx v-if="urlKey.includes('.doc') || urlKey.includes('.docx')" :src="url" />
|
||||
<vue-office-excel v-if="urlKey.includes('.xls') || urlKey.includes('.xlsx')" :src="url" :options="excelOptions" />
|
||||
<vue-office-excel
|
||||
v-if="urlKey.includes('.xls') || urlKey.includes('.xlsx')"
|
||||
:src="url"
|
||||
:options="excelOptions"
|
||||
/>
|
||||
<!-- <vue-office-pdf v-if="url.includes('.pdf')" :src="url" /> -->
|
||||
<iframe v-if="urlKey.includes('.pdf')" :src="url" style="width: 100%; height: 99%"></iframe>
|
||||
<img v-if="urlKey.includes('.png') || urlKey.includes('.jpg') || urlKey.includes('.gif') || urlKey.includes('.bmp')"
|
||||
:src="url" />
|
||||
<img
|
||||
v-if="
|
||||
urlKey.includes('.png') || urlKey.includes('.jpg') || urlKey.includes('.gif') || urlKey.includes('.bmp')
|
||||
"
|
||||
:src="url"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -19,7 +27,7 @@ import VueOfficeExcel from '@vue-office/excel'
|
||||
//引入VueOfficePdf组件
|
||||
import VueOfficePdf from '@vue-office/pdf'
|
||||
import { downloadFile } from '@/api/system-boot/file'
|
||||
import{previewFile} from '@/utils/fileDownLoad'
|
||||
import { previewFile } from '@/utils/fileDownLoad'
|
||||
|
||||
const { push, options, currentRoute } = useRouter()
|
||||
const VITE_FLAG = import.meta.env.VITE_NAME == 'jibei'
|
||||
@@ -27,15 +35,16 @@ const VITE_FLAG = import.meta.env.VITE_NAME == 'jibei'
|
||||
const url = ref('')
|
||||
const excelOptions = ref({})
|
||||
const urlKey = currentRoute.value?.href?.split('?')[1]
|
||||
if(VITE_FLAG){
|
||||
url.value = '/api-docx/excelreport' + currentRoute.value?.href?.split('?')[1]
|
||||
excelOptions.value = ref({
|
||||
if (VITE_FLAG) {
|
||||
url.value = '/api-docx/excelreport' + currentRoute.value?.href?.split('?')[1]
|
||||
excelOptions.value = ref({
|
||||
xls: currentRoute.value.href?.split('?')[1].split('.')[1] == 'xls' ? true : false
|
||||
})
|
||||
}else{
|
||||
|
||||
const previewUrl = await previewFile(currentRoute.value?.href?.split('?')[1])
|
||||
url.value = previewUrl
|
||||
} else {
|
||||
setTimeout(async () => {
|
||||
const previewUrl = await previewFile(currentRoute.value?.href?.split('?')[1])
|
||||
url.value = previewUrl
|
||||
}, 0)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user