文件预览修改

(cherry picked from commit 61e53d23e577676a091b9c484251d9b67ce00e1b)
This commit is contained in:
Xia Zekun
2024-09-06 17:25:22 +08:00
committed by mzaxd
parent 91de072668
commit b48765c83d
4 changed files with 25 additions and 33 deletions
+1
View File
@@ -2,6 +2,7 @@
* 防止打包部署时路径被写死
*/
window._CONFIG = {}
window._CONFIG.domian = 'http://srms-test.sinotruk.com'
window._CONFIG.domianURL = '/laws-sinotruk' // 路由转发 devServer
window._CONFIG.domianWebSocketURL = 'http://localhost:8184/laws-sinotruk'
// 单点登录地址
+1 -1
View File
@@ -6,7 +6,7 @@ const getToken = () => Vue.ls.get(ACCESS_TOKEN)
// 预览pdf
const previewPdf = (id) => {
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 `${window._CONFIG.domian}/pdfjs/web/viewer.html?file=` + encodeURIComponent(url) + '&.pdf'
}
export {
+2 -16
View File
@@ -12,22 +12,8 @@ export default {
}
},
mounted () {
console.log('file preview mounted')
this.previewUrl = this.$route.query.previewUrl
console.log('this.previewUrl1', this.previewUrl)
console.log('process.env.BASE_URL', process.env.BASE_URL)
if (this.previewUrl.startsWith('/')) { // pdf的 url特殊处理下
const index = this.previewUrl.indexOf('file=')
const firstPart = this.previewUrl.substring(0, index)
const secondPart = this.previewUrl.substring(index + 5)
this.previewUrl = 'http://' + window.location.host + firstPart + encodeURIComponent(secondPart)
// this.previewUrl = 'http://' + window.location.host + encodeURIComponent(this.previewUrl)
// window.open(this.previewUrl)
}
console.log('this.previewUrl2', this.previewUrl)
// console.log('this.$route', this.$route)
// console.log('window.location.host', window.location.host)
this.previewUrl = this.$route.params.previewUrl
console.log('file preview mounted', this.previewUrl)
}
}
</script>
+21 -16
View File
@@ -272,12 +272,17 @@ export default {
loadResultFromSession () {
// 从session获取搜索结果
this.searchParam = JSON.parse(sessionStorage.getItem('searchParam'))
console.log('loadResultFromSession', this.searchParam)
if (!this.searchParam) return
this.searchValue = this.searchParam.searchContent
this.resourceTypeCurrent = this.searchParam.resourceType
this.resourceTypeCurrent = this.searchParam.resourceType === null ? 'all' : this.searchParam.resourceType
this.retrievalModeCurrent = this.searchParam.searchMode
this.standardStatusSetCurrent = this.searchParam.standardStateSet
this.initFilterData()
// 资源类型不是全部,并且有搜索内容时获取筛选条件
if (this.resourceTypeCurrent !== 'all' && this.searchValue) {
this.initFilterData()
}
this.dataSource = JSON.parse(sessionStorage.getItem('dataSource'))
this.ipagination = JSON.parse(sessionStorage.getItem('ipagination'))
},
@@ -677,22 +682,22 @@ export default {
// 预览选择的文件
let url = ''
// 是onlyOffice生成的,预览关联的pdf文件
if (file.pdfId) { // 说明是onlyOffice生成的
console.log('是onlyOffice生成的pdf')
url = previewPdf(file.pdfId)
} else if (file.suffix === 'pdf') {
console.log('是其他的pdf')
url = previewPdf(file.id)
} else { // 其余可预览文件仍使用KKFile进行预览
console.log('其余可预览文件仍使用KKFile进行预览')
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
console.log('fileFullUrl', fileFullUrl)
url = dealUrl(fileFullUrl)
}
// // 是onlyOffice生成的,预览关联的pdf文件
// if (file.pdfId) { // 说明是onlyOffice生成的
// console.log('是onlyOffice生成的pdf')
// url = previewPdf(file.pdfId)
// } else if (file.suffix === 'pdf') {
// console.log('是其他的pdf')
// url = previewPdf(file.id)
// } else { // 其余可预览文件仍使用KKFile进行预览
console.log('其余可预览文件仍使用KKFile进行预览')
const fileFullUrl = `${window._CONFIG.domianWebSocketURL}/sys/common/view/${file.id}?at=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}`
console.log('fileFullUrl', fileFullUrl)
url = dealUrl(fileFullUrl)
// }
console.log('url', url)
// window.open(url)
this.$router.push(`/filePreview?previewUrl=${url}`)
this.$router.push({ name: 'filePreview', params: { previewUrl: url } })
},
/**
* 从文件列表里选择最新文件