黄梓星 2 gadi atpakaļ
vecāks
revīzija
3ef360aa51

+ 3 - 0
.env.development

@@ -6,6 +6,9 @@ ENV = 'development'
 
 # 若依管理系统/开发环境
 VUE_APP_BASE_API = '/ruoyi-admin'
+#应用访问路径 例如使用前缀 /drp/
+VUE_APP_CONTEXT_PATH = '/drp'
+
 
 # 路由懒加载
 VUE_CLI_BABEL_TRANSPILE_MODULES = true

+ 2 - 0
.env.production

@@ -6,3 +6,5 @@ ENV = 'production'
 
 # 若依管理系统/生产环境
 VUE_APP_BASE_API = '/ruoyi-admin'
+#应用访问路径 例如使用前缀 /drp/
+VUE_APP_CONTEXT_PATH = '/drp'

+ 2 - 0
.env.staging

@@ -8,3 +8,5 @@ ENV = 'staging'
 
 # 若依管理系统/测试环境
 VUE_APP_BASE_API = '/ruoyi-admin'
+#应用访问路径 例如使用前缀 /drp/
+VUE_APP_CONTEXT_PATH = '/drp'

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

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

+ 3 - 3
src/permission.js

@@ -8,14 +8,14 @@ import { isRelogin } from '@/utils/request'
 
 NProgress.configure({ showSpinner: false })
 
-const whiteList = ['/drp/login', '/register']
+const whiteList = ['/login', '/register']
 
 router.beforeEach((to, from, next) => {
   NProgress.start()
   if (getToken()) {
     to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
     /* has token*/
-    if (to.path === '/drp/login') {
+    if (to.path === '/login') {
       next({ path: '/' })
       NProgress.done()
     } else {
@@ -45,7 +45,7 @@ router.beforeEach((to, from, next) => {
       // 在免登录白名单,直接进入
       next()
     } else {
-      next(`/drp/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
+      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
       NProgress.done()
     }
   }

+ 4 - 4
src/router/index.js

@@ -42,22 +42,22 @@ export const constantRoutes = [
     ]
   },
   {
-    path: '/drp/login',
+    path: '/login',
     component: () => import('@/views/login'),
     hidden: true
   },
   {
-    path: '/drp/register',
+    path: '/register',
     component: () => import('@/views/register'),
     hidden: true
   },
   {
-    path: '/drp/404',
+    path: '/404',
     component: () => import('@/views/error/404'),
     hidden: true
   },
   {
-    path: '/drp/401',
+    path: '/401',
     component: () => import('@/views/error/401'),
     hidden: true
   },

+ 2 - 2
src/views/register.vue

@@ -55,7 +55,7 @@
           <span v-else>注 册 中...</span>
         </el-button>
         <div style="float: right;">
-          <router-link class="link-type" :to="'/drp/login'">使用已有账户登录</router-link>
+          <router-link class="link-type" :to="'/login'">使用已有账户登录</router-link>
         </div>
       </el-form-item>
     </el-form>
@@ -130,7 +130,7 @@ export default {
               dangerouslyUseHTMLString: true,
               type: 'success'
             }).then(() => {
-              this.$router.push("/drp/login");
+              this.$router.push("/login");
             }).catch(() => {});
           }).catch(() => {
             this.loading = false;

+ 2 - 1
vue.config.js

@@ -18,7 +18,8 @@ module.exports = {
   // 部署生产环境和开发环境下的URL。
   // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
   // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。
-  publicPath: process.env.NODE_ENV === "production" ? "./" : "./",
+  // 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) 的;(项目打包之后,静态资源会放在这个文件夹下)