@origen-ui/admin-cli 1.0.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +11 -7
  2. package/package.json +19 -3
  3. package/templates/current/clean/CHANGELOG.md +137 -0
  4. package/templates/current/clean/component-catalog.json +58 -17
  5. package/templates/current/clean/e2e/admin-shell.spec.ts +6 -0
  6. package/templates/current/clean/e2e/demo-shell.spec.ts +90 -46
  7. package/templates/current/clean/package.json +55 -41
  8. package/templates/current/clean/playwright.config.ts +1 -0
  9. package/templates/current/clean/playwright.demo.config.ts +1 -1
  10. package/templates/current/clean/scaffold.lock.json +2 -2
  11. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
  12. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
  13. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
  14. package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
  15. package/templates/current/clean/scripts/clean-overlay/src/main.ts +23 -14
  16. package/templates/current/clean/scripts/clean-overlay/src/router/componentCache.ts +12 -0
  17. package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
  18. package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
  19. package/templates/current/clean/scripts/clean-overlay/src/router/paths.ts +21 -0
  20. package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
  21. package/templates/current/clean/scripts/demo-api.ts +84 -8
  22. package/templates/current/clean/scripts/generate-api.ts +87 -3
  23. package/templates/current/clean/scripts/vite-build-policy.spec.ts +72 -0
  24. package/templates/current/clean/src/App.vue +10 -3
  25. package/templates/current/clean/src/api/client.ts +90 -10
  26. package/templates/current/clean/src/api/generated/data-contracts.ts +0 -3
  27. package/templates/current/clean/src/api/generated/http-client.ts +28 -26
  28. 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
  29. 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
  30. 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
  31. 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 +6 -9
  32. 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 +7 -10
  33. 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 +6 -9
  34. 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 +6 -9
  35. package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +3 -6
  36. package/templates/current/clean/src/app/adminLocale.ts +90 -0
  37. package/templates/current/clean/src/app/createAdminUi.spec.ts +65 -9
  38. package/templates/current/clean/src/app/createAdminUi.ts +14 -29
  39. package/templates/current/clean/src/app/embedded-token.spec.ts +40 -0
  40. package/templates/current/clean/src/app/embedded.spec.ts +135 -0
  41. package/templates/current/clean/src/app/embedded.ts +255 -0
  42. package/templates/current/clean/src/app/errorMessage.spec.ts +76 -0
  43. package/templates/current/clean/src/app/errorMessage.ts +53 -0
  44. package/templates/current/clean/src/app/localeFormat.ts +52 -0
  45. package/templates/current/clean/src/app/menu-host.spec.ts +77 -0
  46. package/templates/current/clean/src/app/menu.spec.ts +65 -0
  47. package/templates/current/clean/src/app/menu.ts +52 -12
  48. package/templates/current/clean/src/app/menuTypes.ts +1 -0
  49. package/templates/current/clean/src/app/origenUiLocale.spec.ts +6 -5
  50. package/templates/current/clean/src/app/origenUiLocale.ts +3 -58
  51. package/templates/current/clean/src/app/permission.spec.ts +26 -0
  52. package/templates/current/clean/src/app/runtimeConfig.ts +9 -8
  53. package/templates/current/clean/src/demo-api.spec.ts +311 -0
  54. package/templates/current/clean/src/env.d.ts +18 -0
  55. package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +21 -17
  56. package/templates/current/clean/src/features/appearance/store/theme.ts +2 -1
  57. package/templates/current/clean/src/features/auth/pages/Login.vue +22 -12
  58. package/templates/current/clean/src/features/auth/store/auth.ts +6 -9
  59. package/templates/current/clean/src/features/errors/pages/Forbidden.vue +7 -2
  60. package/templates/current/clean/src/features/errors/pages/NotFound.vue +7 -2
  61. package/templates/current/clean/src/features/errors/pages/ServerError.vue +7 -2
  62. package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +11 -2
  63. package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
  64. package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +7 -10
  65. package/templates/current/clean/src/features/security/devtoolsProtection.ts +2 -1
  66. package/templates/current/clean/src/features/system/access/api/admin-repository.spec.ts +14 -0
  67. package/templates/current/clean/src/features/system/access/api/admin-repository.ts +34 -15
  68. package/templates/current/clean/src/features/system/access/api/rbac.ts +52 -32
  69. package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
  70. package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
  71. package/templates/current/clean/src/features/workspace/pages/Empty.vue +4 -1
  72. package/templates/current/clean/src/features/workspace/pages/Profile.vue +14 -12
  73. package/templates/current/clean/src/layouts/AdminLayout.vue +6 -1
  74. package/templates/current/clean/src/layouts/TopBar.vue +60 -11
  75. package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +24 -1
  76. package/templates/current/clean/src/layouts/topBarMenuSearch.ts +10 -0
  77. package/templates/current/clean/src/locales/en-US.json +517 -0
  78. package/templates/current/clean/src/locales/en-US.runtime.ts +22 -0
  79. package/templates/current/clean/src/locales/index.ts +144 -47
  80. package/templates/current/clean/src/locales/messages-types.ts +62 -0
  81. package/templates/current/clean/src/locales/messages.spec.ts +113 -6
  82. package/templates/current/clean/src/locales/vue-i18n.d.ts +5 -0
  83. package/templates/current/clean/src/locales/zh-CN.json +517 -0
  84. package/templates/current/clean/src/locales/zh-CN.runtime.ts +22 -0
  85. package/templates/current/clean/src/locales/zh-TW.json +517 -0
  86. package/templates/current/clean/src/locales/zh-TW.runtime.ts +22 -0
  87. package/templates/current/clean/src/main.ts +23 -14
  88. package/templates/current/clean/src/router/bootstrap.ts +20 -11
  89. package/templates/current/clean/src/router/componentCache.ts +12 -0
  90. package/templates/current/clean/src/router/componentRegistry.ts +2 -13
  91. package/templates/current/clean/src/router/dynamicMenuRefresh.spec.ts +101 -0
  92. package/templates/current/clean/src/router/dynamicMenuRefresh.ts +24 -0
  93. package/templates/current/clean/src/router/dynamicRoutes.spec.ts +34 -4
  94. package/templates/current/clean/src/router/dynamicRoutes.ts +19 -4
  95. package/templates/current/clean/src/router/paths.spec.ts +50 -0
  96. package/templates/current/clean/src/router/paths.ts +21 -0
  97. package/templates/current/clean/src/router/queryEncryption.spec.ts +30 -4
  98. package/templates/current/clean/src/router/queryEncryption.ts +48 -44
  99. package/templates/current/clean/src/router/staticRoutes.ts +6 -6
  100. package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +2 -1
  101. package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +2 -1
  102. package/templates/current/clean/src/templates/og-table.ts +79 -37
  103. package/templates/current/clean/src/templates/templates.spec.ts +19 -0
  104. package/templates/current/clean/tsconfig.json +0 -1
  105. package/templates/current/clean/vite.build-policy.ts +161 -289
  106. package/templates/current/clean/vite.config.ts +34 -5
  107. package/templates/current/examples/CHANGELOG.md +137 -0
  108. package/templates/current/examples/component-catalog.json +58 -17
  109. package/templates/current/examples/e2e/admin-shell.spec.ts +6 -0
  110. package/templates/current/examples/e2e/demo-shell.spec.ts +90 -46
  111. package/templates/current/examples/package.json +55 -41
  112. package/templates/current/examples/playwright.config.ts +1 -0
  113. package/templates/current/examples/playwright.demo.config.ts +1 -1
  114. package/templates/current/examples/scaffold.lock.json +2 -2
  115. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
  116. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
  117. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
  118. package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
  119. package/templates/current/examples/scripts/clean-overlay/src/main.ts +23 -14
  120. package/templates/current/examples/scripts/clean-overlay/src/router/componentCache.ts +12 -0
  121. package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
  122. package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
  123. package/templates/current/examples/scripts/clean-overlay/src/router/paths.ts +21 -0
  124. package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
  125. package/templates/current/examples/scripts/demo-api.ts +84 -8
  126. package/templates/current/examples/scripts/generate-api.ts +87 -3
  127. package/templates/current/examples/scripts/vite-build-policy.spec.ts +72 -0
  128. package/templates/current/examples/src/App.vue +10 -3
  129. package/templates/current/examples/src/api/client.ts +90 -10
  130. package/templates/current/examples/src/api/generated/data-contracts.ts +0 -3
  131. package/templates/current/examples/src/api/generated/http-client.ts +28 -26
  132. 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
  133. 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
  134. 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
  135. 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 +6 -9
  136. 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 +7 -10
  137. 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 +6 -9
  138. 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 +6 -9
  139. package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +3 -6
  140. package/templates/current/examples/src/app/adminLocale.ts +90 -0
  141. package/templates/current/examples/src/app/createAdminUi.spec.ts +65 -9
  142. package/templates/current/examples/src/app/createAdminUi.ts +14 -29
  143. package/templates/current/examples/src/app/embedded-token.spec.ts +40 -0
  144. package/templates/current/examples/src/app/embedded.spec.ts +135 -0
  145. package/templates/current/examples/src/app/embedded.ts +255 -0
  146. package/templates/current/examples/src/app/errorMessage.spec.ts +76 -0
  147. package/templates/current/examples/src/app/errorMessage.ts +53 -0
  148. package/templates/current/examples/src/app/localeFormat.ts +52 -0
  149. package/templates/current/examples/src/app/menu-host.spec.ts +77 -0
  150. package/templates/current/examples/src/app/menu.spec.ts +65 -0
  151. package/templates/current/examples/src/app/menu.ts +52 -12
  152. package/templates/current/examples/src/app/menuTypes.ts +1 -0
  153. package/templates/current/examples/src/app/origenUiLocale.spec.ts +6 -5
  154. package/templates/current/examples/src/app/origenUiLocale.ts +3 -58
  155. package/templates/current/examples/src/app/permission.spec.ts +26 -0
  156. package/templates/current/examples/src/app/runtimeConfig.ts +9 -8
  157. package/templates/current/examples/src/demo-api.spec.ts +311 -0
  158. package/templates/current/examples/src/env.d.ts +18 -0
  159. package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +21 -17
  160. package/templates/current/examples/src/features/appearance/store/theme.ts +2 -1
  161. package/templates/current/examples/src/features/auth/pages/Login.vue +22 -12
  162. package/templates/current/examples/src/features/auth/store/auth.ts +6 -9
  163. package/templates/current/examples/src/features/errors/pages/Forbidden.vue +7 -2
  164. package/templates/current/examples/src/features/errors/pages/NotFound.vue +7 -2
  165. package/templates/current/examples/src/features/errors/pages/ServerError.vue +7 -2
  166. package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +9 -1
  167. package/templates/current/examples/src/features/feature-composables.spec.ts +47 -10
  168. package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +5 -2
  169. package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +7 -10
  170. package/templates/current/examples/src/features/security/devtoolsProtection.ts +2 -1
  171. package/templates/current/examples/src/features/system/access/api/admin-repository.spec.ts +14 -0
  172. package/templates/current/examples/src/features/system/access/api/admin-repository.ts +34 -15
  173. package/templates/current/examples/src/features/system/access/api/rbac.ts +52 -32
  174. package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
  175. package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
  176. package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +43 -38
  177. package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +137 -47
  178. package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +215 -107
  179. package/templates/current/examples/src/features/system/menus/menuDraft.spec.ts +204 -0
  180. package/templates/current/examples/src/features/system/menus/menuDraft.ts +116 -0
  181. package/templates/current/examples/src/features/system/menus/menuTreePrecheck.spec.ts +268 -0
  182. package/templates/current/examples/src/features/system/menus/menuTreePrecheck.ts +317 -0
  183. package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +3 -1
  184. package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +19 -15
  185. package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +49 -53
  186. package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +3 -1
  187. package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +22 -19
  188. package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +59 -64
  189. package/templates/current/examples/src/features/system/users/pages/UserList.vue +3 -1
  190. package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +9 -0
  191. package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +54 -26
  192. package/templates/current/examples/src/features/workspace/pages/Empty.vue +4 -1
  193. package/templates/current/examples/src/features/workspace/pages/Profile.vue +14 -12
  194. package/templates/current/examples/src/layouts/AdminLayout.vue +6 -1
  195. package/templates/current/examples/src/layouts/TopBar.vue +60 -11
  196. package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +24 -1
  197. package/templates/current/examples/src/layouts/topBarMenuSearch.ts +10 -0
  198. package/templates/current/examples/src/locales/en-US.json +517 -0
  199. package/templates/current/examples/src/locales/en-US.runtime.ts +22 -0
  200. package/templates/current/examples/src/locales/index.ts +144 -47
  201. package/templates/current/examples/src/locales/messages-types.ts +62 -0
  202. package/templates/current/examples/src/locales/messages.spec.ts +113 -6
  203. package/templates/current/examples/src/locales/vue-i18n.d.ts +5 -0
  204. package/templates/current/examples/src/locales/zh-CN.json +517 -0
  205. package/templates/current/examples/src/locales/zh-CN.runtime.ts +22 -0
  206. package/templates/current/examples/src/locales/zh-TW.json +517 -0
  207. package/templates/current/examples/src/locales/zh-TW.runtime.ts +22 -0
  208. package/templates/current/examples/src/main.ts +43 -15
  209. package/templates/current/examples/src/router/bootstrap.ts +20 -11
  210. package/templates/current/examples/src/router/componentCache.ts +18 -0
  211. package/templates/current/examples/src/router/componentRegistry.ts +1 -18
  212. package/templates/current/examples/src/router/dynamicMenuRefresh.spec.ts +101 -0
  213. package/templates/current/examples/src/router/dynamicMenuRefresh.ts +24 -0
  214. package/templates/current/examples/src/router/dynamicRoutes.spec.ts +37 -2
  215. package/templates/current/examples/src/router/dynamicRoutes.ts +19 -4
  216. package/templates/current/examples/src/router/paths.spec.ts +50 -0
  217. package/templates/current/examples/src/router/paths.ts +21 -0
  218. package/templates/current/examples/src/router/queryEncryption.spec.ts +30 -4
  219. package/templates/current/examples/src/router/queryEncryption.ts +48 -44
  220. package/templates/current/examples/src/router/staticRoutes.ts +4 -4
  221. package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +2 -1
  222. package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +2 -1
  223. package/templates/current/examples/src/templates/og-table.ts +79 -37
  224. package/templates/current/examples/src/templates/templates.spec.ts +19 -0
  225. package/templates/current/examples/tsconfig.json +0 -1
  226. package/templates/current/examples/vite.build-policy.ts +161 -289
  227. package/templates/current/examples/vite.config.ts +34 -5
  228. package/templates/current/clean/scripts/check-admin-bundle.mjs +0 -214
  229. package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
  230. package/templates/current/clean/src/locales/en-US.ts +0 -55
  231. package/templates/current/clean/src/locales/zh-CN.ts +0 -55
  232. package/templates/current/clean/src/locales/zh-TW.ts +0 -44
  233. package/templates/current/examples/scripts/check-admin-bundle.mjs +0 -214
  234. package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +0 -38
  235. package/templates/current/examples/src/locales/en-US.ts +0 -55
  236. package/templates/current/examples/src/locales/zh-CN.ts +0 -55
  237. package/templates/current/examples/src/locales/zh-TW.ts +0 -44
@@ -5,59 +5,51 @@ import type {
5
5
  OgTableRequestContext,
6
6
  TableColumn,
7
7
  } from '@origen-ui/table'
8
+ import type { AdminRecordStatus, AdminUserQuery, AdminUserRecord } from '../../access/api/admin-repository'
9
+ import type { AuthorizationRefresh } from '../../access/composables/useAuthorizationRefresh'
8
10
  import { useDialog } from '@origen-ui/dialog'
9
11
  import { ElMessage } from 'element-plus'
12
+ import { computed } from 'vue'
13
+ import { useI18n } from 'vue-i18n'
14
+ import { formatAdminShortDateTime } from '../../../../app/localeFormat'
10
15
  import { useAuthStore } from '../../../auth/store/auth'
11
16
  import {
12
- type AdminRecordStatus,
13
- type AdminUserQuery,
14
- type AdminUserRecord,
17
+ ADMIN_USER_DEPARTMENTS,
15
18
  createUserDraft,
16
19
  parseUserDraft,
17
20
  userManagementRepository,
18
21
  } from '../../access/api/admin-repository'
19
22
  import { roleOptions } from '../../access/api/rbac'
20
- import {
21
- type AuthorizationRefresh,
22
- useAuthorizationRefresh,
23
- } from '../../access/composables/useAuthorizationRefresh'
23
+ import { useAuthorizationRefresh } from '../../access/composables/useAuthorizationRefresh'
24
24
 
25
25
  interface UseUserManagementOptions {
26
26
  refresh: () => Promise<void>
27
27
  refreshAuthorization?: AuthorizationRefresh
28
28
  }
29
29
 
30
- const statusOptions = [
31
- { label: '正常', value: 'active' },
32
- { label: '停用', value: 'suspended' },
33
- ] as const
34
-
35
- const dateTimeFormat = new Intl.DateTimeFormat('zh-CN', {
36
- month: '2-digit',
37
- day: '2-digit',
38
- hour: '2-digit',
39
- minute: '2-digit',
40
- hour12: false,
41
- })
42
-
43
30
  function formatDateTime(value: unknown): string {
44
- const date = new Date(String(value))
45
- return Number.isNaN(date.valueOf()) ? '-' : dateTimeFormat.format(date)
46
- }
47
-
48
- function statusText(value: unknown): string {
49
- return value === 'suspended' ? '停用' : '正常'
31
+ return formatAdminShortDateTime(value)
50
32
  }
51
33
 
52
34
  export function useUserManagement(options: UseUserManagementOptions) {
53
35
  const auth = useAuthStore()
54
36
  const dialog = useDialog()
37
+ const { t } = useI18n()
55
38
  const refreshAuthorization = options.refreshAuthorization ?? useAuthorizationRefresh()
56
39
  const roleFilterOptions: SelectOption[] = []
57
40
  void roleOptions().then((items) =>
58
41
  roleFilterOptions.splice(0, roleFilterOptions.length, ...items),
59
42
  )
60
43
 
44
+ const statusOptions = computed<SelectOption[]>(() => [
45
+ { label: t('common.status.enabled'), value: 'active' },
46
+ { label: t('common.status.disabled'), value: 'suspended' },
47
+ ])
48
+
49
+ const departmentOptions = computed<SelectOption[]>(() =>
50
+ ADMIN_USER_DEPARTMENTS.map(({ labelKey, value }) => ({ label: t(labelKey), value })),
51
+ )
52
+
61
53
  async function refresh(): Promise<void> {
62
54
  await options.refresh()
63
55
  }
@@ -71,7 +63,7 @@ export function useUserManagement(options: UseUserManagementOptions) {
71
63
  if (row) await userManagementRepository.update(row.id, draft, signal)
72
64
  else await userManagementRepository.create(draft, signal)
73
65
  await refreshAuthorization()
74
- ElMessage.success(row ? '成员信息已更新' : '成员已创建')
66
+ ElMessage.success(row ? t('system.users.userUpdated') : t('system.users.userCreated'))
75
67
  await refresh()
76
68
  return true
77
69
  }
@@ -81,7 +73,7 @@ export function useUserManagement(options: UseUserManagementOptions) {
81
73
  const roleOptionsValue: SelectOption[] = await roleOptions()
82
74
  dialog.open({
83
75
  dialogKey: row ? `user-editor-${row.id}` : 'user-editor-create',
84
- title: row ? '编辑成员' : '新增成员',
76
+ title: row ? t('system.users.editMember') : t('system.users.addMember'),
85
77
  presentation: { width: 680 },
86
78
  protectUnsaved: true,
87
79
  errorFeedback: true,
@@ -99,7 +91,9 @@ export function useUserManagement(options: UseUserManagementOptions) {
99
91
  const controller = signal ? undefined : new AbortController()
100
92
  await userManagementRepository.batchSetStatus(ids, status, signal ?? controller!.signal)
101
93
  await refreshAuthorization()
102
- ElMessage.success(status === 'active' ? '已启用所选成员' : '已停用所选成员')
94
+ ElMessage.success(
95
+ status === 'active' ? t('system.users.enabledSelected') : t('system.users.disabledSelected'),
96
+ )
103
97
  await refresh()
104
98
  }
105
99
 
@@ -107,26 +101,32 @@ export function useUserManagement(options: UseUserManagementOptions) {
107
101
  const controller = signal ? undefined : new AbortController()
108
102
  await userManagementRepository.remove(ids, signal ?? controller!.signal)
109
103
  await refreshAuthorization()
110
- ElMessage.success(ids.length > 1 ? '已移除所选成员' : '成员已移除')
104
+ ElMessage.success(t('system.users.selectedRemoved'))
111
105
  await refresh()
112
106
  }
113
107
 
114
- const columns: TableColumn<AdminUserRecord>[] = [
108
+ const columns = computed<TableColumn<AdminUserRecord>[]>(() => [
115
109
  { type: 'selection', key: 'selection', width: 48 },
116
110
  { type: 'index', key: 'index', label: '#', width: 58 },
117
- { prop: 'name', label: '成员', minWidth: 128, sortable: 'custom' },
118
- { prop: 'email', label: '工作邮箱', minWidth: 210, copyable: true },
119
- { prop: 'department', label: '部门', minWidth: 120 },
111
+ { prop: 'name', label: t('system.users.displayName'), minWidth: 128, sortable: 'custom' },
112
+ { prop: 'email', label: t('system.users.email'), minWidth: 210, copyable: true },
113
+ { prop: 'department', label: t('system.users.department'), minWidth: 120 },
120
114
  {
121
115
  prop: 'roleNames',
122
- label: '角色',
116
+ label: t('system.users.role'),
123
117
  minWidth: 150,
124
- format: (value) => (Array.isArray(value) ? value.join('、') : '-'),
118
+ format: (value) =>
119
+ Array.isArray(value) ? value.join(t('system.users.roleNameSeparator')) : '-',
120
+ },
121
+ {
122
+ prop: 'status',
123
+ label: t('system.users.status'),
124
+ width: 88,
125
+ format: (value) => (value === 'suspended' ? t('common.status.disabled') : t('common.status.enabled')),
125
126
  },
126
- { prop: 'status', label: '状态', width: 88, format: statusText },
127
127
  {
128
128
  prop: 'lastActiveAt',
129
- label: '最近活跃',
129
+ label: t('system.users.lastActive'),
130
130
  minWidth: 132,
131
131
  sortable: 'custom',
132
132
  format: formatDateTime,
@@ -134,58 +134,53 @@ export function useUserManagement(options: UseUserManagementOptions) {
134
134
  {
135
135
  type: 'action',
136
136
  key: 'actions',
137
- label: '操作',
137
+ label: t('common.actions.operations'),
138
138
  width: 224,
139
139
  fixed: 'right',
140
140
  actions: [
141
- { key: 'edit', label: '编辑', permission: 'system:user:write', onClick: openEditor },
141
+ { key: 'edit', label: t('common.actions.edit'), permission: 'system:user:write', onClick: openEditor },
142
142
  {
143
143
  key: 'toggle-status',
144
- label: '切换状态',
144
+ label: t('common.actions.toggleStatus'),
145
145
  permission: 'system:user:write',
146
- confirm: '确认更新该成员的账号状态吗?',
146
+ confirm: t('system.users.confirmToggleStatus'),
147
147
  onClick: (row) => setStatus([row.id], row.status === 'active' ? 'suspended' : 'active'),
148
148
  },
149
149
  {
150
150
  key: 'remove',
151
- label: '移除',
151
+ label: t('common.actions.remove'),
152
152
  permission: 'system:user:write',
153
- confirm: '移除后,该成员将无法访问当前工作区。',
153
+ confirm: t('system.users.confirmRemove'),
154
154
  onClick: (row) => remove([row.id]),
155
155
  },
156
156
  ],
157
157
  },
158
- ]
158
+ ])
159
159
 
160
160
  const dataSource: OgTableDataSource<AdminUserRecord, AdminUserQuery> = {
161
161
  list: (request, context: OgTableRequestContext): Promise<PageResult<AdminUserRecord>> =>
162
162
  userManagementRepository.list(request, context.signal),
163
163
  }
164
164
 
165
- const config: OgTableConfig<AdminUserRecord, AdminUserQuery> = {
165
+ const config = computed<OgTableConfig<AdminUserRecord, AdminUserQuery>>(() => ({
166
166
  search: {
167
- quickSearch: { placeholder: '搜索成员、邮箱、部门或角色' },
167
+ quickSearch: { placeholder: t('system.users.searchPlaceholder') },
168
168
  columns: 4,
169
169
  fields: [
170
- { prop: 'name', label: '成员', placeholder: '按成员姓名筛选' },
170
+ { prop: 'name', label: t('system.users.displayName'), placeholder: t('system.users.filterByName') },
171
171
  {
172
172
  prop: 'department',
173
- label: '部门',
173
+ label: t('system.users.department'),
174
174
  type: 'select',
175
- options: [
176
- { label: '平台产品', value: '平台产品' },
177
- { label: '增长运营', value: '增长运营' },
178
- { label: '数据分析', value: '数据分析' },
179
- { label: '客户成功', value: '客户成功' },
180
- ],
175
+ options: departmentOptions.value,
181
176
  },
182
177
  {
183
178
  prop: 'roleId',
184
- label: '角色',
179
+ label: t('system.users.role'),
185
180
  type: 'select',
186
181
  options: roleFilterOptions,
187
182
  },
188
- { prop: 'status', label: '状态', type: 'select', options: [...statusOptions] },
183
+ { prop: 'status', label: t('system.users.status'), type: 'select', options: statusOptions.value },
189
184
  ],
190
185
  },
191
186
  pagination: { pageSize: 10, pageSizes: [10, 20, 50] },
@@ -197,9 +192,9 @@ export function useUserManagement(options: UseUserManagementOptions) {
197
192
  batch: [
198
193
  {
199
194
  key: 'activate',
200
- label: '批量启用',
195
+ label: t('common.actions.batchEnable'),
201
196
  permission: 'system:user:write',
202
- confirm: '确认启用所选成员吗?',
197
+ confirm: t('system.users.confirmBatchEnable'),
203
198
  onClick: (rows) =>
204
199
  setStatus(
205
200
  rows.map((row) => row.id),
@@ -208,9 +203,9 @@ export function useUserManagement(options: UseUserManagementOptions) {
208
203
  },
209
204
  {
210
205
  key: 'suspend',
211
- label: '批量停用',
206
+ label: t('common.actions.batchDisable'),
212
207
  permission: 'system:user:write',
213
- confirm: '确认停用所选成员吗?',
208
+ confirm: t('system.users.confirmBatchDisable'),
214
209
  onClick: (rows) =>
215
210
  setStatus(
216
211
  rows.map((row) => row.id),
@@ -219,15 +214,15 @@ export function useUserManagement(options: UseUserManagementOptions) {
219
214
  },
220
215
  {
221
216
  key: 'remove',
222
- label: '批量移除',
217
+ label: t('common.actions.batchRemove'),
223
218
  permission: 'system:user:write',
224
- confirm: '移除后所选成员将无法访问当前工作区。',
219
+ confirm: t('system.users.confirmBatchRemove'),
225
220
  onClick: (rows) => remove(rows.map((row) => row.id)),
226
221
  },
227
222
  ],
228
223
  },
229
224
  toolbar: { refresh: true, density: true, columns: true, reset: true },
230
- }
225
+ }))
231
226
 
232
227
  return { columns, config, dataSource, openEditor }
233
228
  }
@@ -5,6 +5,7 @@ import { Plus } from '@element-plus/icons-vue'
5
5
  import { OgTableWithSearch } from '@origen-ui/table-search'
6
6
  import { ElButton } from 'element-plus'
7
7
  import { useTemplateRef } from 'vue'
8
+ import { useI18n } from 'vue-i18n'
8
9
  import { routeStatus } from '../../../../router/routeQuery'
9
10
  import { useRouteQueryDefaults } from '../../../../router/useRouteQueryDefaults'
10
11
  import { useAuthStore } from '../../../auth/store/auth'
@@ -13,6 +14,7 @@ import { useUserManagement } from '../composables/useUserManagement'
13
14
  defineOptions({ name: 'UserListPage' })
14
15
 
15
16
  const auth = useAuthStore()
17
+ const { t } = useI18n()
16
18
  const table = useTemplateRef<OgTableExpose<AdminUserRecord>>('table')
17
19
 
18
20
  async function refreshTable(): Promise<void> {
@@ -41,7 +43,7 @@ const { queryDefaults } = useRouteQueryDefaults({ status: routeStatus })
41
43
  :icon="Plus"
42
44
  @click="openEditor()"
43
45
  >
44
- 新增成员
46
+ {{ t('system.users.addMember') }}
45
47
  </ElButton>
46
48
  </template>
47
49
  </OgTableWithSearch>
@@ -1,11 +1,20 @@
1
1
  import { mount } from '@vue/test-utils'
2
2
  import { describe, expect, it } from 'vitest'
3
+ import { createI18n } from 'vue-i18n'
4
+ import zhCN from '../../../locales/zh-CN.json'
3
5
  import Dashboard from './Dashboard.vue'
4
6
 
7
+ const i18n = createI18n({
8
+ legacy: false,
9
+ locale: 'zh-CN',
10
+ messages: { 'zh-CN': zhCN },
11
+ })
12
+
5
13
  describe('dashboard', () => {
6
14
  it('renders as a dynamic route page without unresolved icon components', () => {
7
15
  const wrapper = mount(Dashboard, {
8
16
  global: {
17
+ plugins: [i18n],
9
18
  stubs: {
10
19
  ElButton: { template: '<button><slot /></button>' },
11
20
  ElCard: { template: '<section><slot name="header" /><slot /></section>' },
@@ -1,41 +1,69 @@
1
1
  <script setup lang="ts">
2
2
  import { ArrowRight, UserFilled } from '@element-plus/icons-vue'
3
3
  import { ElButton, ElCard, ElIcon, ElStatistic } from 'element-plus'
4
+ import { computed } from 'vue'
5
+ import { useI18n } from 'vue-i18n'
4
6
  import { RouterLink } from 'vue-router'
5
7
 
6
8
  defineOptions({ name: 'DashboardPage' })
7
9
 
8
- const stats = [
9
- { label: '今日访问', value: 12680, suffix: '', delta: '+18.2%', tone: 'positive' },
10
- { label: '活跃成员', value: 3842, suffix: '', delta: '+8.7%', tone: 'positive' },
11
- { label: '待处理事项', value: 28, suffix: ' 项', delta: '需关注', tone: 'attention' },
12
- { label: '服务可用性', value: 99.99, suffix: '%', delta: '运行稳定', tone: 'neutral' },
13
- ] as const
10
+ const { t } = useI18n()
14
11
 
15
- const activities = [
16
- { title: '工作区已初始化', meta: '可在 src/features 中添加业务模块', tone: 'success' },
17
- { title: '组件契约已启用', meta: 'AI 会按 @origen-ui 组件规则开发页面', tone: 'primary' },
18
- { title: '远程菜单已启用', meta: '页面由 /system/menus 动态注册', tone: 'warning' },
19
- ] as const
12
+ const stats = computed(() => [
13
+ { label: t('workspace.dashboard.visits'), value: 12680, suffix: '', delta: '+18.2%', tone: 'positive' },
14
+ { label: t('workspace.dashboard.activeMembers'), value: 3842, suffix: '', delta: '+8.7%', tone: 'positive' },
15
+ {
16
+ label: t('workspace.dashboard.pendingItems'),
17
+ value: 28,
18
+ suffix: t('workspace.dashboard.pendingSuffix'),
19
+ delta: t('workspace.dashboard.attention'),
20
+ tone: 'attention',
21
+ },
22
+ {
23
+ label: t('workspace.dashboard.serviceAvailability'),
24
+ value: 99.99,
25
+ suffix: '%',
26
+ delta: t('workspace.dashboard.stable'),
27
+ tone: 'neutral',
28
+ },
29
+ ])
30
+
31
+ const activities = computed(() => [
32
+ {
33
+ title: t('workspace.dashboard.activityWorkspaceInit'),
34
+ meta: t('workspace.dashboard.activityWorkspaceInitMeta'),
35
+ tone: 'success',
36
+ },
37
+ {
38
+ title: t('workspace.dashboard.activityContractEnabled'),
39
+ meta: t('workspace.dashboard.activityContractEnabledMeta'),
40
+ tone: 'primary',
41
+ },
42
+ {
43
+ title: t('workspace.dashboard.activityRemoteMenu'),
44
+ meta: t('workspace.dashboard.activityRemoteMenuMeta'),
45
+ tone: 'warning',
46
+ },
47
+ ])
20
48
 
21
- const tasks = [
22
- { label: '配置远程认证', value: 1, to: '/profile' },
49
+ const tasks = computed(() => [
50
+ { label: t('workspace.dashboard.taskConfigureAuth'), value: 1, to: '/profile' },
23
51
  {
24
- label: '检查用户权限',
52
+ label: t('workspace.dashboard.taskCheckUsers'),
25
53
  value: 2,
26
54
  to: { path: '/system/users', query: { status: 'suspended' } },
27
55
  },
28
56
  {
29
- label: '发布远程菜单',
57
+ label: t('workspace.dashboard.taskPublishMenus'),
30
58
  value: 3,
31
59
  to: { path: '/system/menus', query: { status: 'suspended' } },
32
60
  },
33
- ] as const
61
+ ])
34
62
  </script>
35
63
 
36
64
  <template>
37
65
  <main class="dashboard-page">
38
- <section class="dashboard-page__metrics" aria-label="核心运营指标">
66
+ <section class="dashboard-page__metrics" :aria-label="t('workspace.dashboard.metricsLabel')">
39
67
  <article v-for="stat in stats" :key="stat.label" class="metric-card og-card">
40
68
  <p class="metric-card__label">
41
69
  {{ stat.label }}
@@ -52,8 +80,8 @@ const tasks = [
52
80
  <template #header>
53
81
  <div class="dashboard-panel__header">
54
82
  <div>
55
- <h2>工作动态</h2>
56
- <p>最近 24 小时关键操作</p>
83
+ <h2>{{ t('workspace.dashboard.activityTitle') }}</h2>
84
+ <p>{{ t('workspace.dashboard.activitySubtitle') }}</p>
57
85
  </div>
58
86
  </div>
59
87
  </template>
@@ -76,8 +104,8 @@ const tasks = [
76
104
  <template #header>
77
105
  <div class="dashboard-panel__header">
78
106
  <div>
79
- <h2>待处理</h2>
80
- <p>需要人工判断的队列</p>
107
+ <h2>{{ t('workspace.dashboard.tasksTitle') }}</h2>
108
+ <p>{{ t('workspace.dashboard.tasksSubtitle') }}</p>
81
109
  </div>
82
110
  <ElIcon class="dashboard-panel__header-icon">
83
111
  <UserFilled />
@@ -92,17 +120,17 @@ const tasks = [
92
120
  </ElCard>
93
121
  </section>
94
122
 
95
- <section class="dashboard-page__commands og-card" aria-label="常用操作">
123
+ <section class="dashboard-page__commands og-card" :aria-label="t('workspace.dashboard.quickActionsLabel')">
96
124
  <div>
97
- <p class="dashboard-page__commands-eyebrow">常用操作</p>
98
- <h2>开始构建业务工作区</h2>
125
+ <p class="dashboard-page__commands-eyebrow">{{ t('workspace.dashboard.quickActionsLabel') }}</p>
126
+ <h2>{{ t('workspace.dashboard.buildCta') }}</h2>
99
127
  </div>
100
128
  <div class="dashboard-page__command-actions">
101
129
  <RouterLink to="/system/users">
102
- <ElButton type="primary"> 管理用户 </ElButton>
130
+ <ElButton type="primary"> {{ t('workspace.dashboard.manageUsers') }} </ElButton>
103
131
  </RouterLink>
104
132
  <RouterLink to="/profile">
105
- <ElButton plain> 完善资料 </ElButton>
133
+ <ElButton plain> {{ t('workspace.dashboard.completeProfile') }} </ElButton>
106
134
  </RouterLink>
107
135
  </div>
108
136
  </section>
@@ -1,12 +1,15 @@
1
1
  <script setup lang="ts">
2
2
  import { ElCard, ElEmpty } from 'element-plus'
3
+ import { useI18n } from 'vue-i18n'
3
4
 
4
5
  defineOptions({ name: 'EmptyPage' })
6
+
7
+ const { t } = useI18n()
5
8
  </script>
6
9
 
7
10
  <template>
8
11
  <ElCard shadow="never" class="empty-page">
9
- <ElEmpty description="这是一个可由后端菜单映射的空白页面" />
12
+ <ElEmpty :description="t('workspace.empty.description')" />
10
13
  </ElCard>
11
14
  </template>
12
15
 
@@ -2,15 +2,17 @@
2
2
  import { CircleCheckFilled, Key, Lock, Monitor } from '@element-plus/icons-vue'
3
3
  import { ElAvatar, ElCard, ElDescriptions, ElDescriptionsItem, ElIcon, ElTag } from 'element-plus'
4
4
  import { computed } from 'vue'
5
+ import { useI18n } from 'vue-i18n'
5
6
  import { useAuthStore } from '../../auth/store/auth'
6
7
 
7
8
  defineOptions({ name: 'ProfilePage' })
8
9
 
9
10
  const auth = useAuthStore()
11
+ const { t } = useI18n()
10
12
  const user = computed(() => auth.session?.user)
11
13
  const permissions = computed(() => auth.session?.permissions ?? [])
12
14
  const sessionId = computed(() =>
13
- auth.session?.token ? `${auth.session.token.slice(0, 8)}••••` : '未建立会话',
15
+ auth.session?.token ? `${auth.session.token.slice(0, 8)}••••` : t('workspace.profile.noSession'),
14
16
  )
15
17
  </script>
16
18
 
@@ -22,21 +24,21 @@ const sessionId = computed(() =>
22
24
  {{ user?.displayName.slice(0, 1) }}
23
25
  </ElAvatar>
24
26
  <div>
25
- <h2>{{ user?.displayName ?? '管理员' }}</h2>
26
- <p>{{ user?.email ?? 'admin@example.com' }}</p>
27
+ <h2>{{ user?.displayName ?? t('workspace.profile.admin') }}</h2>
28
+ <p>{{ user?.email ?? t('workspace.profile.noEmail') }}</p>
27
29
  </div>
28
30
  <ElTag type="success" effect="plain">
29
- <ElIcon><CircleCheckFilled /></ElIcon> 当前在线
31
+ <ElIcon><CircleCheckFilled /></ElIcon> {{ t('workspace.profile.online') }}
30
32
  </ElTag>
31
33
  </div>
32
34
  <ElDescriptions :column="1" class="profile-card__details">
33
- <ElDescriptionsItem label="登录账号">
35
+ <ElDescriptionsItem :label="t('workspace.profile.loginAccount')">
34
36
  {{ user?.username ?? '-' }}
35
37
  </ElDescriptionsItem>
36
- <ElDescriptionsItem label="用户 ID">
38
+ <ElDescriptionsItem :label="t('workspace.profile.userId')">
37
39
  {{ user?.id ?? '-' }}
38
40
  </ElDescriptionsItem>
39
- <ElDescriptionsItem label="会话标识">
41
+ <ElDescriptionsItem :label="t('workspace.profile.sessionId')">
40
42
  {{ sessionId }}
41
43
  </ElDescriptionsItem>
42
44
  </ElDescriptions>
@@ -46,9 +48,9 @@ const sessionId = computed(() =>
46
48
  <template #header>
47
49
  <div class="profile-card__heading">
48
50
  <div>
49
- <ElIcon><Key /></ElIcon><strong>访问授权</strong>
51
+ <ElIcon><Key /></ElIcon><strong>{{ t('workspace.profile.accessGrant') }}</strong>
50
52
  </div>
51
- <span>{{ permissions.length }} 项权限</span>
53
+ <span>{{ permissions.length }} {{ t('workspace.profile.permissionItems') }}</span>
52
54
  </div>
53
55
  </template>
54
56
  <div class="permission-list">
@@ -58,13 +60,13 @@ const sessionId = computed(() =>
58
60
  </div>
59
61
  </ElCard>
60
62
 
61
- <section class="profile-page__sessions og-card" aria-label="安全状态">
63
+ <section class="profile-page__sessions og-card" :aria-label="t('workspace.profile.securityStatus')">
62
64
  <div class="profile-page__session-icon">
63
65
  <ElIcon><Monitor /></ElIcon>
64
66
  </div>
65
67
  <div>
66
- <h2>当前会话</h2>
67
- <p>本设备通过受保护会话访问管理工作区。</p>
68
+ <h2>{{ t('workspace.profile.currentSession') }}</h2>
69
+ <p>{{ t('workspace.profile.sessionDescription') }}</p>
68
70
  </div>
69
71
  <ElIcon class="profile-page__session-lock">
70
72
  <Lock />
@@ -2,8 +2,10 @@
2
2
  import { OgDialogHost } from '@origen-ui/dialog'
3
3
  import { RouterViewHost } from '@origen-ui/router'
4
4
  import { ElDrawer } from 'element-plus'
5
+ import { useI18n } from 'vue-i18n'
5
6
  import AdminWatermark from '../features/shell/components/AdminWatermark.vue'
6
7
  import { useSidebarStore } from '../features/shell/store/sidebar'
8
+ import { useAuthorizationPolling } from '../features/system/access/composables/useAuthorizationPolling'
7
9
  import BreadcrumbBar from './BreadcrumbBar.vue'
8
10
  import SideMenu from './SideMenu.vue'
9
11
  import TopBar from './TopBar.vue'
@@ -11,6 +13,9 @@ import WorkspaceTabs from './WorkspaceTabs.vue'
11
13
 
12
14
  defineOptions({ name: 'AdminLayout' })
13
15
  const sidebar = useSidebarStore()
16
+ const { t } = useI18n()
17
+ // 会话内轮询 RBAC revision:服务端权限/菜单变更经确认后刷新,随布局卸载停止。
18
+ useAuthorizationPolling()
14
19
  </script>
15
20
 
16
21
  <template>
@@ -18,7 +23,7 @@ const sidebar = useSidebarStore()
18
23
  <div class="admin-shell">
19
24
  <TopBar />
20
25
  <div class="admin-shell__body" :class="{ 'is-collapsed': sidebar.collapsed }">
21
- <aside class="admin-shell__sidebar" aria-label="主导航">
26
+ <aside class="admin-shell__sidebar" :aria-label="t('shell.applicationNavigation')">
22
27
  <SideMenu />
23
28
  </aside>
24
29
  <main class="admin-shell__main">