49 lines
1.1 KiB
HTML
49 lines
1.1 KiB
HTML
|
|
<template id="pdf-viewer">
|
|
<div style="width: 100%; padding: 65% 0;position: relative;">
|
|
<iframe :src="'/<$ ctx.app.config.appId $>/public/pdf/web/viewer.html?file=' + src" frameborder="0" style="position: absolute;width: 100%; height: 100%; top: 0;left: 0"></iframe>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
Vue.component("pdf-viewer", {
|
|
template: "#pdf-viewer",
|
|
name: "pdf-viewer",
|
|
props: {
|
|
params: {
|
|
type: Object,
|
|
default: () => {
|
|
return {}
|
|
}
|
|
}
|
|
},
|
|
watch: {
|
|
},
|
|
data () {
|
|
return {
|
|
appId: '<$ ctx.app.config.appId $>',
|
|
prefix: '<$ ctx.app.config.downloadBasePath $>',
|
|
}
|
|
},
|
|
computed: {
|
|
src() {
|
|
if (this.params.src) {
|
|
// 替换appId
|
|
const src = this.params.src.replace('__appId__', this.appId);
|
|
if (src.includes('/upload/')) {
|
|
return encodeURIComponent(this.prefix + '/' + src.split('upload')[1]);
|
|
} else {
|
|
return encodeURIComponent(this.prefix + src);
|
|
}
|
|
}
|
|
return '';
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
}
|
|
})
|
|
</script>
|
|
<style>
|
|
|
|
</style>
|