From 4d5048435c5c48dad64cfbc086b1a59576bc6454 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 08 十一月 2021 18:17:29 +0800 Subject: [PATCH] fix 修复 ruoyi 关于 配置应用前缀路径的bug 改为配置文件统一配置 --- ruoyi-ui/src/utils/request.js | 2 +- ruoyi-ui/.env.production | 3 +++ ruoyi-ui/.env.staging | 3 +++ ruoyi-ui/.env.development | 3 +++ ruoyi-ui/vue.config.js | 3 +-- ruoyi-ui/src/router/index.js | 1 - ruoyi-ui/src/layout/components/Navbar.vue | 2 +- 7 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ruoyi-ui/.env.development b/ruoyi-ui/.env.development index 3b003aa..4addbcd 100644 --- a/ruoyi-ui/.env.development +++ b/ruoyi-ui/.env.development @@ -7,6 +7,9 @@ # 鑻ヤ緷绠$悊绯荤粺/寮�鍙戠幆澧� VUE_APP_BASE_API = '/dev-api' +# 搴旂敤璁块棶璺緞 渚嬪浣跨敤鍓嶇紑 /admin/index +VUE_APP_CONTEXT_PATH = '/index' + # 鐩戞帶鍦板潃 VUE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/login' diff --git a/ruoyi-ui/.env.production b/ruoyi-ui/.env.production index 2d0bb61..45f4ad1 100644 --- a/ruoyi-ui/.env.production +++ b/ruoyi-ui/.env.production @@ -4,6 +4,9 @@ # 鐢熶骇鐜閰嶇疆 ENV = 'production' +# 搴旂敤璁块棶璺緞 渚嬪浣跨敤鍓嶇紑 /admin/index +VUE_APP_CONTEXT_PATH = '/index' + # 鐩戞帶鍦板潃 VUE_APP_MONITRO_ADMIN = '/admin/login' diff --git a/ruoyi-ui/.env.staging b/ruoyi-ui/.env.staging index 49ce55c..ed147ca 100644 --- a/ruoyi-ui/.env.staging +++ b/ruoyi-ui/.env.staging @@ -6,6 +6,9 @@ # 娴嬭瘯鐜閰嶇疆 ENV = 'staging' +# 搴旂敤璁块棶璺緞 渚嬪浣跨敤鍓嶇紑 /admin/index +VUE_APP_CONTEXT_PATH = '/index' + # 鐩戞帶鍦板潃 VUE_APP_MONITRO_ADMIN = '/admin/login' diff --git a/ruoyi-ui/src/layout/components/Navbar.vue b/ruoyi-ui/src/layout/components/Navbar.vue index e6721b7..8f73e7c 100644 --- a/ruoyi-ui/src/layout/components/Navbar.vue +++ b/ruoyi-ui/src/layout/components/Navbar.vue @@ -102,7 +102,7 @@ type: 'warning' }).then(() => { this.$store.dispatch('LogOut').then(() => { - location.href = this.$router.options.base + '/index'; + location.href = process.env.VUE_APP_CONTEXT_PATH; }) }).catch(() => {}); } diff --git a/ruoyi-ui/src/router/index.js b/ruoyi-ui/src/router/index.js index cedf0b3..96f557b 100644 --- a/ruoyi-ui/src/router/index.js +++ b/ruoyi-ui/src/router/index.js @@ -167,7 +167,6 @@ ] export default new Router({ - base: "", // 椤圭洰鍓嶇紑 涓� publicPath 鍚屾 渚嬪 /api mode: 'history', // 鍘绘帀url涓殑# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js index e8b3b5f..5ce0d00 100644 --- a/ruoyi-ui/src/utils/request.js +++ b/ruoyi-ui/src/utils/request.js @@ -65,7 +65,7 @@ } ).then(() => { store.dispatch('LogOut').then(() => { - location.href = this.$router.options.base + '/index'; + location.href = process.env.VUE_APP_CONTEXT_PATH; }) }).catch(() => {}); return Promise.reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�') diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 4d6967b..73c2177 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -16,8 +16,7 @@ // 閮ㄧ讲鐢熶骇鐜鍜屽紑鍙戠幆澧冧笅鐨刄RL銆� // 榛樿鎯呭喌涓嬶紝Vue CLI 浼氬亣璁句綘鐨勫簲鐢ㄦ槸琚儴缃插湪涓�涓煙鍚嶇殑鏍硅矾寰勪笂 // 渚嬪 https://www.ruoyi.vip/銆傚鏋滃簲鐢ㄨ閮ㄧ讲鍦ㄤ竴涓瓙璺緞涓婏紝浣犲氨闇�瑕佺敤杩欎釜閫夐」鎸囧畾杩欎釜瀛愯矾寰勩�備緥濡傦紝濡傛灉浣犵殑搴旂敤琚儴缃插湪 https://www.ruoyi.vip/admin/锛屽垯璁剧疆 baseUrl 涓� /admin/銆� - // 璁剧疆鍩鸿矾寰勫弬鑰冩枃妗�: http://doc.ruoyi.vip/ruoyi-vue/document/qdsc.html#搴旂敤璺緞 - publicPath: process.env.NODE_ENV === "production" ? "/" : "/", + publicPath: process.env.VUE_APP_CONTEXT_PATH, // 鍦╪pm run build 鎴� yarn build 鏃� 锛岀敓鎴愭枃浠剁殑鐩綍鍚嶇О锛堣鍜宐aseUrl鐨勭敓浜х幆澧冭矾寰勪竴鑷达級锛堥粯璁ist锛� outputDir: 'dist', // 鐢ㄤ簬鏀剧疆鐢熸垚鐨勯潤鎬佽祫婧� (js銆乧ss銆乮mg銆乫onts) 鐨勶紱锛堥」鐩墦鍖呬箣鍚庯紝闈欐�佽祫婧愪細鏀惧湪杩欎釜鏂囦欢澶逛笅锛� -- Gitblit v1.9.3