文件预览参数token改为at
This commit is contained in:
@@ -53,6 +53,8 @@ import { kkFilePreview } from '@/utils/kkFilePreview'
|
||||
|
||||
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||
const FILE_TYPE_PDF = 'pdf'
|
||||
// 支持预览的文件后缀
|
||||
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
|
||||
|
||||
export default {
|
||||
name: 'CheckReportModal',
|
||||
@@ -149,7 +151,15 @@ export default {
|
||||
handleRelatedMaterialClick (record) {
|
||||
// 截取文件后缀名
|
||||
const fileSuffix = record.declareFileName ? record.declareFileName.split('.')[record.declareFileName.split('.').length - 1] : ''
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}`
|
||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${record.declareFile}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.declareFileName}`
|
||||
const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix === tt)
|
||||
// 判断是否为可预览格式的文件
|
||||
if (!canPreview) {
|
||||
this.$message.loading(this.$t('uploadFile.cannotPreview')).then(() => {
|
||||
this.handleDownload(record.declareFile, record.declareFileName)
|
||||
})
|
||||
return
|
||||
}
|
||||
// 图片预览,使用自己添加的组件
|
||||
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
||||
this.imageUrl = getFileAccessHttpUrl(record.declareFile)
|
||||
@@ -166,13 +176,12 @@ export default {
|
||||
window.open(url)
|
||||
return
|
||||
}
|
||||
// word用KKfile预览
|
||||
if (fileSuffix === 'doc' || fileSuffix === 'docx') {
|
||||
kkFilePreview(fileFullUrl)
|
||||
return
|
||||
}
|
||||
// 如果都不能预览就下载
|
||||
downloadFile(`/sys/common/download/${record.declareFile}`, record.declareFileName)
|
||||
// 其余可预览文件仍使用KKFile进行预览
|
||||
kkFilePreview(fileFullUrl)
|
||||
},
|
||||
handleDownload (id, name) {
|
||||
// 下载文件
|
||||
downloadFile(`/sys/common/download/${id}`, name)
|
||||
},
|
||||
handleCancel () {
|
||||
this.close()
|
||||
|
||||
Reference in New Issue
Block a user