From f82dccc18d2dc59b6598e5f83658cbe965a8c210 Mon Sep 17 00:00:00 2001 From: liuguocan <527956374@qq.com> Date: 星期五, 24 二月 2023 13:32:11 +0800 Subject: [PATCH] 优化request/sftp 路径统一配置 --- src/utils/request.js | 6 ++---- public/index.html | 3 ++- public/static/config.js | 25 +++++++++++++++++++++++++ src/plugins/download.js | 9 +++------ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/public/index.html b/public/index.html index 925455c..95913a2 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,8 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="renderer" content="webkit"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> - <link rel="icon" href="<%= BASE_URL %>favicon.ico"> + <link rel="icon" href="<%= BASE_URL %>favicon.ico"/> + <script src="<%= BASE_URL %>static/config.js"></script> <title><%= webpackConfig.name %></title> <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]--> <style> diff --git a/public/static/config.js b/public/static/config.js new file mode 100644 index 0000000..cee3bee --- /dev/null +++ b/public/static/config.js @@ -0,0 +1,25 @@ + +/*寮�鍙戠幆澧�*/ +const dev = { + baseUrl: 'http://101.43.168.96:8082/admin', + ftpUrl: 'https://echftp.jinmingyuan.com', + AccessTokenKey:'PC-ADMIN-TOKEN', // token + timeout: 15 // 璇锋眰瓒呮椂鏃堕棿銆� +} +/*娴嬭瘯鐜*/ +const test = { + baseUrl: 'http://101.43.168.96:8082/admin', + ftpUrl: 'https://echftp.jinmingyuan.com', + AccessTokenKey:'PC-ADMIN-TOKEN', // token + timeout: 15 // 璇锋眰瓒呮椂鏃堕棿銆� +} + +/*姝e紡鐜*/ +const prod = { + baseUrl: 'http://101.43.168.96:8082/admin', + ftpUrl: 'http://10.8.90.22:80/sftp', + AccessTokenKey:'PC-ADMIN-TOKEN', // token + timeout: 15 // 璇锋眰瓒呮椂鏃堕棿銆� +} + +const globalConf = dev diff --git a/src/plugins/download.js b/src/plugins/download.js index 1ca9d53..8cb5e22 100644 --- a/src/plugins/download.js +++ b/src/plugins/download.js @@ -5,12 +5,9 @@ import errorCode from '@/utils/errorCode' import { blobValidate } from "@/utils/ruoyi"; -// const baseURL = process.env.VUE_APP_BASE_API -const baseURL = "http://localhost:8082/admin"; - export default { name(name, isDelete = true) { - var url = baseURL + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete + var url = globalConf.ftpUrl + "/common/download?fileName=" + encodeURI(name) + "&delete=" + isDelete axios({ method: 'get', url: url, @@ -27,7 +24,7 @@ }) }, resource(resource) { - var url = baseURL + "/common/download/resource?resource=" + encodeURI(resource); + var url = globalConf.ftpUrl + "/common/download/resource?resource=" + encodeURI(resource); axios({ method: 'get', url: url, @@ -44,7 +41,7 @@ }) }, zip(url, name) { - var url = baseURL + url; + var url = globalConf.ftpUrl + url; axios({ method: 'get', url: url, diff --git a/src/utils/request.js b/src/utils/request.js index 3394e6d..fcf3480 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -15,11 +15,9 @@ // 鍒涘缓axios瀹炰緥 const service = axios.create({ // axios涓姹傞厤缃湁baseURL閫夐」锛岃〃绀鸿姹俇RL鍏叡閮ㄥ垎 - // baseURL: process.env.VUE_APP_BASE_API, - baseURL: "http://localhost:8082/admin", - // baseURL: process.env.VUE_SERVER_URL, + baseURL: globalConf.baseUrl, // 瓒呮椂 - timeout: 10000 + timeout: globalConf.timeout * 1000 }) // request鎷︽埅鍣� -- Gitblit v1.9.1