|
|
|
|
@ -1,19 +1,23 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="container">
|
|
|
|
|
<div id="online-preview-container" class="container">
|
|
|
|
|
<template v-if="type === 'docx'">
|
|
|
|
|
<VueOfficeDocx :src="url" style="height: 100vh;"></VueOfficeDocx>
|
|
|
|
|
<VueOfficeDocx :src="url" style="height: 100vh;" />
|
|
|
|
|
</template>
|
|
|
|
|
<template v-if="type === 'xlsx'">
|
|
|
|
|
<VueOfficeExcel :src="url" style="height: 100vh;"></VueOfficeExcel>
|
|
|
|
|
<template v-else-if="type === 'xlsx' || type === 'xls'">
|
|
|
|
|
<VueOfficeExcel :src="url" style="height: 100vh;" />
|
|
|
|
|
</template>
|
|
|
|
|
<template v-if="type === 'pdf'">
|
|
|
|
|
<VueOfficePdf :src="url" style="height: 100vh;"></VueOfficePdf>
|
|
|
|
|
<template v-else-if="type === 'pdf'">
|
|
|
|
|
<iframe :src="url" frameborder="0" style="width: 100%;height: 100%;" />
|
|
|
|
|
<!-- <VueOfficePdf :src="url" style="height: 100vh;" />-->
|
|
|
|
|
</template>
|
|
|
|
|
<!-- <template v-if="type === 'doc'">-->
|
|
|
|
|
<!-- <div ref="docPreview" style="height: 100vh;"></div>-->
|
|
|
|
|
<!-- </template>-->
|
|
|
|
|
<template v-if="type === 'png' || type === 'jpg' || type === 'jpeg' || type === 'gif'">
|
|
|
|
|
<img :src="url" style="width: 100vw;height: 100vh;object-fit: contain" alt="">
|
|
|
|
|
<template v-else-if="['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'].indexOf(type) !== -1">
|
|
|
|
|
<el-image ref="elImage" fit="contain" :preview-src-list="[url]" :src="url" style="width: 100vw;height: 100vh;" alt="" @load="loadImg" />
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<div>
|
|
|
|
|
<h4>文件类型暂不支持在线预览,请下载查看</h4>
|
|
|
|
|
<el-link target="_blank" type="primary" :href="url">点击下载</el-link>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
@ -44,6 +48,14 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
loadImg() {
|
|
|
|
|
this.$refs['elImage']?.$el?.children[0].click()
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
document.querySelector('.el-image-viewer__close').style.display = 'none'
|
|
|
|
|
document.querySelector('.el-image__inner').style.display = 'none'
|
|
|
|
|
document.querySelector('.el-image-viewer__mask').style.pointerEvents = 'none'
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
async resolveUrl(url) {
|
|
|
|
|
if(url) {
|
|
|
|
|
let originalUrl
|
|
|
|
|
|