Преглед изворни кода

增加InternetURL用于配置内网地址,并调整onlyoffice相关url为InternetURL

cfort пре 1 година
родитељ
комит
4e9fa88d5a

+ 8 - 6
public/config.js

@@ -1,17 +1,19 @@
 (function (global) {
-    const BASE_URL = 'http://dev1.local/'
-    const PUBLIC_URL = 'http://dev1.local/'
+    // 是否启用动态API,启用后,将根据访问IP的origin获取API地址
+    const ENABLE_DYNAMIC_API = true
+    const HOST_URL = `${location.origin}${location.pathname}`
+    const BASE_URL = ENABLE_DYNAMIC_API ? HOST_URL : 'http://dev1.local/'
     global.__IBPS_CONFIG__ = {
         // 是否启用配置
         ENABLE_CONFIG: true,
         // 基础路径
         BASE_URL,
-        //公网路径
-        PUBLIC_URL,
+        //公网地址(文件预览下载、扫码回调)
+        PUBLIC_URL: 'http://dev1.local/',
+        // 内网地址(onlyoffice相关url默认使用该ip)
+        INTRANET_URL: 'http://dev1.local/',
         //  api
         BASE_API: `${ BASE_URL }ibps`,
-        // 是否启用动态API,启用后,将根据访问IP的origin获取API地址
-        ENABLE_DYNAMIC_API: false,
         // GATEWAY API
         BASE_GATEWAY_API: `${ BASE_URL }ibps`,
         // WEBSOCKET api

+ 4 - 2
src/api/baseUrl.js

@@ -1,6 +1,7 @@
 import store from '@/store'
 import {
     BASE_API as baseApi,
+    INTRANET_URL,
     BASE_GATEWAY_API as gatewayApi,
     BASE_WEBSOCKET as baseWebsocket,
     SINGLE, MULTIPLE_DOMAIN, API_DOMAIN_NAMES
@@ -23,8 +24,9 @@ const getApi = (api, i) => {
 }
 
 // 默认url
-export const BASE_API = function (i) {
-    const api = store && store.getters.baseApi ? store.getters.baseApi : baseApi
+export const BASE_API = function (i, type = '') {
+    const base = type === 'intranet' ? `${INTRANET_URL}ibps` : baseApi
+    const api = store && store.getters.baseApi ? store.getters.baseApi : base
     return MULTIPLE_DOMAIN ? getApi(api, i) : api
 }
 // 网关API 解决上传乱码问题

+ 97 - 103
src/api/platform/file/attachment.js

@@ -1,140 +1,135 @@
 import request from '@/utils/request'
 import axios from 'axios'
-import {
-  getToken
-} from '@/utils/auth'
-import {
-  BASE_API,
-  SYSTEM_URL
-} from '@/api/baseUrl'
+import { getToken } from '@/utils/auth'
+import { BASE_API, SYSTEM_URL } from '@/api/baseUrl'
 import store from '@/store'
-
 import qs from 'qs'
+
 /**
  * 查询列表数据
  * @param {*} params
  */
-export function queryPageList(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/attachment/query',
-    method: 'post',
-    data: params
-  })
+export function queryPageList (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/attachment/query',
+        method: 'post',
+        data: params
+    })
 }
 /**
  * 删除数据
  * @param {*} params
  */
-export function remove(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/attachment/remove',
-    method: 'post',
-    isLoading: true,
-    params: params
-  })
+export function remove (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/attachment/remove',
+        method: 'post',
+        isLoading: true,
+        params: params
+    })
 }
 /**
  * 删除文件
  * @param {*} params
  */
- export function deleteFile(params) {
+export function deleteFile (params) {
     return request({
-      url: SYSTEM_URL() + '/file/delete',
-      method: 'post',
-      isLoading: true,
-      params: params
+        url: SYSTEM_URL() + '/file/delete',
+        method: 'post',
+        isLoading: true,
+        params: params
     })
-  }
+}
 /**
  * 保存数据
  * @param {*} params
  */
-export function save(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/attachment/save',
-    method: 'post',
-    isLoading: true,
-    data: params
-  })
+export function save (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/attachment/save',
+        method: 'post',
+        isLoading: true,
+        data: params
+    })
 }
 
 /**
  * 获取数据
  * @param {*} params
  */
-export function get(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/attachment/get',
-    method: 'get',
-    params
-  })
+export function get (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/attachment/get',
+        method: 'get',
+        params
+    })
 }
 
 /**
  * 获取数据(通过ID转换为名称)
  * @param {*} params
  */
-export function transfer(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/attachment/transfer',
-    method: 'post',
-    data: params
-  })
+export function transfer (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/attachment/transfer',
+        method: 'post',
+        data: params
+    })
 }
 
 /**
  * 保存修改文件名
  * @param {*} params
  */
-export function modifyName(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/attachment/modifyName',
-    method: 'post',
-    isLoading: true,
-    params: params
-  })
+export function modifyName (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/attachment/modifyName',
+        method: 'post',
+        isLoading: true,
+        params: params
+    })
 }
 /**
  * 下载文件url
  * @param {*} params
  */
-export function downloadUrl(params) {
-  return SYSTEM_URL() + '/file/download?' + qs.parse(params)
+export function downloadUrl (params) {
+    return SYSTEM_URL() + '/file/download?' + qs.parse(params)
 }
 
 /**
  * 下载文件
  * @param {*} params
  */
-export function download(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/download',
-    method: 'get',
-    isLoading: true,
-    responseType: 'arraybuffer',
-    params: params
-  })
+export function download (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/download',
+        method: 'get',
+        isLoading: true,
+        responseType: 'arraybuffer',
+        params: params
+    })
 }
 /**
  * 根据文件id获取文件流
  * @param {*} params
  */
-export function getFileByte(params) {
+export function getFileByte (params) {
     return request({
-      url: SYSTEM_URL() + '/file/getFileByte',
-      method: 'get',
-      isLoading: true,
-      responseType: 'arraybuffer',
-      params: params
+        url: SYSTEM_URL() + '/file/getFileByte',
+        method: 'get',
+        isLoading: true,
+        responseType: 'arraybuffer',
+        params: params
     })
-  }
+}
 /* 在线编辑进行实时回调 */
-export function showView(params) {
-  return request({
-    url: SYSTEM_URL() + '/file/showView',
-    method: 'get',
-    params: params
-  })
+export function showView (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/showView',
+        method: 'get',
+        params: params
+    })
 }
 
 /**
@@ -142,26 +137,26 @@ export function showView(params) {
  * @param {*} file
  * @param {*} uploadFileVo
  */
-export function uploadFile(file, uploadFileVo) {
-  const data = new FormData() // 创建form对象
-  data.append('file', file)
-  // data.append('uploadFileVo', null)
+export function uploadFile (file, uploadFileVo) {
+    const data = new FormData() // 创建form对象
+    data.append('file', file)
+    // data.append('uploadFileVo', null)
 
-  return request({
-    url: SYSTEM_URL() + '/file/upload',
-    method: 'post',
-    isLoading: true,
-    gateway: true,
-    data: data
-  })
+    return request({
+        url: SYSTEM_URL() + '/file/upload',
+        method: 'post',
+        isLoading: true,
+        gateway: true,
+        data: data
+    })
 }
 
 /**
  * 获取文件预览地址
  * @param {*} attachmentId
  */
-export function previewFile(attachmentId) {
-  return BASE_API() + SYSTEM_URL() + '/file/preview?attachmentId=' +
+export function previewFile (attachmentId) {
+    return BASE_API() + SYSTEM_URL() + '/file/preview?attachmentId=' +
     attachmentId + '&access_token=' + getToken() + '&tenantId=' + store.getters.tenantid
 }
 
@@ -169,8 +164,8 @@ export function previewFile(attachmentId) {
  * 获取图片地址
  * @param {*} attachmentId
  */
-export function getImage(attachmentId) {
-  return BASE_API() + SYSTEM_URL() + '/file/getImage?attachmentId=' +
+export function getImage (attachmentId) {
+    return BASE_API() + SYSTEM_URL() + '/file/getImage?attachmentId=' +
     attachmentId + '&access_token=' + getToken() + '&tenantId=' + store.getters.tenantid
 }
 
@@ -178,27 +173,26 @@ export function getImage(attachmentId) {
  * 获取照片地址
  * @param {*} attachmentId
  */
-export function getPhoto(photo) {
-  return BASE_API() + SYSTEM_URL() + photo + '&access_token=' + getToken() + '&tenantId=' + store.getters.tenantid
+export function getPhoto (photo) {
+    return BASE_API() + SYSTEM_URL() + photo + '&access_token=' + getToken() + '&tenantId=' + store.getters.tenantid
 }
 
 /**
  * 返回保存数据库附件格式地址
  * @param {*} fileId
  */
-export function fileUrl(fileId) {
-  return '/file/getImage?attachmentId=' + fileId
+export function fileUrl (fileId) {
+    return '/file/getImage?attachmentId=' + fileId
 }
 /**
  * 脚本保存文件
  * @param {*} params
  */
-export function snapshoot(params) {
-
-  return request({
-    url: SYSTEM_URL() + '/file/upload/runQianUpload',
-    method: 'post',
-    isLoading: true,
-    params: params
-  })
+export function snapshoot (params) {
+    return request({
+        url: SYSTEM_URL() + '/file/upload/runQianUpload',
+        method: 'post',
+        isLoading: true,
+        params: params
+    })
 }

+ 3 - 2
src/business/platform/file/attachment/selector.vue

@@ -474,8 +474,9 @@ export default {
         // 处理编辑文件
         handleEdit (index, data, type) {
             // 1、获取文件数据 及下载流接口
-            this.optionFile.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + data.id
-            this.optionFile.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + data.fileName + '&fileType=' + data.ext + '&type=' + type + '&id=' + data.id
+            const api = BASE_API('', 'intranet') + SYSTEM_URL()
+            this.optionFile.url = api + '/file/download?attachmentId=' + data.id
+            this.optionFile.editUrl = api + '/file/editCallback?fileName=' + data.fileName + '&fileType=' + data.ext + '&type=' + type + '&id=' + data.id
             this.optionFile.title = data.fileName // 文件名称
             this.optionFile.fileType = data.ext // 类型
             this.optionFile.data = data // 记录编制的位置,需要替换。

+ 4 - 2
src/business/platform/file/attachment/template-selector.vue

@@ -261,6 +261,7 @@ export default {
 
             const data = this.value ? JSON.parse(this.value) : []
             this.selectorValue = this.multiple ? [data] : data
+            this.templateOption = this.fileOption
         },
         setCacheData () {
             if (this.$utils.isEmpty(this.selectorValue)) return
@@ -551,10 +552,11 @@ export default {
          */
         getPreview (index) {
             // 1、获取文件数据 及下载流接口
+            const api = BASE_API('', 'intranet') + SYSTEM_URL()
             // 下载地址
-            this.optionFileView.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + this.attachment.id
+            this.optionFileView.url = api + '/file/download?attachmentId=' + this.attachment.id
             // 回调接口url
-            this.optionFileView.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + this.attachment.fileName + '&fileType=' + this.attachment.ext
+            this.optionFileView.editUrl = api + '/file/editCallback?fileName=' + this.attachment.fileName + '&fileType=' + this.attachment.ext
             this.optionFileView.title = this.attachment.fileName // 文件名称
             this.optionFileView.fileType = this.attachment.ext // 类型
             this.optionFileView.data = this.attachment // 记录编制的位置,需要替换。

+ 45 - 45
src/business/platform/file/file-preview/index.vue

@@ -1,59 +1,59 @@
 <template>
- <ibps-file-viewer
-    :visible.sync="dialogVisible"
-    :title="title"
-    :url="url"
-    :optionFile="optionFile"
-    :file-ext="fileExt"
-    @close="$emit('close', false)"
-  />
+    <ibps-file-viewer
+        :visible.sync="dialogVisible"
+        :title="title"
+        :url="url"
+        :option-file="optionFile"
+        :file-ext="fileExt"
+        @close="$emit('close', false)"
+    />
 </template>
 <script>
 import IbpsFileViewer from '@/components/ibps-file-viewer'
 import { previewFile } from '@/api/platform/file/attachment'
 export default {
-  components: {
-    IbpsFileViewer
-  },
-  props: {
-    visible: {
-      type: Boolean,
-      default: false
+    components: {
+        IbpsFileViewer
     },
-    file: {
-      type: Object
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        file: {
+            type: Object
+        },
+        optionFile: {
+            type: Object,
+            default: () => {
+                return {}
+            }
+        }
     },
-    optionFile: {
-      type: Object,
-      default: () => {
-        return {}
-      }
+    data () {
+        return {
+            dialogVisible: false,
+            title: '',
+            fileId: '',
+            fileExt: '',
+            fileType: '',
+            url: ''
+        }
     },
-  },
-  data() {
-    return {
-      dialogVisible: false,
-      title: '',
-      fileId: '',
-      fileExt: '',
-      fileType: '',
-      url: ''
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-        if (this.dialogVisible) {
-          this.title = this.file.fileName
-          this.fileId = this.file.id
-          this.fileExt = this.file.ext
-          this.url = previewFile(this.file.id) || ''
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+                if (this.dialogVisible) {
+                    this.title = this.file.fileName
+                    this.fileId = this.file.id
+                    this.fileExt = this.file.ext
+                    this.url = previewFile(this.file.id) || ''
+                }
+            },
+            immediate: true
         }
-      },
-      immediate: true
     }
-  }
 
 }
 </script>

+ 4 - 6
src/constant.js

@@ -13,16 +13,14 @@ export default __IBPS_CONFIG__
 
 const enableConfig = __IBPS_CONFIG__.ENABLE_CONFIG || false
 
-const HOSTAPI = `${location.origin}${location.pathname}ibps`
-const HOSTURL = `${location.origin}${location.pathname}`
-
 /**
  * 接口服务器
  * @type {*|string}
  */
-export const BASE_URL = enableConfig ? (__IBPS_CONFIG__.ENABLE_DYNAMIC_API ? HOSTURL : (__IBPS_CONFIG__.BASE_URL || env.VUE_APP_BASE_URL)) : env.VUE_APP_BASE_URL
-export const PUBLIC_URL = enableConfig ? (__IBPS_CONFIG__.ENABLE_DYNAMIC_API ? HOSTURL : (__IBPS_CONFIG__.PUBLIC_URL || env.VUE_APP_BASE_URL)) : env.VUE_APP_BASE_URL
-export const BASE_API = enableConfig ? (__IBPS_CONFIG__.ENABLE_DYNAMIC_API ? HOSTAPI : (__IBPS_CONFIG__.BASE_API || env.VUE_APP_BASE_API)) : env.VUE_APP_BASE_API
+export const BASE_URL = enableConfig ? (__IBPS_CONFIG__.BASE_URL || env.VUE_APP_BASE_URL) : env.VUE_APP_BASE_URL
+export const PUBLIC_URL = enableConfig ? (__IBPS_CONFIG__.PUBLIC_URL || env.VUE_APP_BASE_URL) : env.VUE_APP_BASE_URL
+export const INTRANET_URL = enableConfig ? (__IBPS_CONFIG__.INTRANET_URL || env.VUE_APP_BASE_URL) : env.VUE_APP_BASE_URL
+export const BASE_API = enableConfig ? (__IBPS_CONFIG__.BASE_API || env.VUE_APP_BASE_API) : env.VUE_APP_BASE_API
 export const BASE_GATEWAY_API = enableConfig ? (__IBPS_CONFIG__.BASE_GATEWAY_API || env.VUE_APP_BASE_GATEWAY_API) : env.VUE_APP_BASE_GATEWAY_API
 export const BASE_WEBSOCKET = enableConfig ? (__IBPS_CONFIG__.BASE_WEBSOCKET_API || env.VUE_APP_BASE_WEBSOCKET) : env.VUE_APP_BASE_WEBSOCKET
 export const BASE_REPORT_API = enableConfig ? (__IBPS_CONFIG__.BASE_REPORT_API || env.VUE_APP_BASE_REPORT_API) : env.VUE_APP_BASE_REPORT_API

+ 179 - 180
src/store/modules/ibps/modules/api.js

@@ -8,196 +8,195 @@ let base = BASE_API
 let websocket = BASE_WEBSOCKET
 
 if (process.env.NODE_ENV === 'development') {
-  optionsEnv = Object.keys(env)
-    .filter(keyName => /^VUE_APP_BASE_API_\d+_\w+$/.test(keyName))
-    .map(keyName => {
-      const [index, single, ...name] = keyName.replace('VUE_APP_BASE_API_', '').split('_')
-      return {
-        index: Number(index),
-        single: Number(single) === 1,
-        name: name.join('_'),
-        value: env[keyName]
-      }
-    })
-    .sort((a, b) => a.index - b.index)
-    .map(e => ({
-      single: e.single,
-      name: e.name,
-      value: e.value,
-      type: 'env'
-    }))
+    optionsEnv = Object.keys(env)
+        .filter(keyName => /^VUE_APP_BASE_API_\d+_\w+$/.test(keyName))
+        .map(keyName => {
+            const [index, single, ...name] = keyName.replace('VUE_APP_BASE_API_', '').split('_')
+            return {
+                index: Number(index),
+                single: Number(single) === 1,
+                name: name.join('_'),
+                value: env[keyName]
+            }
+        })
+        .sort((a, b) => a.index - b.index)
+        .map(e => ({
+            single: e.single,
+            name: e.name,
+            value: e.value,
+            type: 'env'
+        }))
 
-  base = BASE_API || (optionsEnv.length > 0 ? optionsEnv[0].value : '')
+    base = BASE_API || (optionsEnv.length > 0 ? optionsEnv[0].value : '')
 
-  websocket = BASE_WEBSOCKET || (optionsEnv.length > 0 ? optionsEnv[0].value : '')
+    websocket = BASE_WEBSOCKET || (optionsEnv.length > 0 ? optionsEnv[0].value : '')
 }
 
 export default {
-  namespaced: true,
-  state: {
-    // 是否是单体
-    single,
-    // 网络请求地址
-    base,
-    // websocket 地址
-    websocket,
-    // env 中设置的地址选项
-    optionsEnv,
-    // 用户自己添加的地址
-    optionsUser: []
-  },
-  getters: {
-    // 混合系统提供的地址和用户自己设置的地址记录
-    options(state) {
-      return [
-        ...state.optionsUser,
-        ...state.optionsEnv
-      ]
-    }
-  },
-  actions: {
-    /**
-       * @description 设置自定义选项
-       * @param {Object} vuex context
-       * @param {String} value
-       * @param {Boolean} single
-       */
-    async custom({ state, dispatch }, {
-      baseUrl,
-      single = false
-    }) {
-      // 如果和现在的值一样 直接返回
-      if (state.base === baseUrl) return
-      // 如果不是选项中的值 将其加入选项
-      const findIndex = [
-        ...state.optionsEnv,
-        ...state.optionsUser
-      ].map(e => e.value).indexOf(baseUrl)
-
-      if (findIndex === -1) {
-        state.optionsUser.push({
-          name: '自定义',
-          single: single,
-          value: baseUrl,
-          type: 'custom'
-        })
-        // 持久化用户自定义选项
-        await dispatch('ibps/db/set', {
-          dbName: 'sys',
-          path: 'api.optionsUser',
-          value: state.optionsUser,
-          user: false
-        }, { root: true })
-      } else {
-        Notification({
-          title: '接口地址已经存在!!',
-          type: 'warning',
-          message: baseUrl
-        })
-      }
+    namespaced: true,
+    state: {
+        // 是否是单体
+        single,
+        // 网络请求地址
+        base,
+        // websocket 地址
+        websocket,
+        // env 中设置的地址选项
+        optionsEnv,
+        // 用户自己添加的地址
+        optionsUser: []
     },
-    /**
-     *
-       * @description 改变网络请求地址
-       * @param {Object} vuex context
-       * @param {String} value
-       * @param {Boolean} single
-     */
-    async set({ state, dispatch }, {
-      baseUrl,
-      single = false,
-      vm
-    }) {
-      // 设置当前子系统为空
-      await dispatch('ibps/system/set', null, {
-        root: true
-      })
-      // 注销当前用户登录
-      await dispatch('ibps/account/fedLogout', {
-        vm: vm
-      }, { root: true })
+    getters: {
+        // 混合系统提供的地址和用户自己设置的地址记录
+        options (state) {
+            return [
+                ...state.optionsUser,
+                ...state.optionsEnv
+            ]
+        }
+    },
+    actions: {
+        /**
+         * @description 设置自定义选项
+         * @param {Object} vuex context
+         * @param {String} value
+         * @param {Boolean} single
+         */
+        async custom ({ state, dispatch }, {
+            baseUrl,
+            single = false
+        }) {
+            // 如果和现在的值一样 直接返回
+            if (state.base === baseUrl) return
+            // 如果不是选项中的值 将其加入选项
+            const findIndex = [
+                ...state.optionsEnv,
+                ...state.optionsUser
+            ].map(e => e.value).indexOf(baseUrl)
 
-      // 接口地址变更
-      state.base = baseUrl
-      // 持久化接口地址设置
-      await dispatch('ibps/db/set', {
-        dbName: 'sys',
-        path: 'api.base',
-        value: state.base,
-        user: false
-      }, { root: true })
+            if (findIndex === -1) {
+                state.optionsUser.push({
+                    name: '自定义',
+                    single: single,
+                    value: baseUrl,
+                    type: 'custom'
+                })
+                // 持久化用户自定义选项
+                await dispatch('ibps/db/set', {
+                    dbName: 'sys',
+                    path: 'api.optionsUser',
+                    value: state.optionsUser,
+                    user: false
+                }, { root: true })
+            } else {
+                Notification({
+                    title: '接口地址已经存在!!',
+                    type: 'warning',
+                    message: baseUrl
+                })
+            }
+        },
+        /**
+         * @description 改变网络请求地址
+         * @param {Object} vuex context
+         * @param {String} value
+         * @param {Boolean} single
+         */
+        async set ({ state, dispatch }, {
+            baseUrl,
+            single = false,
+            vm
+        }) {
+            // 设置当前子系统为空
+            await dispatch('ibps/system/set', null, {
+                root: true
+            })
+            // 注销当前用户登录
+            await dispatch('ibps/account/fedLogout', {
+                vm: vm
+            }, { root: true })
 
-      // 单体应用变更
-      state.single = single
-      // 持久化单体应用设置
-      await dispatch('ibps/db/set', {
-        dbName: 'sys',
-        path: 'api.single',
-        value: state.single,
-        user: false
-      }, { root: true })
-      // 显示提示
-      Notification({
-        title: '接口地址变更',
-        message: baseUrl
-      })
-    },
-    /**
-       * @description 删除一个用户自己的地址配置
-       * @param {Object} vuex context
-       * @param {String} value
-       */
-    async remove({ state, dispatch }, value) {
-      const index = state.optionsUser.map(e => e.value).indexOf(value)
-      if (index >= 0) {
-        // 移除
-        state.optionsUser.splice(index, 1)
-        // 持久化用户自定义选项
-        await dispatch('ibps/db/set', {
-          dbName: 'sys',
-          path: 'api.optionsUser',
-          value: state.optionsUser,
-          user: false
-        }, { root: true })
+            // 接口地址变更
+            state.base = baseUrl
+            // 持久化接口地址设置
+            await dispatch('ibps/db/set', {
+                dbName: 'sys',
+                path: 'api.base',
+                value: state.base,
+                user: false
+            }, { root: true })
 
-        // 显示提示
-        Message({
-          message: `${value} 已经删除`,
-          type: 'success'
-        })
-      }
-    },
-    /**
-       * @description 加载设置
-       * @param {Object} vuex context
-       */
-    async load({ state, dispatch }) {
-      if (process.env.NODE_ENV !== 'development') {
-        return
-      }
-      // 加载接口地址设置
-      state.base = await dispatch('ibps/db/get', {
-        dbName: 'sys',
-        path: 'api.base',
-        defaultValue: base,
-        user: false
-      }, { root: true })
+            // 单体应用变更
+            state.single = single
+            // 持久化单体应用设置
+            await dispatch('ibps/db/set', {
+                dbName: 'sys',
+                path: 'api.single',
+                value: state.single,
+                user: false
+            }, { root: true })
+            // 显示提示
+            Notification({
+                title: '接口地址变更',
+                message: baseUrl
+            })
+        },
+        /**
+         * @description 删除一个用户自己的地址配置
+         * @param {Object} vuex context
+         * @param {String} value
+         */
+        async remove ({ state, dispatch }, value) {
+            const index = state.optionsUser.map(e => e.value).indexOf(value)
+            if (index >= 0) {
+                // 移除
+                state.optionsUser.splice(index, 1)
+                // 持久化用户自定义选项
+                await dispatch('ibps/db/set', {
+                    dbName: 'sys',
+                    path: 'api.optionsUser',
+                    value: state.optionsUser,
+                    user: false
+                }, { root: true })
+
+                // 显示提示
+                Message({
+                    message: `${value} 已经删除`,
+                    type: 'success'
+                })
+            }
+        },
+        /**
+         * @description 加载设置
+         * @param {Object} vuex context
+         */
+        async load ({ state, dispatch }) {
+            if (process.env.NODE_ENV !== 'development') {
+                return
+            }
+            // 加载接口地址设置
+            state.base = await dispatch('ibps/db/get', {
+                dbName: 'sys',
+                path: 'api.base',
+                defaultValue: base,
+                user: false
+            }, { root: true })
 
-      // 加载单体应用设置
-      state.single = await dispatch('ibps/db/get', {
-        dbName: 'sys',
-        path: 'api.single',
-        defaultValue: single,
-        user: false
-      }, { root: true })
+            // 加载单体应用设置
+            state.single = await dispatch('ibps/db/get', {
+                dbName: 'sys',
+                path: 'api.single',
+                defaultValue: single,
+                user: false
+            }, { root: true })
 
-      // 加载接口地址设置
-      state.optionsUser = await dispatch('ibps/db/get', {
-        dbName: 'sys',
-        path: 'api.optionsUser',
-        defaultValue: [],
-        user: false
-      }, { root: true })
+            // 加载接口地址设置
+            state.optionsUser = await dispatch('ibps/db/get', {
+                dbName: 'sys',
+                path: 'api.optionsUser',
+                defaultValue: [],
+                user: false
+            }, { root: true })
+        }
     }
-  }
 }

+ 3 - 2
src/views/component/fileTraining/index.vue

@@ -502,8 +502,9 @@ export default {
                             totalBytes: val.fileInfos.TOTAL_BYTES_
                         }
 
-                        this.optionFile.url = `${BASE_API()}${SYSTEM_URL()}/file/download?attachmentId=${data.id}`
-                        this.optionFile.editUrl = `${BASE_API()}${SYSTEM_URL()}/file/editCallback?fileName=${data.fileName}&fileType=${data.ext}&type=fileTraining&id=${data.id}`
+                        const api = BASE_API('', 'intranet') + SYSTEM_URL()
+                        this.optionFile.url = `${api}/file/download?attachmentId=${data.id}`
+                        this.optionFile.editUrl = `${api}/file/editCallback?fileName=${data.fileName}&fileType=${data.ext}&type=fileTraining&id=${data.id}`
                         this.optionFile.title = data.fileName // 文件名称
                         this.optionFile.fileType = data.ext // 类型
                         this.optionFile.data = data // 记录编制的位置,需要替换。

+ 3 - 2
src/views/platform/file/attachment/detail.vue

@@ -162,10 +162,11 @@ export default {
                 this.$message.warning('图片附件请直接在列表预览!')
                 return
             }
+            const api = BASE_API('', 'intranet') + SYSTEM_URL()
             this.fileOption.user.id = this.$store.getters.userId
             this.fileOption.user.name = this.$store.getters.name
-            this.fileOption.url = BASE_API() + SYSTEM_URL() + `/file/download?attachmentId=${id}`
-            this.fileOption.editUrl = BASE_API() + SYSTEM_URL() + `/file/editCallback?fileName=${fileName}&fileType=${ext}&id=${id}`
+            this.fileOption.url = api + `/file/download?attachmentId=${id}`
+            this.fileOption.editUrl = api + `/file/editCallback?fileName=${fileName}&fileType=${ext}&id=${id}`
             this.fileOption.title = fileName
             this.fileOption.fileType = ext
             // console.log(this.fileOption)

+ 3 - 2
src/views/platform/file/attachment/list.vue

@@ -284,8 +284,9 @@ export default {
                             newTab.document.write(`<iframe src="${this.$baseUrl}lib/pdfjs-dist/web/viewer.html?file=${encodeURIComponent(url)}&hasRole=${hasRole}" style="width:100%; height:100%;" frameborder="0";>`)
                         })
                     } else {
-                        this.file.url = BASE_API() + SYSTEM_URL() + `/file/download?attachmentId=${data.id}`
-                        this.file.editUrl = BASE_API() + SYSTEM_URL() + `/file/editCallback?fileName=${data.fileName}&fileType=${data.ext}&id=${data.id}`
+                        const api = BASE_API('', 'intranet') + SYSTEM_URL()
+                        this.file.url = `${api}/file/download?attachmentId=${data.id}`
+                        this.file.editUrl = `${api}/file/editCallback?fileName=${data.fileName}&fileType=${data.ext}&id=${data.id}`
                         this.file.title = data.fileName // 文件名称
                         this.file.fileType = data.ext // 类型
                         this.filePreviewVisible = false