irc_web/.svn/pristine/9c/9cce8c4b453419d4a27eb413fd6...

66 lines
1.6 KiB
Plaintext

<template>
<div class="preview-wrapper">
<iframe
v-if="fileType.indexOf('jpg') !== -1 || fileType.indexOf('png') !== -1"
frameborder="0"
:src="filePath"
width="100%"
style="width: 100%; height: 100%"
/>
<!-- <embed v-else-if="fileType.indexOf('pdf') !== -1" :src="filePath" style="width: 100%; height: 100%"> -->
<!-- <iframe v-else-if="fileType.indexOf('pdf') !== -1" :src="`/static/pdfjs/web/viewer.html?file=${filePath}`" width="100%" height="100%" frameborder="0" /> -->
<iframe v-else-if="fileType.indexOf('pdf') !== -1" :src="`/static/pdfjs/web/viewer.html?file=${filePath}?userName=${currentUser}`" width="100%" height="100%" frameborder="0" />
<div v-else>
{{ $t('common:message:downloadFile') }}
<el-link type="primary" @click="downLoadFile">{{ $t('common:button:download') }}</el-link>
</div>
</div>
</template>
<script>
export default {
name: 'PreviewFile',
props: {
filePath: {
type: String,
required: true
},
fileType: {
type: String,
required: true
}
},
data() {
return {
currentUser: zzSessionStorage.getItem('userName')
}
},
methods: {
// 下载文件
decodeURIComponent(url) {
return decodeURIComponent(url)
},
downLoadFile() {
if (!this.filePath) return
window.open(this.filePath, '_blank')
}
}
}
</script>
<style lang="scss">
.preview-wrapper{
height: 100%;
width:100%;
padding: 10px;
::-webkit-scrollbar {
width: 7px;
height: 7px;
}
::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #d0d0d0;
}
}
</style>