预览文件添加地址前缀
This commit is contained in:
@@ -5,6 +5,7 @@ import 'vue3-office-preview/lib/style.css'
|
|||||||
|
|
||||||
const props = defineProps(['previewFile',])
|
const props = defineProps(['previewFile',])
|
||||||
|
|
||||||
|
const currentOrigin = window.location.origin;
|
||||||
// 判断文件类型
|
// 判断文件类型
|
||||||
const handleFileType = (type:string) => {
|
const handleFileType = (type:string) => {
|
||||||
if(type){
|
if(type){
|
||||||
@@ -33,29 +34,33 @@ const handleFileType = (type:string) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="max-h-[70vh] overflow-x-auto rounded-lg border">
|
<div class="max-h-[70vh] overflow-x-auto rounded-lg border">
|
||||||
<!-- 图片预览 -->
|
<!-- 图片预览 -->
|
||||||
<template v-if="handleFileType(previewFile?.file_type) === 'image'">
|
<template v-if="handleFileType(previewFile?.file_type) === 'image'">
|
||||||
<div class="flex items-center justify-center py-2">
|
<div class="flex items-center justify-center py-2">
|
||||||
<NImage :src="previewFile?.file_url" />
|
<NImage :src="currentOrigin + previewFile?.file_url" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<!-- Word 预览 -->
|
<!-- Word 预览 -->
|
||||||
<template v-else-if="handleFileType(previewFile?.file_type) === '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>
|
</template>
|
||||||
<!-- Excel 预览 -->
|
<!-- Excel 预览 -->
|
||||||
<template v-else-if="handleFileType(previewFile?.file_type) === '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>
|
</template>
|
||||||
<!-- Ppt 预览 -->
|
<!-- Ppt 预览 -->
|
||||||
<template v-else-if="handleFileType(previewFile?.file_type) === '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>
|
</template>
|
||||||
<!-- PDF 预览 -->
|
<!-- PDF 预览 -->
|
||||||
<template v-else-if="handleFileType(previewFile?.file_type) === 'pdf'">
|
<template v-else-if="handleFileType(previewFile?.file_type) === 'pdf'">
|
||||||
<div class="h-[68vh]">
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<!-- 其他类型文件预览 -->
|
<!-- 其他类型文件预览 -->
|
||||||
@@ -64,6 +69,6 @@ const handleFileType = (type:string) => {
|
|||||||
<p>暂不支持预览该文件类型</p>
|
<p>暂不支持预览该文件类型</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user