xto-fronted 0.6.2 → 0.6.3
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/dist/api/index.js +1 -1
- package/dist/{index-DIlGh6S6.js → index-BKO6Hzba.js} +1 -1
- package/dist/{index-CYFcc2sd.js → index-BXHwCe22.js} +1 -1
- package/dist/{index-DYmKmoMX.js → index-BZSZ3bx2.js} +1 -1
- package/dist/{index-DGrQCWU0.js → index-DydABgae.js} +1 -1
- package/dist/{index-Dpv33ZXi.js → index-IOKG7Gwo.js} +695 -688
- package/dist/index.js +2 -2
- package/dist/{user-ChcAx-5W.js → user-77I_qZ8j.js} +6 -6
- package/package.json +1 -1
- package/src/router/guards.ts +12 -1
- package/src/stores/menu.ts +15 -6
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as a, c as t, G as o, d as r, e as n, H as u, L as i, i as p, M as l, b as T, f as d, g, h as R, S as c, a as h, j as k, T as f, k as S, l as U, m, n as A, o as M, p as y, q as x, r as L, s as C, t as D, u as b, v as I, w as B, x as F, y as G, z as E, A as P, B as O, C as v, D as w, E as H, I as N, J as j, K as q, N as z } from "./index-
|
|
2
|
-
import { K, b as X,
|
|
1
|
+
import { F as a, c as t, G as o, d as r, e as n, H as u, L as i, i as p, M as l, b as T, f as d, g, h as R, S as c, a as h, j as k, T as f, k as S, l as U, m, n as A, o as M, p as y, q as x, r as L, s as C, t as D, u as b, v as I, w as B, x as F, y as G, z as E, A as P, B as O, C as v, D as w, E as H, I as N, J as j, K as q, N as z } from "./index-IOKG7Gwo.js";
|
|
2
|
+
import { K, b as X, B as Q, c as V, a as W, d as Y, e as Z, f as _, g as $, G as ee, y as se, E as ae, D as te, L as oe, h as re, i as ne, M as ue, N as ie, j as pe, k as le, z as Te, O as de, P as ge, l as Re, m as ce, n as he, A as ke, Q as fe, I as Se, R as Ue, F as me, x as Ae, S as Me, o as ye, p as xe, r as Le, q as Ce, T as De, U as be, H as Ie, J as Be, V as Fe, W as Ge, X as Ee, Y as Pe, Z as Oe, C as ve, _ as we, u as He, s as Ne, t as je, v as qe, w as ze } from "./user-77I_qZ8j.js";
|
|
3
3
|
export {
|
|
4
4
|
a as Footer,
|
|
5
5
|
t as Forbidden,
|
|
@@ -1130,10 +1130,10 @@ function st(l) {
|
|
|
1130
1130
|
return F.post(`/user/${l}/reset-password`);
|
|
1131
1131
|
}
|
|
1132
1132
|
export {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1133
|
+
Sr as A,
|
|
1134
|
+
Ue as B,
|
|
1135
|
+
Tr as C,
|
|
1136
|
+
br as D,
|
|
1137
1137
|
jr as E,
|
|
1138
1138
|
Lr as F,
|
|
1139
1139
|
Fr as G,
|
|
@@ -1181,6 +1181,6 @@ export {
|
|
|
1181
1181
|
tt as v,
|
|
1182
1182
|
ot as w,
|
|
1183
1183
|
K as x,
|
|
1184
|
-
|
|
1185
|
-
|
|
1184
|
+
Ar as y,
|
|
1185
|
+
ze as z
|
|
1186
1186
|
};
|
package/package.json
CHANGED
package/src/router/guards.ts
CHANGED
|
@@ -73,7 +73,18 @@ export function setupRouterGuards(router: Router, options: RouterGuardOptions =
|
|
|
73
73
|
} else {
|
|
74
74
|
// 检查是否已获取用户信息
|
|
75
75
|
if (userStore.isLoggedIn) {
|
|
76
|
-
//
|
|
76
|
+
// 已有用户信息,直接放行;但当前应用菜单为空时(跨应用共享 localStorage 场景)补拉菜单
|
|
77
|
+
if (!menuStore.hasMenu) {
|
|
78
|
+
try {
|
|
79
|
+
const menuList = options.fetchMenu
|
|
80
|
+
? await options.fetchMenu()
|
|
81
|
+
: await getMenuTree(options.appId)
|
|
82
|
+
menuStore.setMenuList(menuList)
|
|
83
|
+
} catch (error) {
|
|
84
|
+
// 菜单拉取失败不影响页面访问,仅记录日志
|
|
85
|
+
console.warn('补拉菜单失败:', error)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
77
88
|
// 添加缓存页面
|
|
78
89
|
if (to.name && to.meta.keepAlive) {
|
|
79
90
|
appStore.addCachedView(to.name as string)
|
package/src/stores/menu.ts
CHANGED
|
@@ -6,10 +6,19 @@ import { defineStore } from 'pinia'
|
|
|
6
6
|
import { ref, computed } from 'vue'
|
|
7
7
|
import type { MenuItem } from '@/types/api'
|
|
8
8
|
import { local } from '@/utils/storage'
|
|
9
|
+
import { getAppId } from '@/utils/config'
|
|
9
10
|
|
|
10
11
|
const MENU_LIST_KEY = 'menu_list'
|
|
11
12
|
const PERMISSION_LIST_KEY = 'permission_list'
|
|
12
13
|
|
|
14
|
+
/**
|
|
15
|
+
* 菜单存储 key 按应用隔离:
|
|
16
|
+
* 多个前端部署在同一域名下(如 appli.tooyu.service/portal、/tangyang)共享 localStorage,
|
|
17
|
+
* 固定 key 会导致 A 应用的菜单被 B 应用复用,必须加 appId 命名空间
|
|
18
|
+
*/
|
|
19
|
+
const menuListKey = () => `${MENU_LIST_KEY}_${getAppId()}`
|
|
20
|
+
const permissionListKey = () => `${PERMISSION_LIST_KEY}_${getAppId()}`
|
|
21
|
+
|
|
13
22
|
// 首页菜单(参考 tineco-ui)
|
|
14
23
|
const indexMenu: MenuItem = {
|
|
15
24
|
menuCode: 'home',
|
|
@@ -62,9 +71,9 @@ function extractPermissions(menus: MenuItem[]): string[] {
|
|
|
62
71
|
|
|
63
72
|
export const useMenuStore = defineStore('menu', () => {
|
|
64
73
|
// 状态
|
|
65
|
-
const menuList = ref<MenuItem[]>(local.get<MenuItem[]>(
|
|
74
|
+
const menuList = ref<MenuItem[]>(local.get<MenuItem[]>(menuListKey()) || [])
|
|
66
75
|
// 功能权限列表
|
|
67
|
-
const permissions = ref<string[]>(local.get<string[]>(
|
|
76
|
+
const permissions = ref<string[]>(local.get<string[]>(permissionListKey()) || [])
|
|
68
77
|
|
|
69
78
|
// 计算属性
|
|
70
79
|
const hasMenu = computed(() => menuList.value.length > 0)
|
|
@@ -73,22 +82,22 @@ export const useMenuStore = defineStore('menu', () => {
|
|
|
73
82
|
const setMenuList = (menus: MenuItem[]) => {
|
|
74
83
|
// 提取功能权限
|
|
75
84
|
permissions.value = extractPermissions(menus)
|
|
76
|
-
local.set(
|
|
85
|
+
local.set(permissionListKey(), permissions.value)
|
|
77
86
|
|
|
78
87
|
// 过滤菜单,只保留菜单项(type !== 1)
|
|
79
88
|
const filteredMenus = filterMenus(menus)
|
|
80
89
|
|
|
81
90
|
// 添加首页菜单到开头
|
|
82
91
|
menuList.value = [indexMenu, ...filteredMenus]
|
|
83
|
-
local.set(
|
|
92
|
+
local.set(menuListKey(), menuList.value)
|
|
84
93
|
}
|
|
85
94
|
|
|
86
95
|
// 清除菜单
|
|
87
96
|
const clearMenu = () => {
|
|
88
97
|
menuList.value = []
|
|
89
98
|
permissions.value = []
|
|
90
|
-
local.remove(
|
|
91
|
-
local.remove(
|
|
99
|
+
local.remove(menuListKey())
|
|
100
|
+
local.remove(permissionListKey())
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
// 检查是否有某个权限
|