@origen-ui/admin-cli 1.0.3 → 1.1.0

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.
Files changed (163) hide show
  1. package/package.json +3 -3
  2. package/templates/current/clean/CHANGELOG.md +34 -0
  3. package/templates/current/clean/component-catalog.json +9 -9
  4. package/templates/current/clean/package.json +41 -41
  5. package/templates/current/clean/scaffold.lock.json +2 -2
  6. package/templates/current/clean/scripts/vite-build-policy.spec.ts +71 -0
  7. package/templates/current/clean/src/App.vue +10 -3
  8. package/templates/current/clean/src/api/client.ts +90 -10
  9. package/templates/current/clean/src/api/generated/data-contracts.ts +3 -3
  10. package/templates/current/clean/src/api/generated/http-client.ts +1 -1
  11. 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 +1 -1
  12. 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 -1
  13. 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 +1 -1
  14. 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 +2 -3
  15. 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 +3 -5
  16. 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 +2 -3
  17. 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 +2 -3
  18. package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +1 -1
  19. package/templates/current/clean/src/app/adminLocale.ts +90 -0
  20. package/templates/current/clean/src/app/createAdminUi.spec.ts +65 -9
  21. package/templates/current/clean/src/app/createAdminUi.ts +14 -29
  22. package/templates/current/clean/src/app/embedded-token.spec.ts +40 -0
  23. package/templates/current/clean/src/app/embedded.spec.ts +135 -0
  24. package/templates/current/clean/src/app/embedded.ts +255 -0
  25. package/templates/current/clean/src/app/localeFormat.ts +52 -0
  26. package/templates/current/clean/src/app/menu.spec.ts +26 -0
  27. package/templates/current/clean/src/app/menu.ts +4 -0
  28. package/templates/current/clean/src/app/menuTypes.ts +1 -0
  29. package/templates/current/clean/src/app/origenUiLocale.spec.ts +6 -5
  30. package/templates/current/clean/src/app/origenUiLocale.ts +3 -58
  31. package/templates/current/clean/src/app/permission.spec.ts +26 -0
  32. package/templates/current/clean/src/app/runtimeConfig.ts +8 -7
  33. package/templates/current/clean/src/env.d.ts +18 -0
  34. package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +21 -17
  35. package/templates/current/clean/src/features/appearance/store/theme.ts +2 -1
  36. package/templates/current/clean/src/features/auth/pages/Login.vue +15 -11
  37. package/templates/current/clean/src/features/auth/store/auth.ts +13 -3
  38. package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
  39. package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +7 -10
  40. package/templates/current/clean/src/features/security/devtoolsProtection.ts +2 -1
  41. package/templates/current/clean/src/features/system/access/api/admin-repository.spec.ts +14 -0
  42. package/templates/current/clean/src/features/system/access/api/admin-repository.ts +38 -15
  43. package/templates/current/clean/src/features/system/access/api/rbac.ts +37 -27
  44. package/templates/current/clean/src/features/workspace/pages/Empty.vue +4 -1
  45. package/templates/current/clean/src/features/workspace/pages/Profile.vue +13 -11
  46. package/templates/current/clean/src/layouts/AdminLayout.vue +3 -1
  47. package/templates/current/clean/src/layouts/TopBar.vue +26 -8
  48. package/templates/current/clean/src/locales/en-US.json +490 -0
  49. package/templates/current/clean/src/locales/en-US.runtime.ts +20 -0
  50. package/templates/current/clean/src/locales/index.ts +129 -45
  51. package/templates/current/clean/src/locales/messages-types.ts +62 -0
  52. package/templates/current/clean/src/locales/messages.spec.ts +113 -6
  53. package/templates/current/clean/src/locales/vue-i18n.d.ts +5 -0
  54. package/templates/current/clean/src/locales/zh-CN.json +490 -0
  55. package/templates/current/clean/src/locales/zh-CN.runtime.ts +20 -0
  56. package/templates/current/clean/src/locales/zh-TW.json +490 -0
  57. package/templates/current/clean/src/locales/zh-TW.runtime.ts +20 -0
  58. package/templates/current/clean/src/router/bootstrap.ts +22 -7
  59. package/templates/current/clean/src/router/dynamicRoutes.ts +5 -1
  60. package/templates/current/clean/src/router/queryEncryption.spec.ts +30 -4
  61. package/templates/current/clean/src/router/queryEncryption.ts +48 -44
  62. package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +2 -1
  63. package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +2 -1
  64. package/templates/current/clean/src/templates/og-table.ts +81 -37
  65. package/templates/current/clean/src/templates/templates.spec.ts +19 -0
  66. package/templates/current/clean/vite.build-policy.ts +114 -289
  67. package/templates/current/clean/vite.config.ts +4 -5
  68. package/templates/current/examples/CHANGELOG.md +34 -0
  69. package/templates/current/examples/component-catalog.json +9 -9
  70. package/templates/current/examples/package.json +41 -41
  71. package/templates/current/examples/scaffold.lock.json +2 -2
  72. package/templates/current/examples/scripts/vite-build-policy.spec.ts +71 -0
  73. package/templates/current/examples/src/App.vue +10 -3
  74. package/templates/current/examples/src/api/client.ts +90 -10
  75. package/templates/current/examples/src/api/generated/data-contracts.ts +3 -3
  76. package/templates/current/examples/src/api/generated/http-client.ts +1 -1
  77. 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 +1 -1
  78. 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 -1
  79. 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 +1 -1
  80. 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 +2 -3
  81. 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 +3 -5
  82. 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 +2 -3
  83. 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 +2 -3
  84. package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +1 -1
  85. package/templates/current/examples/src/app/adminLocale.ts +90 -0
  86. package/templates/current/examples/src/app/createAdminUi.spec.ts +65 -9
  87. package/templates/current/examples/src/app/createAdminUi.ts +14 -29
  88. package/templates/current/examples/src/app/embedded-token.spec.ts +40 -0
  89. package/templates/current/examples/src/app/embedded.spec.ts +135 -0
  90. package/templates/current/examples/src/app/embedded.ts +255 -0
  91. package/templates/current/examples/src/app/localeFormat.ts +52 -0
  92. package/templates/current/examples/src/app/menu.spec.ts +26 -0
  93. package/templates/current/examples/src/app/menu.ts +4 -0
  94. package/templates/current/examples/src/app/menuTypes.ts +1 -0
  95. package/templates/current/examples/src/app/origenUiLocale.spec.ts +6 -5
  96. package/templates/current/examples/src/app/origenUiLocale.ts +3 -58
  97. package/templates/current/examples/src/app/permission.spec.ts +26 -0
  98. package/templates/current/examples/src/app/runtimeConfig.ts +8 -7
  99. package/templates/current/examples/src/env.d.ts +18 -0
  100. package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +21 -17
  101. package/templates/current/examples/src/features/appearance/store/theme.ts +2 -1
  102. package/templates/current/examples/src/features/auth/pages/Login.vue +15 -11
  103. package/templates/current/examples/src/features/auth/store/auth.ts +13 -3
  104. package/templates/current/examples/src/features/errors/pages/Forbidden.vue +6 -2
  105. package/templates/current/examples/src/features/errors/pages/NotFound.vue +6 -2
  106. package/templates/current/examples/src/features/errors/pages/ServerError.vue +6 -2
  107. package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +9 -1
  108. package/templates/current/examples/src/features/feature-composables.spec.ts +36 -9
  109. package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
  110. package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +7 -10
  111. package/templates/current/examples/src/features/security/devtoolsProtection.ts +2 -1
  112. package/templates/current/examples/src/features/system/access/api/admin-repository.spec.ts +14 -0
  113. package/templates/current/examples/src/features/system/access/api/admin-repository.ts +38 -15
  114. package/templates/current/examples/src/features/system/access/api/rbac.ts +37 -27
  115. package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +43 -38
  116. package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +33 -30
  117. package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +81 -69
  118. package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +3 -1
  119. package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +18 -15
  120. package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +49 -53
  121. package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +3 -1
  122. package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +22 -19
  123. package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +59 -64
  124. package/templates/current/examples/src/features/system/users/pages/UserList.vue +3 -1
  125. package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +9 -0
  126. package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +54 -26
  127. package/templates/current/examples/src/features/workspace/pages/Empty.vue +4 -1
  128. package/templates/current/examples/src/features/workspace/pages/Profile.vue +13 -11
  129. package/templates/current/examples/src/layouts/AdminLayout.vue +3 -1
  130. package/templates/current/examples/src/layouts/TopBar.vue +26 -8
  131. package/templates/current/examples/src/locales/en-US.json +490 -0
  132. package/templates/current/examples/src/locales/en-US.runtime.ts +20 -0
  133. package/templates/current/examples/src/locales/index.ts +129 -45
  134. package/templates/current/examples/src/locales/messages-types.ts +62 -0
  135. package/templates/current/examples/src/locales/messages.spec.ts +113 -6
  136. package/templates/current/examples/src/locales/vue-i18n.d.ts +5 -0
  137. package/templates/current/examples/src/locales/zh-CN.json +490 -0
  138. package/templates/current/examples/src/locales/zh-CN.runtime.ts +20 -0
  139. package/templates/current/examples/src/locales/zh-TW.json +490 -0
  140. package/templates/current/examples/src/locales/zh-TW.runtime.ts +20 -0
  141. package/templates/current/examples/src/main.ts +31 -5
  142. package/templates/current/examples/src/router/bootstrap.ts +22 -7
  143. package/templates/current/examples/src/router/dynamicRoutes.spec.ts +17 -0
  144. package/templates/current/examples/src/router/dynamicRoutes.ts +5 -1
  145. package/templates/current/examples/src/router/queryEncryption.spec.ts +30 -4
  146. package/templates/current/examples/src/router/queryEncryption.ts +48 -44
  147. package/templates/current/examples/src/router/staticRoutes.ts +1 -1
  148. package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +2 -1
  149. package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +2 -1
  150. package/templates/current/examples/src/templates/og-table.ts +81 -37
  151. package/templates/current/examples/src/templates/templates.spec.ts +19 -0
  152. package/templates/current/examples/vite.build-policy.ts +114 -289
  153. package/templates/current/examples/vite.config.ts +4 -5
  154. package/templates/current/clean/scripts/check-admin-bundle.mjs +0 -214
  155. package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
  156. package/templates/current/clean/src/locales/en-US.ts +0 -55
  157. package/templates/current/clean/src/locales/zh-CN.ts +0 -55
  158. package/templates/current/clean/src/locales/zh-TW.ts +0 -44
  159. package/templates/current/examples/scripts/check-admin-bundle.mjs +0 -214
  160. package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
  161. package/templates/current/examples/src/locales/en-US.ts +0 -55
  162. package/templates/current/examples/src/locales/zh-CN.ts +0 -55
  163. package/templates/current/examples/src/locales/zh-TW.ts +0 -44
@@ -5,6 +5,32 @@ import { fetchMenus, parseMenuResponse } from './menu'
5
5
  const timestamps = { createdAt: '2026-01-01T00:00:00.000Z', updatedAt: '2026-01-01T00:00:00.000Z' }
6
6
 
7
7
  describe('parseMenuResponse', () => {
8
+ it('preserves an optional titleKey on backend menu nodes', () => {
9
+ expect(
10
+ parseMenuResponse([
11
+ { code: 'dashboard', path: '/dashboard', title: 'Dashboard', titleKey: 'menu.dashboard' },
12
+ ]),
13
+ ).toEqual([
14
+ {
15
+ code: 'dashboard',
16
+ path: '/dashboard',
17
+ title: 'Dashboard',
18
+ titleKey: 'menu.dashboard',
19
+ componentKey: undefined,
20
+ icon: undefined,
21
+ permissions: undefined,
22
+ parentPath: undefined,
23
+ menu: undefined,
24
+ hidden: undefined,
25
+ order: undefined,
26
+ cache: undefined,
27
+ tabHidden: undefined,
28
+ redirect: undefined,
29
+ children: undefined,
30
+ },
31
+ ])
32
+ })
33
+
8
34
  it('maps a paged RBAC response into runtime menu nodes', () => {
9
35
  const menus = parseMenuResponse({
10
36
  list: [
@@ -43,6 +43,7 @@ function readNode(value: unknown, index: string): BackendMenuNode {
43
43
  code: value.code,
44
44
  path: value.path,
45
45
  title: value.title,
46
+ ...(typeof value.titleKey === 'string' && value.titleKey ? { titleKey: value.titleKey } : {}),
46
47
  componentKey: typeof value.componentKey === 'string' ? value.componentKey : undefined,
47
48
  icon: typeof value.icon === 'string' ? value.icon : undefined,
48
49
  permissions: Array.isArray(value.permissions)
@@ -71,6 +72,7 @@ interface RbacMenuNode {
71
72
  kind: RbacMenuKind
72
73
  code: string
73
74
  title: string
75
+ titleKey?: string
74
76
  path?: string
75
77
  componentKey?: string
76
78
  icon?: string
@@ -118,6 +120,7 @@ function readRbacMenuNode(value: unknown, index: string): RbacMenuNode {
118
120
  kind,
119
121
  code: value.code,
120
122
  title: value.title,
123
+ titleKey: typeof value.titleKey === 'string' && value.titleKey ? value.titleKey : undefined,
121
124
  path: value.path,
122
125
  componentKey: typeof value.componentKey === 'string' ? value.componentKey : undefined,
123
126
  icon: typeof value.icon === 'string' ? value.icon : undefined,
@@ -183,6 +186,7 @@ function parseRbacMenuPage(value: Record<string, unknown>): readonly BackendMenu
183
186
  code: menu.code,
184
187
  path: menu.path,
185
188
  title: menu.title,
189
+ ...(menu.titleKey ? { titleKey: menu.titleKey } : {}),
186
190
  componentKey: menu.componentKey,
187
191
  icon: menu.icon,
188
192
  permissions: menu.permission ? [menu.permission] : undefined,
@@ -3,6 +3,7 @@ export interface BackendMenuNode {
3
3
  code: string
4
4
  path: string
5
5
  title: string
6
+ titleKey?: string
6
7
  componentKey?: string
7
8
  icon?: string
8
9
  permissions?: readonly string[]
@@ -1,14 +1,15 @@
1
1
  import { describe, expect, it } from 'vitest'
2
- import { resolveAdminLocale, resolveAdminOrigenUiLocale } from './origenUiLocale'
2
+ import { resolveAdminLocale } from './origenUiLocale'
3
3
 
4
- describe('admin Origen UI locale', () => {
5
- it('resolves zh-CN and en-US for every component namespace', () => {
4
+ describe('admin locale resolution', () => {
5
+ it('keeps the supported application locales', () => {
6
6
  expect(resolveAdminLocale('zh-CN')).toBe('zh-CN')
7
- expect(resolveAdminOrigenUiLocale('zh-CN').tabs?.close).toBe('关闭页签')
8
- expect(resolveAdminOrigenUiLocale('en-US').tabs?.close).toBe('Close tab')
7
+ expect(resolveAdminLocale('en-US')).toBe('en-US')
8
+ expect(resolveAdminLocale('zh-TW')).toBe('zh-TW')
9
9
  })
10
10
 
11
11
  it('falls back unknown locales to zh-CN', () => {
12
12
  expect(resolveAdminLocale('fr-FR')).toBe('zh-CN')
13
+ expect(resolveAdminLocale(undefined)).toBe('zh-CN')
13
14
  })
14
15
  })
@@ -1,65 +1,10 @@
1
- import type { DeepPartial } from '@origen-ui/shared'
2
- import type { OrigenUiMessages } from 'origen-ui'
3
- import {
4
- OG_DIALOG_LOCALE_EN_US,
5
- OG_DIALOG_LOCALE_ZH_CN,
6
- OG_DIALOG_LOCALE_ZH_TW,
7
- } from '@origen-ui/dialog/runtime'
8
- import {
9
- OG_FORM_LOCALE_EN_US,
10
- OG_FORM_LOCALE_ZH_CN,
11
- OG_FORM_LOCALE_ZH_TW,
12
- } from '@origen-ui/form/runtime'
13
- import {
14
- OG_SEARCH_LOCALE_EN_US,
15
- OG_SEARCH_LOCALE_ZH_CN,
16
- OG_SEARCH_LOCALE_ZH_TW,
17
- } from '@origen-ui/search/runtime'
18
- import {
19
- OG_TABLE_LOCALE_EN_US,
20
- OG_TABLE_LOCALE_ZH_CN,
21
- OG_TABLE_LOCALE_ZH_TW,
22
- } from '@origen-ui/table/runtime'
23
- import {
24
- OG_TABS_LOCALE_EN_US,
25
- OG_TABS_LOCALE_ZH_CN,
26
- OG_TABS_LOCALE_ZH_TW,
27
- } from '@origen-ui/tabs/runtime'
1
+ import type { AdminLocale } from './adminLocale'
28
2
 
29
- export type AdminLocale = 'zh-CN' | 'en-US' | 'zh-TW'
30
- export type OrigenUiLocaleBundle = DeepPartial<OrigenUiMessages>
3
+ export type { AdminLocale } from './adminLocale'
31
4
 
32
- /** Resolves every component namespace from the same locale selected for vue-i18n. */
5
+ /** Resolves the application locale selected for vue-i18n and the Origen UI language runtime. */
33
6
  export function resolveAdminLocale(locale: string | undefined): AdminLocale {
34
7
  if (locale === 'en-US') return 'en-US'
35
8
  if (locale === 'zh-TW') return 'zh-TW'
36
9
  return 'zh-CN'
37
10
  }
38
-
39
- export function resolveAdminOrigenUiLocale(locale: string | undefined): OrigenUiLocaleBundle {
40
- if (resolveAdminLocale(locale) === 'en-US') {
41
- return {
42
- dialog: OG_DIALOG_LOCALE_EN_US,
43
- form: OG_FORM_LOCALE_EN_US,
44
- search: OG_SEARCH_LOCALE_EN_US,
45
- table: OG_TABLE_LOCALE_EN_US,
46
- tabs: OG_TABS_LOCALE_EN_US,
47
- }
48
- }
49
- if (resolveAdminLocale(locale) === 'zh-TW') {
50
- return {
51
- dialog: OG_DIALOG_LOCALE_ZH_TW,
52
- form: OG_FORM_LOCALE_ZH_TW,
53
- search: OG_SEARCH_LOCALE_ZH_TW,
54
- table: OG_TABLE_LOCALE_ZH_TW,
55
- tabs: OG_TABS_LOCALE_ZH_TW,
56
- }
57
- }
58
- return {
59
- dialog: OG_DIALOG_LOCALE_ZH_CN,
60
- form: OG_FORM_LOCALE_ZH_CN,
61
- search: OG_SEARCH_LOCALE_ZH_CN,
62
- table: OG_TABLE_LOCALE_ZH_CN,
63
- tabs: OG_TABS_LOCALE_ZH_CN,
64
- }
65
- }
@@ -0,0 +1,26 @@
1
+ import { setActivePinia } from 'pinia'
2
+ import { beforeEach, describe, expect, it } from 'vitest'
3
+ import { useAuthStore } from '../features/auth/store/auth'
4
+ import { pinia } from '../store'
5
+ import { permission } from './permission'
6
+
7
+ describe('admin permission runtime', () => {
8
+ beforeEach(() => {
9
+ // runtime 实例在 app.use(pinia) 之前创建,因此不能读取激活的 Pinia 实例。
10
+ setActivePinia(undefined)
11
+ useAuthStore(pinia).$reset()
12
+ })
13
+
14
+ it('reads permissions from the explicit application Pinia instance before installation', () => {
15
+ useAuthStore(pinia).session = {
16
+ token: 'test-token',
17
+ user: { id: '1', username: 'admin', displayName: 'Admin' },
18
+ permissions: ['system:users:read'],
19
+ roleIds: [],
20
+ authorizationRevision: 3,
21
+ }
22
+
23
+ expect(permission.can('system:users:read')).toBe(true)
24
+ expect(permission.can('system:users:write')).toBe(false)
25
+ })
26
+ })
@@ -3,8 +3,12 @@ import type { OgFormGlobalConfig } from '@origen-ui/form'
3
3
  import type { OgSearchGlobalConfig } from '@origen-ui/search'
4
4
  import type { CreateOgTableOptions } from '@origen-ui/table'
5
5
  import type { OgTabsGlobalConfig } from '@origen-ui/tabs'
6
- import type { OrigenUiLocaleBundle } from './origenUiLocale'
7
- import { resolveAdminLocale, resolveAdminOrigenUiLocale } from './origenUiLocale'
6
+
7
+ function resolveConfiguredLocale(locale: string | undefined): 'zh-CN' | 'en-US' | 'zh-TW' {
8
+ if (locale === 'en-US') return 'en-US'
9
+ if (locale === 'zh-TW') return 'zh-TW'
10
+ return 'zh-CN'
11
+ }
8
12
 
9
13
  export interface AdminRuntimeConfig {
10
14
  http: {
@@ -20,11 +24,10 @@ export interface AdminRuntimeConfig {
20
24
  csrfHeaderName: string
21
25
  refreshBusinessCodes: readonly number[]
22
26
  }
23
- locale: { default: 'zh-CN' | 'en-US' | 'zh-TW', fallback: 'zh-CN' | 'en-US' | 'zh-TW' }
27
+ locale: { default: 'zh-CN' | 'en-US' | 'zh-TW' }
24
28
  router: { workspace: { enabled: boolean, key: string, scope: string, version: number } }
25
29
  origenUi: {
26
30
  size: 'small' | 'default' | 'large'
27
- locale: OrigenUiLocaleBundle
28
31
  dialog: CreateOgDialogOptions
29
32
  form: OgFormGlobalConfig
30
33
  search: OgSearchGlobalConfig
@@ -33,7 +36,7 @@ export interface AdminRuntimeConfig {
33
36
  }
34
37
  }
35
38
 
36
- const configuredLocale = resolveAdminLocale(import.meta.env.VITE_DEFAULT_LOCALE)
39
+ const configuredLocale = resolveConfiguredLocale(import.meta.env.VITE_DEFAULT_LOCALE)
37
40
 
38
41
  export const appRuntimeConfig: AdminRuntimeConfig = {
39
42
  http: {
@@ -51,7 +54,6 @@ export const appRuntimeConfig: AdminRuntimeConfig = {
51
54
  },
52
55
  locale: {
53
56
  default: configuredLocale,
54
- fallback: 'en-US',
55
57
  },
56
58
  router: {
57
59
  workspace: {
@@ -63,7 +65,6 @@ export const appRuntimeConfig: AdminRuntimeConfig = {
63
65
  },
64
66
  origenUi: {
65
67
  size: 'default',
66
- locale: resolveAdminOrigenUiLocale(configuredLocale),
67
68
  dialog: {},
68
69
  form: {},
69
70
  search: {},
@@ -7,8 +7,26 @@ interface ImportMetaEnv {
7
7
  readonly VITE_DEMO_LOGIN_HINT?: string
8
8
  readonly VITE_ROUTE_QUERY_ENCRYPTION?: string
9
9
  readonly VITE_ROUTE_QUERY_KEY?: string
10
+ /** 'true' 时意图进入微前端嵌入模式(仍需运行时探测主壳环境,见 app/embedded.ts) */
11
+ readonly VITE_EMBEDDED?: string
10
12
  }
11
13
 
12
14
  interface ImportMeta {
13
15
  readonly env: ImportMetaEnv
14
16
  }
17
+
18
+ /** micro-app 子应用注入环境(app/embedded.ts 探测与桥接使用) */
19
+ interface MicroAppChildEnv {
20
+ __MICRO_APP_ENVIRONMENT__?: boolean
21
+ __MICRO_APP_NAME__?: string
22
+ microApp?: {
23
+ getData?: () => Record<string, unknown>
24
+ addDataListener?: (
25
+ callback: (data: Record<string, unknown>) => void,
26
+ autoTrigger?: boolean,
27
+ ) => void
28
+ dispatch?: (data: Record<string, unknown>) => void
29
+ }
30
+ }
31
+
32
+ interface Window extends MicroAppChildEnv {}
@@ -3,6 +3,8 @@ import type { Component } from 'vue'
3
3
  import type { ThemeMode } from '../store/theme'
4
4
  import { Check, Monitor, Moon, Sunny } from '@element-plus/icons-vue'
5
5
  import { ElColorPicker, ElDropdownItem, ElDropdownMenu, ElIcon } from 'element-plus'
6
+ import { computed } from 'vue'
7
+ import { useI18n } from 'vue-i18n'
6
8
  import { useTheme } from '../composables/useTheme'
7
9
 
8
10
  defineOptions({ name: 'ThemePanel' })
@@ -13,19 +15,21 @@ interface ThemeModeOption {
13
15
  icon: Component
14
16
  }
15
17
 
16
- const modeOptions: ThemeModeOption[] = [
17
- { value: 'light', label: '浅色', icon: Sunny },
18
- { value: 'dark', label: '深色', icon: Moon },
19
- { value: 'auto', label: '跟随系统', icon: Monitor },
20
- ]
18
+ const { t } = useI18n()
21
19
 
22
- const primaryPresets = [
23
- { label: '靛青', value: '#5E6AD2' },
24
- { label: '蓝色', value: '#2563EB' },
25
- { label: '青绿', value: '#0F766E' },
26
- { label: '玫红', value: '#DB2777' },
27
- { label: '琥珀', value: '#D97706' },
28
- ]
20
+ const modeOptions = computed<ThemeModeOption[]>(() => [
21
+ { value: 'light', label: t('appearance.light'), icon: Sunny },
22
+ { value: 'dark', label: t('appearance.dark'), icon: Moon },
23
+ { value: 'auto', label: t('appearance.system'), icon: Monitor },
24
+ ])
25
+
26
+ const primaryPresets = computed(() => [
27
+ { label: t('appearance.presetIndigo'), value: '#5E6AD2' },
28
+ { label: t('appearance.presetBlue'), value: '#2563EB' },
29
+ { label: t('appearance.presetTeal'), value: '#0F766E' },
30
+ { label: t('appearance.presetRose'), value: '#DB2777' },
31
+ { label: t('appearance.presetAmber'), value: '#D97706' },
32
+ ])
29
33
 
30
34
  const { mode, primary, setMode, setPrimary } = useTheme()
31
35
  </script>
@@ -33,7 +37,7 @@ const { mode, primary, setMode, setPrimary } = useTheme()
33
37
  <template>
34
38
  <ElDropdownMenu class="theme-panel">
35
39
  <ElDropdownItem class="theme-panel__section" disabled>
36
- <span>主题模式</span>
40
+ <span>{{ t('appearance.theme') }}</span>
37
41
  </ElDropdownItem>
38
42
  <ElDropdownItem
39
43
  v-for="option in modeOptions"
@@ -53,8 +57,8 @@ const { mode, primary, setMode, setPrimary } = useTheme()
53
57
 
54
58
  <li class="theme-panel__separator" aria-hidden="true" />
55
59
  <li class="theme-panel__primary">
56
- <span class="theme-panel__section-label">主色</span>
57
- <div class="theme-panel__swatches" aria-label="主色预设">
60
+ <span class="theme-panel__section-label">{{ t('appearance.primaryColor') }}</span>
61
+ <div class="theme-panel__swatches" :aria-label="t('appearance.primaryPresets')">
58
62
  <button
59
63
  v-for="preset in primaryPresets"
60
64
  :key="preset.value"
@@ -62,7 +66,7 @@ const { mode, primary, setMode, setPrimary } = useTheme()
62
66
  class="theme-panel__swatch"
63
67
  :class="{ 'is-active': primary === preset.value }"
64
68
  :style="{ backgroundColor: preset.value }"
65
- :aria-label="`使用${preset.label}主色`"
69
+ :aria-label="t('appearance.usePrimary', { color: preset.label })"
66
70
  :aria-pressed="primary === preset.value"
67
71
  @click.stop="setPrimary(preset.value)"
68
72
  >
@@ -73,7 +77,7 @@ const { mode, primary, setMode, setPrimary } = useTheme()
73
77
  </div>
74
78
  </li>
75
79
  <li class="theme-panel__custom">
76
- <span>自定义</span>
80
+ <span>{{ t('appearance.custom') }}</span>
77
81
  <div class="theme-panel__picker">
78
82
  <ElColorPicker
79
83
  :model-value="primary"
@@ -1,6 +1,7 @@
1
+ import type { PrimaryPalette } from '../../../utils/color-mix'
1
2
  import { defineStore } from 'pinia'
2
3
  import { computed, shallowRef } from 'vue'
3
- import { derivePrimaryPalette, type PrimaryPalette } from '../../../utils/color-mix'
4
+ import { derivePrimaryPalette } from '../../../utils/color-mix'
4
5
 
5
6
  const STORAGE_KEY = 'og-admin-theme'
6
7
 
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { ElAlert, ElButton, ElCard, ElForm, ElFormItem, ElInput } from 'element-plus'
3
3
  import { reactive, shallowRef } from 'vue'
4
+ import { useI18n } from 'vue-i18n'
4
5
  import { useRoute, useRouter } from 'vue-router'
5
6
  import { useAuthStore } from '../store/auth'
6
7
 
@@ -8,6 +9,7 @@ defineOptions({ name: 'LoginPage' })
8
9
  const auth = useAuthStore()
9
10
  const route = useRoute()
10
11
  const router = useRouter()
12
+ const { t } = useI18n()
11
13
  const loading = shallowRef(false)
12
14
  const errorMessage = shallowRef('')
13
15
  const form = reactive({ username: '', password: '' })
@@ -15,7 +17,7 @@ const demoLoginHint = import.meta.env.VITE_DEMO_LOGIN_HINT
15
17
 
16
18
  async function submit(): Promise<void> {
17
19
  if (!form.username || !form.password) {
18
- errorMessage.value = '请输入账号和密码'
20
+ errorMessage.value = t('auth.requiredCredentials')
19
21
  return
20
22
  }
21
23
  loading.value = true
@@ -25,7 +27,7 @@ async function submit(): Promise<void> {
25
27
  const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : '/dashboard'
26
28
  await router.push(redirect)
27
29
  } catch (error: unknown) {
28
- errorMessage.value = error instanceof Error ? error.message : '登录失败,请稍后重试'
30
+ errorMessage.value = error instanceof Error ? error.message : t('auth.loginFailed')
29
31
  } finally {
30
32
  loading.value = false
31
33
  }
@@ -38,10 +40,10 @@ async function submit(): Promise<void> {
38
40
  <div class="login-card__intro">
39
41
  <div class="login-card__mark">HS</div>
40
42
  <p class="login-card__eyebrow">@origen-ui Admin</p>
41
- <h1>欢迎回来</h1>
42
- <p>登录控制台,管理你的业务工作区。</p>
43
+ <h1>{{ t('workspace.welcome') }}</h1>
44
+ <p>{{ t('auth.signInDescription') }}</p>
43
45
  </div>
44
- <p v-if="demoLoginHint" class="login-card__hint">演示账号:{{ demoLoginHint }}</p>
46
+ <p v-if="demoLoginHint" class="login-card__hint">{{ t('auth.demoHint') }}:{{ demoLoginHint }}</p>
45
47
  <ElAlert
46
48
  v-if="errorMessage"
47
49
  class="login-card__alert"
@@ -49,27 +51,29 @@ async function submit(): Promise<void> {
49
51
  type="error"
50
52
  :closable="false"
51
53
  />
52
- <ElForm label-position="top" @submit.prevent="submit">
53
- <ElFormItem label="账号">
54
+ <ElForm :model="form" label-position="top" @submit.prevent="submit">
55
+ <ElFormItem prop="username" :label="t('auth.username')">
54
56
  <ElInput
57
+ id="username"
55
58
  v-model="form.username"
56
59
  autocomplete="username"
57
- placeholder="请输入账号"
60
+ :placeholder="t('auth.usernamePlaceholder')"
58
61
  @keyup.enter="submit"
59
62
  />
60
63
  </ElFormItem>
61
- <ElFormItem label="密码">
64
+ <ElFormItem prop="password" :label="t('auth.password')">
62
65
  <ElInput
66
+ id="password"
63
67
  v-model="form.password"
64
68
  type="password"
65
69
  show-password
66
70
  autocomplete="current-password"
67
- placeholder="请输入密码"
71
+ :placeholder="t('auth.passwordPlaceholder')"
68
72
  @keyup.enter="submit"
69
73
  />
70
74
  </ElFormItem>
71
75
  <ElButton class="login-card__submit" type="primary" :loading="loading" @click="submit">
72
- 登录
76
+ {{ t('auth.login') }}
73
77
  </ElButton>
74
78
  </ElForm>
75
79
  </ElCard>
@@ -1,9 +1,19 @@
1
1
  import type { ApiBusinessError } from '@origen-ui/http'
2
2
  import type { Permission } from '@origen-ui/shared'
3
+ import type { AdminMessageKey } from '../../../locales'
3
4
  import { ApiBusinessError as ApiBusinessErrorClass } from '@origen-ui/http'
4
5
  import { hasCodePermission } from '@origen-ui/permission/codes'
5
6
  import { defineStore } from 'pinia'
6
7
  import { apiClient, tokenManager } from '../../../api/client'
8
+ import { getAdminI18n } from '../../../locales'
9
+
10
+ function translate(key: string): string {
11
+ const global = getAdminI18n()?.global as unknown as
12
+ | { te?: (key: string) => boolean, t: (key: string) => string } |
13
+ undefined
14
+ if (!global) return key
15
+ return global.te?.(key) ? global.t(key as AdminMessageKey) : key
16
+ }
7
17
 
8
18
  export interface AdminUser {
9
19
  id: string
@@ -101,7 +111,7 @@ function cacheProfile(session: AdminSession): void {
101
111
  }
102
112
 
103
113
  function parseLoginPayload(value: unknown): LoginPayload {
104
- if (!isRecord(value)) throw new Error('登录响应格式无效')
114
+ if (!isRecord(value)) throw new Error(translate('auth.invalidResponse'))
105
115
  return {
106
116
  token: readString(value.token),
107
117
  accessToken: readString(value.accessToken),
@@ -129,7 +139,7 @@ function parseProfile(value: unknown, fallbackUsername: string): Omit<AdminSessi
129
139
 
130
140
  function errorMessage(error: unknown): string {
131
141
  if (error instanceof ApiBusinessErrorClass || error instanceof Error) return error.message
132
- return '请求失败'
142
+ return translate('auth.requestFailed')
133
143
  }
134
144
 
135
145
  export const useAuthStore = defineStore('admin-auth', {
@@ -152,7 +162,7 @@ export const useAuthStore = defineStore('admin-auth', {
152
162
  })
153
163
  const payload = parseLoginPayload(response)
154
164
  const token = payload.accessToken ?? payload.token
155
- if (!token) throw new Error('登录响应缺少访问令牌')
165
+ if (!token) throw new Error(translate('auth.missingToken'))
156
166
  const session: AdminSession = {
157
167
  token,
158
168
  user: normalizeUser(payload.user, credentials.username),
@@ -1,17 +1,21 @@
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'
4
5
 
5
6
  defineOptions({ name: 'ForbiddenPage' })
6
7
 
7
8
  const router = useRouter()
9
+ const { t } = useI18n()
8
10
  </script>
9
11
 
10
12
  <template>
11
13
  <main class="error-page">
12
- <ElResult icon="warning" title="403" sub-title="抱歉,你没有访问此页面的权限。">
14
+ <ElResult icon="warning" :title="t('errors.forbidden.code')" :sub-title="t('errors.forbidden.message')">
13
15
  <template #extra>
14
- <ElButton type="primary" @click="router.push('/dashboard')"> 回到仪表盘 </ElButton>
16
+ <ElButton type="primary" @click="router.push('/dashboard')">
17
+ {{ t('errors.forbidden.backHome') }}
18
+ </ElButton>
15
19
  </template>
16
20
  </ElResult>
17
21
  </main>
@@ -1,17 +1,21 @@
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'
4
5
 
5
6
  defineOptions({ name: 'NotFoundPage' })
6
7
 
7
8
  const router = useRouter()
9
+ const { t } = useI18n()
8
10
  </script>
9
11
 
10
12
  <template>
11
13
  <main class="error-page">
12
- <ElResult icon="warning" title="404" sub-title="你访问的页面不存在或已经被移除。">
14
+ <ElResult icon="warning" :title="t('errors.notFound.code')" :sub-title="t('errors.notFound.message')">
13
15
  <template #extra>
14
- <ElButton type="primary" @click="router.push('/dashboard')"> 回到仪表盘 </ElButton>
16
+ <ElButton type="primary" @click="router.push('/dashboard')">
17
+ {{ t('errors.notFound.backHome') }}
18
+ </ElButton>
15
19
  </template>
16
20
  </ElResult>
17
21
  </main>
@@ -1,17 +1,21 @@
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'
4
5
 
5
6
  defineOptions({ name: 'ServerErrorPage' })
6
7
 
7
8
  const router = useRouter()
9
+ const { t } = useI18n()
8
10
  </script>
9
11
 
10
12
  <template>
11
13
  <main class="error-page">
12
- <ElResult icon="error" title="500" sub-title="服务暂时不可用,请稍后再试。">
14
+ <ElResult icon="error" :title="t('errors.serverError.code')" :sub-title="t('errors.serverError.message')">
13
15
  <template #extra>
14
- <ElButton type="primary" @click="router.push('/dashboard')"> 回到仪表盘 </ElButton>
16
+ <ElButton type="primary" @click="router.push('/dashboard')">
17
+ {{ t('errors.serverError.backHome') }}
18
+ </ElButton>
15
19
  </template>
16
20
  </ElResult>
17
21
  </main>
@@ -1,9 +1,17 @@
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'
3
5
  import Forbidden from './Forbidden.vue'
4
6
  import NotFound from './NotFound.vue'
5
7
  import ServerError from './ServerError.vue'
6
8
 
9
+ const i18n = createI18n({
10
+ legacy: false,
11
+ locale: 'zh-CN',
12
+ messages: { 'zh-CN': zhCN },
13
+ })
14
+
7
15
  const { push } = vi.hoisted(() => ({
8
16
  push: vi.fn(),
9
17
  }))
@@ -22,7 +30,7 @@ describe('error page navigation', () => {
22
30
  ['404', NotFound],
23
31
  ['500', ServerError],
24
32
  ])('returns to the dashboard by path from the %s page', async (_status, component) => {
25
- const wrapper = mount(component)
33
+ const wrapper = mount(component, { global: { plugins: [i18n] } })
26
34
 
27
35
  await wrapper.get('button').trigger('click')
28
36