@origen-ui/admin-cli 1.1.0 → 2.0.1
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 +11 -7
- package/package.json +18 -2
- package/templates/current/clean/CHANGELOG.md +103 -0
- package/templates/current/clean/component-catalog.json +58 -17
- package/templates/current/clean/e2e/admin-shell.spec.ts +6 -0
- package/templates/current/clean/e2e/demo-shell.spec.ts +90 -46
- package/templates/current/clean/package.json +35 -21
- package/templates/current/clean/playwright.config.ts +1 -0
- package/templates/current/clean/playwright.demo.config.ts +1 -1
- package/templates/current/clean/scaffold.lock.json +2 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
- package/templates/current/clean/scripts/clean-overlay/src/main.ts +23 -14
- package/templates/current/clean/scripts/clean-overlay/src/router/componentCache.ts +12 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
- package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
- package/templates/current/clean/scripts/clean-overlay/src/router/paths.ts +21 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
- package/templates/current/clean/scripts/demo-api.ts +84 -8
- package/templates/current/clean/scripts/generate-api.ts +87 -3
- package/templates/current/clean/scripts/vite-build-policy.spec.ts +1 -0
- package/templates/current/clean/src/api/generated/data-contracts.ts +2 -5
- package/templates/current/clean/src/api/generated/http-client.ts +28 -26
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +5 -8
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -4
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +2 -5
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +8 -10
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +11 -12
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +8 -10
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +8 -10
- package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +3 -6
- package/templates/current/clean/src/app/errorMessage.spec.ts +76 -0
- package/templates/current/clean/src/app/errorMessage.ts +53 -0
- package/templates/current/clean/src/app/menu-host.spec.ts +77 -0
- package/templates/current/clean/src/app/menu.spec.ts +39 -0
- package/templates/current/clean/src/app/menu.ts +48 -12
- package/templates/current/clean/src/app/runtimeConfig.ts +1 -1
- package/templates/current/clean/src/demo-api.spec.ts +311 -0
- package/templates/current/clean/src/features/auth/pages/Login.vue +8 -2
- package/templates/current/clean/src/features/auth/store/auth.ts +6 -19
- package/templates/current/clean/src/features/errors/pages/Forbidden.vue +7 -2
- package/templates/current/clean/src/features/errors/pages/NotFound.vue +7 -2
- package/templates/current/clean/src/features/errors/pages/ServerError.vue +7 -2
- package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +11 -2
- package/templates/current/clean/src/features/system/access/api/admin-repository.ts +2 -6
- package/templates/current/clean/src/features/system/access/api/rbac.ts +19 -9
- package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
- package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
- package/templates/current/clean/src/features/workspace/pages/Profile.vue +1 -1
- package/templates/current/clean/src/layouts/AdminLayout.vue +3 -0
- package/templates/current/clean/src/layouts/TopBar.vue +37 -6
- package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +24 -1
- package/templates/current/clean/src/layouts/topBarMenuSearch.ts +10 -0
- package/templates/current/clean/src/locales/en-US.json +30 -3
- package/templates/current/clean/src/locales/en-US.runtime.ts +2 -0
- package/templates/current/clean/src/locales/index.ts +39 -26
- package/templates/current/clean/src/locales/zh-CN.json +30 -3
- package/templates/current/clean/src/locales/zh-CN.runtime.ts +2 -0
- package/templates/current/clean/src/locales/zh-TW.json +30 -3
- package/templates/current/clean/src/locales/zh-TW.runtime.ts +2 -0
- package/templates/current/clean/src/main.ts +23 -14
- package/templates/current/clean/src/router/bootstrap.ts +10 -16
- package/templates/current/clean/src/router/componentCache.ts +12 -0
- package/templates/current/clean/src/router/componentRegistry.ts +2 -13
- package/templates/current/clean/src/router/dynamicMenuRefresh.spec.ts +101 -0
- package/templates/current/clean/src/router/dynamicMenuRefresh.ts +24 -0
- package/templates/current/clean/src/router/dynamicRoutes.spec.ts +34 -4
- package/templates/current/clean/src/router/dynamicRoutes.ts +14 -3
- package/templates/current/clean/src/router/paths.spec.ts +50 -0
- package/templates/current/clean/src/router/paths.ts +21 -0
- package/templates/current/clean/src/router/staticRoutes.ts +6 -6
- package/templates/current/clean/src/templates/og-table.ts +2 -4
- package/templates/current/clean/tsconfig.json +0 -1
- package/templates/current/clean/vite.build-policy.ts +55 -8
- package/templates/current/clean/vite.config.ts +30 -0
- package/templates/current/examples/CHANGELOG.md +103 -0
- package/templates/current/examples/component-catalog.json +58 -17
- package/templates/current/examples/e2e/admin-shell.spec.ts +6 -0
- package/templates/current/examples/e2e/demo-shell.spec.ts +90 -46
- package/templates/current/examples/package.json +35 -21
- package/templates/current/examples/playwright.config.ts +1 -0
- package/templates/current/examples/playwright.demo.config.ts +1 -1
- package/templates/current/examples/scaffold.lock.json +2 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
- package/templates/current/examples/scripts/clean-overlay/src/main.ts +23 -14
- package/templates/current/examples/scripts/clean-overlay/src/router/componentCache.ts +12 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
- package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
- package/templates/current/examples/scripts/clean-overlay/src/router/paths.ts +21 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
- package/templates/current/examples/scripts/demo-api.ts +84 -8
- package/templates/current/examples/scripts/generate-api.ts +87 -3
- package/templates/current/examples/scripts/vite-build-policy.spec.ts +1 -0
- package/templates/current/examples/src/api/generated/data-contracts.ts +2 -5
- package/templates/current/examples/src/api/generated/http-client.ts +28 -26
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +5 -8
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -4
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +2 -5
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +8 -10
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +11 -12
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +8 -10
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +8 -10
- package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +3 -6
- package/templates/current/examples/src/app/errorMessage.spec.ts +76 -0
- package/templates/current/examples/src/app/errorMessage.ts +53 -0
- package/templates/current/examples/src/app/menu-host.spec.ts +77 -0
- package/templates/current/examples/src/app/menu.spec.ts +39 -0
- package/templates/current/examples/src/app/menu.ts +48 -12
- package/templates/current/examples/src/app/runtimeConfig.ts +1 -1
- package/templates/current/examples/src/demo-api.spec.ts +311 -0
- package/templates/current/examples/src/features/auth/pages/Login.vue +8 -2
- package/templates/current/examples/src/features/auth/store/auth.ts +6 -19
- package/templates/current/examples/src/features/errors/pages/Forbidden.vue +2 -1
- package/templates/current/examples/src/features/errors/pages/NotFound.vue +2 -1
- package/templates/current/examples/src/features/errors/pages/ServerError.vue +2 -1
- package/templates/current/examples/src/features/feature-composables.spec.ts +11 -1
- package/templates/current/examples/src/features/system/access/api/admin-repository.ts +2 -6
- package/templates/current/examples/src/features/system/access/api/rbac.ts +19 -9
- package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
- package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
- package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +115 -28
- package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +162 -66
- package/templates/current/examples/src/features/system/menus/menuDraft.spec.ts +204 -0
- package/templates/current/examples/src/features/system/menus/menuDraft.ts +116 -0
- package/templates/current/examples/src/features/system/menus/menuTreePrecheck.spec.ts +268 -0
- package/templates/current/examples/src/features/system/menus/menuTreePrecheck.ts +317 -0
- package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +1 -0
- package/templates/current/examples/src/features/workspace/pages/Profile.vue +1 -1
- package/templates/current/examples/src/layouts/AdminLayout.vue +3 -0
- package/templates/current/examples/src/layouts/TopBar.vue +37 -6
- package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +24 -1
- package/templates/current/examples/src/layouts/topBarMenuSearch.ts +10 -0
- package/templates/current/examples/src/locales/en-US.json +30 -3
- package/templates/current/examples/src/locales/en-US.runtime.ts +2 -0
- package/templates/current/examples/src/locales/index.ts +39 -26
- package/templates/current/examples/src/locales/zh-CN.json +30 -3
- package/templates/current/examples/src/locales/zh-CN.runtime.ts +2 -0
- package/templates/current/examples/src/locales/zh-TW.json +30 -3
- package/templates/current/examples/src/locales/zh-TW.runtime.ts +2 -0
- package/templates/current/examples/src/main.ts +24 -22
- package/templates/current/examples/src/router/bootstrap.ts +10 -16
- package/templates/current/examples/src/router/componentCache.ts +18 -0
- package/templates/current/examples/src/router/componentRegistry.ts +1 -18
- package/templates/current/examples/src/router/dynamicMenuRefresh.spec.ts +101 -0
- package/templates/current/examples/src/router/dynamicMenuRefresh.ts +24 -0
- package/templates/current/examples/src/router/dynamicRoutes.spec.ts +20 -2
- package/templates/current/examples/src/router/dynamicRoutes.ts +14 -3
- package/templates/current/examples/src/router/paths.spec.ts +50 -0
- package/templates/current/examples/src/router/paths.ts +21 -0
- package/templates/current/examples/src/router/staticRoutes.ts +3 -3
- package/templates/current/examples/src/templates/og-table.ts +2 -4
- package/templates/current/examples/tsconfig.json +0 -1
- package/templates/current/examples/vite.build-policy.ts +55 -8
- package/templates/current/examples/vite.config.ts +30 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import type { RbacMenu, RbacMenuDraft } from '../access/api/rbac'
|
|
2
|
+
import type { MenuTreeConflict } from './menuTreePrecheck'
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import {
|
|
5
|
+
applyMenuDraftToRows,
|
|
6
|
+
collectMenuTreeConflicts,
|
|
7
|
+
fetchCompleteMenuPages,
|
|
8
|
+
filterIntroducedConflicts,
|
|
9
|
+
flattenCompleteMenuPages,
|
|
10
|
+
flattenMenuRows,
|
|
11
|
+
getMenuPageCount,
|
|
12
|
+
} from './menuTreePrecheck'
|
|
13
|
+
|
|
14
|
+
let seq = 0
|
|
15
|
+
|
|
16
|
+
function row(overrides: Partial<RbacMenu> = {}): RbacMenu {
|
|
17
|
+
seq += 1
|
|
18
|
+
return {
|
|
19
|
+
id: overrides.id ?? `menu-${seq}`,
|
|
20
|
+
kind: 'page',
|
|
21
|
+
code: `page-${seq}`,
|
|
22
|
+
title: `Page ${seq}`,
|
|
23
|
+
titleKey: `menus.page${seq}.title`,
|
|
24
|
+
path: `/page-${seq}`,
|
|
25
|
+
order: seq,
|
|
26
|
+
status: 'active',
|
|
27
|
+
visible: true,
|
|
28
|
+
cache: false,
|
|
29
|
+
tabHidden: false,
|
|
30
|
+
version: 1,
|
|
31
|
+
createdAt: '',
|
|
32
|
+
updatedAt: '',
|
|
33
|
+
...overrides,
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function kinds(rows: readonly RbacMenu[]): string[] {
|
|
38
|
+
return collectMenuTreeConflicts(rows).map((conflict) => conflict.kind)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('collectMenuTreeConflicts', () => {
|
|
42
|
+
it('reports missing title keys for system menu nodes', () => {
|
|
43
|
+
expect(collectMenuTreeConflicts([row({ titleKey: undefined })])).toMatchObject([
|
|
44
|
+
{ kind: 'title-key-missing' },
|
|
45
|
+
])
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('accepts a conflict-free tree', () => {
|
|
49
|
+
const parent = row({ kind: 'directory', path: '/section' })
|
|
50
|
+
const child = row({ parentId: parent.id, path: 'detail', componentKey: 'dashboard' })
|
|
51
|
+
expect(collectMenuTreeConflicts([parent, child])).toEqual([])
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('reports duplicate codes caught by the transformer', () => {
|
|
55
|
+
expect(kinds([row({ code: 'same' }), row({ code: 'same', path: '/other' })])).toContain(
|
|
56
|
+
'duplicate-code',
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it('reports duplicate resolved route paths', () => {
|
|
61
|
+
const conflicts = collectMenuTreeConflicts([row({ path: '/dup' }), row({ path: '/dup', code: 'other' })])
|
|
62
|
+
expect(conflicts).toMatchObject([{ kind: 'duplicate-path', detail: '/dup' }])
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('reports an increase in an existing duplicate-path group', () => {
|
|
66
|
+
const before = [row({ code: 'one', path: '/duplicate' }), row({ code: 'two', path: '/duplicate' })]
|
|
67
|
+
const after = [...before, row({ code: 'three', path: '/duplicate' })]
|
|
68
|
+
const introduced = filterIntroducedConflicts(
|
|
69
|
+
collectMenuTreeConflicts(before),
|
|
70
|
+
collectMenuTreeConflicts(after),
|
|
71
|
+
)
|
|
72
|
+
expect(introduced).toMatchObject([{ kind: 'duplicate-path', detail: '/duplicate', count: 1 }])
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it('reports an increase in an existing duplicate-code group', () => {
|
|
76
|
+
const before = [row({ code: 'duplicate', path: '/one' }), row({ code: 'duplicate', path: '/two' })]
|
|
77
|
+
const after = [...before, row({ code: 'duplicate', path: '/three' })]
|
|
78
|
+
const introduced = filterIntroducedConflicts(
|
|
79
|
+
collectMenuTreeConflicts(before),
|
|
80
|
+
collectMenuTreeConflicts(after),
|
|
81
|
+
)
|
|
82
|
+
expect(introduced).toMatchObject([
|
|
83
|
+
{ kind: 'duplicate-code', detail: 'duplicate', count: 1 },
|
|
84
|
+
])
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('reports cycles even when no root entry exists', () => {
|
|
88
|
+
const a = row({ path: '/a' })
|
|
89
|
+
const b = row({ path: '/b', parentId: a.id })
|
|
90
|
+
expect(kinds([{ ...a, parentId: b.id }, b])).toContain('cycle')
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('reports a cycle when an update moves a node under its own descendant', () => {
|
|
94
|
+
const root = row({ kind: 'directory', path: '/root' })
|
|
95
|
+
const child = row({ parentId: root.id, path: 'mid', kind: 'directory' })
|
|
96
|
+
const grandchild = row({ parentId: child.id, path: 'leaf', componentKey: 'dashboard' })
|
|
97
|
+
expect(kinds([{ ...root, parentId: grandchild.id }, child, grandchild])).toContain('cycle')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('reports orphan parents instead of dropping the row silently', () => {
|
|
101
|
+
expect(kinds([row({ parentId: 'missing' })])).toContain('orphan-parent')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
it('flattens nested trees back into rows', () => {
|
|
105
|
+
const parent = row({ kind: 'directory', path: '/section' })
|
|
106
|
+
const child = row({ parentId: parent.id, path: 'detail' })
|
|
107
|
+
const flattened = flattenMenuRows([{ ...parent, children: [child] }])
|
|
108
|
+
expect(flattened.map((entry) => entry.id)).toEqual([parent.id, child.id])
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
describe('flattenCompleteMenuPages', () => {
|
|
113
|
+
it('flattens every row when all page metadata and counts are complete', () => {
|
|
114
|
+
const first = row({ id: 'menu-1' })
|
|
115
|
+
const second = row({ id: 'menu-2' })
|
|
116
|
+
const third = row({ id: 'menu-3' })
|
|
117
|
+
const pages = [
|
|
118
|
+
{ page: 1, pageSize: 2, total: 3, list: [first, second] },
|
|
119
|
+
{ page: 2, pageSize: 2, total: 3, list: [third] },
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
expect(getMenuPageCount(pages[0]!)).toBe(2)
|
|
123
|
+
expect(flattenCompleteMenuPages(pages)?.map((menu) => menu.id)).toEqual([
|
|
124
|
+
'menu-1',
|
|
125
|
+
'menu-2',
|
|
126
|
+
'menu-3',
|
|
127
|
+
])
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
it('rejects missing pages and inconsistent page snapshots', () => {
|
|
131
|
+
const first = row({ id: 'menu-1' })
|
|
132
|
+
const second = row({ id: 'menu-2' })
|
|
133
|
+
const third = row({ id: 'menu-3' })
|
|
134
|
+
const firstPage = { page: 1, pageSize: 2, total: 3, list: [first, second] }
|
|
135
|
+
expect(flattenCompleteMenuPages([firstPage])).toBeUndefined()
|
|
136
|
+
expect(
|
|
137
|
+
flattenCompleteMenuPages([
|
|
138
|
+
firstPage,
|
|
139
|
+
{ page: 2, pageSize: 2, total: 4, list: [third] },
|
|
140
|
+
]),
|
|
141
|
+
).toBeUndefined()
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
describe('fetchCompleteMenuPages', () => {
|
|
146
|
+
it('rejects implausibly large page counts before requesting remaining pages', async () => {
|
|
147
|
+
const firstPage = {
|
|
148
|
+
page: 1,
|
|
149
|
+
pageSize: 1000,
|
|
150
|
+
total: 100_001,
|
|
151
|
+
list: Array.from({ length: 1000 }, (_, index) => row({ id: `menu-${index}` })),
|
|
152
|
+
}
|
|
153
|
+
let requestedPages = 0
|
|
154
|
+
|
|
155
|
+
await expect(
|
|
156
|
+
fetchCompleteMenuPages(firstPage, async () => {
|
|
157
|
+
requestedPages += 1
|
|
158
|
+
return { page: 2, pageSize: 1000, total: 100_001, list: [] }
|
|
159
|
+
}),
|
|
160
|
+
).resolves.toBeUndefined()
|
|
161
|
+
expect(requestedPages).toBe(0)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('fetches pages in bounded batches and returns a complete snapshot', async () => {
|
|
165
|
+
const total = 17
|
|
166
|
+
const firstPage = { page: 1, pageSize: 1, total, list: [row({ id: 'menu-1' })] }
|
|
167
|
+
let inFlight = 0
|
|
168
|
+
let maxInFlight = 0
|
|
169
|
+
|
|
170
|
+
const rows = await fetchCompleteMenuPages(
|
|
171
|
+
firstPage,
|
|
172
|
+
async (page, pageSize) => {
|
|
173
|
+
inFlight += 1
|
|
174
|
+
maxInFlight = Math.max(maxInFlight, inFlight)
|
|
175
|
+
await Promise.resolve()
|
|
176
|
+
inFlight -= 1
|
|
177
|
+
return { page, pageSize, total, list: [row({ id: `menu-${page}` })] }
|
|
178
|
+
},
|
|
179
|
+
4,
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
expect(maxInFlight).toBe(4)
|
|
183
|
+
expect(rows?.map((menu) => menu.id)).toEqual(
|
|
184
|
+
Array.from({ length: total }, (_, index) => `menu-${index + 1}`),
|
|
185
|
+
)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
it('enforces the shared concurrency ceiling when a larger value is requested', async () => {
|
|
189
|
+
const total = 20
|
|
190
|
+
const firstPage = { page: 1, pageSize: 1, total, list: [row({ id: 'menu-1' })] }
|
|
191
|
+
let inFlight = 0
|
|
192
|
+
let maxInFlight = 0
|
|
193
|
+
|
|
194
|
+
await fetchCompleteMenuPages(
|
|
195
|
+
firstPage,
|
|
196
|
+
async (page, pageSize) => {
|
|
197
|
+
inFlight += 1
|
|
198
|
+
maxInFlight = Math.max(maxInFlight, inFlight)
|
|
199
|
+
await Promise.resolve()
|
|
200
|
+
inFlight -= 1
|
|
201
|
+
return { page, pageSize, total, list: [row({ id: `menu-${page}` })] }
|
|
202
|
+
},
|
|
203
|
+
20,
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
expect(maxInFlight).toBe(8)
|
|
207
|
+
})
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
describe('applyMenuDraftToRows', () => {
|
|
211
|
+
const draft: RbacMenuDraft = {
|
|
212
|
+
parentId: 'parent-2',
|
|
213
|
+
kind: 'page',
|
|
214
|
+
title: 'Moved',
|
|
215
|
+
code: 'moved',
|
|
216
|
+
path: '/moved',
|
|
217
|
+
componentKey: 'dashboard',
|
|
218
|
+
order: 2,
|
|
219
|
+
status: 'active',
|
|
220
|
+
visible: true,
|
|
221
|
+
cache: false,
|
|
222
|
+
tabHidden: false,
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
it('replaces the target row in place on update', () => {
|
|
226
|
+
const original = row({ id: 'menu-1', code: 'old', title: 'Old', path: '/old' })
|
|
227
|
+
const rows = applyMenuDraftToRows([original], draft, 'menu-1')
|
|
228
|
+
expect(rows).toHaveLength(1)
|
|
229
|
+
expect(rows[0]).toMatchObject({ id: 'menu-1', code: 'moved', parentId: 'parent-2' })
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it('appends a provisional row on create', () => {
|
|
233
|
+
const rows = applyMenuDraftToRows([row()], draft)
|
|
234
|
+
expect(rows).toHaveLength(2)
|
|
235
|
+
expect(rows[1]).toMatchObject({ code: 'moved', parentId: 'parent-2', version: 1 })
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
it('lets the post-save tree trial surface conflicts the draft introduces', () => {
|
|
239
|
+
const kept = row({ id: 'menu-2', path: '/kept', code: 'kept' })
|
|
240
|
+
const mover = row({ id: 'menu-1', path: '/old', code: 'mover' })
|
|
241
|
+
const rows = applyMenuDraftToRows(
|
|
242
|
+
[mover, kept],
|
|
243
|
+
{ ...draft, parentId: '', path: '/kept' },
|
|
244
|
+
'menu-1',
|
|
245
|
+
)
|
|
246
|
+
expect(kinds(rows)).toContain('duplicate-path')
|
|
247
|
+
})
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
describe('filterIntroducedConflicts', () => {
|
|
251
|
+
const conflict = (kind: MenuTreeConflict['kind'], detail?: string): MenuTreeConflict => ({
|
|
252
|
+
kind,
|
|
253
|
+
detail,
|
|
254
|
+
})
|
|
255
|
+
|
|
256
|
+
it('only reports conflicts that the change newly introduces', () => {
|
|
257
|
+
const before = [conflict('duplicate-path', '/legacy'), conflict('cycle', 'menu-9')]
|
|
258
|
+
const after = [...before, conflict('duplicate-code', 'moved')]
|
|
259
|
+
expect(filterIntroducedConflicts(before, after).map((item) => item.kind)).toEqual([
|
|
260
|
+
'duplicate-code',
|
|
261
|
+
])
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
it('reports nothing when the tree carries only legacy conflicts', () => {
|
|
265
|
+
const before = [conflict('duplicate-path', '/legacy')]
|
|
266
|
+
expect(filterIntroducedConflicts(before, before)).toEqual([])
|
|
267
|
+
})
|
|
268
|
+
})
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import type { RouteSourceNode } from '@origen-ui/router'
|
|
2
|
+
import type { PageResult } from '@origen-ui/shared'
|
|
3
|
+
import type { RbacMenu, RbacMenuDraft } from '../access/api/rbac'
|
|
4
|
+
import { parseMenuResponse } from '../../../app/menu'
|
|
5
|
+
import { routeTransformer } from '../../../router/dynamicRoutes'
|
|
6
|
+
|
|
7
|
+
// Keep request fan-out and local tree construction bounded when API metadata is wrong.
|
|
8
|
+
const MENU_PRECHECK_MAX_PAGES = 100
|
|
9
|
+
const MENU_PRECHECK_PAGE_FETCH_CONCURRENCY = 8
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 整树保存前预检:把「保存后的菜单行集」按运行时同一条管线
|
|
13
|
+
* (parseMenuResponse → routeTransformer)试算一遍,把原本要等动态路由
|
|
14
|
+
* 装载才暴露的整树级冲突提前到保存时刻。字段级与跨字段规则由表单
|
|
15
|
+
* schema 承载,这里只负责树形/派生层冲突。
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export type MenuTreeConflictKind =
|
|
19
|
+
| 'cycle' |
|
|
20
|
+
'orphan-parent' |
|
|
21
|
+
'duplicate-id' |
|
|
22
|
+
'duplicate-code' |
|
|
23
|
+
'duplicate-path' |
|
|
24
|
+
'ambiguous-parent' |
|
|
25
|
+
'unresolved-parent' |
|
|
26
|
+
'path-missing' |
|
|
27
|
+
'title-key-missing' |
|
|
28
|
+
'unknown'
|
|
29
|
+
|
|
30
|
+
export interface MenuTreeConflict {
|
|
31
|
+
kind: MenuTreeConflictKind
|
|
32
|
+
detail?: string
|
|
33
|
+
/** Technical context retained for logs; never rendered as user-facing copy. */
|
|
34
|
+
diagnostic?: string
|
|
35
|
+
/** Number of conflicting entries beyond the first in a duplicate group. */
|
|
36
|
+
count?: number
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function flattenMenuRows(menus: readonly RbacMenu[]): RbacMenu[] {
|
|
40
|
+
return menus.flatMap((menu) => [menu, ...flattenMenuRows(menu.children ?? [])])
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Returns the page count only for a valid first-page response. */
|
|
44
|
+
export function getMenuPageCount(page: PageResult<RbacMenu>): number | undefined {
|
|
45
|
+
if (
|
|
46
|
+
page.page !== 1 ||
|
|
47
|
+
!Number.isSafeInteger(page.total) ||
|
|
48
|
+
page.total < 0 ||
|
|
49
|
+
!Number.isSafeInteger(page.pageSize) ||
|
|
50
|
+
page.pageSize < 1 ||
|
|
51
|
+
!Array.isArray(page.list) ||
|
|
52
|
+
page.list.length > page.pageSize
|
|
53
|
+
) {
|
|
54
|
+
return undefined
|
|
55
|
+
}
|
|
56
|
+
const pageCount = Math.max(1, Math.ceil(page.total / page.pageSize))
|
|
57
|
+
return pageCount <= MENU_PRECHECK_MAX_PAGES ? pageCount : undefined
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Fetches a bounded page snapshot without fanning out one request per server-reported page. */
|
|
61
|
+
export async function fetchCompleteMenuPages(
|
|
62
|
+
firstPage: PageResult<RbacMenu>,
|
|
63
|
+
fetchPage: (page: number, pageSize: number) => Promise<PageResult<RbacMenu>>,
|
|
64
|
+
concurrency = MENU_PRECHECK_PAGE_FETCH_CONCURRENCY,
|
|
65
|
+
): Promise<readonly RbacMenu[] | undefined> {
|
|
66
|
+
const pageCount = getMenuPageCount(firstPage)
|
|
67
|
+
if (
|
|
68
|
+
pageCount === undefined ||
|
|
69
|
+
!Number.isSafeInteger(concurrency) ||
|
|
70
|
+
concurrency < 1
|
|
71
|
+
) {
|
|
72
|
+
return undefined
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const fetchConcurrency = Math.min(concurrency, MENU_PRECHECK_PAGE_FETCH_CONCURRENCY)
|
|
76
|
+
const pages: PageResult<RbacMenu>[] = [firstPage]
|
|
77
|
+
for (let page = 2; page <= pageCount;) {
|
|
78
|
+
const batchSize = Math.min(fetchConcurrency, pageCount - page + 1)
|
|
79
|
+
const nextPages = await Promise.all(
|
|
80
|
+
Array.from({ length: batchSize }, (_, index) => fetchPage(page + index, firstPage.pageSize)),
|
|
81
|
+
)
|
|
82
|
+
pages.push(...nextPages)
|
|
83
|
+
page += batchSize
|
|
84
|
+
}
|
|
85
|
+
return flattenCompleteMenuPages(pages)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Flattens all pages only when their metadata and row counts form a complete snapshot. */
|
|
89
|
+
export function flattenCompleteMenuPages(
|
|
90
|
+
pages: readonly PageResult<RbacMenu>[],
|
|
91
|
+
): readonly RbacMenu[] | undefined {
|
|
92
|
+
const first = pages[0]
|
|
93
|
+
if (!first || getMenuPageCount(first) !== pages.length) return undefined
|
|
94
|
+
|
|
95
|
+
const rows: RbacMenu[] = []
|
|
96
|
+
for (const [index, page] of pages.entries()) {
|
|
97
|
+
const expectedPage = index + 1
|
|
98
|
+
const expectedRows = Math.min(first.pageSize, Math.max(0, first.total - index * first.pageSize))
|
|
99
|
+
if (
|
|
100
|
+
page.page !== expectedPage ||
|
|
101
|
+
page.pageSize !== first.pageSize ||
|
|
102
|
+
page.total !== first.total ||
|
|
103
|
+
!Array.isArray(page.list) ||
|
|
104
|
+
page.list.length !== expectedRows
|
|
105
|
+
) {
|
|
106
|
+
return undefined
|
|
107
|
+
}
|
|
108
|
+
rows.push(...page.list)
|
|
109
|
+
}
|
|
110
|
+
return flattenMenuRows(rows)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function menuConflictKey(conflict: MenuTreeConflict): string {
|
|
114
|
+
return `${conflict.kind}:${conflict.detail ?? ''}`
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** 以 before 集合为基线,筛出 after 中新引入的冲突;存量冲突不阻断。 */
|
|
118
|
+
export function filterIntroducedConflicts(
|
|
119
|
+
before: readonly MenuTreeConflict[],
|
|
120
|
+
after: readonly MenuTreeConflict[],
|
|
121
|
+
): readonly MenuTreeConflict[] {
|
|
122
|
+
const remainingBaseline = new Map<string, number>()
|
|
123
|
+
for (const conflict of before) {
|
|
124
|
+
const key = menuConflictKey(conflict)
|
|
125
|
+
remainingBaseline.set(key, (remainingBaseline.get(key) ?? 0) + (conflict.count ?? 1))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const introduced: MenuTreeConflict[] = []
|
|
129
|
+
for (const conflict of after) {
|
|
130
|
+
const key = menuConflictKey(conflict)
|
|
131
|
+
const count = conflict.count ?? 1
|
|
132
|
+
const baselineCount = remainingBaseline.get(key) ?? 0
|
|
133
|
+
const introducedCount = Math.max(0, count - baselineCount)
|
|
134
|
+
remainingBaseline.set(key, Math.max(0, baselineCount - count))
|
|
135
|
+
if (introducedCount > 0) introduced.push({ ...conflict, count: introducedCount })
|
|
136
|
+
}
|
|
137
|
+
return introduced
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 构造「保存后」的扁平行集:更新原位替换目标行(parentId 变更即移动节点),
|
|
142
|
+
* 新增以临时 id 追加。行集结构(无 children)由调用方保证来自列表接口。
|
|
143
|
+
*/
|
|
144
|
+
export function applyMenuDraftToRows(
|
|
145
|
+
rows: readonly RbacMenu[],
|
|
146
|
+
draft: RbacMenuDraft,
|
|
147
|
+
rowId?: string,
|
|
148
|
+
): RbacMenu[] {
|
|
149
|
+
const next: RbacMenu[] = rows.map((row) => ({ ...row, children: undefined }))
|
|
150
|
+
const index = rowId ? next.findIndex((row) => row.id === rowId) : -1
|
|
151
|
+
const row: RbacMenu = index >= 0
|
|
152
|
+
? { ...next[index]!, ...draft }
|
|
153
|
+
: { ...draft, id: 'menu-draft', version: 1, createdAt: '', updatedAt: '' }
|
|
154
|
+
if (index >= 0) next[index] = row
|
|
155
|
+
else next.push(row)
|
|
156
|
+
return next
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function collectMenuTreeConflicts(rows: readonly RbacMenu[]): readonly MenuTreeConflict[] {
|
|
160
|
+
const conflicts: MenuTreeConflict[] = []
|
|
161
|
+
const idCounts = new Map<string, number>()
|
|
162
|
+
for (const row of rows) {
|
|
163
|
+
idCounts.set(row.id, (idCounts.get(row.id) ?? 0) + 1)
|
|
164
|
+
}
|
|
165
|
+
for (const [id, count] of idCounts) {
|
|
166
|
+
if (count > 1) conflicts.push({ kind: 'duplicate-id', detail: id, count: count - 1 })
|
|
167
|
+
}
|
|
168
|
+
const byId = new Map<string, RbacMenu>()
|
|
169
|
+
for (const row of rows) {
|
|
170
|
+
if (!byId.has(row.id)) byId.set(row.id, row)
|
|
171
|
+
}
|
|
172
|
+
// 链路环检测与可达性无关:沿 parentId 上溯,链路内重复即成环——
|
|
173
|
+
// 纯环(无任何根入口)不会出现在按根遍历的树里,必须单独扫。
|
|
174
|
+
for (const row of rows) {
|
|
175
|
+
const chain = new Set<string>([row.id])
|
|
176
|
+
let cursor = byId.get(row.parentId ?? '')
|
|
177
|
+
while (cursor) {
|
|
178
|
+
if (chain.has(cursor.id)) {
|
|
179
|
+
conflicts.push({ kind: 'cycle', detail: row.id })
|
|
180
|
+
break
|
|
181
|
+
}
|
|
182
|
+
chain.add(cursor.id)
|
|
183
|
+
cursor = byId.get(cursor.parentId ?? '')
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
conflicts.push(...runTrialPipeline(buildRowTree(rows, conflicts)))
|
|
187
|
+
const unique = new Map<string, MenuTreeConflict>()
|
|
188
|
+
for (const conflict of conflicts) unique.set(`${conflict.kind}:${conflict.detail ?? ''}`, conflict)
|
|
189
|
+
return [...unique.values()]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function buildRowTree(
|
|
193
|
+
rawRows: readonly RbacMenu[],
|
|
194
|
+
conflicts: MenuTreeConflict[],
|
|
195
|
+
): readonly RbacMenu[] {
|
|
196
|
+
// 空串父级在 RBAC 读取契约里非法(会抛 Invalid RBAC menu parent),
|
|
197
|
+
// 统一归一化为根,避免行从试算树里静默消失。
|
|
198
|
+
const rows = rawRows.map((row) => ({ ...row, parentId: row.parentId || undefined }))
|
|
199
|
+
const byId = new Map<string, RbacMenu>()
|
|
200
|
+
for (const row of rows) {
|
|
201
|
+
if (!byId.has(row.id)) byId.set(row.id, row)
|
|
202
|
+
}
|
|
203
|
+
const children = new Map<string | undefined, RbacMenu[]>()
|
|
204
|
+
for (const row of rows) {
|
|
205
|
+
const siblings = children.get(row.parentId) ?? []
|
|
206
|
+
siblings.push(row)
|
|
207
|
+
children.set(row.parentId, siblings)
|
|
208
|
+
}
|
|
209
|
+
const tree: RbacMenu[] = []
|
|
210
|
+
const visit = (row: RbacMenu, chain: Set<string>): RbacMenu => {
|
|
211
|
+
const nested = (children.get(row.id) ?? [])
|
|
212
|
+
.filter((child) => {
|
|
213
|
+
if (!chain.has(child.id)) return true
|
|
214
|
+
conflicts.push({ kind: 'cycle', detail: `${row.id} -> ${child.id}` })
|
|
215
|
+
return false
|
|
216
|
+
})
|
|
217
|
+
.map((child) => visit(child, new Set([...chain, row.id])))
|
|
218
|
+
return nested.length ? { ...row, children: nested } : { ...row, children: undefined }
|
|
219
|
+
}
|
|
220
|
+
for (const root of children.get(undefined) ?? []) tree.push(visit(root, new Set()))
|
|
221
|
+
// 孤儿行(父级不存在)按根处理并显式上报,否则会被静默丢弃、试算漏检。
|
|
222
|
+
for (const row of rows) {
|
|
223
|
+
if (row.parentId && !byId.has(row.parentId)) {
|
|
224
|
+
conflicts.push({ kind: 'orphan-parent', detail: `${row.id} -> ${row.parentId}` })
|
|
225
|
+
tree.push(visit({ ...row, parentId: undefined }, new Set()))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return tree
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function runTrialPipeline(tree: readonly RbacMenu[]): readonly MenuTreeConflict[] {
|
|
232
|
+
let parsed: ReturnType<typeof parseMenuResponse>
|
|
233
|
+
try {
|
|
234
|
+
// 走 parseRbacMenuPage(数组/分页形态中的 { list } 形态):复用运行时的
|
|
235
|
+
// button/suspended 剪枝、环与孤儿父级检测、permission 映射,而非另写一份。
|
|
236
|
+
parsed = parseMenuResponse(
|
|
237
|
+
{
|
|
238
|
+
list: [...tree],
|
|
239
|
+
total: tree.length,
|
|
240
|
+
page: 1,
|
|
241
|
+
pageSize: Math.max(tree.length, 1),
|
|
242
|
+
},
|
|
243
|
+
{ requireTitleKey: true },
|
|
244
|
+
)
|
|
245
|
+
} catch (error) {
|
|
246
|
+
return [mapPipelineError(error)]
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const duplicateCodes = duplicateCodeConflicts(parsed)
|
|
250
|
+
if (duplicateCodes.length) return duplicateCodes
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
return duplicatePathConflicts(routeTransformer(parsed))
|
|
254
|
+
} catch (error) {
|
|
255
|
+
return [mapPipelineError(error)]
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function duplicateCodeConflicts(
|
|
260
|
+
sources: ReturnType<typeof parseMenuResponse>,
|
|
261
|
+
): readonly MenuTreeConflict[] {
|
|
262
|
+
const counts = new Map<string, number>()
|
|
263
|
+
for (const source of sources) counts.set(source.code, (counts.get(source.code) ?? 0) + 1)
|
|
264
|
+
return [...counts.entries()]
|
|
265
|
+
.filter(([, count]) => count > 1)
|
|
266
|
+
.map(([code, count]) => ({
|
|
267
|
+
kind: 'duplicate-code',
|
|
268
|
+
detail: code,
|
|
269
|
+
count: count - 1,
|
|
270
|
+
}))
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function pipelineDetail(message: string, prefix: string): string | undefined {
|
|
274
|
+
const detail = message.slice(prefix.length).replace(/^:\s*/u, '').trim()
|
|
275
|
+
return detail || undefined
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function mapPipelineError(error: unknown): MenuTreeConflict {
|
|
279
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
280
|
+
if (message.startsWith('Circular RBAC menu parent relationship'))
|
|
281
|
+
return { kind: 'cycle', detail: pipelineDetail(message, 'Circular RBAC menu parent relationship') }
|
|
282
|
+
if (message.startsWith('Unknown RBAC menu parent'))
|
|
283
|
+
return { kind: 'orphan-parent', detail: pipelineDetail(message, 'Unknown RBAC menu parent') }
|
|
284
|
+
if (message.startsWith('Duplicate RBAC menu id'))
|
|
285
|
+
return { kind: 'duplicate-id', detail: pipelineDetail(message, 'Duplicate RBAC menu id') }
|
|
286
|
+
if (message.startsWith('Missing route path for RBAC menu'))
|
|
287
|
+
return { kind: 'path-missing', detail: pipelineDetail(message, 'Missing route path for RBAC menu') }
|
|
288
|
+
if (message.startsWith('Missing RBAC menu title key'))
|
|
289
|
+
return { kind: 'title-key-missing', detail: pipelineDetail(message, 'Missing RBAC menu title key') }
|
|
290
|
+
if (message.startsWith('Duplicate dynamic route code'))
|
|
291
|
+
return { kind: 'duplicate-code', detail: pipelineDetail(message, 'Duplicate dynamic route code') }
|
|
292
|
+
if (message.startsWith('Ambiguous dynamic route parent path'))
|
|
293
|
+
return { kind: 'ambiguous-parent', detail: pipelineDetail(message, 'Ambiguous dynamic route parent path') }
|
|
294
|
+
if (message.startsWith('Unresolved dynamic route parent path'))
|
|
295
|
+
return { kind: 'unresolved-parent', detail: pipelineDetail(message, 'Unresolved dynamic route parent path') }
|
|
296
|
+
return message.trim() ? { kind: 'unknown', diagnostic: message } : { kind: 'unknown' }
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** routeTransformer 自动去重路由名,但不校验路径——这里按解析后的完整路径补查。 */
|
|
300
|
+
function duplicatePathConflicts(
|
|
301
|
+
sources: readonly RouteSourceNode[],
|
|
302
|
+
): readonly MenuTreeConflict[] {
|
|
303
|
+
const counts = new Map<string, number>()
|
|
304
|
+
const walk = (nodes: readonly RouteSourceNode[], parentPath: string): void => {
|
|
305
|
+
for (const node of nodes) {
|
|
306
|
+
const path = node.path.startsWith('/')
|
|
307
|
+
? node.path
|
|
308
|
+
: `${parentPath.replace(/\/$/, '')}/${node.path}`
|
|
309
|
+
counts.set(path, (counts.get(path) ?? 0) + 1)
|
|
310
|
+
walk(node.children ?? [], path)
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
walk(sources, '')
|
|
314
|
+
return [...counts.entries()]
|
|
315
|
+
.filter(([, count]) => count > 1)
|
|
316
|
+
.map(([path, count]) => ({ kind: 'duplicate-path', detail: path, count: count - 1 }))
|
|
317
|
+
}
|
|
@@ -78,6 +78,7 @@ const schema = computed<OgFormSchema<RoleFormModel>>(() => ({
|
|
|
78
78
|
filterable: true,
|
|
79
79
|
placeholder: t('system.roles.form.permissionsPlaceholder'),
|
|
80
80
|
treeData: props.permissionTree,
|
|
81
|
+
treeNodeKey: 'value',
|
|
81
82
|
treeCheckable: true,
|
|
82
83
|
treeCheckStrictly: true,
|
|
83
84
|
},
|
|
@@ -25,7 +25,7 @@ const sessionId = computed(() =>
|
|
|
25
25
|
</ElAvatar>
|
|
26
26
|
<div>
|
|
27
27
|
<h2>{{ user?.displayName ?? t('workspace.profile.admin') }}</h2>
|
|
28
|
-
<p>{{ user?.email ?? '
|
|
28
|
+
<p>{{ user?.email ?? t('workspace.profile.noEmail') }}</p>
|
|
29
29
|
</div>
|
|
30
30
|
<ElTag type="success" effect="plain">
|
|
31
31
|
<ElIcon><CircleCheckFilled /></ElIcon> {{ t('workspace.profile.online') }}
|
|
@@ -5,6 +5,7 @@ import { ElDrawer } from 'element-plus'
|
|
|
5
5
|
import { useI18n } from 'vue-i18n'
|
|
6
6
|
import AdminWatermark from '../features/shell/components/AdminWatermark.vue'
|
|
7
7
|
import { useSidebarStore } from '../features/shell/store/sidebar'
|
|
8
|
+
import { useAuthorizationPolling } from '../features/system/access/composables/useAuthorizationPolling'
|
|
8
9
|
import BreadcrumbBar from './BreadcrumbBar.vue'
|
|
9
10
|
import SideMenu from './SideMenu.vue'
|
|
10
11
|
import TopBar from './TopBar.vue'
|
|
@@ -13,6 +14,8 @@ import WorkspaceTabs from './WorkspaceTabs.vue'
|
|
|
13
14
|
defineOptions({ name: 'AdminLayout' })
|
|
14
15
|
const sidebar = useSidebarStore()
|
|
15
16
|
const { t } = useI18n()
|
|
17
|
+
// 会话内轮询 RBAC revision:服务端权限/菜单变更经确认后刷新,随布局卸载停止。
|
|
18
|
+
useAuthorizationPolling()
|
|
16
19
|
</script>
|
|
17
20
|
|
|
18
21
|
<template>
|