@origen-ui/admin-cli 1.1.0 → 2.0.2
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 +41 -9
- package/package.json +26 -2
- package/templates/current/clean/.node-version +1 -0
- package/templates/current/clean/CHANGELOG.md +125 -0
- package/templates/current/clean/README.md +2 -1
- 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 +94 -50
- package/templates/current/clean/package.json +39 -25
- package/templates/current/clean/playwright.config.ts +1 -0
- package/templates/current/clean/playwright.demo.config.ts +1 -1
- package/templates/current/clean/pnpm-workspace.yaml +18 -0
- package/templates/current/clean/scaffold.lock.json +2 -2
- package/templates/current/clean/scripts/check-admin-scaffold.mjs +5 -1
- 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 +88 -12
- package/templates/current/clean/scripts/generate-api.ts +87 -3
- package/templates/current/clean/scripts/remove-examples.mjs +4 -4
- 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 +314 -3
- package/templates/current/clean/src/features/auth/pages/Login.vue +9 -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/queryEncryption.spec.ts +10 -1
- package/templates/current/clean/src/router/routeQuery.spec.ts +2 -1
- package/templates/current/clean/src/router/routeQuery.ts +4 -1
- 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/.node-version +1 -0
- package/templates/current/examples/CHANGELOG.md +125 -0
- package/templates/current/examples/README.md +2 -1
- 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 +94 -50
- package/templates/current/examples/package.json +39 -25
- package/templates/current/examples/playwright.config.ts +1 -0
- package/templates/current/examples/playwright.demo.config.ts +1 -1
- package/templates/current/examples/pnpm-workspace.yaml +18 -0
- package/templates/current/examples/scaffold.lock.json +2 -2
- package/templates/current/examples/scripts/check-admin-scaffold.mjs +5 -1
- 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 +88 -12
- package/templates/current/examples/scripts/generate-api.ts +87 -3
- package/templates/current/examples/scripts/remove-examples.mjs +4 -4
- 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 +314 -3
- package/templates/current/examples/src/features/auth/pages/Login.vue +9 -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/queryEncryption.spec.ts +10 -1
- package/templates/current/examples/src/router/routeQuery.spec.ts +2 -1
- package/templates/current/examples/src/router/routeQuery.ts +4 -1
- 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
|
@@ -18,7 +18,12 @@ import { useI18n } from 'vue-i18n'
|
|
|
18
18
|
import { useAuthStore } from '../features/auth/store/auth'
|
|
19
19
|
import { useSidebarStore } from '../features/shell/store/sidebar'
|
|
20
20
|
import { getRouting } from '../router/bootstrap'
|
|
21
|
-
import {
|
|
21
|
+
import { replaceDynamicMenusWithAccessibleFallback } from '../router/dynamicMenuRefresh'
|
|
22
|
+
import {
|
|
23
|
+
flattenMenuSearchOptions,
|
|
24
|
+
isMenuRefreshDisabled,
|
|
25
|
+
isMenuSearchDisabled,
|
|
26
|
+
} from './topBarMenuSearch'
|
|
22
27
|
|
|
23
28
|
defineOptions({ name: 'TopBar' })
|
|
24
29
|
const ThemePanel = defineAsyncComponent({
|
|
@@ -33,6 +38,7 @@ const auth = useAuthStore()
|
|
|
33
38
|
const user = computed(() => auth.session?.user)
|
|
34
39
|
const menuSearchValue = shallowRef<string>()
|
|
35
40
|
const menuRefreshFailed = shallowRef(false)
|
|
41
|
+
const menuRefreshing = shallowRef(false)
|
|
36
42
|
const language = useOrigenUiLanguage()!
|
|
37
43
|
const languageOptions = computed(() => [
|
|
38
44
|
{ value: 'zh-CN', label: t('shell.languageZhCN') },
|
|
@@ -42,20 +48,33 @@ const languageOptions = computed(() => [
|
|
|
42
48
|
const menuSearchOptions = computed(() => flattenMenuSearchOptions(getRouting().menu.value))
|
|
43
49
|
|
|
44
50
|
async function refreshLocalizedMenus(): Promise<void> {
|
|
51
|
+
if (isMenuRefreshDisabled(menuRefreshing.value, language.status.value === 'loading')) return
|
|
52
|
+
menuRefreshing.value = true
|
|
45
53
|
try {
|
|
46
|
-
await getRouting()
|
|
54
|
+
await replaceDynamicMenusWithAccessibleFallback(getRouting())
|
|
47
55
|
menuRefreshFailed.value = false
|
|
48
56
|
} catch {
|
|
49
57
|
menuRefreshFailed.value = true
|
|
50
58
|
ElMessage.error({ message: t('shell.menuRefreshFailed'), showClose: true })
|
|
59
|
+
} finally {
|
|
60
|
+
menuRefreshing.value = false
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
|
|
54
64
|
async function switchLanguage(locale: string): Promise<void> {
|
|
55
|
-
if (
|
|
65
|
+
if (
|
|
66
|
+
!language ||
|
|
67
|
+
menuRefreshing.value ||
|
|
68
|
+
language.status.value === 'loading' ||
|
|
69
|
+
language.current.value === locale
|
|
70
|
+
) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
56
73
|
try {
|
|
57
74
|
const result = await language.setLocale(locale)
|
|
58
|
-
if (!result.applied)
|
|
75
|
+
if (!result.applied) {
|
|
76
|
+
return
|
|
77
|
+
}
|
|
59
78
|
} catch {
|
|
60
79
|
ElMessage.error({ message: t('shell.languageLoadFailed'), showClose: true })
|
|
61
80
|
return
|
|
@@ -100,6 +119,7 @@ async function logout(): Promise<void> {
|
|
|
100
119
|
<ElSelect
|
|
101
120
|
v-model="menuSearchValue"
|
|
102
121
|
class="top-bar__search"
|
|
122
|
+
:disabled="isMenuSearchDisabled(menuRefreshing, language.status.value === 'loading')"
|
|
103
123
|
:placeholder="t('shell.searchMenu')"
|
|
104
124
|
filterable
|
|
105
125
|
clearable
|
|
@@ -140,12 +160,23 @@ async function logout(): Promise<void> {
|
|
|
140
160
|
<ElDropdownItem
|
|
141
161
|
v-for="item in languageOptions"
|
|
142
162
|
:key="item.value"
|
|
143
|
-
:disabled="
|
|
163
|
+
:disabled="
|
|
164
|
+
language.current.value === item.value
|
|
165
|
+
|| menuRefreshing
|
|
166
|
+
|| language.status.value === 'loading'
|
|
167
|
+
"
|
|
144
168
|
@click="switchLanguage(item.value)"
|
|
145
169
|
>
|
|
146
170
|
{{ item.label }}
|
|
147
171
|
</ElDropdownItem>
|
|
148
|
-
<ElDropdownItem
|
|
172
|
+
<ElDropdownItem
|
|
173
|
+
v-if="menuRefreshFailed"
|
|
174
|
+
divided
|
|
175
|
+
:disabled="
|
|
176
|
+
isMenuRefreshDisabled(menuRefreshing, language.status.value === 'loading')
|
|
177
|
+
"
|
|
178
|
+
@click="refreshLocalizedMenus"
|
|
179
|
+
>
|
|
149
180
|
<ElIcon><Refresh /></ElIcon>
|
|
150
181
|
{{ t('shell.retryMenuRefresh') }}
|
|
151
182
|
</ElDropdownItem>
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import type { RouteMenuItem } from '@origen-ui/router'
|
|
2
2
|
import { describe, expect, it } from 'vitest'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
flattenMenuSearchOptions,
|
|
5
|
+
isMenuRefreshDisabled,
|
|
6
|
+
isMenuSearchDisabled,
|
|
7
|
+
} from './topBarMenuSearch'
|
|
8
|
+
|
|
9
|
+
describe('isMenuSearchDisabled', () => {
|
|
10
|
+
it('disables menu search while localized routes are loading or refreshing', () => {
|
|
11
|
+
expect(isMenuSearchDisabled(true, false)).toBe(true)
|
|
12
|
+
expect(isMenuSearchDisabled(false, true)).toBe(true)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('keeps menu search enabled when route state is settled', () => {
|
|
16
|
+
expect(isMenuSearchDisabled(false, false)).toBe(false)
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('isMenuRefreshDisabled', () => {
|
|
21
|
+
it('prevents a refresh while another refresh or locale transition is active', () => {
|
|
22
|
+
expect(isMenuRefreshDisabled(true, false)).toBe(true)
|
|
23
|
+
expect(isMenuRefreshDisabled(false, true)).toBe(true)
|
|
24
|
+
expect(isMenuRefreshDisabled(false, false)).toBe(false)
|
|
25
|
+
})
|
|
26
|
+
})
|
|
4
27
|
|
|
5
28
|
describe('flattenMenuSearchOptions', () => {
|
|
6
29
|
it('returns only navigable leaves with their visible hierarchy', () => {
|
|
@@ -7,6 +7,16 @@ export interface TopBarMenuSearchOption {
|
|
|
7
7
|
to: RouteLocationRaw
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/** Keep menu search unavailable while its route-backed options are being replaced. */
|
|
11
|
+
export function isMenuSearchDisabled(menuRefreshing: boolean, languageLoading: boolean): boolean {
|
|
12
|
+
return menuRefreshing || languageLoading
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Prevent menu refreshes from racing a locale transition. */
|
|
16
|
+
export function isMenuRefreshDisabled(menuRefreshing: boolean, languageLoading: boolean): boolean {
|
|
17
|
+
return menuRefreshing || languageLoading
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
/** Builds searchable destinations from the visible leaf menu items. */
|
|
11
21
|
export function flattenMenuSearchOptions(
|
|
12
22
|
items: readonly RouteMenuItem[],
|
|
@@ -138,7 +138,9 @@
|
|
|
138
138
|
},
|
|
139
139
|
"errors": {
|
|
140
140
|
"unknownPageError": "An unexpected page error occurred",
|
|
141
|
-
"startupFailed": "The application failed to start"
|
|
141
|
+
"startupFailed": "The application failed to start",
|
|
142
|
+
"networkError": "A network error occurred. Please try again later.",
|
|
143
|
+
"invalidResponse": "The service returned an invalid response."
|
|
142
144
|
}
|
|
143
145
|
},
|
|
144
146
|
"workspace": {
|
|
@@ -202,7 +204,8 @@
|
|
|
202
204
|
"permissionItems": "permissions",
|
|
203
205
|
"securityStatus": "Security Status",
|
|
204
206
|
"currentSession": "Current Session",
|
|
205
|
-
"sessionDescription": "This device accesses the admin workspace through a protected session."
|
|
207
|
+
"sessionDescription": "This device accesses the admin workspace through a protected session.",
|
|
208
|
+
"noEmail": "No email set"
|
|
206
209
|
}
|
|
207
210
|
},
|
|
208
211
|
"errors": {
|
|
@@ -440,15 +443,32 @@
|
|
|
440
443
|
"pathRequired": "Please enter the menu route path",
|
|
441
444
|
"submenuRelativePath": "Child menus must use relative route paths",
|
|
442
445
|
"rootPathSlash": "Root menu paths must start with /",
|
|
443
|
-
"componentRequired": "Please select a registered page capability"
|
|
446
|
+
"componentRequired": "Please select a registered page capability",
|
|
447
|
+
"treeCycle": "Menu parent chain contains a cycle",
|
|
448
|
+
"treeOrphanParent": "Parent menu does not exist or was removed",
|
|
449
|
+
"treeDuplicateId": "Duplicate menu identifier",
|
|
450
|
+
"treeDuplicateCode": "Duplicate menu code",
|
|
451
|
+
"treeDuplicatePath": "Duplicate resolved route path",
|
|
452
|
+
"treeAmbiguousParent": "Ambiguous parent route path",
|
|
453
|
+
"treeUnresolvedParent": "Unresolved parent route path",
|
|
454
|
+
"treePrecheckFailed": "Menu tree validation failed",
|
|
455
|
+
"treeTitleKeyMissing": "Menu title is missing a translation key",
|
|
456
|
+
"treeDetail": "Detail: {detail}",
|
|
457
|
+
"titleKeyRequired": "Enter a translation key for the menu title",
|
|
458
|
+
"versionConflict": "Menu was modified by someone else. Refresh and retry"
|
|
444
459
|
},
|
|
445
460
|
"form": {
|
|
446
461
|
"kind": "Node Type",
|
|
462
|
+
"redirect": "Directory Redirect",
|
|
463
|
+
"redirectPlaceholder": "Leave empty to fall back to the home route",
|
|
447
464
|
"parentButton": "Parent Page",
|
|
448
465
|
"parentDirectory": "Parent Directory",
|
|
449
466
|
"rootDirectory": "Root Directory",
|
|
450
467
|
"title": "Menu Name",
|
|
451
468
|
"titlePlaceholder": "e.g. Component coverage",
|
|
469
|
+
"titleKey": "Title Translation Key",
|
|
470
|
+
"titleKeyPlaceholder": "e.g. menus.coverage.title",
|
|
471
|
+
"titleKeyRuleMessage": "Start with a letter; letters, digits, dots or hyphens allowed",
|
|
452
472
|
"code": "Menu Code",
|
|
453
473
|
"codePlaceholder": "e.g. user-list",
|
|
454
474
|
"codeRuleMessage": "Use 3-48 lowercase letters, digits or hyphens",
|
|
@@ -472,6 +492,13 @@
|
|
|
472
492
|
"tabHidden": "Hide Tab"
|
|
473
493
|
}
|
|
474
494
|
},
|
|
495
|
+
"access": {
|
|
496
|
+
"revision": {
|
|
497
|
+
"title": "Permissions updated",
|
|
498
|
+
"body": "Menu or permission configuration has changed. Refresh now?",
|
|
499
|
+
"refreshNow": "Refresh now"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
475
502
|
"audit": {
|
|
476
503
|
"title": "Audit Log",
|
|
477
504
|
"occurredAt": "Time",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OG_DIALOG_LOCALE_EN_US } from '@origen-ui/dialog/locale'
|
|
2
2
|
import { OG_EDITOR_LOCALE_EN_US } from '@origen-ui/editor/locale'
|
|
3
|
+
import { OG_FORM_TABLE_LOCALE_EN_US } from '@origen-ui/form-table/locale'
|
|
3
4
|
import { OG_FORM_LOCALE_EN_US } from '@origen-ui/form/locale'
|
|
4
5
|
import { OG_SEARCH_LOCALE_EN_US } from '@origen-ui/search/locale'
|
|
5
6
|
import { OG_TABLE_LOCALE_EN_US } from '@origen-ui/table/locale'
|
|
@@ -13,6 +14,7 @@ export const origenUi = {
|
|
|
13
14
|
dialog: OG_DIALOG_LOCALE_EN_US,
|
|
14
15
|
editor: OG_EDITOR_LOCALE_EN_US,
|
|
15
16
|
form: OG_FORM_LOCALE_EN_US,
|
|
17
|
+
formTable: OG_FORM_TABLE_LOCALE_EN_US,
|
|
16
18
|
search: OG_SEARCH_LOCALE_EN_US,
|
|
17
19
|
table: OG_TABLE_LOCALE_EN_US,
|
|
18
20
|
tabs: OG_TABS_LOCALE_EN_US,
|
|
@@ -6,7 +6,11 @@ import type { I18n } from 'vue-i18n'
|
|
|
6
6
|
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
|
7
7
|
import type { AdminLocale } from '../app/adminLocale'
|
|
8
8
|
import type { AdminMessages } from './messages-types'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
createOrigenUiLanguageRuntime,
|
|
11
|
+
defineOrigenUiLanguage,
|
|
12
|
+
mergeLocale,
|
|
13
|
+
} from 'origen-ui/language'
|
|
10
14
|
import { watch } from 'vue'
|
|
11
15
|
import { createI18n } from 'vue-i18n'
|
|
12
16
|
import {
|
|
@@ -15,26 +19,14 @@ import {
|
|
|
15
19
|
resolveInitialLocale,
|
|
16
20
|
setAdminLocale,
|
|
17
21
|
} from '../app/adminLocale'
|
|
18
|
-
import {
|
|
19
|
-
enUSLocale,
|
|
20
|
-
validateAdminLocaleMessages,
|
|
21
|
-
zhCNLocale,
|
|
22
|
-
zhTWLocale,
|
|
23
|
-
} from './messages-types'
|
|
22
|
+
import { enUSLocale, validateAdminLocaleMessages, zhCNLocale, zhTWLocale } from './messages-types'
|
|
24
23
|
import zhCN from './zh-CN.json'
|
|
25
|
-
import {
|
|
26
|
-
elementPlus as zhCNElementPlus,
|
|
27
|
-
origenUi as zhCNOrigenUi,
|
|
28
|
-
} from './zh-CN.runtime'
|
|
24
|
+
import { elementPlus as zhCNElementPlus, origenUi as zhCNOrigenUi } from './zh-CN.runtime'
|
|
29
25
|
|
|
30
26
|
export type { AdminLocale } from '../app/adminLocale'
|
|
31
27
|
export { currentAdminLocale, normalizeAdminLocale, SUPPORTED_LOCALES } from '../app/adminLocale'
|
|
32
28
|
|
|
33
|
-
export type AdminLanguageModule = OrigenUiLanguageModule<
|
|
34
|
-
AdminMessages,
|
|
35
|
-
unknown,
|
|
36
|
-
OrigenUiMessages
|
|
37
|
-
>
|
|
29
|
+
export type AdminLanguageModule = OrigenUiLanguageModule<AdminMessages, unknown, OrigenUiMessages>
|
|
38
30
|
|
|
39
31
|
/** Admin 消息树叶子 key 的联合类型(如 'auth.login'),用于动态 key 的编译期标注。 */
|
|
40
32
|
export type AdminMessageKey = PathKeys<AdminMessages>
|
|
@@ -99,26 +91,45 @@ export function getAdminI18n(): I18n | null {
|
|
|
99
91
|
return runtimeI18n
|
|
100
92
|
}
|
|
101
93
|
|
|
94
|
+
/** vue-i18n Composer narrowed to the admin message keys. */
|
|
95
|
+
export interface AdminTranslator {
|
|
96
|
+
t: (key: AdminMessageKey, named?: Record<string, unknown>) => string
|
|
97
|
+
te: (key: AdminMessageKey) => boolean
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function translatorOf(i18n: I18n | null | undefined): AdminTranslator | undefined {
|
|
101
|
+
// The single cast boundary: vue-i18n's Composer is generic over message
|
|
102
|
+
// schemas, while admin callers pass runtime string keys guarded by te().
|
|
103
|
+
return i18n?.global as unknown as AdminTranslator | undefined
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** te-guarded translation: unknown keys and pre-bootstrap calls return `options.fallback ?? key`. */
|
|
107
|
+
export function translateAdminMessage(
|
|
108
|
+
key: string,
|
|
109
|
+
options: { fallback?: string, named?: Record<string, unknown> } = {},
|
|
110
|
+
): string {
|
|
111
|
+
const translator = translatorOf(getAdminI18n())
|
|
112
|
+
if (!translator || !translator.te(key as AdminMessageKey)) return options.fallback ?? key
|
|
113
|
+
return translator.t(key as AdminMessageKey, options.named)
|
|
114
|
+
}
|
|
115
|
+
|
|
102
116
|
export function createAdminTitleResolver(
|
|
103
117
|
i18n: I18n,
|
|
104
118
|
): (route: RouteLocationNormalizedLoaded, meta: AdapterRouteMeta) => string | undefined {
|
|
105
119
|
return (_route, meta) => {
|
|
106
120
|
const key = meta.breadcrumb?.labelKey ?? meta.titleKey
|
|
107
121
|
if (!key) return meta.title
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
if (global.te?.(key)) return global.t(key as AdminMessageKey)
|
|
113
|
-
return meta.breadcrumb?.labelKey ? meta.breadcrumb?.label ?? meta.title : meta.title
|
|
122
|
+
const translator = translatorOf(i18n)
|
|
123
|
+
if (translator?.te(key as AdminMessageKey)) return translator.t(key as AdminMessageKey)
|
|
124
|
+
return meta.breadcrumb?.labelKey ? (meta.breadcrumb?.label ?? meta.title) : meta.title
|
|
114
125
|
}
|
|
115
126
|
}
|
|
116
127
|
|
|
117
128
|
export function createAdminI18n(existing?: I18n): AdminI18nRuntime {
|
|
118
129
|
const hostLocale = existing?.global.locale
|
|
119
|
-
const initial =
|
|
120
|
-
typeof hostLocale === 'string' ? hostLocale : hostLocale?.value
|
|
121
|
-
|
|
130
|
+
const initial =
|
|
131
|
+
normalizeAdminLocale(typeof hostLocale === 'string' ? hostLocale : hostLocale?.value) ??
|
|
132
|
+
resolveInitialLocale()
|
|
122
133
|
const i18n =
|
|
123
134
|
existing ??
|
|
124
135
|
createI18n({
|
|
@@ -166,7 +177,9 @@ export function createAdminI18n(existing?: I18n): AdminI18nRuntime {
|
|
|
166
177
|
i18n.global.setLocaleMessage(
|
|
167
178
|
module.locale,
|
|
168
179
|
mergeLocale(
|
|
169
|
-
(hostMessages && typeof hostMessages === 'object'
|
|
180
|
+
(hostMessages && typeof hostMessages === 'object'
|
|
181
|
+
? hostMessages
|
|
182
|
+
: {}) as AdminMessages,
|
|
170
183
|
module.messages,
|
|
171
184
|
),
|
|
172
185
|
)
|
|
@@ -138,7 +138,9 @@
|
|
|
138
138
|
},
|
|
139
139
|
"errors": {
|
|
140
140
|
"unknownPageError": "页面发生未知错误",
|
|
141
|
-
"startupFailed": "应用启动失败"
|
|
141
|
+
"startupFailed": "应用启动失败",
|
|
142
|
+
"networkError": "网络异常,请稍后再试",
|
|
143
|
+
"invalidResponse": "服务响应格式无效"
|
|
142
144
|
}
|
|
143
145
|
},
|
|
144
146
|
"workspace": {
|
|
@@ -202,7 +204,8 @@
|
|
|
202
204
|
"permissionItems": "项权限",
|
|
203
205
|
"securityStatus": "安全状态",
|
|
204
206
|
"currentSession": "当前会话",
|
|
205
|
-
"sessionDescription": "本设备通过受保护会话访问管理工作区。"
|
|
207
|
+
"sessionDescription": "本设备通过受保护会话访问管理工作区。",
|
|
208
|
+
"noEmail": "未设置邮箱"
|
|
206
209
|
}
|
|
207
210
|
},
|
|
208
211
|
"errors": {
|
|
@@ -440,15 +443,32 @@
|
|
|
440
443
|
"pathRequired": "请填写菜单路由路径",
|
|
441
444
|
"submenuRelativePath": "子菜单应使用相对路由路径",
|
|
442
445
|
"rootPathSlash": "根菜单路由必须以 / 开头",
|
|
443
|
-
"componentRequired": "请选择已注册的页面能力"
|
|
446
|
+
"componentRequired": "请选择已注册的页面能力",
|
|
447
|
+
"treeCycle": "菜单父子关系存在循环引用",
|
|
448
|
+
"treeOrphanParent": "上级菜单不存在或已被删除",
|
|
449
|
+
"treeDuplicateId": "菜单标识重复",
|
|
450
|
+
"treeDuplicateCode": "菜单编码重复",
|
|
451
|
+
"treeDuplicatePath": "解析后的路由路径重复",
|
|
452
|
+
"treeAmbiguousParent": "上级路由路径存在歧义",
|
|
453
|
+
"treeUnresolvedParent": "上级路由路径无法解析",
|
|
454
|
+
"treePrecheckFailed": "菜单树校验未通过",
|
|
455
|
+
"treeTitleKeyMissing": "菜单标题缺少翻译键",
|
|
456
|
+
"treeDetail": "详情:{detail}",
|
|
457
|
+
"titleKeyRequired": "请输入菜单标题翻译键",
|
|
458
|
+
"versionConflict": "菜单已被他人修改,请刷新列表后重试"
|
|
444
459
|
},
|
|
445
460
|
"form": {
|
|
446
461
|
"kind": "节点类型",
|
|
462
|
+
"redirect": "目录重定向",
|
|
463
|
+
"redirectPlaceholder": "留空则回退到首页路由",
|
|
447
464
|
"parentButton": "所属页面",
|
|
448
465
|
"parentDirectory": "上级目录",
|
|
449
466
|
"rootDirectory": "根目录",
|
|
450
467
|
"title": "菜单名称",
|
|
451
468
|
"titlePlaceholder": "例如:组件覆盖率",
|
|
469
|
+
"titleKey": "标题翻译键",
|
|
470
|
+
"titleKeyPlaceholder": "例如:menus.coverage.title",
|
|
471
|
+
"titleKeyRuleMessage": "使用字母开头的翻译键,可含字母、数字、点或连字符",
|
|
452
472
|
"code": "菜单编码",
|
|
453
473
|
"codePlaceholder": "例如:user-list",
|
|
454
474
|
"codeRuleMessage": "使用 3-48 位小写字母、数字或连字符",
|
|
@@ -472,6 +492,13 @@
|
|
|
472
492
|
"tabHidden": "隐藏标签页"
|
|
473
493
|
}
|
|
474
494
|
},
|
|
495
|
+
"access": {
|
|
496
|
+
"revision": {
|
|
497
|
+
"title": "权限已更新",
|
|
498
|
+
"body": "检测到菜单或权限配置已变更,是否立即刷新?",
|
|
499
|
+
"refreshNow": "立即刷新"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
475
502
|
"audit": {
|
|
476
503
|
"title": "审计日志",
|
|
477
504
|
"occurredAt": "发生时间",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OG_DIALOG_LOCALE_ZH_CN } from '@origen-ui/dialog/locale'
|
|
2
2
|
import { OG_EDITOR_LOCALE_ZH_CN } from '@origen-ui/editor/locale'
|
|
3
|
+
import { OG_FORM_TABLE_LOCALE_ZH_CN } from '@origen-ui/form-table/locale'
|
|
3
4
|
import { OG_FORM_LOCALE_ZH_CN } from '@origen-ui/form/locale'
|
|
4
5
|
import { OG_SEARCH_LOCALE_ZH_CN } from '@origen-ui/search/locale'
|
|
5
6
|
import { OG_TABLE_LOCALE_ZH_CN } from '@origen-ui/table/locale'
|
|
@@ -13,6 +14,7 @@ export const origenUi = {
|
|
|
13
14
|
dialog: OG_DIALOG_LOCALE_ZH_CN,
|
|
14
15
|
editor: OG_EDITOR_LOCALE_ZH_CN,
|
|
15
16
|
form: OG_FORM_LOCALE_ZH_CN,
|
|
17
|
+
formTable: OG_FORM_TABLE_LOCALE_ZH_CN,
|
|
16
18
|
search: OG_SEARCH_LOCALE_ZH_CN,
|
|
17
19
|
table: OG_TABLE_LOCALE_ZH_CN,
|
|
18
20
|
tabs: OG_TABS_LOCALE_ZH_CN,
|
|
@@ -138,7 +138,9 @@
|
|
|
138
138
|
},
|
|
139
139
|
"errors": {
|
|
140
140
|
"unknownPageError": "頁面發生未知錯誤",
|
|
141
|
-
"startupFailed": "應用程式啟動失敗"
|
|
141
|
+
"startupFailed": "應用程式啟動失敗",
|
|
142
|
+
"networkError": "網路異常,請稍後再試",
|
|
143
|
+
"invalidResponse": "服務回應格式無效"
|
|
142
144
|
}
|
|
143
145
|
},
|
|
144
146
|
"workspace": {
|
|
@@ -202,7 +204,8 @@
|
|
|
202
204
|
"permissionItems": "項權限",
|
|
203
205
|
"securityStatus": "安全狀態",
|
|
204
206
|
"currentSession": "目前工作階段",
|
|
205
|
-
"sessionDescription": "本裝置透過受保護的工作階段訪問管理工作區。"
|
|
207
|
+
"sessionDescription": "本裝置透過受保護的工作階段訪問管理工作區。",
|
|
208
|
+
"noEmail": "未設定電子郵件"
|
|
206
209
|
}
|
|
207
210
|
},
|
|
208
211
|
"errors": {
|
|
@@ -440,15 +443,32 @@
|
|
|
440
443
|
"pathRequired": "請填寫選單路由路徑",
|
|
441
444
|
"submenuRelativePath": "子選單應使用相對路由路徑",
|
|
442
445
|
"rootPathSlash": "根選單路由必須以 / 開頭",
|
|
443
|
-
"componentRequired": "請選擇已註冊的頁面能力"
|
|
446
|
+
"componentRequired": "請選擇已註冊的頁面能力",
|
|
447
|
+
"treeCycle": "選單父子關係存在循環參照",
|
|
448
|
+
"treeOrphanParent": "上層選單不存在或已被刪除",
|
|
449
|
+
"treeDuplicateId": "選單識別碼重複",
|
|
450
|
+
"treeDuplicateCode": "選單編碼重複",
|
|
451
|
+
"treeDuplicatePath": "解析後的路由路徑重複",
|
|
452
|
+
"treeAmbiguousParent": "上層路由路徑存在歧義",
|
|
453
|
+
"treeUnresolvedParent": "上層路由路徑無法解析",
|
|
454
|
+
"treePrecheckFailed": "選單樹校驗未通過",
|
|
455
|
+
"treeTitleKeyMissing": "選單標題缺少翻譯鍵",
|
|
456
|
+
"treeDetail": "詳情:{detail}",
|
|
457
|
+
"titleKeyRequired": "請輸入選單標題翻譯鍵",
|
|
458
|
+
"versionConflict": "選單已被他人修改,請重新整理後再試"
|
|
444
459
|
},
|
|
445
460
|
"form": {
|
|
446
461
|
"kind": "節點類型",
|
|
462
|
+
"redirect": "目錄重定向",
|
|
463
|
+
"redirectPlaceholder": "留空則回退到首頁路由",
|
|
447
464
|
"parentButton": "所屬頁面",
|
|
448
465
|
"parentDirectory": "上級目錄",
|
|
449
466
|
"rootDirectory": "根目錄",
|
|
450
467
|
"title": "選單名稱",
|
|
451
468
|
"titlePlaceholder": "例如:元件覆蓋率",
|
|
469
|
+
"titleKey": "標題翻譯鍵",
|
|
470
|
+
"titleKeyPlaceholder": "例如:menus.coverage.title",
|
|
471
|
+
"titleKeyRuleMessage": "使用字母開頭的翻譯鍵,可含字母、數字、點或連字號",
|
|
452
472
|
"code": "選單編碼",
|
|
453
473
|
"codePlaceholder": "例如:user-list",
|
|
454
474
|
"codeRuleMessage": "使用 3-48 位小寫字母、數字或連字號",
|
|
@@ -472,6 +492,13 @@
|
|
|
472
492
|
"tabHidden": "隱藏分頁"
|
|
473
493
|
}
|
|
474
494
|
},
|
|
495
|
+
"access": {
|
|
496
|
+
"revision": {
|
|
497
|
+
"title": "權限已更新",
|
|
498
|
+
"body": "檢測到選單或權限配置已變更,是否立即重新整理?",
|
|
499
|
+
"refreshNow": "立即重新整理"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
475
502
|
"audit": {
|
|
476
503
|
"title": "稽核日誌",
|
|
477
504
|
"occurredAt": "發生時間",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OG_DIALOG_LOCALE_ZH_TW } from '@origen-ui/dialog/locale'
|
|
2
2
|
import { OG_EDITOR_LOCALE_ZH_TW } from '@origen-ui/editor/locale'
|
|
3
|
+
import { OG_FORM_TABLE_LOCALE_ZH_TW } from '@origen-ui/form-table/locale'
|
|
3
4
|
import { OG_FORM_LOCALE_ZH_TW } from '@origen-ui/form/locale'
|
|
4
5
|
import { OG_SEARCH_LOCALE_ZH_TW } from '@origen-ui/search/locale'
|
|
5
6
|
import { OG_TABLE_LOCALE_ZH_TW } from '@origen-ui/table/locale'
|
|
@@ -13,6 +14,7 @@ export const origenUi = {
|
|
|
13
14
|
dialog: OG_DIALOG_LOCALE_ZH_TW,
|
|
14
15
|
editor: OG_EDITOR_LOCALE_ZH_TW,
|
|
15
16
|
form: OG_FORM_LOCALE_ZH_TW,
|
|
17
|
+
formTable: OG_FORM_TABLE_LOCALE_ZH_TW,
|
|
16
18
|
search: OG_SEARCH_LOCALE_ZH_TW,
|
|
17
19
|
table: OG_TABLE_LOCALE_ZH_TW,
|
|
18
20
|
tabs: OG_TABS_LOCALE_ZH_TW,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { AdminMessageKey } from './locales'
|
|
2
1
|
import { createApp } from 'vue'
|
|
3
2
|
import App from './App.vue'
|
|
4
3
|
import { embeddedMode, readHostInjection, startEmbeddedBridge } from './app/embedded'
|
|
4
|
+
import { translateAdminError } from './app/errorMessage'
|
|
5
5
|
import { permission } from './app/permission'
|
|
6
6
|
import { useAuthStore } from './features/auth/store/auth'
|
|
7
7
|
import { devtoolsProtection } from './features/security/devtoolsProtection'
|
|
8
|
-
import {
|
|
8
|
+
import { translateAdminMessage } from './locales'
|
|
9
|
+
import { replaceDynamicMenusWithAccessibleFallback } from './router/dynamicMenuRefresh'
|
|
9
10
|
import { createRuntimeErrorRecovery, createStaleAssetRecovery } from './router/runtimeErrorRecovery'
|
|
10
11
|
import { pinia } from './store'
|
|
11
12
|
import 'element-plus/theme-chalk/src/tabs.scss'
|
|
@@ -16,8 +17,7 @@ import './styles/layout.css'
|
|
|
16
17
|
import './styles/shell.css'
|
|
17
18
|
|
|
18
19
|
function tOrFallback(key: string, fallback: string): string {
|
|
19
|
-
|
|
20
|
-
return global?.t(key as AdminMessageKey) ?? fallback
|
|
20
|
+
return translateAdminMessage(key, { fallback })
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
async function notifyRuntimeError(message: string): Promise<void> {
|
|
@@ -56,12 +56,16 @@ async function bootstrap(): Promise<void> {
|
|
|
56
56
|
language.install(app)
|
|
57
57
|
const { createAdminUi } = await import('./app/createAdminUi')
|
|
58
58
|
app.use(createAdminUi(language))
|
|
59
|
+
// 唯一的 errorHandler 装配点:运行期错误统一走提示 + 陈旧资源/运行时恢复,
|
|
60
|
+
// 不再在启动后半程二次覆盖装配。
|
|
59
61
|
app.config.errorHandler = (error: unknown) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
console.error('[admin] runtime error', error)
|
|
63
|
+
const message = translateAdminError(error, {
|
|
64
|
+
fallbackKey: 'common.errors.unknownPageError',
|
|
65
|
+
fallback: '页面发生未知错误',
|
|
66
|
+
})
|
|
64
67
|
void notifyRuntimeError(message)
|
|
68
|
+
if (!staleAssetRecovery.handle(error)) recoverRuntimeError()
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
const auth = useAuthStore(pinia)
|
|
@@ -70,10 +74,12 @@ async function bootstrap(): Promise<void> {
|
|
|
70
74
|
await language.ready
|
|
71
75
|
const session = await auth.fetchSession()
|
|
72
76
|
app.use(routing)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
// 路由就绪是硬性等待;布局仅在登录态下并行预热。catch-tap 保证路由先失败
|
|
78
|
+
// 时预热 rejection 不会变成 unhandled——两个失败最终都按启动失败上报。
|
|
79
|
+
const layoutPreload = session ? import('./layouts/AdminLayout.vue') : undefined
|
|
80
|
+
layoutPreload?.catch(() => {})
|
|
81
|
+
await routing.ready()
|
|
82
|
+
await layoutPreload
|
|
77
83
|
// 嵌入模式:iframe 继承主壳路径,子应用路由按主壳下发的初始路径导航
|
|
78
84
|
if (embeddedMode) {
|
|
79
85
|
const initialPath = String(readHostInjection().initialPath ?? '/')
|
|
@@ -82,26 +88,22 @@ async function bootstrap(): Promise<void> {
|
|
|
82
88
|
// routing from a child data-listener deadlocks with the sandbox lifecycle.
|
|
83
89
|
await routing.router.replace(initialPath).catch(() => {})
|
|
84
90
|
}
|
|
85
|
-
const reportRuntimeError = app.config.errorHandler
|
|
86
91
|
const { authorizationRefreshKey } =
|
|
87
92
|
await import('./features/system/access/composables/useAuthorizationRefresh')
|
|
88
|
-
app.config.errorHandler = (error, instance, info) => {
|
|
89
|
-
reportRuntimeError?.(error, instance, info)
|
|
90
|
-
if (!staleAssetRecovery.handle(error)) recoverRuntimeError()
|
|
91
|
-
}
|
|
92
93
|
app.provide(authorizationRefreshKey, async () => {
|
|
93
94
|
await auth.refreshAuthorization()
|
|
94
|
-
await routing
|
|
95
|
+
await replaceDynamicMenusWithAccessibleFallback(routing)
|
|
95
96
|
})
|
|
96
97
|
app.mount('#app')
|
|
97
98
|
staleAssetRecovery.clear()
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
void bootstrap().catch((error: unknown) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
console.error('[admin] startup failed', error)
|
|
103
|
+
const message = translateAdminError(error, {
|
|
104
|
+
fallbackKey: 'common.errors.startupFailed',
|
|
105
|
+
fallback: '应用启动失败',
|
|
106
|
+
})
|
|
105
107
|
const root = document.querySelector('#app')
|
|
106
108
|
if (root) {
|
|
107
109
|
const panel = document.createElement('main')
|
|
@@ -2,13 +2,15 @@ import type { RouterAdapter } from '@origen-ui/router'
|
|
|
2
2
|
import type { BackendMenuNode } from '../app/menuTypes'
|
|
3
3
|
import { createAccessPolicy, createRouterAdapter, createWebStorageAdapter } from '@origen-ui/router'
|
|
4
4
|
import { createWebHistory } from 'vue-router'
|
|
5
|
-
import { embeddedMode,
|
|
6
|
-
import {
|
|
5
|
+
import { embeddedMode, reportMenusToHost } from '../app/embedded'
|
|
6
|
+
import { loadMenusFromHost } from '../app/menu'
|
|
7
7
|
import { appRuntimeConfig } from '../app/runtimeConfig'
|
|
8
8
|
import { useAuthStore } from '../features/auth/store/auth'
|
|
9
9
|
import { pinia } from '../store'
|
|
10
10
|
import { hasPermission } from '../utils/permissions'
|
|
11
|
-
import { componentRegistry
|
|
11
|
+
import { componentRegistry } from './componentRegistry'
|
|
12
|
+
import { routeTransformer } from './dynamicRoutes'
|
|
13
|
+
import { NOT_FOUND_ROUTE_NAME } from './paths'
|
|
12
14
|
import { staticRoutes } from './staticRoutes'
|
|
13
15
|
|
|
14
16
|
type QueryCodecs = Pick<
|
|
@@ -23,16 +25,6 @@ type TitleOptions = Pick<
|
|
|
23
25
|
|
|
24
26
|
let routing: RouterAdapter<BackendMenuNode> | undefined
|
|
25
27
|
|
|
26
|
-
// 嵌入模式:动态菜单优先取主壳聚合下发(data 通道 backendMenus 字段,契约随
|
|
27
|
-
// M3/D-2 定稿);主壳未下发时回落到子应用经主壳网关拉取自身菜单,独立模式不受影响。
|
|
28
|
-
function loadMenusFromHost(): Promise<BackendMenuNode[]> {
|
|
29
|
-
const menus = readHostInjection().backendMenus
|
|
30
|
-
if (Array.isArray(menus) && menus.length > 0) {
|
|
31
|
-
return Promise.resolve(menus as BackendMenuNode[])
|
|
32
|
-
}
|
|
33
|
-
return fetchMenus().then((menus) => [...menus])
|
|
34
|
-
}
|
|
35
|
-
|
|
36
28
|
export function getRouting(): RouterAdapter<BackendMenuNode> {
|
|
37
29
|
if (!routing) {
|
|
38
30
|
throw new Error('Routing has not been initialized yet')
|
|
@@ -55,7 +47,7 @@ export function initializeRouting(
|
|
|
55
47
|
syncDocumentTitle: !embeddedMode,
|
|
56
48
|
access: createAccessPolicy({
|
|
57
49
|
getSession: () => useAuthStore(pinia).session,
|
|
58
|
-
canAccess: (
|
|
50
|
+
canAccess: (_to, session, meta) => hasPermission(session, meta.permissions ?? []),
|
|
59
51
|
loginRoute: { name: 'login' },
|
|
60
52
|
forbiddenRoute: { name: '403' },
|
|
61
53
|
}),
|
|
@@ -63,7 +55,9 @@ export function initializeRouting(
|
|
|
63
55
|
// 嵌入模式:菜单装载完成后向主壳上报(sub-app-menu);独立模式不触发。
|
|
64
56
|
// 上报在 embedded.ts 内 try/catch 兜底,装载主流程不受影响。
|
|
65
57
|
load: async () => {
|
|
66
|
-
|
|
58
|
+
// 嵌入模式:菜单装载完成后向主壳上报(sub-app-menu);独立模式不触发。
|
|
59
|
+
// loadMenusFromHost 内部处理主壳未下发时的 fetchMenus 回落。
|
|
60
|
+
const menus = await loadMenusFromHost()
|
|
67
61
|
if (embeddedMode) reportMenusToHost(menus)
|
|
68
62
|
return menus
|
|
69
63
|
},
|
|
@@ -71,7 +65,7 @@ export function initializeRouting(
|
|
|
71
65
|
resolveComponent: (key) => componentRegistry.get(key),
|
|
72
66
|
},
|
|
73
67
|
fallbacks: {
|
|
74
|
-
notFound: { name:
|
|
68
|
+
notFound: { name: NOT_FOUND_ROUTE_NAME },
|
|
75
69
|
error: { name: '500' },
|
|
76
70
|
},
|
|
77
71
|
workspace: {
|