@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,6 +18,10 @@ interface DemoRecord {
|
|
|
18
18
|
id: string
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
interface DemoRole extends DemoRecord {
|
|
22
|
+
permissions: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
21
25
|
interface DemoSummary {
|
|
22
26
|
userCount: number
|
|
23
27
|
roleCount: number
|
|
@@ -50,15 +54,15 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
50
54
|
request,
|
|
51
55
|
}) => {
|
|
52
56
|
const login = await demoRequest<DemoLogin>(request, 'POST', '/api/auth/login', undefined, {
|
|
53
|
-
username: 'admin',
|
|
54
|
-
password: '
|
|
57
|
+
username: 'demo-admin',
|
|
58
|
+
password: 'demo-password',
|
|
55
59
|
})
|
|
56
60
|
expect(login.permissions).toContain('system:user:write')
|
|
57
61
|
|
|
58
62
|
await page.goto('/login')
|
|
59
63
|
const loginInputs = page.locator('.login-page input')
|
|
60
|
-
await loginInputs.nth(0).fill('admin')
|
|
61
|
-
await loginInputs.nth(1).fill('
|
|
64
|
+
await loginInputs.nth(0).fill('demo-admin')
|
|
65
|
+
await loginInputs.nth(1).fill('demo-password')
|
|
62
66
|
await Promise.all([
|
|
63
67
|
page.waitForURL('**/dashboard'),
|
|
64
68
|
page.locator('button.login-card__submit').click(),
|
|
@@ -67,23 +71,27 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
67
71
|
await expect(page.locator('.admin-shell')).toBeVisible({ timeout: 15_000 })
|
|
68
72
|
await page.setViewportSize({ width: 1920, height: 1080 })
|
|
69
73
|
await expect(page.locator('.dashboard-page')).toBeVisible()
|
|
74
|
+
const languageMenuItem = (name: string) => page.getByRole('menuitem', { name, exact: true })
|
|
75
|
+
const menuSearch = page.locator('.top-bar__search input')
|
|
70
76
|
await page.getByRole('button', { name: '简体中文', exact: true }).click()
|
|
71
|
-
await
|
|
72
|
-
await
|
|
73
|
-
|
|
74
|
-
)
|
|
77
|
+
await expect(languageMenuItem('English')).toBeVisible()
|
|
78
|
+
await languageMenuItem('English').click()
|
|
79
|
+
await expect(page.locator('.top-bar__search .el-select__placeholder')).toHaveText('Search menu')
|
|
75
80
|
await expect(page.locator('html')).toHaveAttribute('lang', 'en-US')
|
|
81
|
+
await expect(menuSearch).toBeEnabled()
|
|
82
|
+
await expect(languageMenuItem('繁體中文')).toBeHidden()
|
|
76
83
|
await page.getByRole('button', { name: 'English', exact: true }).click()
|
|
77
|
-
await
|
|
78
|
-
await
|
|
79
|
-
|
|
80
|
-
)
|
|
84
|
+
await expect(languageMenuItem('繁體中文')).toBeVisible()
|
|
85
|
+
await languageMenuItem('繁體中文').click()
|
|
86
|
+
await expect(page.locator('.top-bar__search .el-select__placeholder')).toHaveText('搜尋選單')
|
|
81
87
|
await expect(page.locator('html')).toHaveAttribute('lang', 'zh-TW')
|
|
88
|
+
await expect(menuSearch).toBeEnabled()
|
|
89
|
+
await expect(languageMenuItem('简体中文')).toBeHidden()
|
|
82
90
|
await page.getByRole('button', { name: '繁體中文', exact: true }).click()
|
|
83
|
-
await
|
|
84
|
-
await
|
|
85
|
-
|
|
86
|
-
)
|
|
91
|
+
await expect(languageMenuItem('简体中文')).toBeVisible()
|
|
92
|
+
await languageMenuItem('简体中文').click()
|
|
93
|
+
await expect(page.locator('.top-bar__search .el-select__placeholder')).toHaveText('搜索菜单')
|
|
94
|
+
await expect(menuSearch).toBeEnabled()
|
|
87
95
|
await expect(page.getByRole('button', { name: '消息' })).toHaveCount(0)
|
|
88
96
|
const documentNavigations: string[] = []
|
|
89
97
|
const runtimeWarnings: string[] = []
|
|
@@ -95,12 +103,15 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
95
103
|
if (message.type() === 'warning' || message.type() === 'error')
|
|
96
104
|
runtimeWarnings.push(message.text())
|
|
97
105
|
})
|
|
98
|
-
const menuSearch = page.locator('.top-bar__search input')
|
|
99
106
|
await menuSearch.fill('Users')
|
|
100
|
-
|
|
101
|
-
await expect(
|
|
107
|
+
const usersSearchOption = page.getByRole('option', { name: 'System / Users', exact: true })
|
|
108
|
+
await expect(usersSearchOption).toBeVisible()
|
|
109
|
+
await usersSearchOption.click()
|
|
110
|
+
await expect(page).toHaveURL(/\/system\/users$/, { timeout: 15_000 })
|
|
102
111
|
await menuSearch.fill('Dashboard')
|
|
103
|
-
|
|
112
|
+
const dashboardSearchOption = page.getByRole('option', { name: 'Dashboard', exact: true })
|
|
113
|
+
await expect(dashboardSearchOption).toBeVisible()
|
|
114
|
+
await dashboardSearchOption.click()
|
|
104
115
|
await expect(page).toHaveURL(/\/dashboard$/)
|
|
105
116
|
await page.getByText('System', { exact: true }).click()
|
|
106
117
|
await expect(page.getByRole('menuitem', { name: 'Users', exact: true })).toBeVisible()
|
|
@@ -109,7 +120,7 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
109
120
|
await expect(page.locator('.table-page')).toBeVisible()
|
|
110
121
|
await expect(page.locator('.page-header')).toHaveCount(0)
|
|
111
122
|
const breadcrumbBox = await page.locator('.breadcrumb-bar').boundingBox()
|
|
112
|
-
const tableBox = await page.locator('.table-page > .table').boundingBox()
|
|
123
|
+
const tableBox = await page.locator('.table-page > .og-table').boundingBox()
|
|
113
124
|
const routeViewBox = await page.locator('.admin-shell__route-view').boundingBox()
|
|
114
125
|
expect(breadcrumbBox).not.toBeNull()
|
|
115
126
|
expect(tableBox).not.toBeNull()
|
|
@@ -117,9 +128,9 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
117
128
|
expect(breadcrumbBox!.y + breadcrumbBox!.height).toBeLessThanOrEqual(tableBox!.y)
|
|
118
129
|
expect(tableBox!.height).toBeGreaterThan(routeViewBox!.height * 0.8)
|
|
119
130
|
await expect(page.locator('.top-bar__badge')).toHaveCount(0)
|
|
120
|
-
await expect(page.locator('.search')).toHaveAttribute('data-search-columns', '4')
|
|
121
|
-
const searchGridBox = await page.locator('.search__grid').boundingBox()
|
|
122
|
-
const searchFieldBox = await page.locator('[data-search-field="keyword"]').boundingBox()
|
|
131
|
+
await expect(page.locator('.og-search')).toHaveAttribute('data-og-search-columns', '4')
|
|
132
|
+
const searchGridBox = await page.locator('.og-search__grid').boundingBox()
|
|
133
|
+
const searchFieldBox = await page.locator('[data-og-search-field="keyword"]').boundingBox()
|
|
123
134
|
expect(searchGridBox).not.toBeNull()
|
|
124
135
|
expect(searchFieldBox).not.toBeNull()
|
|
125
136
|
expect(searchFieldBox!.width).toBeLessThan(searchGridBox!.width * 0.3)
|
|
@@ -128,12 +139,14 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
128
139
|
).toBeVisible()
|
|
129
140
|
|
|
130
141
|
await menuSearch.fill('Menus')
|
|
131
|
-
|
|
142
|
+
const menusSearchOption = page.getByRole('option', { name: 'System / Menus', exact: true })
|
|
143
|
+
await expect(menusSearchOption).toBeVisible()
|
|
144
|
+
await menusSearchOption.click()
|
|
132
145
|
await expect(page).toHaveURL(/\/system\/menus$/)
|
|
133
146
|
const updatedHeader = page
|
|
134
147
|
.locator('.el-table__header th.el-table__cell.is-sortable')
|
|
135
148
|
.filter({ hasText: '最近更新' })
|
|
136
|
-
const updatedHeaderContent = updatedHeader.locator('.table__header-content')
|
|
149
|
+
const updatedHeaderContent = updatedHeader.locator('.og-table__header-content')
|
|
137
150
|
const updatedCaret = updatedHeader.locator('.caret-wrapper')
|
|
138
151
|
await expect(updatedHeaderContent).toBeVisible()
|
|
139
152
|
await expect(updatedCaret).toBeVisible()
|
|
@@ -179,7 +192,7 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
179
192
|
)
|
|
180
193
|
expect(new Set(tabTops).size).toBe(1)
|
|
181
194
|
|
|
182
|
-
const keywordField = page.locator('[data-search-field="keyword"]')
|
|
195
|
+
const keywordField = page.locator('[data-og-search-field="keyword"]')
|
|
183
196
|
const keywordLabel = keywordField.locator('.el-form-item__label')
|
|
184
197
|
const keywordInput = keywordField.locator('input')
|
|
185
198
|
const labelBox = await keywordLabel.boundingBox()
|
|
@@ -194,13 +207,13 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
194
207
|
elements.map((element) => Math.round(element.getBoundingClientRect().top)),
|
|
195
208
|
)
|
|
196
209
|
expect(new Set(narrowTabTops).size).toBe(1)
|
|
197
|
-
const rowActions = page.locator('.table-row-actions').first()
|
|
198
|
-
await expect(rowActions.locator('.table-row-actions__action')).toHaveCount(1)
|
|
199
|
-
await expect(rowActions.locator('.table-row-actions__more')).toBeVisible()
|
|
210
|
+
const rowActions = page.locator('.og-table-row-actions').first()
|
|
211
|
+
await expect(rowActions.locator('.og-table-row-actions__action')).toHaveCount(1)
|
|
212
|
+
await expect(rowActions.locator('.og-table-row-actions__more')).toBeVisible()
|
|
200
213
|
await expect(
|
|
201
|
-
page.locator('.table-page > .table--bordered.table--no-pagination .table__body'),
|
|
214
|
+
page.locator('.table-page > .og-table--bordered.og-table--no-pagination .og-table__body'),
|
|
202
215
|
).toHaveCSS('margin-bottom', '10px')
|
|
203
|
-
await rowActions.locator('.table-row-actions__action').click()
|
|
216
|
+
await rowActions.locator('.og-table-row-actions__action').click()
|
|
204
217
|
const mobileDialog = page.locator('.el-dialog.dialog__surface')
|
|
205
218
|
await expect(mobileDialog).toBeVisible()
|
|
206
219
|
for (const width of [600, 375]) {
|
|
@@ -224,11 +237,10 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
224
237
|
await expect(page).toHaveURL(new RegExp(`/system/${menu.toLowerCase()}$`))
|
|
225
238
|
await page.getByRole('button', { name: createButton, exact: true }).click()
|
|
226
239
|
|
|
227
|
-
const dialog = page
|
|
228
|
-
.locator('.el-dialog.dialog__surface')
|
|
229
|
-
.filter({ has: page.locator('.form-container') })
|
|
240
|
+
const dialog = page.getByRole('dialog').filter({ hasText: createButton })
|
|
230
241
|
const body = dialog.locator('.el-dialog__body')
|
|
231
|
-
await expect(dialog).toBeVisible()
|
|
242
|
+
await expect(dialog).toBeVisible({ timeout: 15_000 })
|
|
243
|
+
await expect(dialog.locator('.og-form-container')).toBeVisible()
|
|
232
244
|
await expect(body).toBeVisible()
|
|
233
245
|
expect(await body.evaluate((element) => element.scrollWidth <= element.clientWidth)).toBe(true)
|
|
234
246
|
|
|
@@ -257,23 +269,55 @@ test('admin demo logs in, registers remote routes, and persists mutations for th
|
|
|
257
269
|
await assertEditorFormDoesNotOverflow('Menus', '新增菜单')
|
|
258
270
|
}
|
|
259
271
|
|
|
260
|
-
await page.setViewportSize({ width:
|
|
272
|
+
await page.setViewportSize({ width: 1280, height: 900 })
|
|
273
|
+
await page.goto('/system/roles')
|
|
274
|
+
await expect(page).toHaveURL(/\/system\/roles$/)
|
|
275
|
+
await page.getByRole('button', { name: '新增角色', exact: true }).click()
|
|
276
|
+
const roleDialog = page.getByRole('dialog').filter({ hasText: '新增角色' })
|
|
277
|
+
await expect(roleDialog).toBeVisible()
|
|
261
278
|
|
|
262
279
|
const suffix = `${Date.now()}`
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
)
|
|
280
|
+
const roleField = (label: string) =>
|
|
281
|
+
roleDialog.locator('.el-form-item').filter({ hasText: label })
|
|
282
|
+
await roleField('角色名称').locator('input').fill(`Demo smoke role ${suffix}`)
|
|
283
|
+
await roleField('角色标识').locator('input').fill(`demo_smoke_${suffix}`)
|
|
284
|
+
await roleField('角色说明').locator('textarea').fill('Created by the local demo Playwright smoke test.')
|
|
285
|
+
|
|
286
|
+
const permissionsField = roleField('权限范围')
|
|
287
|
+
await permissionsField.locator('.el-select').click()
|
|
288
|
+
const rolePermissionGroup = page.getByRole('treeitem', { name: '角色管理' })
|
|
289
|
+
await rolePermissionGroup.locator('.el-tree-node__expand-icon').click()
|
|
290
|
+
const roleWritePermission = page.getByRole('treeitem', { name: '新增和编辑角色' })
|
|
291
|
+
await expect(roleWritePermission).toBeVisible()
|
|
292
|
+
await roleWritePermission.locator('.el-tree-node__content').click()
|
|
293
|
+
await expect(permissionsField).toContainText('新增和编辑角色')
|
|
294
|
+
await page.keyboard.press('Escape')
|
|
295
|
+
|
|
296
|
+
const roleCreation = page.waitForResponse((response) => {
|
|
297
|
+
const request = response.request()
|
|
298
|
+
return (
|
|
299
|
+
request.method() === 'POST' &&
|
|
300
|
+
new URL(response.url()).pathname === '/api/system/roles'
|
|
301
|
+
)
|
|
302
|
+
})
|
|
303
|
+
await roleDialog.getByRole('button', { name: '确定', exact: true }).click()
|
|
304
|
+
const roleResponse = await roleCreation
|
|
305
|
+
expect(roleResponse.ok()).toBe(true)
|
|
306
|
+
const role = ((await roleResponse.json()) as Envelope<DemoRole>).data
|
|
276
307
|
expect(role.id).toMatch(/^role-/)
|
|
308
|
+
expect(role.permissions).toEqual(['system:role:write'])
|
|
309
|
+
expect(roleResponse.request().postDataJSON()).toMatchObject({
|
|
310
|
+
permissions: ['system:role:write'],
|
|
311
|
+
})
|
|
312
|
+
await expect(roleDialog).toBeHidden()
|
|
313
|
+
|
|
314
|
+
expect(runtimeWarnings).not.toEqual(
|
|
315
|
+
expect.arrayContaining([
|
|
316
|
+
expect.stringContaining('Invalid prop: type check failed for prop "value"'),
|
|
317
|
+
]),
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
await page.setViewportSize({ width: 600, height: 900 })
|
|
277
321
|
|
|
278
322
|
const user = await demoRequest<DemoRecord>(
|
|
279
323
|
request,
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origen-ui/admin-scaffold",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.2",
|
|
5
5
|
"private": true,
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": "
|
|
7
|
+
"node": ">=22.0.0"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "vite",
|
|
11
11
|
"dev:demo": "vite --mode demo",
|
|
12
|
+
"prepare:api": "pnpm run generate:api",
|
|
13
|
+
"prebuild": "pnpm run prepare:api",
|
|
12
14
|
"build": "vue-tsc --noEmit && vite build",
|
|
13
15
|
"build:debug": "vue-tsc --noEmit && vite build --mode debug",
|
|
14
16
|
"preview": "vite preview",
|
|
17
|
+
"pretype-check": "pnpm run prepare:api",
|
|
15
18
|
"type-check": "vue-tsc --noEmit",
|
|
19
|
+
"pretest": "pnpm run prepare:api",
|
|
16
20
|
"test": "vitest run",
|
|
17
21
|
"test:e2e": "playwright test -c playwright.config.ts",
|
|
18
22
|
"test:demo:e2e": "playwright test -c playwright.demo.config.ts",
|
|
@@ -23,36 +27,39 @@
|
|
|
23
27
|
"dependencies": {
|
|
24
28
|
"@element-plus/icons-vue": "2.3.2",
|
|
25
29
|
"@noble/ciphers": "2.3.0",
|
|
26
|
-
"@origen-ui/dialog": "
|
|
27
|
-
"@origen-ui/editor": "
|
|
28
|
-
"@origen-ui/form": "
|
|
29
|
-
"@origen-ui/
|
|
30
|
-
"@origen-ui/
|
|
31
|
-
"@origen-ui/
|
|
32
|
-
"@origen-ui/
|
|
33
|
-
"@origen-ui/
|
|
34
|
-
"@origen-ui/
|
|
35
|
-
"@origen-ui/table
|
|
36
|
-
"@origen-ui/
|
|
37
|
-
"@origen-ui/
|
|
30
|
+
"@origen-ui/dialog": "2.0.2",
|
|
31
|
+
"@origen-ui/editor": "2.0.2",
|
|
32
|
+
"@origen-ui/form": "2.0.2",
|
|
33
|
+
"@origen-ui/form-table": "2.0.2",
|
|
34
|
+
"@origen-ui/http": "2.0.2",
|
|
35
|
+
"@origen-ui/permission": "2.0.2",
|
|
36
|
+
"@origen-ui/router": "2.0.2",
|
|
37
|
+
"@origen-ui/search": "2.0.2",
|
|
38
|
+
"@origen-ui/shared": "2.0.2",
|
|
39
|
+
"@origen-ui/table": "2.0.2",
|
|
40
|
+
"@origen-ui/table-search": "2.0.2",
|
|
41
|
+
"@origen-ui/tabs": "2.0.2",
|
|
42
|
+
"@origen-ui/upload": "2.0.2",
|
|
38
43
|
"@vue/devtools-api": "8.2.1",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"vue
|
|
44
|
+
"@vueuse/core": "15.0.0",
|
|
45
|
+
"axios": "1.20.0",
|
|
46
|
+
"element-plus": "2.14.7",
|
|
47
|
+
"origen-ui": "2.0.2",
|
|
48
|
+
"pinia": "4.1.0",
|
|
49
|
+
"sortablejs": "1.15.7",
|
|
50
|
+
"vue": "3.5.44",
|
|
51
|
+
"vue-i18n": "11.4.16",
|
|
52
|
+
"vue-router": "5.4.0"
|
|
46
53
|
},
|
|
47
54
|
"devDependencies": {
|
|
48
|
-
"@origen-ui/admin-cli": "
|
|
55
|
+
"@origen-ui/admin-cli": "2.0.2",
|
|
49
56
|
"@playwright/test": "1.62.1",
|
|
50
57
|
"@types/node": "22.20.1",
|
|
51
58
|
"@vitejs/plugin-vue": "6.0.8",
|
|
52
59
|
"@vitejs/plugin-vue-jsx": "5.1.6",
|
|
53
60
|
"@vitest/coverage-v8": "4.1.11",
|
|
54
|
-
"@vue/compiler-sfc": "3.5.
|
|
55
|
-
"@vue/test-utils": "2.
|
|
61
|
+
"@vue/compiler-sfc": "3.5.44",
|
|
62
|
+
"@vue/test-utils": "2.5.1",
|
|
56
63
|
"jsdom": "30.0.1",
|
|
57
64
|
"sass": "1.103.0",
|
|
58
65
|
"swagger-typescript-api": "^13.12.6",
|
|
@@ -60,6 +67,13 @@
|
|
|
60
67
|
"unplugin-element-plus": "0.11.2",
|
|
61
68
|
"vite": "8.2.2",
|
|
62
69
|
"vitest": "4.1.11",
|
|
63
|
-
"vue-tsc": "3.3.
|
|
70
|
+
"vue-tsc": "3.3.13"
|
|
71
|
+
},
|
|
72
|
+
"devEngines": {
|
|
73
|
+
"packageManager": {
|
|
74
|
+
"name": "pnpm",
|
|
75
|
+
"version": "11.22.0",
|
|
76
|
+
"onFail": "error"
|
|
77
|
+
}
|
|
64
78
|
}
|
|
65
79
|
}
|
|
@@ -17,7 +17,7 @@ export default defineConfig({
|
|
|
17
17
|
},
|
|
18
18
|
projects: [{ name: 'demo-chromium', use: { ...devices['Desktop Chrome'], launchOptions } }],
|
|
19
19
|
webServer: {
|
|
20
|
-
command: 'pnpm exec vite --mode demo --host 127.0.0.1 --port 4176 --strictPort',
|
|
20
|
+
command: 'pnpm exec vite --mode demo --force --host 127.0.0.1 --port 4176 --strictPort',
|
|
21
21
|
url: 'http://127.0.0.1:4176',
|
|
22
22
|
reuseExistingServer: false,
|
|
23
23
|
timeout: 120_000,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
allowBuilds:
|
|
2
|
+
'@parcel/watcher': true
|
|
3
|
+
esbuild: true
|
|
4
|
+
msw: false
|
|
5
|
+
vue-demi: true
|
|
6
|
+
|
|
7
|
+
strictPeerDependencies: true
|
|
8
|
+
|
|
9
|
+
overrides:
|
|
10
|
+
# The npm braces line has no published fixed release; use the maintained patched fork.
|
|
11
|
+
braces: npm:@zklogic/braces@3.0.7
|
|
12
|
+
dompurify: 3.4.14
|
|
13
|
+
fast-uri: 3.1.5
|
|
14
|
+
js-yaml: 4.3.1
|
|
15
|
+
source-map-js: 1.2.2
|
|
16
|
+
unplugin-element-plus>@nuxt/kit: 4.4.2
|
|
17
|
+
vitepress>@vue/shared: 3.5.44
|
|
18
|
+
vitepress>vue: 3.5.44
|
|
@@ -6,7 +6,11 @@ import process from 'node:process'
|
|
|
6
6
|
import { parse } from '@vue/compiler-sfc'
|
|
7
7
|
import ts from 'typescript'
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const rootFlagIndex = process.argv.indexOf('--root')
|
|
10
|
+
const root =
|
|
11
|
+
rootFlagIndex >= 0
|
|
12
|
+
? resolve(process.cwd(), process.argv[rootFlagIndex + 1] || '.')
|
|
13
|
+
: resolve(process.cwd())
|
|
10
14
|
const source = existsSync(join(root, 'apps', 'admin', 'scaffold', 'agent-contracts'))
|
|
11
15
|
? join(root, 'apps', 'admin', 'scaffold', 'agent-contracts')
|
|
12
16
|
: root
|
package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ElButton, ElResult } from 'element-plus'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
3
4
|
import { useRouter } from 'vue-router'
|
|
5
|
+
import { HOME_ROUTE } from '../../../router/paths'
|
|
4
6
|
|
|
5
7
|
defineOptions({ name: 'ForbiddenPage' })
|
|
6
8
|
|
|
7
9
|
const router = useRouter()
|
|
10
|
+
const { t } = useI18n()
|
|
8
11
|
</script>
|
|
9
12
|
|
|
10
13
|
<template>
|
|
11
14
|
<main class="error-page">
|
|
12
|
-
<ElResult icon="warning" title="
|
|
15
|
+
<ElResult icon="warning" :title="t('errors.forbidden.code')" :sub-title="t('errors.forbidden.message')">
|
|
13
16
|
<template #extra>
|
|
14
|
-
<ElButton type="primary" @click="router.push(
|
|
17
|
+
<ElButton type="primary" @click="router.push(HOME_ROUTE)">
|
|
18
|
+
{{ t('errors.forbidden.backHome') }}
|
|
19
|
+
</ElButton>
|
|
15
20
|
</template>
|
|
16
21
|
</ElResult>
|
|
17
22
|
</main>
|
package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ElButton, ElResult } from 'element-plus'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
3
4
|
import { useRouter } from 'vue-router'
|
|
5
|
+
import { HOME_ROUTE } from '../../../router/paths'
|
|
4
6
|
|
|
5
7
|
defineOptions({ name: 'NotFoundPage' })
|
|
6
8
|
|
|
7
9
|
const router = useRouter()
|
|
10
|
+
const { t } = useI18n()
|
|
8
11
|
</script>
|
|
9
12
|
|
|
10
13
|
<template>
|
|
11
14
|
<main class="error-page">
|
|
12
|
-
<ElResult icon="warning" title="
|
|
15
|
+
<ElResult icon="warning" :title="t('errors.notFound.code')" :sub-title="t('errors.notFound.message')">
|
|
13
16
|
<template #extra>
|
|
14
|
-
<ElButton type="primary" @click="router.push(
|
|
17
|
+
<ElButton type="primary" @click="router.push(HOME_ROUTE)">
|
|
18
|
+
{{ t('errors.notFound.backHome') }}
|
|
19
|
+
</ElButton>
|
|
15
20
|
</template>
|
|
16
21
|
</ElResult>
|
|
17
22
|
</main>
|
package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ElButton, ElResult } from 'element-plus'
|
|
3
|
+
import { useI18n } from 'vue-i18n'
|
|
3
4
|
import { useRouter } from 'vue-router'
|
|
5
|
+
import { HOME_ROUTE } from '../../../router/paths'
|
|
4
6
|
|
|
5
7
|
defineOptions({ name: 'ServerErrorPage' })
|
|
6
8
|
|
|
7
9
|
const router = useRouter()
|
|
10
|
+
const { t } = useI18n()
|
|
8
11
|
</script>
|
|
9
12
|
|
|
10
13
|
<template>
|
|
11
14
|
<main class="error-page">
|
|
12
|
-
<ElResult icon="error" title="
|
|
15
|
+
<ElResult icon="error" :title="t('errors.serverError.code')" :sub-title="t('errors.serverError.message')">
|
|
13
16
|
<template #extra>
|
|
14
|
-
<ElButton type="primary" @click="router.push(
|
|
17
|
+
<ElButton type="primary" @click="router.push(HOME_ROUTE)">
|
|
18
|
+
{{ t('errors.serverError.backHome') }}
|
|
19
|
+
</ElButton>
|
|
15
20
|
</template>
|
|
16
21
|
</ElResult>
|
|
17
22
|
</main>
|
package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils'
|
|
2
2
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import { createI18n } from 'vue-i18n'
|
|
4
|
+
import zhCN from '../../../locales/zh-CN.json'
|
|
5
|
+
import { HOME_ROUTE } from '../../../router/paths'
|
|
3
6
|
import Forbidden from './Forbidden.vue'
|
|
4
7
|
import NotFound from './NotFound.vue'
|
|
5
8
|
import ServerError from './ServerError.vue'
|
|
6
9
|
|
|
10
|
+
const i18n = createI18n({
|
|
11
|
+
legacy: false,
|
|
12
|
+
locale: 'zh-CN',
|
|
13
|
+
messages: { 'zh-CN': zhCN },
|
|
14
|
+
})
|
|
15
|
+
|
|
7
16
|
const { push } = vi.hoisted(() => ({
|
|
8
17
|
push: vi.fn(),
|
|
9
18
|
}))
|
|
@@ -22,11 +31,11 @@ describe('clean error page navigation', () => {
|
|
|
22
31
|
['404', NotFound],
|
|
23
32
|
['500', ServerError],
|
|
24
33
|
])('returns to the empty workspace from the %s page', async (_status, component) => {
|
|
25
|
-
const wrapper = mount(component)
|
|
34
|
+
const wrapper = mount(component, { global: { plugins: [i18n] } })
|
|
26
35
|
|
|
27
36
|
await wrapper.get('button').trigger('click')
|
|
28
37
|
|
|
29
38
|
expect(push).toHaveBeenCalledOnce()
|
|
30
|
-
expect(push).toHaveBeenCalledWith(
|
|
39
|
+
expect(push).toHaveBeenCalledWith(HOME_ROUTE)
|
|
31
40
|
})
|
|
32
41
|
})
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createApp } from 'vue'
|
|
2
2
|
import App from './App.vue'
|
|
3
|
+
import { translateAdminError } from './app/errorMessage'
|
|
3
4
|
import { permission } from './app/permission'
|
|
4
5
|
import { useAuthStore } from './features/auth/store/auth'
|
|
5
6
|
import { devtoolsProtection } from './features/security/devtoolsProtection'
|
|
7
|
+
import { translateAdminMessage } from './locales'
|
|
8
|
+
import { replaceDynamicMenusWithAccessibleFallback } from './router/dynamicMenuRefresh'
|
|
6
9
|
import { createRuntimeErrorRecovery, createStaleAssetRecovery } from './router/runtimeErrorRecovery'
|
|
7
10
|
import { pinia } from './store'
|
|
8
11
|
import 'element-plus/theme-chalk/src/tabs.scss'
|
|
@@ -46,43 +49,49 @@ async function bootstrap(): Promise<void> {
|
|
|
46
49
|
language.install(app)
|
|
47
50
|
const { createAdminUi } = await import('./app/createAdminUi')
|
|
48
51
|
app.use(createAdminUi(language))
|
|
52
|
+
// 唯一的 errorHandler 装配点:运行期错误统一走提示 + 陈旧资源/运行时恢复。
|
|
49
53
|
app.config.errorHandler = (error: unknown) => {
|
|
50
|
-
|
|
54
|
+
console.error('[admin] runtime error', error)
|
|
55
|
+
const message = translateAdminError(error, {
|
|
56
|
+
fallbackKey: 'common.errors.unknownPageError',
|
|
57
|
+
fallback: '页面发生未知错误',
|
|
58
|
+
})
|
|
51
59
|
void notifyRuntimeError(message)
|
|
60
|
+
if (!staleAssetRecovery.handle(error)) recoverRuntimeError()
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
const auth = useAuthStore(pinia)
|
|
55
64
|
const session = await auth.fetchSession()
|
|
56
65
|
app.use(routing)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
])
|
|
62
|
-
|
|
66
|
+
// 路由就绪是硬性等待;布局仅在登录态下并行预热。catch-tap 保证路由先失败
|
|
67
|
+
// 时预热 rejection 不会变成 unhandled——两个失败最终都按启动失败上报。
|
|
68
|
+
const layoutPreload = session ? import('./layouts/AdminLayout.vue') : undefined
|
|
69
|
+
layoutPreload?.catch(() => {})
|
|
70
|
+
await Promise.all([language.ready, routing.ready()])
|
|
71
|
+
await layoutPreload
|
|
63
72
|
const { authorizationRefreshKey } =
|
|
64
73
|
await import('./features/system/access/composables/useAuthorizationRefresh')
|
|
65
|
-
app.config.errorHandler = (error, instance, info) => {
|
|
66
|
-
reportRuntimeError?.(error, instance, info)
|
|
67
|
-
if (!staleAssetRecovery.handle(error)) recoverRuntimeError()
|
|
68
|
-
}
|
|
69
74
|
app.provide(authorizationRefreshKey, async () => {
|
|
70
75
|
await auth.refreshAuthorization()
|
|
71
|
-
await routing
|
|
76
|
+
await replaceDynamicMenusWithAccessibleFallback(routing)
|
|
72
77
|
})
|
|
73
78
|
app.mount('#app')
|
|
74
79
|
staleAssetRecovery.clear()
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
void bootstrap().catch((error: unknown) => {
|
|
78
|
-
|
|
83
|
+
console.error('[admin] startup failed', error)
|
|
84
|
+
const message = translateAdminError(error, {
|
|
85
|
+
fallbackKey: 'common.errors.startupFailed',
|
|
86
|
+
fallback: '应用启动失败',
|
|
87
|
+
})
|
|
79
88
|
const root = document.querySelector('#app')
|
|
80
89
|
if (root) {
|
|
81
90
|
const panel = document.createElement('main')
|
|
82
91
|
panel.style.padding = '32px'
|
|
83
92
|
panel.style.fontFamily = 'system-ui, sans-serif'
|
|
84
93
|
const heading = document.createElement('h1')
|
|
85
|
-
heading.textContent = '@origen-ui/admin 启动失败'
|
|
94
|
+
heading.textContent = `${'@origen-ui/admin'} ${translateAdminMessage('common.errors.startupFailed', { fallback: '启动失败' })}`
|
|
86
95
|
const detail = document.createElement('p')
|
|
87
96
|
detail.textContent = message
|
|
88
97
|
panel.append(heading, detail)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* componentKey → 页面组件 name 映射,用于生成 KeepAlive 缓存名单。
|
|
3
|
+
*
|
|
4
|
+
* KeepAlive 的 `:include` 匹配的是页面组件渲染后的 name(SFC `defineOptions({ name })`),
|
|
5
|
+
* 因此这里的值必须与各页面组件的 defineOptions name 完全一致,否则缓存失效。
|
|
6
|
+
* 修改组件 name 时必须同步更新此表,并保持 dynamicRoutes.spec.ts 断言一致。
|
|
7
|
+
*/
|
|
8
|
+
export const componentCacheNames: Readonly<Record<string, string>> = {
|
|
9
|
+
workspace: 'EmptyPage',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const fallbackComponentKey = 'workspace'
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import type { Component } from 'vue'
|
|
2
2
|
import { RouterViewHost } from '@origen-ui/router'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* componentKey → 页面组件 name 映射,用于生成 KeepAlive 缓存名单。
|
|
8
|
-
*
|
|
9
|
-
* KeepAlive 的 `:include` 匹配的是页面组件渲染后的 name(SFC `defineOptions({ name })`),
|
|
10
|
-
* 因此这里的值必须与各页面组件的 defineOptions name 完全一致,否则缓存失效。
|
|
11
|
-
* 修改组件 name 时必须同步更新此表,并保持 dynamicRoutes.spec.ts 断言一致。
|
|
12
|
-
*/
|
|
13
|
-
export const componentCacheNames: Readonly<Record<string, string>> = {
|
|
14
|
-
workspace: 'EmptyPage',
|
|
15
|
-
}
|
|
4
|
+
export { componentCacheNames, fallbackComponentKey } from './componentCache'
|
|
16
5
|
|
|
17
|
-
|
|
6
|
+
type ComponentLoader = () => Promise<Component>
|
|
18
7
|
|
|
19
8
|
export const componentRegistry: Map<string, ComponentLoader> = new Map([
|
|
20
9
|
[
|