feat(文件预览): 添加对PDF、Word和Excel文件的预览支持
添加新的文件预览组件,支持PDF、Word(docx)、Excel(xlsx/xls)文件类型预览 重构图片预览为独立组件,并添加相关依赖包
This commit is contained in:
38
klp-ui/src/components/FilePreview/preview/docx/index.vue
Normal file
38
klp-ui/src/components/FilePreview/preview/docx/index.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<div class="docx-preview">
|
||||
<vue-office-docx :src="src" @render-error="handleDocxError" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import VueOfficeDocx from '@vue-office/docx';
|
||||
import '@vue-office/docx/lib/index.css';
|
||||
|
||||
export default {
|
||||
name: "DocxPreview",
|
||||
components: {
|
||||
VueOfficeDocx
|
||||
},
|
||||
props: {
|
||||
src: {
|
||||
type: String,
|
||||
required: true,
|
||||
description: "Word文件的URL或路径"
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleDocxError(err) {
|
||||
console.error('docx预览失败:', err);
|
||||
this.$message.error('文档预览失败,请下载查看');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.docx-preview {
|
||||
width: 100%;
|
||||
height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user