befly-admin 3.15.8 → 3.15.10

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/README.md CHANGED
@@ -133,7 +133,7 @@ bun run build
133
133
 
134
134
  1. **自动导入**:按需配置自动导入范围
135
135
  2. **登录功能**:当前为模拟登录,需要对接真实 API
136
- 3. **Token 存储**:使用 localStorage,生产环境建议使用更安全的方式
136
+ 3. **Token 存储**:统一通过 `@/plugins/store.js` 中的 `$Store.local` 访问,底层默认使用 localStorage,生产环境建议使用更安全的方式
137
137
  4. **API 代理**:开发环境 `/api` 代理到 `http://localhost:3000`
138
138
 
139
139
  ## License
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "befly-admin",
3
- "version": "3.15.8",
4
- "gitHead": "c98b9286276d0f73a0b0894d21c10baa76db5343",
3
+ "version": "3.15.10",
4
+ "gitHead": "5c05c5ec3616748021723a09de6514d27b0cf577",
5
5
  "private": false,
6
6
  "description": "Befly Admin - 基于 Vue3 + TDesign Vue Next 的后台管理系统",
7
7
  "files": [
@@ -28,8 +28,8 @@
28
28
  "preview": "bunx --bun befly-vite preview"
29
29
  },
30
30
  "dependencies": {
31
- "befly-admin-ui": "^1.9.5",
32
- "befly-shared": "^2.0.7",
31
+ "befly-admin-ui": "^1.9.6",
32
+ "befly-shared": "^2.0.8",
33
33
  "befly-vite": "^1.5.31",
34
34
  "pinia": "^3.0.4",
35
35
  "tdesign-icons-vue-next": "^0.4.4",
@@ -1,5 +1,7 @@
1
1
  import { createHttp } from "befly-shared/createHttp";
2
2
 
3
+ import { $Store } from "@/plugins/store.js";
4
+
3
5
  let redirecting = false;
4
6
 
5
7
  async function redirectToLogin() {
@@ -9,7 +11,7 @@ async function redirectToLogin() {
9
11
 
10
12
  redirecting = true;
11
13
  try {
12
- localStorage.removeItem($Config.tokenName);
14
+ $Store.local.remove($Config.tokenName);
13
15
 
14
16
  const current = (window.location.hash || "").replace(/^#/, "");
15
17
  const currentPath = current.split("?")[0] || "/";
@@ -30,7 +32,7 @@ async function redirectToLogin() {
30
32
 
31
33
  export const $Http = createHttp({
32
34
  apiPath: $Config.apiPath,
33
- getToken: () => localStorage.getItem($Config.tokenName) ?? "",
35
+ getToken: () => $Store.local.get($Config.tokenName, ""),
34
36
  onReturn: async (payload) => {
35
37
  if (payload?.reason === "auth") {
36
38
  await redirectToLogin();
@@ -2,6 +2,7 @@ import { Layouts } from "befly-vite";
2
2
  import { createRouter, createWebHashHistory } from "vue-router";
3
3
  import { routes } from "vue-router/auto-routes";
4
4
  import { $Config } from "@/plugins/config.js";
5
+ import { $Store } from "@/plugins/store.js";
5
6
 
6
7
  // 应用自定义布局系统(同时可选注入根路径重定向)
7
8
  const finalRoutes = Layouts(routes, $Config.homePath, (layoutName) => {
@@ -42,7 +43,7 @@ export const $Router = createRouter({
42
43
 
43
44
  // 路由守卫 - 基础鉴权(最小实现:public 放行;未登录跳登录;已登录访问登录页跳首页)
44
45
  $Router.beforeEach((to, _from) => {
45
- const token = localStorage.getItem($Config.tokenName);
46
+ const token = $Store.local.get($Config.tokenName, "");
46
47
  const toPath = to.path;
47
48
 
48
49
  // 根路径:按是否登录分流(兜底,避免 / 永远重定向到首页)
@@ -0,0 +1,3 @@
1
+ import { createStore } from "befly-shared/createStore";
2
+
3
+ export const $Store = createStore();