befly-admin 3.14.16 → 3.14.17
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 +6 -7
- package/src/plugins/http.js +36 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "befly-admin",
|
|
3
|
-
"version": "3.14.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "3.14.17",
|
|
4
|
+
"gitHead": "523163fa281ad94542dda8e88551360c4cb8b200",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Befly Admin - 基于 Vue3 + TDesign Vue Next 的后台管理系统",
|
|
7
7
|
"files": [
|
|
@@ -23,18 +23,17 @@
|
|
|
23
23
|
"registry": "https://registry.npmjs.org"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"dev": "bunx --bun vite",
|
|
27
|
-
"build": "bunx --bun vite build",
|
|
28
|
-
"preview": "bunx --bun vite preview"
|
|
26
|
+
"dev": "bunx --bun befly-vite",
|
|
27
|
+
"build": "bunx --bun befly-vite build",
|
|
28
|
+
"preview": "bunx --bun befly-vite preview"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"befly-admin-ui": "^1.8.37",
|
|
32
32
|
"befly-shared": "^2.0.6",
|
|
33
|
-
"befly-vite": "^1.5.
|
|
33
|
+
"befly-vite": "^1.5.25",
|
|
34
34
|
"pinia": "^3.0.4",
|
|
35
35
|
"tdesign-icons-vue-next": "^0.4.0",
|
|
36
36
|
"tdesign-vue-next": "^1.18.5",
|
|
37
|
-
"vite": "^8.0.1",
|
|
38
37
|
"vue": "^3.5.30",
|
|
39
38
|
"vue-router": "^5.0.3"
|
|
40
39
|
},
|
package/src/plugins/http.js
CHANGED
|
@@ -1,6 +1,41 @@
|
|
|
1
1
|
import { createHttp } from "befly-shared/createHttp";
|
|
2
2
|
|
|
3
|
+
let redirecting = false;
|
|
4
|
+
|
|
5
|
+
async function redirectToLogin() {
|
|
6
|
+
if (redirecting) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
redirecting = true;
|
|
11
|
+
try {
|
|
12
|
+
localStorage.removeItem($Config.tokenName);
|
|
13
|
+
|
|
14
|
+
const current = (window.location.hash || "").replace(/^#/, "");
|
|
15
|
+
const currentPath = current.split("?")[0] || "/";
|
|
16
|
+
if (currentPath === $Config.loginPath) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
await $Router.replace({
|
|
21
|
+
path: $Config.loginPath,
|
|
22
|
+
query: {
|
|
23
|
+
redirect: currentPath
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
} finally {
|
|
27
|
+
redirecting = false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
3
31
|
export const $Http = createHttp({
|
|
4
32
|
apiPath: $Config.apiPath,
|
|
5
|
-
getToken: () => localStorage.getItem($Config.tokenName) ?? ""
|
|
33
|
+
getToken: () => localStorage.getItem($Config.tokenName) ?? "",
|
|
34
|
+
onReturn: async (payload) => {
|
|
35
|
+
if (payload?.reason === "auth") {
|
|
36
|
+
await redirectToLogin();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return payload;
|
|
40
|
+
}
|
|
6
41
|
});
|