|
|
|
|
@ -9,6 +9,12 @@
|
|
|
|
|
<template v-if="type === 'pdf'">
|
|
|
|
|
<VueOfficePdf :src="url" style="height: 100vh;"></VueOfficePdf>
|
|
|
|
|
</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>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
@ -24,6 +30,7 @@ import '@vue-office/excel/lib/index.css'
|
|
|
|
|
//引入VueOfficePdf组件
|
|
|
|
|
import VueOfficePdf from '@vue-office/pdf'
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
//import { renderAsync } from 'docx-preview'
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
VueOfficeDocx,
|
|
|
|
|
@ -37,7 +44,7 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
resolveUrl(url) {
|
|
|
|
|
async resolveUrl(url) {
|
|
|
|
|
if(url) {
|
|
|
|
|
let originalUrl
|
|
|
|
|
try {
|
|
|
|
|
@ -48,11 +55,19 @@ export default {
|
|
|
|
|
this.type = this.$route.query.type || originalUrl.split('.').at(-1)
|
|
|
|
|
try {
|
|
|
|
|
this.url = process.env.VUE_APP_DOMIAN + (window.location.origin === window.top.location.origin ? '' : '/oa') + new URL(originalUrl).pathname
|
|
|
|
|
console.log(this.url)
|
|
|
|
|
} catch (err) {
|
|
|
|
|
//this.url = this.$route.query.url
|
|
|
|
|
this.url = process.env.VUE_APP_DOMIAN + '/oa' + new URL(originalUrl).pathname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log(this.url)
|
|
|
|
|
// if(this.type === 'doc') {
|
|
|
|
|
// const res = await fetch(this.url)
|
|
|
|
|
// const blob = res.blob()
|
|
|
|
|
// this.$nextTick(() => {
|
|
|
|
|
// renderAsync(blob, this.$refs['docPreview'])
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {},
|
|
|
|
|
|