@origen-ui/admin-cli 1.1.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -9
- package/package.json +26 -2
- package/templates/current/clean/.node-version +1 -0
- package/templates/current/clean/CHANGELOG.md +125 -0
- package/templates/current/clean/README.md +2 -1
- package/templates/current/clean/component-catalog.json +58 -17
- package/templates/current/clean/e2e/admin-shell.spec.ts +6 -0
- package/templates/current/clean/e2e/demo-shell.spec.ts +94 -50
- package/templates/current/clean/package.json +39 -25
- package/templates/current/clean/playwright.config.ts +1 -0
- package/templates/current/clean/playwright.demo.config.ts +1 -1
- package/templates/current/clean/pnpm-workspace.yaml +18 -0
- package/templates/current/clean/scaffold.lock.json +2 -2
- package/templates/current/clean/scripts/check-admin-scaffold.mjs +5 -1
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
- package/templates/current/clean/scripts/clean-overlay/src/main.ts +23 -14
- package/templates/current/clean/scripts/clean-overlay/src/router/componentCache.ts +12 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
- package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
- package/templates/current/clean/scripts/clean-overlay/src/router/paths.ts +21 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
- package/templates/current/clean/scripts/demo-api.ts +88 -12
- package/templates/current/clean/scripts/generate-api.ts +87 -3
- package/templates/current/clean/scripts/remove-examples.mjs +4 -4
- package/templates/current/clean/scripts/vite-build-policy.spec.ts +1 -0
- package/templates/current/clean/src/api/generated/data-contracts.ts +2 -5
- package/templates/current/clean/src/api/generated/http-client.ts +28 -26
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +5 -8
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -4
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +2 -5
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +8 -10
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +11 -12
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +8 -10
- package/templates/current/clean/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +8 -10
- package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +3 -6
- package/templates/current/clean/src/app/errorMessage.spec.ts +76 -0
- package/templates/current/clean/src/app/errorMessage.ts +53 -0
- package/templates/current/clean/src/app/menu-host.spec.ts +77 -0
- package/templates/current/clean/src/app/menu.spec.ts +39 -0
- package/templates/current/clean/src/app/menu.ts +48 -12
- package/templates/current/clean/src/app/runtimeConfig.ts +1 -1
- package/templates/current/clean/src/demo-api.spec.ts +314 -3
- package/templates/current/clean/src/features/auth/pages/Login.vue +9 -2
- package/templates/current/clean/src/features/auth/store/auth.ts +6 -19
- package/templates/current/clean/src/features/errors/pages/Forbidden.vue +7 -2
- package/templates/current/clean/src/features/errors/pages/NotFound.vue +7 -2
- package/templates/current/clean/src/features/errors/pages/ServerError.vue +7 -2
- package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +11 -2
- package/templates/current/clean/src/features/system/access/api/admin-repository.ts +2 -6
- package/templates/current/clean/src/features/system/access/api/rbac.ts +19 -9
- package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
- package/templates/current/clean/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
- package/templates/current/clean/src/features/workspace/pages/Profile.vue +1 -1
- package/templates/current/clean/src/layouts/AdminLayout.vue +3 -0
- package/templates/current/clean/src/layouts/TopBar.vue +37 -6
- package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +24 -1
- package/templates/current/clean/src/layouts/topBarMenuSearch.ts +10 -0
- package/templates/current/clean/src/locales/en-US.json +30 -3
- package/templates/current/clean/src/locales/en-US.runtime.ts +2 -0
- package/templates/current/clean/src/locales/index.ts +39 -26
- package/templates/current/clean/src/locales/zh-CN.json +30 -3
- package/templates/current/clean/src/locales/zh-CN.runtime.ts +2 -0
- package/templates/current/clean/src/locales/zh-TW.json +30 -3
- package/templates/current/clean/src/locales/zh-TW.runtime.ts +2 -0
- package/templates/current/clean/src/main.ts +23 -14
- package/templates/current/clean/src/router/bootstrap.ts +10 -16
- package/templates/current/clean/src/router/componentCache.ts +12 -0
- package/templates/current/clean/src/router/componentRegistry.ts +2 -13
- package/templates/current/clean/src/router/dynamicMenuRefresh.spec.ts +101 -0
- package/templates/current/clean/src/router/dynamicMenuRefresh.ts +24 -0
- package/templates/current/clean/src/router/dynamicRoutes.spec.ts +34 -4
- package/templates/current/clean/src/router/dynamicRoutes.ts +14 -3
- package/templates/current/clean/src/router/paths.spec.ts +50 -0
- package/templates/current/clean/src/router/paths.ts +21 -0
- package/templates/current/clean/src/router/queryEncryption.spec.ts +10 -1
- package/templates/current/clean/src/router/routeQuery.spec.ts +2 -1
- package/templates/current/clean/src/router/routeQuery.ts +4 -1
- package/templates/current/clean/src/router/staticRoutes.ts +6 -6
- package/templates/current/clean/src/templates/og-table.ts +2 -4
- package/templates/current/clean/tsconfig.json +0 -1
- package/templates/current/clean/vite.build-policy.ts +55 -8
- package/templates/current/clean/vite.config.ts +30 -0
- package/templates/current/examples/.node-version +1 -0
- package/templates/current/examples/CHANGELOG.md +125 -0
- package/templates/current/examples/README.md +2 -1
- package/templates/current/examples/component-catalog.json +58 -17
- package/templates/current/examples/e2e/admin-shell.spec.ts +6 -0
- package/templates/current/examples/e2e/demo-shell.spec.ts +94 -50
- package/templates/current/examples/package.json +39 -25
- package/templates/current/examples/playwright.config.ts +1 -0
- package/templates/current/examples/playwright.demo.config.ts +1 -1
- package/templates/current/examples/pnpm-workspace.yaml +18 -0
- package/templates/current/examples/scaffold.lock.json +2 -2
- package/templates/current/examples/scripts/check-admin-scaffold.mjs +5 -1
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +7 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +7 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +7 -2
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +11 -2
- package/templates/current/examples/scripts/clean-overlay/src/main.ts +23 -14
- package/templates/current/examples/scripts/clean-overlay/src/router/componentCache.ts +12 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +2 -13
- package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +34 -4
- package/templates/current/examples/scripts/clean-overlay/src/router/paths.ts +21 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +6 -6
- package/templates/current/examples/scripts/demo-api.ts +88 -12
- package/templates/current/examples/scripts/generate-api.ts +87 -3
- package/templates/current/examples/scripts/remove-examples.mjs +4 -4
- package/templates/current/examples/scripts/vite-build-policy.spec.ts +1 -0
- package/templates/current/examples/src/api/generated/data-contracts.ts +2 -5
- package/templates/current/examples/src/api/generated/http-client.ts +28 -26
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/206/205/345/256/271/346/226/207/347/253/240.ts +5 -8
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/345/256/241/350/256/241.ts +1 -4
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/346/226/207/344/273/266/344/270/212/344/274/240.ts +2 -5
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/347/224/250/346/210/267.ts +8 -10
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/217/234/345/215/225.ts +11 -12
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/247/222/350/211/262.ts +8 -10
- package/templates/current/examples/src/api/generated//347/263/273/347/273/237/347/256/241/347/220/206/350/256/242/345/215/225/350/215/211/347/250/277.ts +8 -10
- package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +3 -6
- package/templates/current/examples/src/app/errorMessage.spec.ts +76 -0
- package/templates/current/examples/src/app/errorMessage.ts +53 -0
- package/templates/current/examples/src/app/menu-host.spec.ts +77 -0
- package/templates/current/examples/src/app/menu.spec.ts +39 -0
- package/templates/current/examples/src/app/menu.ts +48 -12
- package/templates/current/examples/src/app/runtimeConfig.ts +1 -1
- package/templates/current/examples/src/demo-api.spec.ts +314 -3
- package/templates/current/examples/src/features/auth/pages/Login.vue +9 -2
- package/templates/current/examples/src/features/auth/store/auth.ts +6 -19
- package/templates/current/examples/src/features/errors/pages/Forbidden.vue +2 -1
- package/templates/current/examples/src/features/errors/pages/NotFound.vue +2 -1
- package/templates/current/examples/src/features/errors/pages/ServerError.vue +2 -1
- package/templates/current/examples/src/features/feature-composables.spec.ts +11 -1
- package/templates/current/examples/src/features/system/access/api/admin-repository.ts +2 -6
- package/templates/current/examples/src/features/system/access/api/rbac.ts +19 -9
- package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.spec.ts +134 -0
- package/templates/current/examples/src/features/system/access/composables/useAuthorizationPolling.ts +96 -0
- package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +115 -28
- package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +162 -66
- package/templates/current/examples/src/features/system/menus/menuDraft.spec.ts +204 -0
- package/templates/current/examples/src/features/system/menus/menuDraft.ts +116 -0
- package/templates/current/examples/src/features/system/menus/menuTreePrecheck.spec.ts +268 -0
- package/templates/current/examples/src/features/system/menus/menuTreePrecheck.ts +317 -0
- package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +1 -0
- package/templates/current/examples/src/features/workspace/pages/Profile.vue +1 -1
- package/templates/current/examples/src/layouts/AdminLayout.vue +3 -0
- package/templates/current/examples/src/layouts/TopBar.vue +37 -6
- package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +24 -1
- package/templates/current/examples/src/layouts/topBarMenuSearch.ts +10 -0
- package/templates/current/examples/src/locales/en-US.json +30 -3
- package/templates/current/examples/src/locales/en-US.runtime.ts +2 -0
- package/templates/current/examples/src/locales/index.ts +39 -26
- package/templates/current/examples/src/locales/zh-CN.json +30 -3
- package/templates/current/examples/src/locales/zh-CN.runtime.ts +2 -0
- package/templates/current/examples/src/locales/zh-TW.json +30 -3
- package/templates/current/examples/src/locales/zh-TW.runtime.ts +2 -0
- package/templates/current/examples/src/main.ts +24 -22
- package/templates/current/examples/src/router/bootstrap.ts +10 -16
- package/templates/current/examples/src/router/componentCache.ts +18 -0
- package/templates/current/examples/src/router/componentRegistry.ts +1 -18
- package/templates/current/examples/src/router/dynamicMenuRefresh.spec.ts +101 -0
- package/templates/current/examples/src/router/dynamicMenuRefresh.ts +24 -0
- package/templates/current/examples/src/router/dynamicRoutes.spec.ts +20 -2
- package/templates/current/examples/src/router/dynamicRoutes.ts +14 -3
- package/templates/current/examples/src/router/paths.spec.ts +50 -0
- package/templates/current/examples/src/router/paths.ts +21 -0
- package/templates/current/examples/src/router/queryEncryption.spec.ts +10 -1
- package/templates/current/examples/src/router/routeQuery.spec.ts +2 -1
- package/templates/current/examples/src/router/routeQuery.ts +4 -1
- package/templates/current/examples/src/router/staticRoutes.ts +3 -3
- package/templates/current/examples/src/templates/og-table.ts +2 -4
- package/templates/current/examples/tsconfig.json +0 -1
- package/templates/current/examples/vite.build-policy.ts +55 -8
- package/templates/current/examples/vite.config.ts +30 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { RouteSourceNode } from '@origen-ui/router'
|
|
2
2
|
import type { BackendMenuNode } from '../app/menuTypes'
|
|
3
|
-
import { componentCacheNames, fallbackComponentKey } from './
|
|
4
|
-
|
|
5
|
-
export { componentRegistry } from './componentRegistry'
|
|
3
|
+
import { componentCacheNames, fallbackComponentKey } from './componentCache'
|
|
6
4
|
|
|
7
5
|
function routeName(source: BackendMenuNode, used: Set<string>): string {
|
|
8
6
|
const base = `dyn-${source.code.replace(/[^\w-]+/g, '-').replace(/^-|-$/g, '') || 'route'}`
|
|
@@ -128,6 +126,8 @@ function buildTree(nodes: readonly BackendMenuNode[]): readonly BackendMenuNode[
|
|
|
128
126
|
])
|
|
129
127
|
candidates.delete(item)
|
|
130
128
|
if (candidates.size > 1) throw new Error(`Ambiguous dynamic route parent path: ${parentPath}`)
|
|
129
|
+
if (candidates.size === 0)
|
|
130
|
+
throw new Error(`Unresolved dynamic route parent path: ${parentPath}`)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
for (const item of entries) {
|
|
@@ -144,7 +144,18 @@ function buildTree(nodes: readonly BackendMenuNode[]): readonly BackendMenuNode[
|
|
|
144
144
|
return roots.map(materialize)
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
function assertUniqueCodes(nodes: readonly BackendMenuNode[], seen = new Set<string>()): void {
|
|
148
|
+
for (const node of nodes) {
|
|
149
|
+
if (seen.has(node.code)) throw new Error(`Duplicate dynamic route code: ${node.code}`)
|
|
150
|
+
seen.add(node.code)
|
|
151
|
+
assertUniqueCodes(node.children ?? [], seen)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
147
155
|
export function routeTransformer(sources: readonly BackendMenuNode[]): readonly RouteSourceNode[] {
|
|
156
|
+
// buildTree 按 code 去重会静默丢弃后到的重复节点,连同其子树一起消失;
|
|
157
|
+
// 在此显式失败,给出可定位的数据错误。
|
|
158
|
+
assertUniqueCodes(sources)
|
|
148
159
|
const usedNames = new Set<string>()
|
|
149
160
|
const tree = buildTree(sources)
|
|
150
161
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { RouteMenuItem } from '@origen-ui/router'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
import { firstMenuTarget, HOME_ROUTE, NOT_FOUND_ROUTE_NAME } from './paths'
|
|
4
|
+
import { staticRoutes } from './staticRoutes'
|
|
5
|
+
|
|
6
|
+
describe('router paths', () => {
|
|
7
|
+
it('keeps the root static redirect aligned with HOME_ROUTE', () => {
|
|
8
|
+
const root = staticRoutes.find((route) => route.name === 'root')
|
|
9
|
+
expect(root?.redirect).toBe(HOME_ROUTE)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('pins the not-found fallback to the static 404 route', () => {
|
|
13
|
+
expect(staticRoutes.some((route) => route.name === NOT_FOUND_ROUTE_NAME)).toBe(true)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('resolves the first navigable menu target depth-first', () => {
|
|
17
|
+
const items = [
|
|
18
|
+
{ id: 'locked', label: 'Locked', children: [] },
|
|
19
|
+
{
|
|
20
|
+
id: 'section',
|
|
21
|
+
label: 'Section',
|
|
22
|
+
to: { name: 'section' },
|
|
23
|
+
children: [{ id: 'inner', label: 'Inner', to: { name: 'inner' }, children: [] }],
|
|
24
|
+
},
|
|
25
|
+
] as readonly RouteMenuItem[]
|
|
26
|
+
|
|
27
|
+
expect(firstMenuTarget(items)).toEqual({ name: 'section' })
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it('returns undefined when no menu item is navigable', () => {
|
|
31
|
+
const items = [{ id: 'empty', label: 'Empty', children: [] }] as readonly RouteMenuItem[]
|
|
32
|
+
|
|
33
|
+
expect(firstMenuTarget(items)).toBeUndefined()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('skips entries rejected by the reachability predicate', () => {
|
|
37
|
+
const items = [
|
|
38
|
+
{ id: 'gone', label: 'Gone', to: { path: '/gone' }, children: [] },
|
|
39
|
+
{ id: 'live', label: 'Live', to: { name: 'live' }, children: [] },
|
|
40
|
+
] as readonly RouteMenuItem[]
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
firstMenuTarget(items, (to) => {
|
|
44
|
+
const path = typeof to === 'string' ? to : to.path
|
|
45
|
+
return path !== '/gone'
|
|
46
|
+
}),
|
|
47
|
+
).toEqual({ name: 'live' })
|
|
48
|
+
expect(firstMenuTarget(items, () => false)).toBeUndefined()
|
|
49
|
+
})
|
|
50
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RouteMenuItem } from '@origen-ui/router'
|
|
2
|
+
import type { RouteLocationRaw } from 'vue-router'
|
|
3
|
+
|
|
4
|
+
/** 授权后的默认首页路由;与 staticRoutes 根路由 redirect 由 paths.spec 钉住一致。 */
|
|
5
|
+
export const HOME_ROUTE = '/workspace'
|
|
6
|
+
|
|
7
|
+
/** staticRoutes 中 404 兜底页的路由名。 */
|
|
8
|
+
export const NOT_FOUND_ROUTE_NAME = '404'
|
|
9
|
+
|
|
10
|
+
/** 深度优先取菜单树中首个可导航入口;isReachable 用于剔除重定向到已裁撤路由的目录项。 */
|
|
11
|
+
export function firstMenuTarget(
|
|
12
|
+
items: readonly RouteMenuItem[],
|
|
13
|
+
isReachable: (to: RouteLocationRaw) => boolean = () => true,
|
|
14
|
+
): RouteLocationRaw | undefined {
|
|
15
|
+
for (const item of items) {
|
|
16
|
+
if (item.to && isReachable(item.to)) return item.to
|
|
17
|
+
const child = firstMenuTarget(item.children, isReachable)
|
|
18
|
+
if (child) return child
|
|
19
|
+
}
|
|
20
|
+
return undefined
|
|
21
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RouteRecordRaw } from 'vue-router'
|
|
2
2
|
import { gcm } from '@noble/ciphers/aes.js'
|
|
3
|
-
import { createRouterAdapter } from '@origen-ui/router'
|
|
3
|
+
import { createRouterAdapter, getRouteQueryString } from '@origen-ui/router'
|
|
4
4
|
import { describe, expect, it } from 'vitest'
|
|
5
5
|
import { defineComponent } from 'vue'
|
|
6
6
|
import { createMemoryHistory } from 'vue-router'
|
|
@@ -70,6 +70,15 @@ describe('route query encryption', () => {
|
|
|
70
70
|
expect(codec.parseQuery(`${encoded}&_q=${encodeURIComponent('v2.invalid.ciphertext')}`)).toEqual({})
|
|
71
71
|
})
|
|
72
72
|
|
|
73
|
+
it('normalizes encrypted single-value arrays without choosing duplicate values', () => {
|
|
74
|
+
const codec = createRouteQueryEncryption({ enabled: true, key })!
|
|
75
|
+
const single = codec.parseQuery(codec.stringifyQuery({ redirect: ['/dashboard'] }))
|
|
76
|
+
const duplicate = codec.parseQuery(codec.stringifyQuery({ redirect: ['/a', '/b'] }))
|
|
77
|
+
|
|
78
|
+
expect(getRouteQueryString(single.redirect)).toBe('/dashboard')
|
|
79
|
+
expect(getRouteQueryString(duplicate.redirect)).toBeUndefined()
|
|
80
|
+
})
|
|
81
|
+
|
|
73
82
|
it('rejects authenticated JSON values that are not a route query shape', () => {
|
|
74
83
|
const codec = createRouteQueryEncryption({ enabled: true, key })!
|
|
75
84
|
|
|
@@ -5,7 +5,8 @@ describe('route query helpers', () => {
|
|
|
5
5
|
it('accepts only supported status values', () => {
|
|
6
6
|
expect(routeStatus('active')).toBe('active')
|
|
7
7
|
expect(routeStatus('suspended')).toBe('suspended')
|
|
8
|
-
expect(routeStatus(['suspended'])).
|
|
8
|
+
expect(routeStatus(['suspended'])).toBe('suspended')
|
|
9
|
+
expect(routeStatus(['active', 'suspended'])).toBeUndefined()
|
|
9
10
|
expect(routeStatus('unknown')).toBeUndefined()
|
|
10
11
|
})
|
|
11
12
|
})
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { getRouteQueryString } from '@origen-ui/router'
|
|
2
|
+
|
|
1
3
|
export function routeStatus(value: unknown): 'active' | 'suspended' | undefined {
|
|
2
|
-
|
|
4
|
+
const normalized = getRouteQueryString(value)
|
|
5
|
+
return normalized === 'active' || normalized === 'suspended' ? normalized : undefined
|
|
3
6
|
}
|
|
@@ -26,7 +26,7 @@ export const staticRoutes: RouteRecordRaw[] = [
|
|
|
26
26
|
path: '/login',
|
|
27
27
|
name: 'login',
|
|
28
28
|
component: Login,
|
|
29
|
-
meta: { adapter: {
|
|
29
|
+
meta: { adapter: { titleKey: 'auth.login', ...hiddenPublic } },
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
path: '/profile',
|
|
@@ -34,10 +34,10 @@ export const staticRoutes: RouteRecordRaw[] = [
|
|
|
34
34
|
component: Profile,
|
|
35
35
|
meta: {
|
|
36
36
|
adapter: {
|
|
37
|
-
|
|
37
|
+
titleKey: 'menu.profile',
|
|
38
38
|
icon: 'profile',
|
|
39
39
|
menu: { order: 20 },
|
|
40
|
-
breadcrumb: {
|
|
40
|
+
breadcrumb: { labelKey: 'menu.profile' },
|
|
41
41
|
cache: { enabled: true, name: 'ProfilePage' },
|
|
42
42
|
},
|
|
43
43
|
},
|
|
@@ -46,18 +46,18 @@ export const staticRoutes: RouteRecordRaw[] = [
|
|
|
46
46
|
path: '/403',
|
|
47
47
|
name: '403',
|
|
48
48
|
component: Forbidden,
|
|
49
|
-
meta: { adapter: {
|
|
49
|
+
meta: { adapter: { titleKey: 'errors.forbidden.title', ...hiddenPublic } },
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
path: '/404',
|
|
53
53
|
name: '404',
|
|
54
54
|
component: NotFound,
|
|
55
|
-
meta: { adapter: {
|
|
55
|
+
meta: { adapter: { titleKey: 'errors.notFound.title', ...hiddenPublic } },
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
path: '/500',
|
|
59
59
|
name: '500',
|
|
60
60
|
component: ServerError,
|
|
61
|
-
meta: { adapter: {
|
|
61
|
+
meta: { adapter: { titleKey: 'errors.serverError.title', ...hiddenPublic } },
|
|
62
62
|
},
|
|
63
63
|
]
|
|
@@ -9,12 +9,10 @@ import type {
|
|
|
9
9
|
TableRowKey,
|
|
10
10
|
} from '@origen-ui/table'
|
|
11
11
|
import type { AdminMessageKey } from '../locales'
|
|
12
|
-
import {
|
|
12
|
+
import { translateAdminMessage } from '../locales'
|
|
13
13
|
|
|
14
14
|
function tableText(key: AdminMessageKey): string {
|
|
15
|
-
|
|
16
|
-
{ t: (key: AdminMessageKey) => string } | undefined
|
|
17
|
-
return global ? global.t(key) : key
|
|
15
|
+
return translateAdminMessage(key)
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
function withLocalizedLabel<T extends object>(
|
|
@@ -7,10 +7,7 @@ const packageBuildDirectories = new Set(['dist', 'es', 'esm', 'lib', 'src'])
|
|
|
7
7
|
const MAX_INITIAL_VENDOR_CHUNK_BYTES = 300 * 1024
|
|
8
8
|
const MAX_ASYNC_VENDOR_CHUNK_BYTES = 400 * 1024
|
|
9
9
|
|
|
10
|
-
type AdminCodeSplitting = Exclude<
|
|
11
|
-
NonNullable<Rolldown.OutputOptions['codeSplitting']>,
|
|
12
|
-
boolean
|
|
13
|
-
>
|
|
10
|
+
type AdminCodeSplitting = Exclude<NonNullable<Rolldown.OutputOptions['codeSplitting']>, boolean>
|
|
14
11
|
|
|
15
12
|
function chunkName(value: string): string {
|
|
16
13
|
return value
|
|
@@ -20,7 +17,12 @@ function chunkName(value: string): string {
|
|
|
20
17
|
.toLowerCase()
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
|
|
20
|
+
interface ModuleLocation {
|
|
21
|
+
name: string
|
|
22
|
+
path: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function dependencyPath(normalized: string): ModuleLocation | undefined {
|
|
24
26
|
const marker = '/node_modules/'
|
|
25
27
|
const nodeModulesIndex = normalized.lastIndexOf(marker)
|
|
26
28
|
if (nodeModulesIndex < 0) return undefined
|
|
@@ -35,7 +37,7 @@ function dependencyPath(normalized: string): { name: string, path: string[] } |
|
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
function workspacePackagePath(normalized: string):
|
|
40
|
+
function workspacePackagePath(normalized: string): ModuleLocation | undefined {
|
|
39
41
|
const match = normalized.match(/\/packages\/([^/]+)\/(?:dist|src)\/(.+)$/)
|
|
40
42
|
if (!match) return undefined
|
|
41
43
|
return { name: `og-${match[1]}`, path: match[2].split('/') }
|
|
@@ -62,7 +64,9 @@ function vendorLocation(id: string) {
|
|
|
62
64
|
|
|
63
65
|
function matchesPackageFamily(id: string, names: readonly string[]): boolean {
|
|
64
66
|
const name = vendorLocation(id)?.name
|
|
65
|
-
return Boolean(
|
|
67
|
+
return Boolean(
|
|
68
|
+
name && names.some((candidate) => name === candidate || name.startsWith(`${candidate}/`)),
|
|
69
|
+
)
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
function matchesPackageEntry(id: string, packageName: string, entry: string): boolean {
|
|
@@ -70,6 +74,24 @@ function matchesPackageEntry(id: string, packageName: string, entry: string): bo
|
|
|
70
74
|
return location?.name === packageName && location.path[0] === entry
|
|
71
75
|
}
|
|
72
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Element Plus table internals are extracted from the table-suite chunk they
|
|
79
|
+
* would otherwise co-locate with. The og-table family chunk itself must stay
|
|
80
|
+
* a single chunk — splitting it creates circular chunk-evaluation edges
|
|
81
|
+
* before Element Plus initializes (see the vendor-table-suite note) — but the
|
|
82
|
+
* Element Plus table code it pulls in is a leaf dependency and splits safely.
|
|
83
|
+
* This separation is what keeps the family chunk under the single-chunk
|
|
84
|
+
* budget instead of carrying the whole Element Plus table surface.
|
|
85
|
+
*
|
|
86
|
+
* `moduleLocation` strips the build directory, so published `es/components/…`
|
|
87
|
+
* paths start at `components`.
|
|
88
|
+
*/
|
|
89
|
+
function matchesElementPlusTableModule(id: string, component: 'table' | 'table-v2'): boolean {
|
|
90
|
+
const location = vendorLocation(id)
|
|
91
|
+
if (!location || location.name !== 'element-plus') return false
|
|
92
|
+
return location.path[0] === 'components' && location.path[1] === component
|
|
93
|
+
}
|
|
94
|
+
|
|
73
95
|
function dynamicPackageGroup(
|
|
74
96
|
id: string,
|
|
75
97
|
directory?: 'components' | 'languages' | 'locale',
|
|
@@ -77,7 +99,8 @@ function dynamicPackageGroup(
|
|
|
77
99
|
const location = vendorLocation(id)
|
|
78
100
|
if (!location || location.name === 'element-plus') return undefined
|
|
79
101
|
if (directory && location.path[0] !== directory) return undefined
|
|
80
|
-
const suffix =
|
|
102
|
+
const suffix =
|
|
103
|
+
directory === 'components' ? '-components' : directory ? `-${chunkName(directory)}` : ''
|
|
81
104
|
return `vendor-${chunkName(location.name)}${suffix}`
|
|
82
105
|
}
|
|
83
106
|
|
|
@@ -104,6 +127,14 @@ export function createAdminCodeSplitting(): AdminCodeSplitting {
|
|
|
104
127
|
test: (id) => matchesPackageFamily(id, ['@floating-ui', '@sxzz/popperjs-es']),
|
|
105
128
|
priority: 85,
|
|
106
129
|
},
|
|
130
|
+
{
|
|
131
|
+
// async-validator is a leaf dependency shared by the form and table
|
|
132
|
+
// surfaces. Keeping it outside the table family avoids making the
|
|
133
|
+
// deliberately single-chunk family carry validation internals.
|
|
134
|
+
name: 'vendor-async-validator',
|
|
135
|
+
test: (id) => matchesPackageFamily(id, ['async-validator']),
|
|
136
|
+
priority: 83,
|
|
137
|
+
},
|
|
107
138
|
{
|
|
108
139
|
name: 'vendor-table-suite',
|
|
109
140
|
test: (id) =>
|
|
@@ -122,6 +153,22 @@ export function createAdminCodeSplitting(): AdminCodeSplitting {
|
|
|
122
153
|
// circular chunk-evaluation edge before Element Plus initializes.
|
|
123
154
|
priority: 80,
|
|
124
155
|
},
|
|
156
|
+
{
|
|
157
|
+
// Leaf dependency of the table-suite family: extracted so the family
|
|
158
|
+
// chunk stays under the single-chunk budget. The priority must sit
|
|
159
|
+
// ABOVE vendor-table-suite — Rolldown lets a higher-priority chunk
|
|
160
|
+
// pull lower-priority-grouped dependencies into itself, which is
|
|
161
|
+
// exactly how the Element Plus table internals ended up inside the
|
|
162
|
+
// family chunk — but still below the positioning/vueuse families.
|
|
163
|
+
name: 'vendor-element-table-v2',
|
|
164
|
+
test: (id) => matchesElementPlusTableModule(id, 'table-v2'),
|
|
165
|
+
priority: 82,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'vendor-element-table',
|
|
169
|
+
test: (id) => matchesElementPlusTableModule(id, 'table'),
|
|
170
|
+
priority: 81,
|
|
171
|
+
},
|
|
125
172
|
{
|
|
126
173
|
name: 'vendor-initial',
|
|
127
174
|
test: (id) => Boolean(vendorLocation(id)),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs'
|
|
2
|
+
import { dirname, join } from 'node:path'
|
|
1
3
|
import process from 'node:process'
|
|
2
4
|
import { fileURLToPath } from 'node:url'
|
|
3
5
|
import vue from '@vitejs/plugin-vue'
|
|
@@ -9,6 +11,17 @@ import { defineConfig } from 'vitest/config'
|
|
|
9
11
|
// with the application source as ./vite.build-policy.ts.
|
|
10
12
|
import { createAdminBuildOptions, createAdminBuildPlugins } from './vite.build-policy.js'
|
|
11
13
|
|
|
14
|
+
const elementPlusPackageRoot = dirname(dirname(fileURLToPath(import.meta.resolve('element-plus'))))
|
|
15
|
+
const elementPlusStyleIncludes = readdirSync(join(elementPlusPackageRoot, 'es/components'), {
|
|
16
|
+
withFileTypes: true,
|
|
17
|
+
})
|
|
18
|
+
.filter(
|
|
19
|
+
(entry) =>
|
|
20
|
+
entry.isDirectory() &&
|
|
21
|
+
existsSync(join(elementPlusPackageRoot, 'es/components', entry.name, 'style/index.mjs')),
|
|
22
|
+
)
|
|
23
|
+
.map((entry) => `element-plus/es/components/${entry.name}/style/index`)
|
|
24
|
+
|
|
12
25
|
export default defineConfig(({ command, mode }) => {
|
|
13
26
|
const loadedEnv = loadEnv(mode, process.cwd(), '')
|
|
14
27
|
const apiTarget = loadedEnv.VITE_API_TARGET || 'http://127.0.0.1:8080'
|
|
@@ -17,6 +30,23 @@ export default defineConfig(({ command, mode }) => {
|
|
|
17
30
|
return {
|
|
18
31
|
plugins: [vue(), vueJsx(), ...createAdminBuildPlugins(), ElementPlus({ useSource: true })],
|
|
19
32
|
resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } },
|
|
33
|
+
optimizeDeps: {
|
|
34
|
+
// Element Plus injects these entries only after lazy SFCs transform.
|
|
35
|
+
// Pre-bundle them up front and keep the dependency set fixed for route loads.
|
|
36
|
+
noDiscovery: true,
|
|
37
|
+
include: [
|
|
38
|
+
'@element-plus/icons-vue',
|
|
39
|
+
'@vueuse/core',
|
|
40
|
+
'axios',
|
|
41
|
+
'element-plus',
|
|
42
|
+
'pinia',
|
|
43
|
+
'sortablejs',
|
|
44
|
+
'vue',
|
|
45
|
+
'vue-i18n',
|
|
46
|
+
'vue-router',
|
|
47
|
+
...elementPlusStyleIncludes,
|
|
48
|
+
],
|
|
49
|
+
},
|
|
20
50
|
oxc: {
|
|
21
51
|
jsx: { runtime: 'automatic', importSource: 'vue' },
|
|
22
52
|
...(command === 'build' && !isDebugBuild ? { dropConsole: true, dropDebugger: true } : {}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.23.2
|
|
@@ -1,5 +1,130 @@
|
|
|
1
1
|
# @origen-ui/admin
|
|
2
2
|
|
|
3
|
+
## 1.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- Updated dependencies [98175de]
|
|
9
|
+
- Updated dependencies [fc5a6b3]
|
|
10
|
+
- @origen-ui/shared@2.0.2
|
|
11
|
+
- @origen-ui/permission@2.0.2
|
|
12
|
+
- @origen-ui/http@2.0.2
|
|
13
|
+
- @origen-ui/dialog@2.0.2
|
|
14
|
+
- @origen-ui/editor@2.0.2
|
|
15
|
+
- @origen-ui/upload@2.0.2
|
|
16
|
+
- @origen-ui/search@2.0.2
|
|
17
|
+
- @origen-ui/table@2.0.2
|
|
18
|
+
- @origen-ui/tabs@2.0.2
|
|
19
|
+
- @origen-ui/router@2.0.2
|
|
20
|
+
- @origen-ui/form@2.0.2
|
|
21
|
+
- @origen-ui/form-table@2.0.2
|
|
22
|
+
- @origen-ui/table-search@2.0.2
|
|
23
|
+
- origen-ui@2.0.2
|
|
24
|
+
|
|
25
|
+
## 1.0.6
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies
|
|
30
|
+
- Updated dependencies [d37826a]
|
|
31
|
+
- Updated dependencies [d37826a]
|
|
32
|
+
- Updated dependencies [bb0b902]
|
|
33
|
+
- Updated dependencies [cdbd053]
|
|
34
|
+
- @origen-ui/shared@2.0.1
|
|
35
|
+
- @origen-ui/permission@2.0.1
|
|
36
|
+
- @origen-ui/http@2.0.1
|
|
37
|
+
- @origen-ui/dialog@2.0.1
|
|
38
|
+
- @origen-ui/editor@2.0.1
|
|
39
|
+
- @origen-ui/upload@2.0.1
|
|
40
|
+
- @origen-ui/search@2.0.1
|
|
41
|
+
- @origen-ui/table@2.0.1
|
|
42
|
+
- @origen-ui/tabs@2.0.1
|
|
43
|
+
- @origen-ui/router@2.0.1
|
|
44
|
+
- @origen-ui/form@2.0.1
|
|
45
|
+
- @origen-ui/form-table@2.0.1
|
|
46
|
+
- @origen-ui/table-search@2.0.1
|
|
47
|
+
- origen-ui@2.0.1
|
|
48
|
+
|
|
49
|
+
## 1.0.5
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [ea4fecb]
|
|
54
|
+
- Updated dependencies [ea4fecb]
|
|
55
|
+
- Updated dependencies [608aade]
|
|
56
|
+
- Updated dependencies [8026b2c]
|
|
57
|
+
- Updated dependencies [608aade]
|
|
58
|
+
- Updated dependencies [e0a0dd0]
|
|
59
|
+
- Updated dependencies [013595e]
|
|
60
|
+
- Updated dependencies [2a33f03]
|
|
61
|
+
- Updated dependencies [3ad1c7d]
|
|
62
|
+
- Updated dependencies [2a33f03]
|
|
63
|
+
- Updated dependencies [2a33f03]
|
|
64
|
+
- Updated dependencies [e7b866d]
|
|
65
|
+
- Updated dependencies [013595e]
|
|
66
|
+
- Updated dependencies [005939a]
|
|
67
|
+
- Updated dependencies [e0a0dd0]
|
|
68
|
+
- Updated dependencies [005939a]
|
|
69
|
+
- Updated dependencies [9365e91]
|
|
70
|
+
- Updated dependencies [2a33f03]
|
|
71
|
+
- Updated dependencies [74c09ae]
|
|
72
|
+
- Updated dependencies [2a33f03]
|
|
73
|
+
- Updated dependencies [2a33f03]
|
|
74
|
+
- Updated dependencies [987d611]
|
|
75
|
+
- Updated dependencies [2a33f03]
|
|
76
|
+
- Updated dependencies [013595e]
|
|
77
|
+
- Updated dependencies [3ad1c7d]
|
|
78
|
+
- Updated dependencies [013595e]
|
|
79
|
+
- Updated dependencies [313f8bc]
|
|
80
|
+
- Updated dependencies [013595e]
|
|
81
|
+
- Updated dependencies [013595e]
|
|
82
|
+
- Updated dependencies [013595e]
|
|
83
|
+
- Updated dependencies [013595e]
|
|
84
|
+
- Updated dependencies [987d611]
|
|
85
|
+
- Updated dependencies [ae45cc4]
|
|
86
|
+
- Updated dependencies [8026b2c]
|
|
87
|
+
- Updated dependencies [24aaae4]
|
|
88
|
+
- Updated dependencies [007abdc]
|
|
89
|
+
- Updated dependencies [005939a]
|
|
90
|
+
- Updated dependencies [007abdc]
|
|
91
|
+
- Updated dependencies [007abdc]
|
|
92
|
+
- Updated dependencies [007abdc]
|
|
93
|
+
- Updated dependencies [007abdc]
|
|
94
|
+
- Updated dependencies [007abdc]
|
|
95
|
+
- Updated dependencies [005939a]
|
|
96
|
+
- Updated dependencies [2a33f03]
|
|
97
|
+
- Updated dependencies [2a33f03]
|
|
98
|
+
- Updated dependencies [013595e]
|
|
99
|
+
- Updated dependencies [7d9a7fe]
|
|
100
|
+
- Updated dependencies [987d611]
|
|
101
|
+
- Updated dependencies [ae45cc4]
|
|
102
|
+
- Updated dependencies [ae45cc4]
|
|
103
|
+
- Updated dependencies [15f8a34]
|
|
104
|
+
- Updated dependencies [2a33f03]
|
|
105
|
+
- Updated dependencies [2a33f03]
|
|
106
|
+
- Updated dependencies [987d611]
|
|
107
|
+
- Updated dependencies [005939a]
|
|
108
|
+
- Updated dependencies [825186e]
|
|
109
|
+
- Updated dependencies [a0456b5]
|
|
110
|
+
- Updated dependencies [e7010c6]
|
|
111
|
+
- Updated dependencies [e7010c6]
|
|
112
|
+
- Updated dependencies [e7010c6]
|
|
113
|
+
- @origen-ui/http@2.0.0
|
|
114
|
+
- @origen-ui/editor@2.0.0
|
|
115
|
+
- @origen-ui/form@2.0.0
|
|
116
|
+
- @origen-ui/form-table@2.0.0
|
|
117
|
+
- @origen-ui/router@2.0.0
|
|
118
|
+
- @origen-ui/table@2.0.0
|
|
119
|
+
- @origen-ui/table-search@2.0.0
|
|
120
|
+
- @origen-ui/upload@2.0.0
|
|
121
|
+
- @origen-ui/dialog@2.0.0
|
|
122
|
+
- @origen-ui/search@2.0.0
|
|
123
|
+
- @origen-ui/tabs@2.0.0
|
|
124
|
+
- @origen-ui/permission@2.0.0
|
|
125
|
+
- @origen-ui/shared@2.0.0
|
|
126
|
+
- origen-ui@2.0.0
|
|
127
|
+
|
|
3
128
|
## 1.0.4
|
|
4
129
|
|
|
5
130
|
### Patch Changes
|
|
@@ -13,7 +13,8 @@ Use `pnpm admin:dev` for normal development. Requests to `/api` are proxied to
|
|
|
13
13
|
|
|
14
14
|
Use `pnpm admin:demo` to run the Admin with its local, in-memory development
|
|
15
15
|
API. This mode does not proxy `/api`; it resets its seed data on every server
|
|
16
|
-
restart. Sign in with `admin` / `
|
|
16
|
+
restart. Sign in with `demo-admin` / `demo-password`. These credentials are
|
|
17
|
+
mock-only and must never be used in production.
|
|
17
18
|
|
|
18
19
|
`apps/admin` 是一个 Vue 3 + Pinia 生产管理后台。它只在应用层组合仓库现有的 `@origen-ui/router`、`@origen-ui/http`、独立 Pro 组件包、`origen-ui` 样式子路径与 Element Plus API,不修改任何 `packages/*` 源码。
|
|
19
20
|
|