Forráskód Böngészése

fix 修复 ruoyi 关于 配置应用前缀路径的bug 改为配置文件统一配置

疯狂的狮子Li 3 éve
szülő
commit
4d5048435c

+ 3 - 0
ruoyi-ui/.env.development

@@ -7,6 +7,9 @@ ENV = 'development'
 # 若依管理系统/开发环境
 VUE_APP_BASE_API = '/dev-api'
 
+# 应用访问路径 例如使用前缀 /admin/index
+VUE_APP_CONTEXT_PATH = '/index'
+
 # 监控地址
 VUE_APP_MONITRO_ADMIN = 'http://localhost:9090/admin/login'
 

+ 3 - 0
ruoyi-ui/.env.production

@@ -4,6 +4,9 @@ VUE_APP_TITLE = RuoYi-Vue-Plus后台管理系统
 # 生产环境配置
 ENV = 'production'
 
+# 应用访问路径 例如使用前缀 /admin/index
+VUE_APP_CONTEXT_PATH = '/index'
+
 # 监控地址
 VUE_APP_MONITRO_ADMIN = '/admin/login'
 

+ 3 - 0
ruoyi-ui/.env.staging

@@ -6,6 +6,9 @@ NODE_ENV = production
 # 测试环境配置
 ENV = 'staging'
 
+# 应用访问路径 例如使用前缀 /admin/index
+VUE_APP_CONTEXT_PATH = '/index'
+
 # 监控地址
 VUE_APP_MONITRO_ADMIN = '/admin/login'
 

+ 1 - 1
ruoyi-ui/src/layout/components/Navbar.vue

@@ -102,7 +102,7 @@ export default {
         type: 'warning'
       }).then(() => {
         this.$store.dispatch('LogOut').then(() => {
-          location.href = this.$router.options.base + '/index';
+          location.href = process.env.VUE_APP_CONTEXT_PATH;
         })
       }).catch(() => {});
     }

+ 0 - 1
ruoyi-ui/src/router/index.js

@@ -167,7 +167,6 @@ export const constantRoutes = [
 ]
 
 export default new Router({
-  base: "", // 项目前缀 与 publicPath 同步 例如 /api
   mode: 'history', // 去掉url中的#
   scrollBehavior: () => ({ y: 0 }),
   routes: constantRoutes

+ 1 - 1
ruoyi-ui/src/utils/request.js

@@ -65,7 +65,7 @@ service.interceptors.response.use(res => {
         }
       ).then(() => {
         store.dispatch('LogOut').then(() => {
-          location.href = this.$router.options.base + '/index';
+          location.href = process.env.VUE_APP_CONTEXT_PATH;
         })
       }).catch(() => {});
       return Promise.reject('无效的会话,或者会话已过期,请重新登录。')

+ 1 - 2
ruoyi-ui/vue.config.js

@@ -16,8 +16,7 @@ module.exports = {
   // 部署生产环境和开发环境下的URL。
   // 默认情况下,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,
   // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
   outputDir: 'dist',
   // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)