From c11f69cb1f54ba4e8c1354c8f2be618d2134fc54 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Thu, 28 Aug 2025 16:20:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 1 + .env.production | 1 + .env.staging | 2 + src/layout/components/Navbar.vue | 330 ++++++++++++++++--------------- src/router/index.js | 1 + src/utils/request.js | 6 +- src/utils/request_formdata.js | 6 +- 7 files changed, 190 insertions(+), 157 deletions(-) diff --git a/.env.development b/.env.development index 3e6e27e..9163a1a 100644 --- a/.env.development +++ b/.env.development @@ -3,6 +3,7 @@ VUE_APP_TITLE = 实名制管理系统 # 开发环境配置 ENV = 'development' +VUE_APP_ENV = 'development' # 实名制管理系统/开发环境 VUE_APP_BASE_API = '/dev-api' diff --git a/.env.production b/.env.production index acac8e1..f4ee254 100644 --- a/.env.production +++ b/.env.production @@ -3,6 +3,7 @@ VUE_APP_TITLE = 实名制管理系统 # 生产环境配置 ENV = 'production' +VUE_APP_ENV = 'production' # 实名制管理系统/生产环境 VUE_APP_BASE_API = '/hd-realname/prod-api' diff --git a/.env.staging b/.env.staging index a045b20..b302309 100644 --- a/.env.staging +++ b/.env.staging @@ -6,5 +6,7 @@ NODE_ENV = production # 测试环境配置 ENV = 'staging' +VUE_APP_ENV = 'staging' + # 实名制管理系统/测试环境 VUE_APP_BASE_API = '/stage-api' diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 3c26ed0..9e1dfd9 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -1,43 +1,62 @@ diff --git a/src/router/index.js b/src/router/index.js index 07f6ce8..72d2300 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -197,4 +197,5 @@ export default new Router({ mode: 'history', // 去掉url中的# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes, + base: process.env.VUE_APP_ENV === 'production' ? '/hd-realname' : '', }) diff --git a/src/utils/request.js b/src/utils/request.js index 90d8994..12131f6 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -167,7 +167,11 @@ service.interceptors.response.use( .then(() => { isRelogin.show = false store.dispatch('LogOut').then(() => { - location.href = '/index' + // location.href = '/index' + location.href = + process.env.VUE_APP_ENV === 'production' + ? '/hd-realname/index' + : '/index' }) }) .catch(() => { diff --git a/src/utils/request_formdata.js b/src/utils/request_formdata.js index 625f920..ab8f508 100644 --- a/src/utils/request_formdata.js +++ b/src/utils/request_formdata.js @@ -189,7 +189,11 @@ service.interceptors.response.use( .then(() => { isRelogin.show = false store.dispatch('LogOut').then(() => { - location.href = '/index' + // location.href = '/index' + location.href = + process.env.VUE_APP_ENV === 'production' + ? '/hd-realname/index' + : '/index' }) }) .catch(() => {