优化 vue2 的前端,登出系统时,拼接 BASE PATH

This commit is contained in:
YunaiV
2022-04-18 21:15:01 +08:00
parent d9a129d317
commit 4944f65905
43 changed files with 1025 additions and 879 deletions

View File

@@ -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;
}