befly-admin 3.13.17 → 3.13.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/plugins/config.js +10 -0
- package/src/plugins/http.js +3 -4
- package/src/plugins/router.js +8 -10
- package/.env +0 -7
- package/.env.development +0 -7
- package/.env.production +0 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-admin",
|
|
3
|
-
"version": "3.13.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "3.13.19",
|
|
4
|
+
"gitHead": "0690bdde6ac3f8c13ba8f580d39a7f2f6e31f10a",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly Admin - 基于 Vue3 + TDesign Vue Next 的后台管理系统",
|
|
7
7
|
"files": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"axios": "^1.13.5",
|
|
32
|
-
"befly-admin-ui": "1.8.
|
|
32
|
+
"befly-admin-ui": "1.8.24",
|
|
33
33
|
"befly-vite": "^1.5.7",
|
|
34
34
|
"pinia": "^3.0.4",
|
|
35
35
|
"tdesign-icons-vue-next": "^0.4.0",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const $Config = {
|
|
2
|
+
appTitle: "野蜂飞舞",
|
|
3
|
+
appDesc: "轻量级业务快速开发框架",
|
|
4
|
+
loginFootnote: "",
|
|
5
|
+
tokenName: "befly-admin-token",
|
|
6
|
+
loginPath: "/core/login",
|
|
7
|
+
homePath: "/core",
|
|
8
|
+
uploadPath: "",
|
|
9
|
+
apiPath: import.meta.env.PROD ? "http://localhost:3000/api" : "http://localhost:3000/api"
|
|
10
|
+
};
|
package/src/plugins/http.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL;
|
|
2
1
|
async function requestPost(tokenGetter, url, data, dropValues, dropKeyValue) {
|
|
3
2
|
try {
|
|
4
|
-
const fullUrl = `${
|
|
3
|
+
const fullUrl = `${$Config.apiPath}${url}`;
|
|
5
4
|
const isForm = data instanceof FormData;
|
|
6
5
|
const dropList = Array.isArray(dropValues) ? dropValues : [null, undefined];
|
|
7
6
|
const dropKeyMap = dropKeyValue && typeof dropKeyValue === "object" ? dropKeyValue : {};
|
|
@@ -84,9 +83,9 @@ async function requestPost(tokenGetter, url, data, dropValues, dropKeyValue) {
|
|
|
84
83
|
}
|
|
85
84
|
export const $Http = {
|
|
86
85
|
json: async (url, data, dropValues, dropKeyValue) => {
|
|
87
|
-
return requestPost(() => localStorage.getItem(
|
|
86
|
+
return requestPost(() => localStorage.getItem($Config.tokenName) ?? "", url, data ?? {}, dropValues, dropKeyValue);
|
|
88
87
|
},
|
|
89
88
|
form: async (url, formData, dropValues, dropKeyValue) => {
|
|
90
|
-
return requestPost(() => localStorage.getItem(
|
|
89
|
+
return requestPost(() => localStorage.getItem($Config.tokenName) ?? "", url, formData, dropValues, dropKeyValue);
|
|
91
90
|
}
|
|
92
91
|
};
|
package/src/plugins/router.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Layouts } from "befly-vite";
|
|
2
2
|
import { createRouter, createWebHashHistory } from "vue-router";
|
|
3
3
|
import { routes } from "vue-router/auto-routes";
|
|
4
|
+
import { $Config } from "@/plugins/config.js";
|
|
4
5
|
|
|
5
6
|
// 应用自定义布局系统(同时可选注入根路径重定向)
|
|
6
|
-
const finalRoutes = Layouts(routes,
|
|
7
|
+
const finalRoutes = Layouts(routes, $Config.homePath, (layoutName) => {
|
|
7
8
|
if (layoutName === "default") {
|
|
8
9
|
return () => import("befly-admin-ui/layouts/default.vue");
|
|
9
10
|
}
|
|
@@ -26,12 +27,12 @@ export const $Router = createRouter({
|
|
|
26
27
|
|
|
27
28
|
// 路由守卫 - 基础鉴权(最小实现:public 放行;未登录跳登录;已登录访问登录页跳首页)
|
|
28
29
|
$Router.beforeEach((to, _from) => {
|
|
29
|
-
const token = localStorage.getItem(
|
|
30
|
+
const token = localStorage.getItem($Config.tokenName);
|
|
30
31
|
const toPath = to.path;
|
|
31
32
|
|
|
32
33
|
// 根路径:按是否登录分流(兜底,避免 / 永远重定向到首页)
|
|
33
34
|
if (toPath === "/") {
|
|
34
|
-
return token ?
|
|
35
|
+
return token ? $Config.homePath : $Config.loginPath;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// 公开路由放行
|
|
@@ -40,13 +41,13 @@ $Router.beforeEach((to, _from) => {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
// 未登录访问非公开路由 → 登录页
|
|
43
|
-
if (!token && toPath !==
|
|
44
|
-
return
|
|
44
|
+
if (!token && toPath !== $Config.loginPath) {
|
|
45
|
+
return $Config.loginPath;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
// 已登录访问登录页 → 首页
|
|
48
|
-
if (token && toPath ===
|
|
49
|
-
return
|
|
49
|
+
if (token && toPath === $Config.loginPath) {
|
|
50
|
+
return $Config.homePath;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
return true;
|
|
@@ -55,7 +56,4 @@ $Router.beforeEach((to, _from) => {
|
|
|
55
56
|
// 路由就绪后处理
|
|
56
57
|
$Router.afterEach((_to) => {
|
|
57
58
|
// 可以在这里添加页面访问统计等
|
|
58
|
-
if (import.meta.env.DEV) {
|
|
59
|
-
// 开发环境调试日志请使用更合适的日志方案(此处避免 console 触发 lint 门禁)
|
|
60
|
-
}
|
|
61
59
|
});
|
package/.env
DELETED
package/.env.development
DELETED