mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-13 18:45:06 +08:00
优化 vue2 的前端,登出系统时,拼接 BASE PATH
This commit is contained in:
@ -56,6 +56,7 @@ import SizeSelect from '@/components/SizeSelect'
|
||||
import Search from '@/components/HeaderSearch'
|
||||
import RuoYiGit from '@/components/RuoYi/Git'
|
||||
import RuoYiDoc from '@/components/RuoYi/Doc'
|
||||
import {getPath} from "@/utils/ruoyi";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -98,7 +99,7 @@ export default {
|
||||
async logout() {
|
||||
this.$modal.confirm('确定注销并退出系统吗?', '提示').then(() => {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
location.href = '/index';
|
||||
location.href = getPath('/index');
|
||||
})
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import store from '@/store'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import errorCode from '@/utils/errorCode'
|
||||
import Cookies from "js-cookie";
|
||||
import {getTenantEnable} from "@/utils/ruoyi";
|
||||
import {getPath, getTenantEnable} from "@/utils/ruoyi";
|
||||
|
||||
// 是否显示重新登录
|
||||
export let isRelogin = { show: false };
|
||||
@ -76,7 +76,7 @@ service.interceptors.response.use(res => {
|
||||
).then(() => {
|
||||
isRelogin.show = false;
|
||||
store.dispatch('LogOut').then(() => {
|
||||
location.href = '/index';
|
||||
location.href = getPath('/index');
|
||||
})
|
||||
}).catch(() => {
|
||||
isRelogin.show = false;
|
||||
|
@ -197,3 +197,28 @@ export function getDocEnable() {
|
||||
}
|
||||
return process.env.VUE_APP_DOC_ENABLE || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 Vue 应用的基础路径
|
||||
*/
|
||||
export function getBasePath() {
|
||||
return process.env.VUE_APP_APP_NAME || '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得 Vue 应用的访问路径
|
||||
*
|
||||
* @param path 路径
|
||||
*/
|
||||
export function getPath(path) {
|
||||
// 基础路径,必须以 / 结尾
|
||||
let basePath = getBasePath();
|
||||
if (!basePath.endsWith('/')) {
|
||||
return basePath + '/';
|
||||
}
|
||||
// 访问路径,必须不能以 / 开头
|
||||
if (path.startsWith('/')) {
|
||||
path = path.substring(1);
|
||||
}
|
||||
return basePath + path;
|
||||
}
|
||||
|
Reference in New Issue
Block a user