fix 文件预览token改为at
This commit is contained in:
@@ -103,7 +103,7 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||||
// 图片预览,使用自己添加的组件
|
// 图片预览,使用自己添加的组件
|
||||||
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix.toLowerCase())) {
|
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix.toLowerCase())) {
|
||||||
this.imageUrl = getFileAccessHttpUrl(file.id)
|
this.imageUrl = getFileAccessHttpUrl(file.id)
|
||||||
|
|||||||
@@ -309,7 +309,7 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.response.result.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
||||||
console.log(fileSuffix)
|
console.log(fileSuffix)
|
||||||
// 图片预览,使用自己添加的组件
|
// 图片预览,使用自己添加的组件
|
||||||
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.response.result.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
|
||||||
console.log(fileSuffix)
|
console.log(fileSuffix)
|
||||||
// 图片预览,使用自己添加的组件
|
// 图片预览,使用自己添加的组件
|
||||||
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
if (FILE_TYPE_IMGS.includes(fileSuffix)) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const getToken = () => Vue.ls.get(ACCESS_TOKEN)
|
|||||||
|
|
||||||
// 预览pdf
|
// 预览pdf
|
||||||
const previewPdf = (id) => {
|
const previewPdf = (id) => {
|
||||||
const url = `${window._CONFIG.domianURL}/sys/common/view/${id}?type=view&token=${getToken()}`
|
const url = `${window._CONFIG.domianURL}/sys/common/view/${id}?type=view&at=${getToken()}`
|
||||||
return `${process.env.BASE_URL}pdfjs/web/viewer.html?file=` + encodeURIComponent(url) + '&.pdf'
|
return `${process.env.BASE_URL}pdfjs/web/viewer.html?file=` + encodeURIComponent(url) + '&.pdf'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import Vue from 'vue'
|
|||||||
import * as api from '@/api/api'
|
import * as api from '@/api/api'
|
||||||
import { isURL } from '@/utils/validate'
|
import { isURL } from '@/utils/validate'
|
||||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||||
|
import { getFileInfo } from '@/api/api'
|
||||||
|
import { dealUrl, kkFilePreview } from './kkFilePreview'
|
||||||
|
import { previewPdf } from './previewPdf'
|
||||||
// import onlineCommons from '@/components/onlineForm/onlineForm'
|
// import onlineCommons from '@/components/onlineForm/onlineForm'
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -678,3 +681,37 @@ export function getConfusionCode (tableName, fieldName) {
|
|||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过文件id在当前窗口预览文件
|
||||||
|
* @param fileId
|
||||||
|
*/
|
||||||
|
export function previewFileCurrentWindowByFileId (fileId) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
getFileInfo({ id: fileId }).then(res => {
|
||||||
|
if (res.success) {
|
||||||
|
const file = res.result || {}
|
||||||
|
// 支持预览的文件后缀
|
||||||
|
const CAN_PREVIEW_FILE_SUFFIX = ['jpg', 'jpeg', 'png', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx']
|
||||||
|
const fileSuffix = file.fileName ? file.fileName.split('.')[file.fileName.split('.').length - 1] : ''
|
||||||
|
const canPreview = CAN_PREVIEW_FILE_SUFFIX.some(tt => fileSuffix.toLowerCase() === tt)
|
||||||
|
// 判断是否为可预览格式的文件
|
||||||
|
if (!canPreview) {
|
||||||
|
reject('该文件类型不支持预览')
|
||||||
|
}
|
||||||
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||||
|
const FILE_TYPE_IMGS = ['jpg', 'jpeg', 'png', 'raw']
|
||||||
|
const FILE_TYPE_PDF = 'pdf'
|
||||||
|
// pdf预览
|
||||||
|
if (canPreview && FILE_TYPE_PDF.includes(fileSuffix)) {
|
||||||
|
const url = previewPdf(file.id)
|
||||||
|
window.open(url, '_self')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 其余可预览文件仍使用KKFile进行预览
|
||||||
|
const kkFileUrl = dealUrl(fileFullUrl)
|
||||||
|
window.open(kkFileUrl, '_self')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||||
// 图片预览,使用自己添加的组件
|
// 图片预览,使用自己添加的组件
|
||||||
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix.toLowerCase())) {
|
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix.toLowerCase())) {
|
||||||
this.imageUrl = getFileAccessHttpUrl(file.id)
|
this.imageUrl = getFileAccessHttpUrl(file.id)
|
||||||
@@ -236,4 +236,4 @@ export default {
|
|||||||
.basis-description {
|
.basis-description {
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ export default {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.fileName}`
|
||||||
console.log(fileFullUrl)
|
console.log(fileFullUrl)
|
||||||
// 图片预览,使用自己添加的组件
|
// 图片预览,使用自己添加的组件
|
||||||
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix.toLowerCase())) {
|
if (canPreview && FILE_TYPE_IMGS.includes(fileSuffix.toLowerCase())) {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ export default {
|
|||||||
getFileInfo({ id: fileId }).then(res => {
|
getFileInfo({ id: fileId }).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
const fileInfo = res.result || {}
|
const fileInfo = res.result || {}
|
||||||
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${fileInfo.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${fileInfo.fileName}`
|
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${fileInfo.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${fileInfo.fileName}`
|
||||||
// 截取文件后缀名
|
// 截取文件后缀名
|
||||||
const fileSuffix = (fileInfo.fileName ? fileInfo.fileName.split('.')[fileInfo.fileName.split('.').length - 1] : '').toLowerCase()
|
const fileSuffix = (fileInfo.fileName ? fileInfo.fileName.split('.')[fileInfo.fileName.split('.').length - 1] : '').toLowerCase()
|
||||||
switch (fileSuffix) {
|
switch (fileSuffix) {
|
||||||
@@ -261,4 +261,4 @@ export default {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user