Просмотр исходного кода

内外网、ip不同导致文件预览问题

cyy 6 месяцев назад
Родитель
Сommit
daa52119f7
2 измененных файлов с 15 добавлено и 7 удалено
  1. 14 6
      src/components/ibps-file-preview/index.vue
  2. 1 1
      vue.config.js

+ 14 - 6
src/components/ibps-file-preview/index.vue

@@ -57,6 +57,7 @@ import AudioPlayer from './audio'
 import VideoPlayer from './video'
 import officeViewer from './viewFile'
 import { previewFile } from '@/api/platform/file/attachment'
+import { dbSqlConfig } from '@/constant'
 import {
   officeType,
   pdfType,
@@ -135,7 +136,7 @@ export default {
         this.loadViewer()
       },
       immediate: true,
-      deep:true
+      deep: true
     }
   },
   // beforeDestroy() {
@@ -177,18 +178,25 @@ export default {
       this.fileType = 'word'
       this.getFile()
     },
-    getFile() {
-      console.log(this.file,'filefilefile')
+    async getFile() {
+      console.log(this.file, 'filefilefile')
       // 1、获取文件数据 及下载流接口
       // 下载地址
+      const sql = `select * from t_ipcc where id_ = '1'`
+      let ipccUrl = ''
+      await this.$common.request(dbSqlConfig ? 'query' : 'sql', dbSqlConfig ? { key: 'getIpConfig', params: [null] } : sql).then(res => {
+        const datas = res.variables.data
+        const ip = datas[0].nei_rong_
+        ipccUrl = ip + '/ibps'
+      })
       this.option.url =
-        BASE_API() +
+      (BASE_API() === ipccUrl ? BASE_API() : ipccUrl) +
         SYSTEM_URL() +
         '/file/download?attachmentId=' +
         this.file.id
       // 回调接口url
       this.option.editUrl =
-        BASE_API() +
+      (BASE_API() === ipccUrl ? BASE_API() : ipccUrl) +
         SYSTEM_URL() +
         '/file/editCallback?fileName=' +
         this.file.fileName +
@@ -197,7 +205,7 @@ export default {
       this.option.title = this.file.fileName // 文件名称
       this.option.fileType = this.file.ext // 类型
       this.option.data = this.file // 记录编制的位置,需要替换。
-      console.log(this.option,'3123213131313123')
+      console.log(this.option, '3123213131313123')
     },
     closeDialog() {
       this.fileType = ''

+ 1 - 1
vue.config.js

@@ -9,7 +9,7 @@ const resolve = dir => path.join(__dirname, dir)
 process.env.VUE_APP_VERSION = require('./package.json').version
 
 // 基础路径 注意发布之前要先修改这里
-const publicPath = process.env.VUE_APP_PUBLIC_PATH || './'
+const publicPath = process.env.VUE_APP_PUBLIC_PATH || process.env.NODE_ENV === 'development' ? '/' : './'
 
 // If your port is set to 80,
 // use administrator privileges to execute the command line.