From 5816fbf205483af9fca512c7a09a4b3d0ae96536 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Thu, 30 Dec 2021 09:34:50 +0800 Subject: [PATCH] =?UTF-8?q?baseUrl=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 8 +-- .env.heb | 8 +-- .env.ntyl | 8 +-- .env.production | 8 +-- .env.staging | 8 +-- src/api/jlmap3d/assets3d.js | 4 +- src/api/upload.js | 2 +- src/components/QuillEditor/index.vue | 2 +- .../jl3ddrive/moveupdate/DrivingConnectNew.js | 5 +- .../jl3dFaultDeviceVr/jl3dFaultDeviceVr.js | 4 +- .../jl3dmaintainer/jl3dOtherVr/Jl3dothervr.js | 4 +- .../jl3dTrainRescue/jl3dTrainRescueVr.js | 4 +- .../jl3dmaintainer/maintainerconnect.js | 4 +- .../jl3dpassflow/connect/passflowconnect.js | 1 - .../jl3drailwaydrive/loader/AssetLoader.js | 4 +- .../moveupdate/DrivingConnectNew.js | 4 +- .../connect/Jlmap3dSubscribeNew.js | 4 +- .../connect/silumationConnect.js | 1 - .../connect/stationConnect.js | 1 - .../jl3dtrafficplan/connect/stationconnect.js | 1 - .../connect/stationpassconnect.js | 1 - .../jl3dtrafficplan/connect/trainconnect.js | 1 - .../connect/trainpassconnect.js | 1 - .../jl3dtrafficplan/sandbox/sandboxconnect.js | 1 - src/jlmap3d/main/loaders/AssetLoader.js | 4 -- src/layout/components/Entry.vue | 2 +- src/permission.js | 17 +++--- src/store/modules/user.js | 28 ++++++--- src/utils/baseUrl.js | 57 +++++++++++++++++-- src/utils/indexedDb.js | 4 +- src/utils/request.js | 6 +- src/utils/sock.js | 3 +- src/views/editor/index.vue | 2 +- src/views/uploadPdf/edit.vue | 2 +- static/workertest/driverWebWorker.js | 1 - static/workertest/jsonworker.js | 1 - static/workertest/jsonworkernew.js | 1 - static/workertest/maintainerworker.js | 1 - static/workertest/otherVrViewWorker.js | 1 - static/workertest/railwayWorker.js | 1 - static/workertest/vrwebworker.js | 1 - 41 files changed, 130 insertions(+), 91 deletions(-) diff --git a/.env.development b/.env.development index 44f32c558..75fe8ce84 100644 --- a/.env.development +++ b/.env.development @@ -5,10 +5,10 @@ NODE_ENV = 'development' # base api # VUE_APP_BASE_API = 'https://joylink.club/jlcloud' # VUE_APP_BASE_API = 'http://192.168.3.4:9000' -VUE_APP_BASE_API = 'http://192.168.3.6:9000' -VUE_APP_VOICE_API = 'http://119.3.163.89/oss/joylink' -VUE_APP_UPLOAD_API = 'http://joylink.club/jlfile' -VUE_APP_BASE_SITE='https://test.joylink.club/cbtc' +# VUE_APP_BASE_API = 'http://192.168.3.6:9000' +# VUE_APP_VOICE_API = 'http://119.3.163.89/oss/joylink' +# VUE_APP_UPLOAD_API = 'http://joylink.club/jlfile' +# VUE_APP_BASE_SITE='https://test.joylink.club/cbtc' # VUE_APP_VOICE_API = 'http://192.168.8.110:9008' diff --git a/.env.heb b/.env.heb index 3dacc354d..ba476b42d 100644 --- a/.env.heb +++ b/.env.heb @@ -3,7 +3,7 @@ NODE_ENV = 'production' VUE_APP_PRO = 'local' # base api -VUE_APP_BASE_API = 'http://160.20.60.15:9000' -VUE_APP_VOICE_API = 'http://160.20.60.15/oss/joylink' -VUE_APP_UPLOAD_API = 'http://160.20.60.15' -VUE_APP_BASE_SITE='http://160.20.60.15' +# VUE_APP_BASE_API = 'http://160.20.60.15:9000' +# VUE_APP_VOICE_API = 'http://160.20.60.15/oss/joylink' +# VUE_APP_UPLOAD_API = 'http://160.20.60.15' +# VUE_APP_BASE_SITE='http://160.20.60.15' diff --git a/.env.ntyl b/.env.ntyl index 23049259f..8aebc8513 100644 --- a/.env.ntyl +++ b/.env.ntyl @@ -3,7 +3,7 @@ NODE_ENV = 'production' VUE_APP_PRO = 'ntyl' # base api -VUE_APP_BASE_API = 'https://joylink.club/jlcloud' -VUE_APP_VOICE_API = 'https://joylink.club/oss/joylink' -VUE_APP_UPLOAD_API = 'https://upload.joylink.club' -VUE_APP_BASE_SITE='https://joylink.club/cbtc' +# VUE_APP_BASE_API = 'https://joylink.club/jlcloud' +# VUE_APP_VOICE_API = 'https://joylink.club/oss/joylink' +# VUE_APP_UPLOAD_API = 'https://upload.joylink.club' +# VUE_APP_BASE_SITE='https://joylink.club/cbtc' diff --git a/.env.production b/.env.production index 51d591827..594d4ddea 100644 --- a/.env.production +++ b/.env.production @@ -2,7 +2,7 @@ NODE_ENV = 'production' # base api -VUE_APP_BASE_API = 'https://api.joylink.club/jlcloud' -VUE_APP_VOICE_API = 'https://joylink.club/oss/joylink' -VUE_APP_UPLOAD_API = 'https://upload.joylink.club' -VUE_APP_BASE_SITE='https://joylink.club/cbtc' +# VUE_APP_BASE_API = 'https://joylink.club/jlcloud' +# VUE_APP_VOICE_API = 'https://joylink.club/oss/joylink' +# VUE_APP_UPLOAD_API = 'https://upload.joylink.club' +# VUE_APP_BASE_SITE='https://joylink.club/cbtc' diff --git a/.env.staging b/.env.staging index 789da186f..522c97e6b 100644 --- a/.env.staging +++ b/.env.staging @@ -2,7 +2,7 @@ NODE_ENV = 'test' # base api -VUE_APP_BASE_API = 'https://test.joylink.club/jlcloud' -VUE_APP_VOICE_API = 'https://joylink.club/oss/joylink' -VUE_APP_UPLOAD_API = 'https://upload.joylink.club' -VUE_APP_BASE_SITE='https://test.joylink.club/cbtc' +# VUE_APP_BASE_API = 'https://test.joylink.club/jlcloud' +# VUE_APP_VOICE_API = 'https://joylink.club/oss/joylink' +# VUE_APP_UPLOAD_API = 'https://upload.joylink.club' +# VUE_APP_BASE_SITE='https://test.joylink.club/cbtc' diff --git a/src/api/jlmap3d/assets3d.js b/src/api/jlmap3d/assets3d.js index a7abce7b2..4c9a14a97 100644 --- a/src/api/jlmap3d/assets3d.js +++ b/src/api/jlmap3d/assets3d.js @@ -1,9 +1,9 @@ import request from '@/utils/request'; - +import store from '@/store/index'; const publicPath = process.env.VUE_APP_PRO == 'local' ? '' : '/cbtc'; export const JL3D_LOCAL_STATIC = publicPath+"/static"; -const BASE_UPLOAD_API = process.env.VUE_APP_UPLOAD_API; +const BASE_UPLOAD_API = store.state.user.uploadUrl; export const BASE_ASSET_API = this.$store.user.state.resourcesUrl; // console.log(JL3D_LOCAL_STATIC); // console.log(BASE_UPLOAD_API); diff --git a/src/api/upload.js b/src/api/upload.js index c2ea6b1de..735f35be4 100644 --- a/src/api/upload.js +++ b/src/api/upload.js @@ -10,7 +10,7 @@ export const meansUrl = `/api/upload/MEANS?appId=${productIdentify}`; // export const regulationUrl = `/api/upload/regulation?appId=${productIdentify}`; export function getUrl(relatedUrl) { - return `${process.env.VUE_APP_UPLOAD_API}${relatedUrl}`; + return `${this.$store.state.user.uploadUrl}${relatedUrl}`; } export function uploadFile(url, data) { diff --git a/src/components/QuillEditor/index.vue b/src/components/QuillEditor/index.vue index 37c7dd208..b950c2e50 100644 --- a/src/components/QuillEditor/index.vue +++ b/src/components/QuillEditor/index.vue @@ -75,7 +75,7 @@ export default { loading: true, name: 'file', size: 3, - action: `${process.env.VUE_APP_UPLOAD_API}/api/upload/PICTURE?appId=00001&appSecret=joylink00001`, + action: `${this.$store.state.user.uploadUrl}/api/upload/PICTURE?appId=00001&appSecret=joylink00001`, response: (res) => { return `${this.$store.user.state.resourcesUrl}${res.data}`; }, diff --git a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js index 824f66be9..4b1f8fa81 100644 --- a/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js +++ b/src/jlmap3d/jl3ddrive/moveupdate/DrivingConnectNew.js @@ -1,6 +1,5 @@ import StompClient from '@/utils/sock'; - -import { getBaseUrl } from '@/utils/baseUrl' +import store from '@/store/index'; import { getToken } from '@/utils/auth'; // 定于仿真socket接口 @@ -43,7 +42,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,dri let header = {'X-Token': getToken() }; let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:this.topic, token:getToken(), }; diff --git a/src/jlmap3d/jl3dmaintainer/jl3dFaultDeviceVr/jl3dFaultDeviceVr.js b/src/jlmap3d/jl3dmaintainer/jl3dFaultDeviceVr/jl3dFaultDeviceVr.js index 6cc60007b..f88be5cd3 100644 --- a/src/jlmap3d/jl3dmaintainer/jl3dFaultDeviceVr/jl3dFaultDeviceVr.js +++ b/src/jlmap3d/jl3dmaintainer/jl3dFaultDeviceVr/jl3dFaultDeviceVr.js @@ -20,9 +20,9 @@ import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js'; import { getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata'; import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import { sendCommandNew } from '@/api/jmap/training'; +import store from '@/store/index'; var clock = new THREE.Clock(); @@ -176,7 +176,7 @@ export function jl3dFaultDeviceVr(dom,group,skinCode) { let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:'/user/queue/simulation/jl3d/'+group, token:getToken(), }; diff --git a/src/jlmap3d/jl3dmaintainer/jl3dOtherVr/Jl3dothervr.js b/src/jlmap3d/jl3dmaintainer/jl3dOtherVr/Jl3dothervr.js index a8ae46529..5a1b554d0 100644 --- a/src/jlmap3d/jl3dmaintainer/jl3dOtherVr/Jl3dothervr.js +++ b/src/jlmap3d/jl3dmaintainer/jl3dOtherVr/Jl3dothervr.js @@ -15,7 +15,7 @@ import {Materialload} from '@/jlmap3d/main/loaders/Materialload.js'; import { getPublishMapDetail,getPublish3dMapDetail} from '@/api/jlmap3d/load3ddata'; import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' +import store from '@/store/index'; import { getToken } from '@/utils/auth'; import { sendCommandNew } from '@/api/jmap/training'; @@ -174,7 +174,7 @@ export function Jl3dOtherVR(dom,group,skinCode) { let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:'/user/queue/simulation/jl3d/'+group, token:getToken(), }; diff --git a/src/jlmap3d/jl3dmaintainer/jl3dTrainRescue/jl3dTrainRescueVr.js b/src/jlmap3d/jl3dmaintainer/jl3dTrainRescue/jl3dTrainRescueVr.js index 22a5d5ea8..2ecaba81b 100644 --- a/src/jlmap3d/jl3dmaintainer/jl3dTrainRescue/jl3dTrainRescueVr.js +++ b/src/jlmap3d/jl3dmaintainer/jl3dTrainRescue/jl3dTrainRescueVr.js @@ -10,9 +10,9 @@ import { ModelManagerVR } from '@/jlmap3d/jl3dmaintainer/jl3dTrainRescue/trainre import { VRButton } from '@/jlmap3d/jl3dmaintainer/jl3dFaultDeviceVr/utils/VRButton.js'; import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import { sendCommandNew } from '@/api/jmap/training'; +import store from '@/store/index'; var clock = new THREE.Clock(); @@ -170,7 +170,7 @@ export function Jl3dTrainRescueVr(dom,group,skinCode) { let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:'/user/queue/simulation/jl3d/'+group, token:getToken(), }; diff --git a/src/jlmap3d/jl3dmaintainer/maintainerconnect.js b/src/jlmap3d/jl3dmaintainer/maintainerconnect.js index 88efed322..53a87a4fb 100644 --- a/src/jlmap3d/jl3dmaintainer/maintainerconnect.js +++ b/src/jlmap3d/jl3dmaintainer/maintainerconnect.js @@ -2,8 +2,8 @@ import StompClient from '@/utils/sock'; // import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation'; // import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; +import store from '@/store/index'; // 定于仿真socket接口 export function Maintainerconnect(jlmap3d,routegroup,jsonwebwork,lablecodemap) { @@ -45,7 +45,7 @@ export function Maintainerconnect(jlmap3d,routegroup,jsonwebwork,lablecodemap) { let header = {'X-Token': getToken() }; let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:this.topic, token:getToken(), }; diff --git a/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js b/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js index 379fbe3a3..3c98dbae5 100644 --- a/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js +++ b/src/jlmap3d/jl3dpassflow/connect/passflowconnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3drailwaydrive/loader/AssetLoader.js b/src/jlmap3d/jl3drailwaydrive/loader/AssetLoader.js index e09c1d851..ae90f88dc 100644 --- a/src/jlmap3d/jl3drailwaydrive/loader/AssetLoader.js +++ b/src/jlmap3d/jl3drailwaydrive/loader/AssetLoader.js @@ -1,8 +1,8 @@ import { AssetModel } from '@/jlmap3d/main/loaders/model/Assetmodel'; import { Assetmaterial } from '@/jlmap3d/main/loaders/model/Assetmaterial'; -import { getBaseUrl } from '@/utils/baseUrl'; +import store from '@/store/index'; import { Loading } from 'element-ui'; -const BASE_API = getBaseUrl(); +const BASE_API = store.state.user.baseUrl; import { JL3D_LOCAL_STATIC,BASE_ASSET_API } from '@/api/jlmap3d/assets3d.js'; let signal5 = { diff --git a/src/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew.js b/src/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew.js index 15c0a6c90..b77165962 100644 --- a/src/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew.js +++ b/src/jlmap3d/jl3drailwaydrive/moveupdate/DrivingConnectNew.js @@ -1,6 +1,6 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' +import store from '@/store/index'; import { getToken } from '@/utils/auth'; // 定于仿真socket接口 @@ -45,7 +45,7 @@ export function Jl3dDrivingNew(mixers,updatemmi,sound,translation,routegroup,sta let header = {'X-Token': getToken() }; let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:this.topic, token:getToken(), }; diff --git a/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js b/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js index 4e65a0c66..330825868 100644 --- a/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js +++ b/src/jlmap3d/jl3dsimulation/connect/Jlmap3dSubscribeNew.js @@ -2,7 +2,7 @@ import StompClient from '@/utils/sock'; // import { getTrainingCbtcDemon, runDiagramStart, runDiagramOver, setTrainingCbtcInitTime } from '@/api/simulation'; // import { creatSubscribe, clearSubscribe, displayTopic, screenTopic } from '@/utils/stomp'; -import { getBaseUrl } from '@/utils/baseUrl' +import store from '@/store/index'; import { getToken } from '@/utils/auth'; // 定于仿真socket接口 @@ -46,7 +46,7 @@ export function Jlmap3dSubscribeNew(jlmap3d,routegroup,jsonwebwork) { let header = {'X-Token': getToken() }; let connectmsg = { type:'init', - baseurl:getBaseUrl(), + baseurl:store.state.user.baseUrl, topic:this.topic, token:getToken(), }; diff --git a/src/jlmap3d/jl3dstationmanager/connect/silumationConnect.js b/src/jlmap3d/jl3dstationmanager/connect/silumationConnect.js index d48f34415..404c824ea 100644 --- a/src/jlmap3d/jl3dstationmanager/connect/silumationConnect.js +++ b/src/jlmap3d/jl3dstationmanager/connect/silumationConnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3dstationmanager/connect/stationConnect.js b/src/jlmap3d/jl3dstationmanager/connect/stationConnect.js index 1fb2530f6..aa22bf4e1 100644 --- a/src/jlmap3d/jl3dstationmanager/connect/stationConnect.js +++ b/src/jlmap3d/jl3dstationmanager/connect/stationConnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js b/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js index 808b8ae90..8f7dd3303 100644 --- a/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/connect/stationconnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3dtrafficplan/connect/stationpassconnect.js b/src/jlmap3d/jl3dtrafficplan/connect/stationpassconnect.js index c8d5218b8..b52830453 100644 --- a/src/jlmap3d/jl3dtrafficplan/connect/stationpassconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/connect/stationpassconnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3dtrafficplan/connect/trainconnect.js b/src/jlmap3d/jl3dtrafficplan/connect/trainconnect.js index 6ad33a03c..652c864a8 100644 --- a/src/jlmap3d/jl3dtrafficplan/connect/trainconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/connect/trainconnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3dtrafficplan/connect/trainpassconnect.js b/src/jlmap3d/jl3dtrafficplan/connect/trainpassconnect.js index 989dd57f6..7c4ef9712 100644 --- a/src/jlmap3d/jl3dtrafficplan/connect/trainpassconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/connect/trainpassconnect.js @@ -1,5 +1,4 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js b/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js index bc56cc406..b63cd13d1 100644 --- a/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js +++ b/src/jlmap3d/jl3dtrafficplan/sandbox/sandboxconnect.js @@ -1,6 +1,5 @@ import StompClient from '@/utils/sock'; -import { getBaseUrl } from '@/utils/baseUrl' import { getToken } from '@/utils/auth'; import store from '@/store/index'; diff --git a/src/jlmap3d/main/loaders/AssetLoader.js b/src/jlmap3d/main/loaders/AssetLoader.js index c9f0daef6..6b59d5165 100644 --- a/src/jlmap3d/main/loaders/AssetLoader.js +++ b/src/jlmap3d/main/loaders/AssetLoader.js @@ -4,13 +4,9 @@ import { import { Assetmaterial } from '@/jlmap3d/main/loaders/model/Assetmaterial'; -import { - getBaseUrl -} from '@/utils/baseUrl'; import { Loading } from 'element-ui'; -const BASE_API = getBaseUrl(); import { JL3D_LOCAL_STATIC, BASE_ASSET_API diff --git a/src/layout/components/Entry.vue b/src/layout/components/Entry.vue index 9aebf7261..1e9df0c17 100644 --- a/src/layout/components/Entry.vue +++ b/src/layout/components/Entry.vue @@ -142,7 +142,7 @@ export default { // } else { // href = 'https://joylink.club/docs'; // } - href = process.env.VUE_APP_BASE_SITE + '/docs/'; + href = this.$store.state.user.baseSite + '/docs/'; window.open(href, '_blank'); }, goEmpty() {}, diff --git a/src/permission.js b/src/permission.js index ad5a051dc..de434e11c 100644 --- a/src/permission.js +++ b/src/permission.js @@ -7,7 +7,7 @@ import 'nprogress/nprogress.css'; import { setToken, getToken, removeToken, getSessionStorage } from '@/utils/auth'; import { getBaseUrlByProject } from '@/api/projectServer'; import localStore from 'storejs'; -import { getBaseUrl } from '@/utils/baseUrl'; +import { handlerUrl } from '@/utils/baseUrl'; const whiteList = ['/login', '/design/login', '/gzzbxy/relay', '/authorization', '/AUSline', '/AUStool', '/demo', '/thirdLogin']; // 不重定向白名单 @@ -90,16 +90,13 @@ router.beforeEach( async (to, from, next) => { if (!store.state.user.baseUrl && project && loginInfo[project]) { try { const resp = await getBaseUrlByProject(ProjectCode[project]); - if (resp && resp.data && resp.data.domainName) { - store.dispatch('setBaseUrl', resp.data.domainName); - } else { - store.dispatch('setBaseUrl', getBaseUrl()); - } - if (resp && resp.data && resp.data.resourcesDomainName) { - store.dispatch('setResourcesUrl', resp.data.resourcesDomainName); - } + const urlData = handlerUrl(resp.data); + store.dispatch('setBaseUrl', urlData.BASE_API); + store.dispatch('setResourcesUrl', urlData.VOICE_API); + store.dispatch('setUploadUrl', urlData.UPLOAD_API); + store.dispatch('setBaseSite', urlData.BASE_SITE); } catch (e) { - store.dispatch('setBaseUrl', getBaseUrl()); + console.error(e); } } document.title = loginInfo[project || 'login'] ? loginInfo[project || 'login'].browserTitle || loginInfo[project || 'login'].title : ''; diff --git a/src/store/modules/user.js b/src/store/modules/user.js index ff71d64ee..ee9f742b7 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -22,7 +22,9 @@ const user = { companyName: '', companyProjectList: [], baseUrl:'', - resourcesUrl: process.env.VUE_APP_VOICE_API + resourcesUrl: '', + uploadUrl: '', + baseSite: '' }, mutations: { @@ -83,9 +85,15 @@ const user = { setBaseUrl: (state, baseUrl) => { state.baseUrl = baseUrl; }, - setResourcesUrl: (state, resourcesUrl) => { - state.resourcesUrl = resourcesUrl; - } + setResourcesUrl: (state, resourcesUrl) => { + state.resourcesUrl = resourcesUrl; + }, + setUploadUrl: (state, uploadUrl) => { + state.uploadUrl = uploadUrl; + }, + setBaseSite: (state, baseSite) => { + state.baseSite = baseSite; + } }, actions: { @@ -217,9 +225,15 @@ const user = { setBaseUrl ({commit}, baseUrl) { commit('setBaseUrl', baseUrl); }, - setResourcesUrl({commit}, resourcesUrl) { - commit('setResourcesUrl', resourcesUrl); - }, + setResourcesUrl({commit}, resourcesUrl) { + commit('setResourcesUrl', resourcesUrl); + }, + setUploadUrl({commit}, uploadUrl) { + commit('setUploadUrl', uploadUrl); + }, + setBaseSite({commit}, baseSite) { + commit('setBaseSite', baseSite); + }, setToken({commit}, token) { commit('SET_TOKEN', token); } diff --git a/src/utils/baseUrl.js b/src/utils/baseUrl.js index 85ac2f3b5..2d26dee7f 100644 --- a/src/utils/baseUrl.js +++ b/src/utils/baseUrl.js @@ -1,6 +1,29 @@ -export function getBaseUrl() { +import store from '@/store/index'; +// export function getBaseUrl() { +// let BASE_API; +// if (process.env.NODE_ENV === 'development') { +// // BASE_API = 'https://joylink.club/jlcloud'; +// // BASE_API = 'https://test.joylink.club/jlcloud'; +// // BASE_API = 'http://114.116.51.125/jlcloud'; +// // BASE_API = 'http://192.168.8.152:9000'; // 袁琪 +// // BASE_API = 'http://192.168.8.172:9200'; // 旭强 +// // BASE_API = 'http://192.168.8.109:9000'; // 张赛 +// // BASE_API = 'http://192.168.8.140:9000'; // 杜康 +// // BASE_API = 'http://b29z135112.zicp.vip'; +// // BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康 +// BASE_API = 'http://2i38984j47.qicp.vip'; // 张赛 +// } else { +// BASE_API = process.env.VUE_APP_BASE_API; +// } +// return BASE_API; +// } +export function handlerUrl(data) { let BASE_API; + let VOICE_API; + let UPLOAD_API; + let BASE_SITE; if (process.env.NODE_ENV === 'development') { + // const data = null; // BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'http://114.116.51.125/jlcloud'; @@ -11,8 +34,34 @@ export function getBaseUrl() { // BASE_API = 'http://b29z135112.zicp.vip'; // BASE_API = 'http://2925963m2a.zicp.vip'; // 杜康 BASE_API = 'http://2i38984j47.qicp.vip'; // 张赛 - } else { - BASE_API = process.env.VUE_APP_BASE_API; + BASE_API = data && data.domainName ? data.domainName : BASE_API; + VOICE_API = data && data.resourcesDomainName ? data.resourcesDomainName : 'https://joylink.club/oss/joylink'; + UPLOAD_API = 'http://joylink.club/jlfile'; + BASE_SITE = 'https://test.joylink.club/cbtc'; + } else if (process.env.NODE_ENV === 'test') { + BASE_API = data && data.domainName ? data.domainName : 'https://test.joylink.club/jlcloud'; + VOICE_API = data && data.resourcesDomainName ? data.resourcesDomainName : 'https://joylink.club/oss/joylink'; + UPLOAD_API = 'http://joylink.club/jlfile'; + BASE_SITE = 'https://test.joylink.club/cbtc'; + } else if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_PRO === 'local') { + BASE_API = 'http://160.20.60.15:9000'; + VOICE_API = 'http://160.20.60.15/oss/joylink'; + UPLOAD_API = 'http://160.20.60.15'; + BASE_SITE = 'http://160.20.60.15'; + } else if (process.env.NODE_ENV === 'production' && process.env.VUE_APP_PRO === 'ntyl') { + BASE_API = 'https://joylink.club/jlcloud'; + VOICE_API = 'https://joylink.club/oss/joylink'; + UPLOAD_API = 'http://joylink.club/jlfile'; + BASE_SITE = 'https://joylink.club/cbtc'; + } else if (process.env.NODE_ENV === 'production') { + BASE_API = data && data.domainName ? data.domainName : 'https://joylink.club/jlcloud'; + // store.dispatch('setBaseUrl', data && data.domainName ? data.domainName : BASE_API); + VOICE_API = data && data.resourcesDomainName ? data.resourcesDomainName : 'https://joylink.club/oss/joylink'; + // store.dispatch('setResourcesUrl', data && data.resourcesDomainName ? data.resourcesDomainName : VOICE_API); + UPLOAD_API = 'http://joylink.club/jlfile'; + // store.dispatch('setUploadUrl', UPLOAD_API); + BASE_SITE = 'https://joylink.club/cbtc'; + // store.dispatch('setBaseSite', BASE_SITE); } - return BASE_API; + return {BASE_API, VOICE_API, UPLOAD_API, BASE_SITE}; } diff --git a/src/utils/indexedDb.js b/src/utils/indexedDb.js index 1fe60c2b9..ee9992d3f 100644 --- a/src/utils/indexedDb.js +++ b/src/utils/indexedDb.js @@ -1,9 +1,9 @@ import Vue from 'vue'; -import { getBaseUrl } from '@/utils/baseUrl'; +import store from '@/store/index'; // 创建或者打开数据库 export function openIndexedDB() { - const baseUrl = getBaseUrl(); + const baseUrl = store.state.user.baseUrl; const indexedDBName = baseUrl.replace(/http.?:\/\/(.*)[\/|:].*/, '$1'); const request = window.indexedDB.open(indexedDBName, 1); request.onerror = function (event) { diff --git a/src/utils/request.js b/src/utils/request.js index 2a5ad9f77..5673dd619 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -4,17 +4,17 @@ import qs from 'qs'; import { i18n } from '@/main.js'; import { MessageBox } from 'element-ui'; import { getToken } from '@/utils/auth'; -import { getBaseUrl } from '@/utils/baseUrl'; +import { handlerUrl } from '@/utils/baseUrl'; import { EventBus } from '@/scripts/event-bus'; import ConstConfig from '@/scripts/ConstConfig'; import Vue from 'vue'; import router from '../router/index'; -const BASE_API = getBaseUrl(); +const urlData = handlerUrl(); // 创建axios实例 const service = axios.create({ - baseURL: BASE_API, // api的base_url + baseURL: urlData.BASE_API, // api的base_url withCredentials: true, // 跨域请求时是否需要使用凭证 timeout: 600000 // 请求超时时间 }); diff --git a/src/utils/sock.js b/src/utils/sock.js index 16b000d8a..dc4347a03 100644 --- a/src/utils/sock.js +++ b/src/utils/sock.js @@ -1,16 +1,15 @@ import { getToken } from '@/utils/auth'; import { checkLoginLine } from '@/api/login'; -import { getBaseUrl } from '@/utils/baseUrl'; import { MessageBox } from 'element-ui'; import store from '@/store/index'; import Stomp from 'stompjs'; const isDev = process.env.NODE_ENV === 'development'; const isTest = process.env.NODE_ENV === 'test'; -const websocketUrl = `${getBaseUrl()}/joylink-websocket?token=`; const reconnectInterval = [1000, 3000, 5000, 10000, 30000, 60000]; var StompClient = function (headers) { + const websocketUrl = `${store.state.user.baseUrl}/joylink-websocket?token=`; this.url = websocketUrl + getToken(); this.headers = headers || {}; this.subscribeMap = new Map(); // 已订阅,对象{dest:'', handler:function, sub: Object} diff --git a/src/views/editor/index.vue b/src/views/editor/index.vue index dbe779aec..8453b8a40 100644 --- a/src/views/editor/index.vue +++ b/src/views/editor/index.vue @@ -26,7 +26,7 @@ export default { }, // 接收父组件的方法 computed: { action() { - return `${process.env.VUE_APP_UPLOAD_API}${pictureUrl}`; + return `${this.$store.state.user.uploadUrl}${pictureUrl}`; }, draft() { return this.$route.query.draft; diff --git a/src/views/uploadPdf/edit.vue b/src/views/uploadPdf/edit.vue index fe2f6c3f8..2aff3161b 100644 --- a/src/views/uploadPdf/edit.vue +++ b/src/views/uploadPdf/edit.vue @@ -57,7 +57,7 @@ export default { }, computed: { action() { - return `${process.env.VUE_APP_UPLOAD_API}${meansUrl}`; + return `${this.$store.state.user.uploadUrl}${meansUrl}`; }, form() { const form = { diff --git a/static/workertest/driverWebWorker.js b/static/workertest/driverWebWorker.js index 4b24eb08f..ec8510672 100644 --- a/static/workertest/driverWebWorker.js +++ b/static/workertest/driverWebWorker.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token='; diff --git a/static/workertest/jsonworker.js b/static/workertest/jsonworker.js index fd865e26b..38e602bc6 100644 --- a/static/workertest/jsonworker.js +++ b/static/workertest/jsonworker.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token='; diff --git a/static/workertest/jsonworkernew.js b/static/workertest/jsonworkernew.js index 1010eef4f..143ea34a5 100644 --- a/static/workertest/jsonworkernew.js +++ b/static/workertest/jsonworkernew.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token='; diff --git a/static/workertest/maintainerworker.js b/static/workertest/maintainerworker.js index 27bc3bff7..b7415c0a9 100644 --- a/static/workertest/maintainerworker.js +++ b/static/workertest/maintainerworker.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token='; diff --git a/static/workertest/otherVrViewWorker.js b/static/workertest/otherVrViewWorker.js index 4487103c2..7959e3fa6 100644 --- a/static/workertest/otherVrViewWorker.js +++ b/static/workertest/otherVrViewWorker.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token='; diff --git a/static/workertest/railwayWorker.js b/static/workertest/railwayWorker.js index ff545e58b..37a37884a 100644 --- a/static/workertest/railwayWorker.js +++ b/static/workertest/railwayWorker.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token='; diff --git a/static/workertest/vrwebworker.js b/static/workertest/vrwebworker.js index 64f9fefbf..101ad117b 100644 --- a/static/workertest/vrwebworker.js +++ b/static/workertest/vrwebworker.js @@ -1,6 +1,5 @@ // importScripts('sockjs.js'); // import { getToken } from '@/utils/auth'; -// import { getBaseUrl } from '@/utils/baseUrl'; // import SockJS from 'sockjs-client'; // const websocketUrl = 'ws://test.joylink.club/jlcloud/joylink-websocket?token=';