From 5078bb9729c29a7642d5439af76159f1b7d35612 Mon Sep 17 00:00:00 2001 From: liushan Date: Sun, 23 Jul 2023 22:07:42 +0800 Subject: [PATCH] .. --- ui/wap/config.json | 3 ++- ui/wap/src/utils/rest.js | 6 +++++- ui/web/config.json | 3 ++- ui/web/src/page/doc.js | 6 +++++- ui/web/src/utils/rest.js | 14 +++++++++++--- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ui/wap/config.json b/ui/wap/config.json index e2669c9..e7bfbcc 100644 --- a/ui/wap/config.json +++ b/ui/wap/config.json @@ -1,3 +1,4 @@ { - "serverURL": "http://175.178.90.181" + "serverURL": "http://lsys.cc", + "serverSslURL": "https://lsys.cc" } \ No newline at end of file diff --git a/ui/wap/src/utils/rest.js b/ui/wap/src/utils/rest.js index fc79fab..6bf7079 100644 --- a/ui/wap/src/utils/rest.js +++ b/ui/wap/src/utils/rest.js @@ -38,8 +38,12 @@ function errorHandler(error) { } export function globalRest(path) { + let api_host = config.serverURL; + if (window.location.protocol == 'https:') { + api_host = config.serverSslURL; + } let ax = axios.create({ - baseURL: config.serverURL + path, + baseURL: api_host + path, timeout: timeout, validateStatus: function (status) { return status >= 200 && status < 600; diff --git a/ui/web/config.json b/ui/web/config.json index e2669c9..e7bfbcc 100644 --- a/ui/web/config.json +++ b/ui/web/config.json @@ -1,3 +1,4 @@ { - "serverURL": "http://175.178.90.181" + "serverURL": "http://lsys.cc", + "serverSslURL": "https://lsys.cc" } \ No newline at end of file diff --git a/ui/web/src/page/doc.js b/ui/web/src/page/doc.js index bed7fb0..c7e2061 100644 --- a/ui/web/src/page/doc.js +++ b/ui/web/src/page/doc.js @@ -104,7 +104,11 @@ function needChangePath(path) { } //替换文件路径,图片 function docFileSrc(id, file) { - let url = `${config.serverURL}/api/docs/raw/${id}/${file}`; + let api_host = config.serverURL; + if (window.location.protocol == 'https:') { + api_host = config.serverSslURL; + } + let url = `${api_host}/api/docs/raw/${id}/${file}`; return url; } diff --git a/ui/web/src/utils/rest.js b/ui/web/src/utils/rest.js index 1031f71..96484a9 100644 --- a/ui/web/src/utils/rest.js +++ b/ui/web/src/utils/rest.js @@ -53,8 +53,12 @@ function errorHandler(error) { } export function globalRest(path) { + let api_host = config.serverURL; + if (window.location.protocol == 'https:') { + api_host = config.serverSslURL; + } let ax = axios.create({ - baseURL: config.serverURL + path, + baseURL: api_host + path, timeout: timeout, validateStatus: function (status) { return status >= 200 && status < 600; @@ -70,16 +74,20 @@ export function globalRest(path) { export function sessionRest(path) { + let api_host = config.serverURL; + if (window.location.protocol == 'https:') { + api_host = config.serverSslURL; + } let session = userSessionGet(); if (!session) { redirectLoginPage() return axios.create({//防止报错。。。 timeout: timeout, - baseURL: config.serverURL + path, + baseURL: api_host + path, }) } let ax = axios.create({ - baseURL: config.serverURL + path, + baseURL: api_host + path, timeout: timeout, transformResponse: [ (data) => {