master
parent
ec98c2c0d8
commit
12807f7116
@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
<template v-if="type === 'docx'">
|
||||||
|
<VueOfficeDocx :src="url" style="height: 100vh;"></VueOfficeDocx>
|
||||||
|
</template>
|
||||||
|
<template v-if="type === 'xlsx'">
|
||||||
|
<VueOfficeExcel :src="url" style="height: 100vh;"></VueOfficeExcel>
|
||||||
|
</template>
|
||||||
|
<template v-if="type === 'pdf'">
|
||||||
|
<VueOfficePdf :src="url" style="height: 100vh;"></VueOfficePdf>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
//引入VueOfficeDocx组件
|
||||||
|
import VueOfficeDocx from '@vue-office/docx'
|
||||||
|
//引入相关样式
|
||||||
|
import '@vue-office/docx/lib/index.css'
|
||||||
|
//引入VueOfficeExcel组件
|
||||||
|
import VueOfficeExcel from '@vue-office/excel'
|
||||||
|
//引入相关样式
|
||||||
|
import '@vue-office/excel/lib/index.css'
|
||||||
|
//引入VueOfficePdf组件
|
||||||
|
import VueOfficePdf from '@vue-office/pdf'
|
||||||
|
import axios from 'axios'
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
VueOfficeDocx,
|
||||||
|
VueOfficePdf,
|
||||||
|
VueOfficeExcel
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
url: "",
|
||||||
|
type: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
resolveUrl(url) {
|
||||||
|
if(url) {
|
||||||
|
let originalUrl
|
||||||
|
try {
|
||||||
|
originalUrl = window.atob(window.decodeURIComponent(this.$route.query.url??""))
|
||||||
|
} catch (err) {
|
||||||
|
originalUrl = window.decodeURIComponent(this.$route.query.url??"")
|
||||||
|
}
|
||||||
|
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 = process.env.VUE_APP_DOMIAN + '/oa' + new URL(originalUrl).pathname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
created() {
|
||||||
|
this.resolveUrl(this.$route.query.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.container {
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in new issue