预览文件添加地址前缀

This commit is contained in:
2026-10-13 11:39:21 +08:00
parent 91536b193c
commit 7797b4479d
+10 -5
View File
@@ -5,6 +5,7 @@ import 'vue3-office-preview/lib/style.css'
const props = defineProps(['previewFile',])
const currentOrigin = window.location.origin;
// 判断文件类型
const handleFileType = (type:string) => {
if(type){
@@ -37,25 +38,29 @@ const handleFileType = (type:string) => {
<!-- 图片预览 -->
<template v-if="handleFileType(previewFile?.file_type) === 'image'">
<div class="flex items-center justify-center py-2">
<NImage :src="previewFile?.file_url" />
<NImage :src="currentOrigin + previewFile?.file_url" />
</div>
</template>
<!-- Word 预览 -->
<template v-else-if="handleFileType(previewFile?.file_type) === 'word'">
<VueOfficeDocx :src="previewFile?.file_url" class="w-full items-center" />
<div class="h-[68vh]">
<VueOfficeDocx :src="currentOrigin + previewFile?.file_url" class="w-full items-center" />
</div>
</template>
<!-- Excel 预览 -->
<template v-else-if="handleFileType(previewFile?.file_type) === 'excel'">
<VueOfficeExcel :src="previewFile?.file_url" class="w-full items-center" />
<div class="h-[68vh]">
<VueOfficeExcel :src="currentOrigin + previewFile?.file_url" class="w-full items-center" />
</div>
</template>
<!-- Ppt 预览 -->
<template v-else-if="handleFileType(previewFile?.file_type) === 'ppt'">
<VueOfficePptx :src="previewFile?.file_url" class="w-full items-center" />
<VueOfficePptx :src="currentOrigin + previewFile?.file_url" class="w-full items-center" />
</template>
<!-- PDF 预览 -->
<template v-else-if="handleFileType(previewFile?.file_type) === 'pdf'">
<div class="h-[68vh]">
<PDF :src="previewFile?.file_url" class="w-full h-full items-center" />
<PDF :src="currentOrigin + previewFile?.file_url" class="w-full h-full items-center" />
</div>
</template>
<!-- 其他类型文件预览 -->