fix: 显示配置

This commit is contained in:
2023-08-22 02:37:38 +08:00
parent 06ca61f7c8
commit 86f80645b2
3 changed files with 56 additions and 10 deletions

View File

@ -2,17 +2,17 @@
* @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-07-18 12:22:11
* @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-07-18 12:46:10
* @LastEditTime: 2023-08-22 01:57:45
* @FilePath: \vue3\packages\preview-office-view\index.vue
* @Description:
*
-->
<template>
<div class="preview-office-view overflow-hidden h-full">
<div class="preview-office-view overflow-hidden h-100vh">
<template v-if="src">
<VueOfficeDocx v-if="extension === 'docx'" class="h-full" :src="src" />
<VueOfficeExcel v-else-if="extension === 'xlsx'" class="h-full" :src="src" />
<VueOfficePdf v-else-if="extension === 'pdf'" class="h-full" :src="src" />
<VueOfficePdf v-else-if="extension === 'pdf'" class="h-full" :src="src" static-file-url="https://registry.npmmirror.com/pdfjs-dist/3.1.81/files/cmaps/" />
</template>
<el-empty v-else>
<template #description>
@ -29,14 +29,18 @@ import VueOfficeExcel from '@vue-office/excel'
import '@vue-office/excel/lib/index.css'
import '@vue-office/docx/lib/index.css'
const route = useRoute()
const { url, extension } = route.query
const props = defineProps<{
/** 文件的url */
url?: string | string[]
/** 文件的拓展名 */
extension?: string
}>()
const src = computed(() => {
const { url } = props
if (typeof url === 'string')
return url
if (Array.isArray(url))
return url[0]
return ''
})
</script>