@origen-ui/admin-cli 1.0.2 → 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 +53 -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 +268 -0
  10. package/templates/current/clean/src/api/generated/http-client.ts +266 -0
  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 +147 -0
  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 +53 -0
  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 +66 -0
  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 +171 -0
  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 +181 -0
  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 +169 -0
  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 +170 -0
  18. package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +98 -0
  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 +53 -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 +268 -0
  76. package/templates/current/examples/src/api/generated/http-client.ts +266 -0
  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 +147 -0
  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 +53 -0
  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 +66 -0
  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 +171 -0
  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 +181 -0
  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 +169 -0
  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 +170 -0
  84. package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +98 -0
  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
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@origen-ui/admin-scaffold",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.1.0",
5
5
  "private": true,
6
6
  "engines": {
7
- "node": ">=20.0.0"
7
+ "node": "^22.22.1 || ^24.15.0"
8
8
  },
9
9
  "scripts": {
10
10
  "dev": "vite",
11
11
  "dev:demo": "vite --mode demo",
12
- "build": "vue-tsc --noEmit && vite build && node scripts/check-admin-bundle.mjs",
13
- "build:debug": "vue-tsc --noEmit && vite build --mode debug && node scripts/check-admin-bundle.mjs --debug",
12
+ "build": "vue-tsc --noEmit && vite build",
13
+ "build:debug": "vue-tsc --noEmit && vite build --mode debug",
14
14
  "preview": "vite preview",
15
15
  "type-check": "vue-tsc --noEmit",
16
16
  "test": "vitest run",
@@ -21,45 +21,45 @@
21
21
  "examples:remove": "node scripts/remove-examples.mjs"
22
22
  },
23
23
  "dependencies": {
24
- "@element-plus/icons-vue": "^2.3.2",
25
- "@origen-ui/dialog": "1.0.2",
26
- "@origen-ui/editor": "1.0.2",
27
- "@origen-ui/form": "1.0.2",
28
- "@origen-ui/http": "1.0.2",
29
- "@origen-ui/permission": "1.0.2",
30
- "@origen-ui/router": "1.0.2",
31
- "@origen-ui/search": "1.0.2",
32
- "@origen-ui/shared": "1.0.2",
33
- "@origen-ui/table": "1.0.2",
34
- "@origen-ui/table-search": "1.0.2",
35
- "@origen-ui/tabs": "1.0.2",
36
- "@origen-ui/upload": "1.0.2",
37
- "axios": "^1.7.7",
38
- "crypto-js": "^4.2.0",
39
- "element-plus": "^2.14.4",
40
- "origen-ui": "1.0.2",
41
- "pinia": "^2.2.0",
42
- "vue": "^3.5.40",
43
- "vue-i18n": "~11.1.12",
44
- "vue-router": "^4.6.4"
24
+ "@element-plus/icons-vue": "2.3.2",
25
+ "@noble/ciphers": "2.3.0",
26
+ "@origen-ui/dialog": "1.1.0",
27
+ "@origen-ui/editor": "1.1.0",
28
+ "@origen-ui/form": "1.1.0",
29
+ "@origen-ui/http": "1.1.0",
30
+ "@origen-ui/permission": "1.1.0",
31
+ "@origen-ui/router": "1.1.0",
32
+ "@origen-ui/search": "1.1.0",
33
+ "@origen-ui/shared": "1.1.0",
34
+ "@origen-ui/table": "1.1.0",
35
+ "@origen-ui/table-search": "1.1.0",
36
+ "@origen-ui/tabs": "1.1.0",
37
+ "@origen-ui/upload": "1.1.0",
38
+ "@vue/devtools-api": "8.2.1",
39
+ "axios": "1.19.0",
40
+ "element-plus": "2.14.5",
41
+ "origen-ui": "1.1.0",
42
+ "pinia": "4.0.3",
43
+ "vue": "3.5.41",
44
+ "vue-i18n": "11.4.8",
45
+ "vue-router": "5.2.0"
45
46
  },
46
47
  "devDependencies": {
47
- "@origen-ui/admin-cli": "1.0.2",
48
- "@playwright/test": "^1.62.0",
49
- "@types/crypto-js": "^4.2.2",
50
- "@types/node": "^22.7.4",
51
- "@vitejs/plugin-vue": "^6.0.1",
52
- "@vitejs/plugin-vue-jsx": "^5.1.1",
53
- "@vitest/coverage-v8": "^3.2.6",
54
- "@vue/compiler-sfc": "^3.5.40",
55
- "@vue/test-utils": "^2.4.6",
56
- "jsdom": "^24.1.3",
57
- "sass": "^1.79.4",
48
+ "@origen-ui/admin-cli": "1.1.0",
49
+ "@playwright/test": "1.62.1",
50
+ "@types/node": "22.20.1",
51
+ "@vitejs/plugin-vue": "6.0.8",
52
+ "@vitejs/plugin-vue-jsx": "5.1.6",
53
+ "@vitest/coverage-v8": "4.1.11",
54
+ "@vue/compiler-sfc": "3.5.41",
55
+ "@vue/test-utils": "2.4.11",
56
+ "jsdom": "30.0.1",
57
+ "sass": "1.103.0",
58
58
  "swagger-typescript-api": "^13.12.6",
59
- "typescript": "^5.6.2",
60
- "unplugin-element-plus": "^0.10.0",
61
- "vite": "^7.3.6",
62
- "vitest": "^3.2.6",
63
- "vue-tsc": "^3.1.8"
59
+ "typescript": "5.9.3",
60
+ "unplugin-element-plus": "0.11.2",
61
+ "vite": "8.2.2",
62
+ "vitest": "4.1.11",
63
+ "vue-tsc": "3.3.10"
64
64
  }
65
65
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "scaffoldVersion": "1.0.2",
4
- "agentContractsVersion": "1.0.2",
3
+ "scaffoldVersion": "1.1.0",
4
+ "agentContractsVersion": "1.1.0",
5
5
  "variant": "examples",
6
6
  "examplesPresent": true,
7
7
  "appliedMigrations": [],
@@ -0,0 +1,71 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { createAdminBuildOptions, createAdminBuildPlugins } from '../vite.build-policy'
3
+
4
+ describe('admin build chunk policy', () => {
5
+ it('uses native Rolldown code splitting groups', () => {
6
+ const output = createAdminBuildOptions(false)?.rolldownOptions?.output
7
+ expect(Array.isArray(output)).toBe(false)
8
+ if (!output || Array.isArray(output)) throw new Error('Expected one Admin output configuration')
9
+
10
+ expect(output.manualChunks).toBeUndefined()
11
+ expect(output.codeSplitting).not.toBe(true)
12
+ expect(output.codeSplitting).not.toBe(false)
13
+ if (!output.codeSplitting || typeof output.codeSplitting !== 'object') {
14
+ throw new Error('Expected native Rolldown code splitting options')
15
+ }
16
+
17
+ const groupNames = output.codeSplitting.groups
18
+ ?.map((group) => group.name)
19
+ .filter((name): name is string => typeof name === 'string')
20
+ expect(groupNames).toEqual(
21
+ expect.arrayContaining([
22
+ 'vendor-vue-runtime',
23
+ 'vendor-vue-i18n',
24
+ 'vendor-vueuse',
25
+ 'vendor-positioning',
26
+ 'vendor-table-suite',
27
+ 'vendor-initial',
28
+ ]),
29
+ )
30
+ expect(output.codeSplitting.groups?.some((group) => group.entriesAware)).toBe(true)
31
+ const tableSuite = output.codeSplitting.groups?.find(
32
+ (group) => group.name === 'vendor-table-suite',
33
+ )
34
+ expect(tableSuite?.maxSize).toBeUndefined()
35
+ })
36
+
37
+ it('drops debug calls in the production output minifier only', () => {
38
+ const productionOutput = createAdminBuildOptions(false)?.rolldownOptions?.output
39
+ const debugOutput = createAdminBuildOptions(true)?.rolldownOptions?.output
40
+ if (!productionOutput || Array.isArray(productionOutput)) {
41
+ throw new Error('Expected one production output configuration')
42
+ }
43
+ if (!debugOutput || Array.isArray(debugOutput)) {
44
+ throw new Error('Expected one debug output configuration')
45
+ }
46
+
47
+ expect(productionOutput.minify).toMatchObject({
48
+ compress: { dropConsole: true, dropDebugger: true },
49
+ mangle: true,
50
+ codegen: true,
51
+ })
52
+ expect(debugOutput.minify).toBeUndefined()
53
+ })
54
+
55
+ it('keeps sourcemaps valid when normalizing empty chunks', async () => {
56
+ const renderChunk = createAdminBuildPlugins()[0]?.renderChunk
57
+ if (typeof renderChunk !== 'function') throw new Error('Expected the empty chunk render hook')
58
+
59
+ const result = await renderChunk.call(
60
+ {} as never,
61
+ 'export {};',
62
+ {} as never,
63
+ {} as never,
64
+ {} as never,
65
+ )
66
+ expect(result).toMatchObject({
67
+ code: 'void 0;\n',
68
+ map: { mappings: '' },
69
+ })
70
+ })
71
+ })
@@ -4,6 +4,7 @@ import zhCn from 'element-plus/es/locale/lang/zh-cn'
4
4
  import { useOrigenUiLanguage } from 'origen-ui/language'
5
5
  import { computed, defineAsyncComponent, onBeforeUnmount, onMounted } from 'vue'
6
6
  import { RouterView, useRoute } from 'vue-router'
7
+ import { embeddedMode } from './app/embedded'
7
8
  import { useThemeStore } from './features/appearance/store/theme'
8
9
  import DevtoolsProtectionOverlay from './features/security/components/DevtoolsProtectionOverlay.vue'
9
10
  import { devtoolsProtection } from './features/security/devtoolsProtection'
@@ -27,12 +28,17 @@ const elementLocale = computed(
27
28
  )
28
29
 
29
30
  const theme = useThemeStore()
30
- theme.hydrate()
31
- theme.apply()
31
+ // 嵌入模式下 dark class 由主壳注入桥持有(embedded.ts applyHostTheme),
32
+ // 本应用自身的主题持久化/auto 跟随不生效,避免与主壳下发互相覆盖
33
+ if (!embeddedMode) {
34
+ theme.hydrate()
35
+ theme.apply()
36
+ }
32
37
  let mql: MediaQueryList | null = null
33
38
  let listener: ((e: MediaQueryListEvent) => void) | null = null
34
39
 
35
40
  onMounted(() => {
41
+ if (embeddedMode) return
36
42
  mql = window.matchMedia('(prefers-color-scheme: dark)')
37
43
  listener = () => {
38
44
  if (theme.mode === 'auto') theme.apply()
@@ -53,7 +59,8 @@ onBeforeUnmount(() => {
53
59
  :aria-hidden="devtoolsBlocked ? 'true' : undefined"
54
60
  >
55
61
  <RouteProgress />
56
- <RouterView v-if="isPublic" />
62
+ <!-- 嵌入模式渲染裸内容页:外壳(侧栏/页签)由主壳提供,壳中壳取一层 -->
63
+ <RouterView v-if="isPublic || embeddedMode" />
57
64
  <AdminLayout v-else />
58
65
  </div>
59
66
  <DevtoolsProtectionOverlay :blocked="devtoolsBlocked" />
@@ -1,22 +1,92 @@
1
1
  import type { RefreshResult, TokenStorage } from '@origen-ui/http'
2
+ import type { AxiosAdapter, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
2
3
  import {
3
4
  ApiClient,
4
5
  createApiEnvelopeAdapter,
5
6
  createBearerAuthStrategy,
6
7
  TokenManager,
7
8
  } from '@origen-ui/http'
9
+ import axios, { AxiosHeaders } from 'axios'
10
+ import { embeddedMode, embeddedTokenStorage, notifyHostUnauthorized, readHostInjection } from '../app/embedded'
11
+ import { currentAdminLocale } from '../app/localeFormat'
8
12
  import { appRuntimeConfig } from '../app/runtimeConfig'
9
13
 
10
14
  const { http } = appRuntimeConfig
11
15
  const responseAdapter = createApiEnvelopeAdapter(http.responseSuccessCode)
12
16
 
13
- function currentLocale(): string {
14
- if (typeof document !== 'undefined' && document.documentElement.lang) {
15
- return document.documentElement.lang
17
+ // 嵌入模式:iframe 沙箱内相对路径解析到主壳源,API 基址改用主壳按注册表
18
+ // 下发的同源网关路径(dev 期 Vite proxy,生产经网关);独立模式保持相对路径。
19
+ // 沙箱补丁与 Rolldown 打包的 axios XHR/fetch 内置适配器不兼容(请求 status 0
20
+ // 或挂起),嵌入模式改用直调 window.fetch 的自定义适配器,绕开沙箱 XHR 补丁。
21
+ const injected = readHostInjection()
22
+ const apiBaseURL =
23
+ embeddedMode && typeof injected.apiBaseURL === 'string' && injected.apiBaseURL !== ''
24
+ ? injected.apiBaseURL
25
+ : http.baseURL
26
+
27
+ function serializeParams(
28
+ url: string,
29
+ params: Record<string, unknown> | URLSearchParams | undefined,
30
+ ): string {
31
+ if (!params) return url
32
+ const search = new URLSearchParams()
33
+ if (params instanceof URLSearchParams) {
34
+ params.forEach((value, key) => search.append(key, value))
35
+ } else {
36
+ for (const [key, value] of Object.entries(params)) {
37
+ if (value === undefined || value === null) continue
38
+ if (Array.isArray(value)) {
39
+ for (const item of value) search.append(key, String(item))
40
+ } else {
41
+ search.append(key, String(value))
42
+ }
43
+ }
16
44
  }
17
- return appRuntimeConfig.locale.default
45
+ const query = search.toString()
46
+ if (query === '') return url
47
+ return url + (url.includes('?') ? '&' : '?') + query
18
48
  }
19
49
 
50
+ function createWindowFetchAdapter(): AxiosAdapter {
51
+ return async (config: InternalAxiosRequestConfig): Promise<AxiosResponse> => {
52
+ const method = (config.method ?? 'get').toUpperCase()
53
+ const headers = AxiosHeaders.from(config.headers)
54
+ headers.set('Accept-Language', currentAdminLocale())
55
+ let body: string | undefined
56
+ if (config.data !== undefined && method !== 'GET' && method !== 'HEAD') {
57
+ headers.setContentType('application/json')
58
+ body = typeof config.data === 'string' ? config.data : JSON.stringify(config.data)
59
+ }
60
+ const url = serializeParams(axios.getUri(config), config.params as never)
61
+ const response = await fetch(url, {
62
+ method,
63
+ headers: headers.toJSON() as Record<string, string>,
64
+ body,
65
+ signal: config.signal as AbortSignal | undefined,
66
+ })
67
+ const text = await response.text()
68
+ let data: unknown = text
69
+ try {
70
+ data = text === '' ? null : JSON.parse(text)
71
+ } catch {
72
+ data = text
73
+ }
74
+ const responseHeaders = AxiosHeaders.from(response.headers as unknown as Record<string, string>)
75
+ return {
76
+ data,
77
+ status: response.status,
78
+ statusText: response.statusText,
79
+ headers: responseHeaders,
80
+ config,
81
+ request: { responseURL: response.url },
82
+ }
83
+ }
84
+ }
85
+
86
+ const embeddedFetchAdapter: AxiosAdapter | undefined = embeddedMode
87
+ ? createWindowFetchAdapter()
88
+ : undefined
89
+
20
90
  function browserStorage(): TokenStorage | undefined {
21
91
  return typeof localStorage === 'undefined' ? undefined : localStorage
22
92
  }
@@ -30,21 +100,27 @@ function readCookie(name: string): string | null {
30
100
 
31
101
  export const tokenManager = new TokenManager({
32
102
  accessKey: http.tokenKey,
33
- accessStorage: browserStorage(),
103
+ accessStorage: embeddedMode ? embeddedTokenStorage : browserStorage(),
34
104
  })
35
105
 
36
106
  const refreshClient = new ApiClient({
37
- baseURL: http.baseURL,
107
+ baseURL: apiBaseURL,
108
+ ...(embeddedFetchAdapter ? { adapter: embeddedFetchAdapter } : {}),
38
109
  responseAdapter,
39
110
  retry: http.refreshRetry,
40
111
  timeout: http.timeout,
41
- resolveHeaders: () => ({ 'Accept-Language': currentLocale() }),
112
+ resolveHeaders: () => ({ 'Accept-Language': currentAdminLocale() }),
42
113
  })
43
114
 
44
115
  export const apiClient = new ApiClient({
45
116
  auth: createBearerAuthStrategy({
46
117
  csrfToken: () => readCookie(http.csrfCookieName),
47
118
  onExpired: () => {
119
+ // 嵌入模式:认证由主壳唯一持有,通知主壳重新授权,不做沙箱内硬导航
120
+ if (embeddedMode) {
121
+ notifyHostUnauthorized()
122
+ return
123
+ }
48
124
  if (typeof window !== 'undefined' && window.location.pathname !== '/login')
49
125
  window.location.assign('/login')
50
126
  },
@@ -60,13 +136,17 @@ export const apiClient = new ApiClient({
60
136
  },
61
137
  )
62
138
  },
139
+ // 嵌入模式冻结自刷新:token 轮换由主壳唯一执行(data 通道推送)
63
140
  shouldRefresh: (error) =>
64
- error.kind === 'business' && http.refreshBusinessCodes.includes(error.code ?? -1),
141
+ !embeddedMode &&
142
+ error.kind === 'business' &&
143
+ http.refreshBusinessCodes.includes(error.code ?? -1),
65
144
  tokenManager,
66
145
  }),
67
- baseURL: http.baseURL,
146
+ ...(embeddedFetchAdapter ? { adapter: embeddedFetchAdapter } : {}),
147
+ baseURL: apiBaseURL,
68
148
  responseAdapter,
69
149
  retry: http.retry,
70
150
  timeout: http.timeout,
71
- resolveHeaders: () => ({ 'Accept-Language': currentLocale() }),
151
+ resolveHeaders: () => ({ 'Accept-Language': currentAdminLocale() }),
72
152
  })
@@ -0,0 +1,268 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+ /*
5
+ * ---------------------------------------------------------------
6
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
+ * ## ##
8
+ * ## AUTHOR: acacode ##
9
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
+ * ---------------------------------------------------------------
11
+ */
12
+
13
+ export interface LoginCredentials {
14
+ /** 用户�?*/
15
+ username: string;
16
+ /** 密码 */
17
+ password: string;
18
+ }
19
+
20
+ export interface LoginResponse {
21
+ /** 访问令牌 */
22
+ token?: string;
23
+ /** 刷新令牌 */
24
+ refreshToken?: string;
25
+ user?: AdminUser;
26
+ /** 权限列表 */
27
+ permissions?: string[];
28
+ /** 角色ID列表 */
29
+ roleIds?: string[];
30
+ /** 授权版本�?*/
31
+ authorizationRevision?: number;
32
+ }
33
+
34
+ export interface ProfileResponse {
35
+ user?: AdminUser;
36
+ permissions?: string[];
37
+ roleIds?: string[];
38
+ authorizationRevision?: number;
39
+ }
40
+
41
+ export interface AdminUser {
42
+ id?: string;
43
+ username?: string;
44
+ name?: string;
45
+ email?: string;
46
+ department?: string;
47
+ roleIds?: string[];
48
+ roleNames?: string[];
49
+ status?: "active" | "suspended";
50
+ /** @format date-time */
51
+ lastActiveAt?: string;
52
+ /** @format date-time */
53
+ createdAt?: string;
54
+ /** @format date-time */
55
+ updatedAt?: string;
56
+ }
57
+
58
+ export interface AdminUserDraft {
59
+ username?: string;
60
+ name: string;
61
+ email?: string;
62
+ department?: string;
63
+ roleIds?: string[];
64
+ status?: "active" | "suspended";
65
+ password?: string;
66
+ }
67
+
68
+ export interface AdminRole {
69
+ id?: string;
70
+ name?: string;
71
+ code?: string;
72
+ description?: string;
73
+ permissions?: string[];
74
+ status?: "active" | "suspended";
75
+ memberCount?: number;
76
+ /** @format date-time */
77
+ createdAt?: string;
78
+ /** @format date-time */
79
+ updatedAt?: string;
80
+ }
81
+
82
+ export interface AdminRoleDraft {
83
+ name: string;
84
+ code: string;
85
+ description?: string;
86
+ permissions?: string[];
87
+ status?: "active" | "suspended";
88
+ }
89
+
90
+ export interface RbacMenu {
91
+ id?: string;
92
+ parentId?: string;
93
+ kind?: "directory" | "page" | "button";
94
+ code?: string;
95
+ title?: string;
96
+ path?: string;
97
+ componentKey?: string;
98
+ icon?: string;
99
+ permission?: string;
100
+ order?: number;
101
+ status?: "active" | "suspended";
102
+ visible?: boolean;
103
+ cache?: boolean;
104
+ tabHidden?: boolean;
105
+ redirect?: string;
106
+ children?: RbacMenu[];
107
+ /** @format date-time */
108
+ createdAt?: string;
109
+ /** @format date-time */
110
+ updatedAt?: string;
111
+ }
112
+
113
+ export interface RbacMenuDraft {
114
+ parentId?: string;
115
+ kind?: "directory" | "page" | "button";
116
+ code?: string;
117
+ title?: string;
118
+ path?: string;
119
+ componentKey?: string;
120
+ icon?: string;
121
+ permission?: string;
122
+ order?: number;
123
+ status?: "active" | "suspended";
124
+ visible?: boolean;
125
+ cache?: boolean;
126
+ tabHidden?: boolean;
127
+ redirect?: string;
128
+ }
129
+
130
+ export interface BackendMenuNode {
131
+ code?: string;
132
+ path?: string;
133
+ title?: string;
134
+ componentKey?: string;
135
+ icon?: string;
136
+ permissions?: string[];
137
+ parentPath?: string;
138
+ menu?: boolean;
139
+ hidden?: boolean;
140
+ order?: number;
141
+ cache?: boolean;
142
+ tabHidden?: boolean;
143
+ redirect?: string;
144
+ children?: BackendMenuNode[];
145
+ }
146
+
147
+ export interface RbacAuditEvent {
148
+ id?: string;
149
+ /** @format date-time */
150
+ at?: string;
151
+ actorId?: string;
152
+ actorName?: string;
153
+ action?: string;
154
+ targetType?: "user" | "role" | "menu" | "authorization";
155
+ targetId?: string;
156
+ targetName?: string;
157
+ detail?: string;
158
+ }
159
+
160
+ export interface OrderDraft {
161
+ id?: string;
162
+ orderNo?: string;
163
+ customer?: string;
164
+ status?: "draft" | "submitted";
165
+ note?: string;
166
+ lines?: OrderDraftLine[];
167
+ totalAmount?: number;
168
+ /** @format date-time */
169
+ createdAt?: string;
170
+ /** @format date-time */
171
+ updatedAt?: string;
172
+ }
173
+
174
+ export interface OrderDraftDraft {
175
+ customer?: string;
176
+ status?: "draft" | "submitted";
177
+ note?: string;
178
+ lines?: OrderDraftLine[];
179
+ }
180
+
181
+ export interface OrderDraftLine {
182
+ id?: string;
183
+ sku?: string;
184
+ name?: string;
185
+ quantity?: number;
186
+ unitPrice?: number;
187
+ }
188
+
189
+ export interface ContentArticle {
190
+ id?: string;
191
+ title?: string;
192
+ summary?: string;
193
+ status?: "draft" | "published";
194
+ contentHtml?: string;
195
+ coverUrl?: string;
196
+ attachments?: ContentArticleAttachment[];
197
+ /** @format date-time */
198
+ createdAt?: string;
199
+ /** @format date-time */
200
+ updatedAt?: string;
201
+ }
202
+
203
+ export interface ContentArticleDraft {
204
+ title?: string;
205
+ summary?: string;
206
+ status?: "draft" | "published";
207
+ contentHtml?: string;
208
+ coverUrl?: string;
209
+ attachments?: ContentArticleAttachment[];
210
+ }
211
+
212
+ export interface ContentArticleAttachment {
213
+ id?: string;
214
+ name?: string;
215
+ url?: string;
216
+ type?: string;
217
+ size?: number;
218
+ }
219
+
220
+ export interface UploadResponse {
221
+ id?: string;
222
+ name?: string;
223
+ url?: string;
224
+ type?: string;
225
+ size?: number;
226
+ }
227
+
228
+ export interface PageResultAdminUser {
229
+ list?: AdminUser[];
230
+ total?: number;
231
+ page?: number;
232
+ pageSize?: number;
233
+ }
234
+
235
+ export interface PageResultAdminRole {
236
+ list?: AdminRole[];
237
+ total?: number;
238
+ page?: number;
239
+ pageSize?: number;
240
+ }
241
+
242
+ export interface PageResultRbacMenu {
243
+ list?: RbacMenu[];
244
+ total?: number;
245
+ page?: number;
246
+ pageSize?: number;
247
+ }
248
+
249
+ export interface PageResultRbacAuditEvent {
250
+ list?: RbacAuditEvent[];
251
+ total?: number;
252
+ page?: number;
253
+ pageSize?: number;
254
+ }
255
+
256
+ export interface PageResultOrderDraft {
257
+ list?: OrderDraft[];
258
+ total?: number;
259
+ page?: number;
260
+ pageSize?: number;
261
+ }
262
+
263
+ export interface PageResultContentArticle {
264
+ list?: ContentArticle[];
265
+ total?: number;
266
+ page?: number;
267
+ pageSize?: number;
268
+ }