From b48765c83d792effb85527cfa519ec361b838189 Mon Sep 17 00:00:00 2001 From: Xia Zekun Date: Tue, 4 Jun 2024 13:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=A2=84=E8=A7=88=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 61e53d23e577676a091b9c484251d9b67ce00e1b) --- public/api_address_config.js | 1 + src/utils/previewPdf.js | 2 +- src/views/FilePreview/FilePreview.vue | 18 ++----------- src/views/search/generalSearch.vue | 37 +++++++++++++++------------ 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/public/api_address_config.js b/public/api_address_config.js index 14d82f9..1ba7132 100644 --- a/public/api_address_config.js +++ b/public/api_address_config.js @@ -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' // 单点登录地址 diff --git a/src/utils/previewPdf.js b/src/utils/previewPdf.js index 8a92344..8d46d95 100644 --- a/src/utils/previewPdf.js +++ b/src/utils/previewPdf.js @@ -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 { diff --git a/src/views/FilePreview/FilePreview.vue b/src/views/FilePreview/FilePreview.vue index 936ad27..ea8c243 100644 --- a/src/views/FilePreview/FilePreview.vue +++ b/src/views/FilePreview/FilePreview.vue @@ -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) } } diff --git a/src/views/search/generalSearch.vue b/src/views/search/generalSearch.vue index 2474b09..633eec5 100644 --- a/src/views/search/generalSearch.vue +++ b/src/views/search/generalSearch.vue @@ -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 } }) }, /** * 从文件列表里选择最新文件