@origen-ui/admin-cli 1.0.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.
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/bin/og-admin.mjs +131 -0
- package/package.json +28 -0
- package/templates/current/clean/.codebuddy/AGENTS.md +18 -0
- package/templates/current/clean/.codebuddy/rules/01-feature-architecture.md +12 -0
- package/templates/current/clean/.codebuddy/rules/02-vue-typescript.md +12 -0
- package/templates/current/clean/.codebuddy/rules/03-component-policy.md +30 -0
- package/templates/current/clean/.codebuddy/rules/04-api-auth-router.md +12 -0
- package/templates/current/clean/.codebuddy/rules/05-style.md +12 -0
- package/templates/current/clean/.codebuddy/rules/06-quality.md +12 -0
- package/templates/current/clean/.codebuddy/skills/build-admin-feature/SKILL.md +17 -0
- package/templates/current/clean/.codebuddy/skills/style-og-origen-ui/SKILL.md +14 -0
- package/templates/current/clean/.codebuddy/skills/use-og-dialog/SKILL.md +15 -0
- package/templates/current/clean/.codebuddy/skills/use-og-editor/SKILL.md +28 -0
- package/templates/current/clean/.codebuddy/skills/use-og-form/SKILL.md +15 -0
- package/templates/current/clean/.codebuddy/skills/use-og-form-table/SKILL.md +28 -0
- package/templates/current/clean/.codebuddy/skills/use-og-http/SKILL.md +16 -0
- package/templates/current/clean/.codebuddy/skills/use-og-router-tabs/SKILL.md +14 -0
- package/templates/current/clean/.codebuddy/skills/use-og-search/SKILL.md +17 -0
- package/templates/current/clean/.codebuddy/skills/use-og-table/SKILL.md +19 -0
- package/templates/current/clean/.codebuddy/skills/use-og-upload/SKILL.md +28 -0
- package/templates/current/clean/.codex/AGENTS.md +15 -0
- package/templates/current/clean/.codex/rules/01-feature-architecture.md +6 -0
- package/templates/current/clean/.codex/rules/02-vue-typescript.md +6 -0
- package/templates/current/clean/.codex/rules/03-component-policy.md +24 -0
- package/templates/current/clean/.codex/rules/04-api-auth-router.md +6 -0
- package/templates/current/clean/.codex/rules/05-style.md +6 -0
- package/templates/current/clean/.codex/rules/06-quality.md +6 -0
- package/templates/current/clean/.codex/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/clean/.codex/skills/build-admin-feature/references/component-selection.md +25 -0
- package/templates/current/clean/.codex/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/clean/.codex/skills/style-og-origen-ui/agents/openai.yaml +4 -0
- package/templates/current/clean/.codex/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/clean/.codex/skills/use-og-dialog/agents/openai.yaml +4 -0
- package/templates/current/clean/.codex/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/clean/.codex/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/clean/.codex/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/clean/.codex/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/clean/.codex/skills/use-og-http/agents/openai.yaml +4 -0
- package/templates/current/clean/.codex/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/clean/.codex/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/clean/.codex/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/clean/.codex/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/clean/.cursor/AGENTS.md +18 -0
- package/templates/current/clean/.cursor/rules/01-feature-architecture.mdc +12 -0
- package/templates/current/clean/.cursor/rules/02-vue-typescript.mdc +12 -0
- package/templates/current/clean/.cursor/rules/03-component-policy.mdc +30 -0
- package/templates/current/clean/.cursor/rules/04-api-auth-router.mdc +12 -0
- package/templates/current/clean/.cursor/rules/05-style.mdc +12 -0
- package/templates/current/clean/.cursor/rules/06-quality.mdc +12 -0
- package/templates/current/clean/.cursor/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/clean/.cursor/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/clean/.cursor/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/clean/.cursor/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/clean/.cursor/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/clean/.cursor/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/clean/.cursor/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/clean/.cursor/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/clean/.cursor/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/clean/.cursor/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/clean/.cursor/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/clean/.env.example +7 -0
- package/templates/current/clean/.env.production.example +31 -0
- package/templates/current/clean/.qoder/AGENTS.md +15 -0
- package/templates/current/clean/.qoder/rules/01-feature-architecture.md +12 -0
- package/templates/current/clean/.qoder/rules/02-vue-typescript.md +12 -0
- package/templates/current/clean/.qoder/rules/03-component-policy.md +30 -0
- package/templates/current/clean/.qoder/rules/04-api-auth-router.md +12 -0
- package/templates/current/clean/.qoder/rules/05-style.md +12 -0
- package/templates/current/clean/.qoder/rules/06-quality.md +12 -0
- package/templates/current/clean/.qoder/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/clean/.qoder/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/clean/.qoder/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/clean/.qoder/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/clean/.qoder/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/clean/.qoder/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/clean/.qoder/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/clean/.qoder/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/clean/.qoder/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/clean/.qoder/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/clean/.qoder/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/clean/AGENTS.md +16 -0
- package/templates/current/clean/README.md +116 -0
- package/templates/current/clean/component-catalog.json +765 -0
- package/templates/current/clean/e2e/admin-shell.spec.ts +150 -0
- package/templates/current/clean/e2e/demo-shell.spec.ts +328 -0
- package/templates/current/clean/evals/component-selection.json +29 -0
- package/templates/current/clean/gitignore +3 -0
- package/templates/current/clean/index.html +13 -0
- package/templates/current/clean/openapi.json +1623 -0
- package/templates/current/clean/package.json +65 -0
- package/templates/current/clean/playwright.config.ts +31 -0
- package/templates/current/clean/playwright.demo.config.ts +25 -0
- package/templates/current/clean/recipes/README.md +7 -0
- package/templates/current/clean/recipes/remote-crud-dialog-form.json +15 -0
- package/templates/current/clean/recipes/remote-crud-dialog-form.vue +66 -0
- package/templates/current/clean/scaffold.lock.json +12 -0
- package/templates/current/clean/scripts/check-admin-bundle.mjs +214 -0
- package/templates/current/clean/scripts/check-admin-scaffold.mjs +168 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/clean/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/clean/scripts/clean-overlay/src/main.ts +91 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/componentRegistry.ts +25 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +47 -0
- package/templates/current/clean/scripts/clean-overlay/src/router/staticRoutes.ts +63 -0
- package/templates/current/clean/scripts/demo-api.ts +797 -0
- package/templates/current/clean/scripts/generate-api.ts +27 -0
- package/templates/current/clean/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +38 -0
- package/templates/current/clean/scripts/remove-examples.mjs +54 -0
- package/templates/current/clean/src/App.vue +67 -0
- package/templates/current/clean/src/api/client.spec.ts +66 -0
- package/templates/current/clean/src/api/client.ts +72 -0
- package/templates/current/clean/src/api/generated/data-contracts.ts +268 -0
- package/templates/current/clean/src/api/generated/http-client.ts +266 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/templates/current/clean/src/api/generated//350/256/244/350/257/201.ts +98 -0
- package/templates/current/clean/src/api/http-adapter.spec.ts +33 -0
- package/templates/current/clean/src/api/http-adapter.ts +83 -0
- package/templates/current/clean/src/api/index.ts +41 -0
- package/templates/current/clean/src/app/createAdminUi.spec.ts +110 -0
- package/templates/current/clean/src/app/createAdminUi.ts +78 -0
- package/templates/current/clean/src/app/menu.spec.ts +255 -0
- package/templates/current/clean/src/app/menu.ts +268 -0
- package/templates/current/clean/src/app/menuTypes.ts +17 -0
- package/templates/current/clean/src/app/origenUiLocale.spec.ts +14 -0
- package/templates/current/clean/src/app/origenUiLocale.ts +65 -0
- package/templates/current/clean/src/app/permission.ts +9 -0
- package/templates/current/clean/src/app/runtimeConfig.ts +77 -0
- package/templates/current/clean/src/demo-api.spec.ts +167 -0
- package/templates/current/clean/src/env.d.ts +14 -0
- package/templates/current/clean/src/features/appearance/components/ThemePanel.vue +200 -0
- package/templates/current/clean/src/features/appearance/composables/useTheme.ts +17 -0
- package/templates/current/clean/src/features/appearance/store/theme.ts +140 -0
- package/templates/current/clean/src/features/auth/pages/Login.vue +159 -0
- package/templates/current/clean/src/features/auth/store/auth.spec.ts +131 -0
- package/templates/current/clean/src/features/auth/store/auth.ts +210 -0
- package/templates/current/clean/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/clean/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/clean/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/clean/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/clean/src/features/security/components/DevtoolsProtectionOverlay.vue +56 -0
- package/templates/current/clean/src/features/security/devtoolsProtection.spec.ts +211 -0
- package/templates/current/clean/src/features/security/devtoolsProtection.ts +242 -0
- package/templates/current/clean/src/features/shell/components/AdminWatermark.spec.ts +90 -0
- package/templates/current/clean/src/features/shell/components/AdminWatermark.vue +47 -0
- package/templates/current/clean/src/features/shell/components/RouteProgress.vue +68 -0
- package/templates/current/clean/src/features/shell/composables/useRouteProgress.spec.ts +95 -0
- package/templates/current/clean/src/features/shell/composables/useRouteProgress.ts +52 -0
- package/templates/current/clean/src/features/shell/store/sidebar.ts +55 -0
- package/templates/current/clean/src/features/system/access/api/admin-repository.ts +279 -0
- package/templates/current/clean/src/features/system/access/api/rbac.spec.ts +72 -0
- package/templates/current/clean/src/features/system/access/api/rbac.ts +272 -0
- package/templates/current/clean/src/features/system/access/composables/useAuthorizationRefresh.ts +15 -0
- package/templates/current/clean/src/features/workspace/pages/Empty.vue +18 -0
- package/templates/current/clean/src/features/workspace/pages/Profile.vue +183 -0
- package/templates/current/clean/src/layouts/AdminLayout.vue +61 -0
- package/templates/current/clean/src/layouts/BreadcrumbBar.vue +27 -0
- package/templates/current/clean/src/layouts/SideMenu.vue +119 -0
- package/templates/current/clean/src/layouts/TopBar.vue +301 -0
- package/templates/current/clean/src/layouts/WorkspaceTabs.vue +44 -0
- package/templates/current/clean/src/layouts/topBarMenuSearch.spec.ts +31 -0
- package/templates/current/clean/src/layouts/topBarMenuSearch.ts +21 -0
- package/templates/current/clean/src/locales/en-US.ts +55 -0
- package/templates/current/clean/src/locales/index.ts +119 -0
- package/templates/current/clean/src/locales/messages.spec.ts +23 -0
- package/templates/current/clean/src/locales/zh-CN.ts +55 -0
- package/templates/current/clean/src/locales/zh-TW.ts +44 -0
- package/templates/current/clean/src/main.ts +91 -0
- package/templates/current/clean/src/router/bootstrap.ts +76 -0
- package/templates/current/clean/src/router/componentRegistry.ts +25 -0
- package/templates/current/clean/src/router/dynamicRoutes.spec.ts +47 -0
- package/templates/current/clean/src/router/dynamicRoutes.ts +162 -0
- package/templates/current/clean/src/router/guards.ts +5 -0
- package/templates/current/clean/src/router/queryEncryption.spec.ts +82 -0
- package/templates/current/clean/src/router/queryEncryption.ts +133 -0
- package/templates/current/clean/src/router/routeQuery.spec.ts +11 -0
- package/templates/current/clean/src/router/routeQuery.ts +3 -0
- package/templates/current/clean/src/router/runtimeErrorRecovery.spec.ts +161 -0
- package/templates/current/clean/src/router/runtimeErrorRecovery.ts +108 -0
- package/templates/current/clean/src/router/staticRoutes.ts +63 -0
- package/templates/current/clean/src/router/useRouteQueryDefaults.spec.ts +90 -0
- package/templates/current/clean/src/router/useRouteQueryDefaults.ts +51 -0
- package/templates/current/clean/src/router/useRouteQueryDefaults.types.ts +19 -0
- package/templates/current/clean/src/store/index.ts +3 -0
- package/templates/current/clean/src/styles/element/index.scss +33 -0
- package/templates/current/clean/src/styles/index.css +39 -0
- package/templates/current/clean/src/styles/layout.css +115 -0
- package/templates/current/clean/src/styles/shell.css +196 -0
- package/templates/current/clean/src/styles/source-package-style-compat.css +1 -0
- package/templates/current/clean/src/templates/og-form.ts +48 -0
- package/templates/current/clean/src/templates/og-table.ts +212 -0
- package/templates/current/clean/src/templates/router.ts +51 -0
- package/templates/current/clean/src/templates/templates.spec.ts +90 -0
- package/templates/current/clean/src/theme/index.ts +7 -0
- package/templates/current/clean/src/utils/__tests__/color-mix.spec.ts +39 -0
- package/templates/current/clean/src/utils/color-mix.ts +76 -0
- package/templates/current/clean/src/utils/permissions.ts +6 -0
- package/templates/current/clean/tsconfig.json +40 -0
- package/templates/current/clean/tsconfig.node.json +9 -0
- package/templates/current/clean/vite.build-policy.ts +405 -0
- package/templates/current/clean/vite.config.ts +37 -0
- package/templates/current/examples/.codebuddy/AGENTS.md +18 -0
- package/templates/current/examples/.codebuddy/rules/01-feature-architecture.md +12 -0
- package/templates/current/examples/.codebuddy/rules/02-vue-typescript.md +12 -0
- package/templates/current/examples/.codebuddy/rules/03-component-policy.md +30 -0
- package/templates/current/examples/.codebuddy/rules/04-api-auth-router.md +12 -0
- package/templates/current/examples/.codebuddy/rules/05-style.md +12 -0
- package/templates/current/examples/.codebuddy/rules/06-quality.md +12 -0
- package/templates/current/examples/.codebuddy/skills/build-admin-feature/SKILL.md +17 -0
- package/templates/current/examples/.codebuddy/skills/style-og-origen-ui/SKILL.md +14 -0
- package/templates/current/examples/.codebuddy/skills/use-og-dialog/SKILL.md +15 -0
- package/templates/current/examples/.codebuddy/skills/use-og-editor/SKILL.md +28 -0
- package/templates/current/examples/.codebuddy/skills/use-og-form/SKILL.md +15 -0
- package/templates/current/examples/.codebuddy/skills/use-og-form-table/SKILL.md +28 -0
- package/templates/current/examples/.codebuddy/skills/use-og-http/SKILL.md +16 -0
- package/templates/current/examples/.codebuddy/skills/use-og-router-tabs/SKILL.md +14 -0
- package/templates/current/examples/.codebuddy/skills/use-og-search/SKILL.md +17 -0
- package/templates/current/examples/.codebuddy/skills/use-og-table/SKILL.md +19 -0
- package/templates/current/examples/.codebuddy/skills/use-og-upload/SKILL.md +28 -0
- package/templates/current/examples/.codex/AGENTS.md +15 -0
- package/templates/current/examples/.codex/rules/01-feature-architecture.md +6 -0
- package/templates/current/examples/.codex/rules/02-vue-typescript.md +6 -0
- package/templates/current/examples/.codex/rules/03-component-policy.md +24 -0
- package/templates/current/examples/.codex/rules/04-api-auth-router.md +6 -0
- package/templates/current/examples/.codex/rules/05-style.md +6 -0
- package/templates/current/examples/.codex/rules/06-quality.md +6 -0
- package/templates/current/examples/.codex/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/examples/.codex/skills/build-admin-feature/references/component-selection.md +25 -0
- package/templates/current/examples/.codex/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/examples/.codex/skills/style-og-origen-ui/agents/openai.yaml +4 -0
- package/templates/current/examples/.codex/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/examples/.codex/skills/use-og-dialog/agents/openai.yaml +4 -0
- package/templates/current/examples/.codex/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/examples/.codex/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/examples/.codex/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/examples/.codex/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/examples/.codex/skills/use-og-http/agents/openai.yaml +4 -0
- package/templates/current/examples/.codex/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/examples/.codex/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/examples/.codex/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/examples/.codex/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/examples/.cursor/AGENTS.md +18 -0
- package/templates/current/examples/.cursor/rules/01-feature-architecture.mdc +12 -0
- package/templates/current/examples/.cursor/rules/02-vue-typescript.mdc +12 -0
- package/templates/current/examples/.cursor/rules/03-component-policy.mdc +30 -0
- package/templates/current/examples/.cursor/rules/04-api-auth-router.mdc +12 -0
- package/templates/current/examples/.cursor/rules/05-style.mdc +12 -0
- package/templates/current/examples/.cursor/rules/06-quality.mdc +12 -0
- package/templates/current/examples/.cursor/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/examples/.cursor/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/examples/.cursor/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/examples/.cursor/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/examples/.cursor/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/examples/.cursor/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/examples/.cursor/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/examples/.cursor/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/examples/.cursor/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/examples/.cursor/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/examples/.cursor/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/examples/.env.example +7 -0
- package/templates/current/examples/.env.production.example +31 -0
- package/templates/current/examples/.qoder/AGENTS.md +15 -0
- package/templates/current/examples/.qoder/rules/01-feature-architecture.md +12 -0
- package/templates/current/examples/.qoder/rules/02-vue-typescript.md +12 -0
- package/templates/current/examples/.qoder/rules/03-component-policy.md +30 -0
- package/templates/current/examples/.qoder/rules/04-api-auth-router.md +12 -0
- package/templates/current/examples/.qoder/rules/05-style.md +12 -0
- package/templates/current/examples/.qoder/rules/06-quality.md +12 -0
- package/templates/current/examples/.qoder/skills/build-admin-feature/SKILL.md +14 -0
- package/templates/current/examples/.qoder/skills/style-og-origen-ui/SKILL.md +11 -0
- package/templates/current/examples/.qoder/skills/use-og-dialog/SKILL.md +12 -0
- package/templates/current/examples/.qoder/skills/use-og-editor/SKILL.md +25 -0
- package/templates/current/examples/.qoder/skills/use-og-form/SKILL.md +12 -0
- package/templates/current/examples/.qoder/skills/use-og-form-table/SKILL.md +25 -0
- package/templates/current/examples/.qoder/skills/use-og-http/SKILL.md +13 -0
- package/templates/current/examples/.qoder/skills/use-og-router-tabs/SKILL.md +11 -0
- package/templates/current/examples/.qoder/skills/use-og-search/SKILL.md +14 -0
- package/templates/current/examples/.qoder/skills/use-og-table/SKILL.md +16 -0
- package/templates/current/examples/.qoder/skills/use-og-upload/SKILL.md +25 -0
- package/templates/current/examples/AGENTS.md +16 -0
- package/templates/current/examples/README.md +116 -0
- package/templates/current/examples/component-catalog.json +765 -0
- package/templates/current/examples/e2e/admin-shell.spec.ts +150 -0
- package/templates/current/examples/e2e/demo-shell.spec.ts +328 -0
- package/templates/current/examples/evals/component-selection.json +29 -0
- package/templates/current/examples/gitignore +3 -0
- package/templates/current/examples/index.html +13 -0
- package/templates/current/examples/openapi.json +1623 -0
- package/templates/current/examples/package.json +65 -0
- package/templates/current/examples/playwright.config.ts +31 -0
- package/templates/current/examples/playwright.demo.config.ts +25 -0
- package/templates/current/examples/recipes/README.md +7 -0
- package/templates/current/examples/recipes/remote-crud-dialog-form.json +15 -0
- package/templates/current/examples/recipes/remote-crud-dialog-form.vue +66 -0
- package/templates/current/examples/scaffold.lock.json +12 -0
- package/templates/current/examples/scripts/check-admin-bundle.mjs +214 -0
- package/templates/current/examples/scripts/check-admin-scaffold.mjs +168 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/examples/scripts/clean-overlay/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/examples/scripts/clean-overlay/src/main.ts +91 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/componentRegistry.ts +25 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/dynamicRoutes.spec.ts +47 -0
- package/templates/current/examples/scripts/clean-overlay/src/router/staticRoutes.ts +63 -0
- package/templates/current/examples/scripts/demo-api.ts +797 -0
- package/templates/current/examples/scripts/generate-api.ts +27 -0
- package/templates/current/examples/scripts/performance/baselines/bundle-gzip-v2-pre-entry-unification.json +38 -0
- package/templates/current/examples/scripts/remove-examples.mjs +54 -0
- package/templates/current/examples/src/App.vue +67 -0
- package/templates/current/examples/src/api/client.spec.ts +66 -0
- package/templates/current/examples/src/api/client.ts +72 -0
- package/templates/current/examples/src/api/generated/data-contracts.ts +268 -0
- package/templates/current/examples/src/api/generated/http-client.ts +266 -0
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/templates/current/examples/src/api/generated//350/256/244/350/257/201.ts +98 -0
- package/templates/current/examples/src/api/http-adapter.spec.ts +33 -0
- package/templates/current/examples/src/api/http-adapter.ts +83 -0
- package/templates/current/examples/src/api/index.ts +41 -0
- package/templates/current/examples/src/app/createAdminUi.spec.ts +110 -0
- package/templates/current/examples/src/app/createAdminUi.ts +78 -0
- package/templates/current/examples/src/app/menu.spec.ts +255 -0
- package/templates/current/examples/src/app/menu.ts +268 -0
- package/templates/current/examples/src/app/menuTypes.ts +17 -0
- package/templates/current/examples/src/app/origenUiLocale.spec.ts +14 -0
- package/templates/current/examples/src/app/origenUiLocale.ts +65 -0
- package/templates/current/examples/src/app/permission.ts +9 -0
- package/templates/current/examples/src/app/runtimeConfig.ts +77 -0
- package/templates/current/examples/src/demo-api.spec.ts +167 -0
- package/templates/current/examples/src/env.d.ts +14 -0
- package/templates/current/examples/src/features/appearance/components/ThemePanel.vue +200 -0
- package/templates/current/examples/src/features/appearance/composables/useTheme.ts +17 -0
- package/templates/current/examples/src/features/appearance/store/theme.ts +140 -0
- package/templates/current/examples/src/features/auth/pages/Login.vue +159 -0
- package/templates/current/examples/src/features/auth/store/auth.spec.ts +131 -0
- package/templates/current/examples/src/features/auth/store/auth.ts +210 -0
- package/templates/current/examples/src/features/errors/pages/Forbidden.vue +26 -0
- package/templates/current/examples/src/features/errors/pages/NotFound.vue +26 -0
- package/templates/current/examples/src/features/errors/pages/ServerError.vue +26 -0
- package/templates/current/examples/src/features/errors/pages/error-pages.spec.ts +32 -0
- package/templates/current/examples/src/features/feature-composables.spec.ts +208 -0
- package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue +56 -0
- package/templates/current/examples/src/features/security/devtoolsProtection.spec.ts +211 -0
- package/templates/current/examples/src/features/security/devtoolsProtection.ts +242 -0
- package/templates/current/examples/src/features/shell/components/AdminWatermark.spec.ts +90 -0
- package/templates/current/examples/src/features/shell/components/AdminWatermark.vue +47 -0
- package/templates/current/examples/src/features/shell/components/RouteProgress.vue +68 -0
- package/templates/current/examples/src/features/shell/composables/useRouteProgress.spec.ts +95 -0
- package/templates/current/examples/src/features/shell/composables/useRouteProgress.ts +52 -0
- package/templates/current/examples/src/features/shell/store/sidebar.ts +55 -0
- package/templates/current/examples/src/features/system/access/api/admin-repository.ts +279 -0
- package/templates/current/examples/src/features/system/access/api/rbac.spec.ts +72 -0
- package/templates/current/examples/src/features/system/access/api/rbac.ts +272 -0
- package/templates/current/examples/src/features/system/access/composables/useAuthorizationRefresh.ts +15 -0
- package/templates/current/examples/src/features/system/audit/composables/useAuditManagement.ts +117 -0
- package/templates/current/examples/src/features/system/audit/pages/AuditList.vue +20 -0
- package/templates/current/examples/src/features/system/menus/components/MenuEditorForm.vue +189 -0
- package/templates/current/examples/src/features/system/menus/composables/useMenuManagement.ts +327 -0
- package/templates/current/examples/src/features/system/menus/pages/MenuList.vue +49 -0
- package/templates/current/examples/src/features/system/roles/components/RoleEditorForm.vue +112 -0
- package/templates/current/examples/src/features/system/roles/composables/useRoleManagement.ts +198 -0
- package/templates/current/examples/src/features/system/roles/pages/RoleList.vue +45 -0
- package/templates/current/examples/src/features/system/users/components/UserEditorForm.vue +101 -0
- package/templates/current/examples/src/features/system/users/composables/useUserManagement.ts +233 -0
- package/templates/current/examples/src/features/system/users/pages/UserList.vue +49 -0
- package/templates/current/examples/src/features/workspace/pages/Dashboard.spec.ts +32 -0
- package/templates/current/examples/src/features/workspace/pages/Dashboard.vue +297 -0
- package/templates/current/examples/src/features/workspace/pages/Empty.vue +18 -0
- package/templates/current/examples/src/features/workspace/pages/Profile.vue +183 -0
- package/templates/current/examples/src/layouts/AdminLayout.vue +61 -0
- package/templates/current/examples/src/layouts/BreadcrumbBar.vue +27 -0
- package/templates/current/examples/src/layouts/SideMenu.vue +119 -0
- package/templates/current/examples/src/layouts/TopBar.vue +301 -0
- package/templates/current/examples/src/layouts/WorkspaceTabs.vue +44 -0
- package/templates/current/examples/src/layouts/topBarMenuSearch.spec.ts +31 -0
- package/templates/current/examples/src/layouts/topBarMenuSearch.ts +21 -0
- package/templates/current/examples/src/locales/en-US.ts +55 -0
- package/templates/current/examples/src/locales/index.ts +119 -0
- package/templates/current/examples/src/locales/messages.spec.ts +23 -0
- package/templates/current/examples/src/locales/zh-CN.ts +55 -0
- package/templates/current/examples/src/locales/zh-TW.ts +44 -0
- package/templates/current/examples/src/main.ts +91 -0
- package/templates/current/examples/src/router/bootstrap.ts +76 -0
- package/templates/current/examples/src/router/componentRegistry.ts +83 -0
- package/templates/current/examples/src/router/dynamicRoutes.spec.ts +109 -0
- package/templates/current/examples/src/router/dynamicRoutes.ts +162 -0
- package/templates/current/examples/src/router/guards.ts +5 -0
- package/templates/current/examples/src/router/queryEncryption.spec.ts +82 -0
- package/templates/current/examples/src/router/queryEncryption.ts +133 -0
- package/templates/current/examples/src/router/routeQuery.spec.ts +11 -0
- package/templates/current/examples/src/router/routeQuery.ts +3 -0
- package/templates/current/examples/src/router/runtimeErrorRecovery.spec.ts +161 -0
- package/templates/current/examples/src/router/runtimeErrorRecovery.ts +108 -0
- package/templates/current/examples/src/router/staticRoutes.ts +63 -0
- package/templates/current/examples/src/router/useRouteQueryDefaults.spec.ts +90 -0
- package/templates/current/examples/src/router/useRouteQueryDefaults.ts +51 -0
- package/templates/current/examples/src/router/useRouteQueryDefaults.types.ts +19 -0
- package/templates/current/examples/src/store/index.ts +3 -0
- package/templates/current/examples/src/styles/element/index.scss +33 -0
- package/templates/current/examples/src/styles/index.css +39 -0
- package/templates/current/examples/src/styles/layout.css +115 -0
- package/templates/current/examples/src/styles/shell.css +196 -0
- package/templates/current/examples/src/styles/source-package-style-compat.css +1 -0
- package/templates/current/examples/src/templates/og-form.ts +48 -0
- package/templates/current/examples/src/templates/og-table.ts +212 -0
- package/templates/current/examples/src/templates/router.ts +51 -0
- package/templates/current/examples/src/templates/templates.spec.ts +90 -0
- package/templates/current/examples/src/theme/index.ts +7 -0
- package/templates/current/examples/src/utils/__tests__/color-mix.spec.ts +39 -0
- package/templates/current/examples/src/utils/color-mix.ts +76 -0
- package/templates/current/examples/src/utils/permissions.ts +6 -0
- package/templates/current/examples/tsconfig.json +40 -0
- package/templates/current/examples/tsconfig.node.json +9 -0
- package/templates/current/examples/vite.build-policy.ts +405 -0
- package/templates/current/examples/vite.config.ts +37 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import type { ApiBusinessError } from '@origen-ui/http'
|
|
2
|
+
import type { Permission } from '@origen-ui/shared'
|
|
3
|
+
import { ApiBusinessError as ApiBusinessErrorClass } from '@origen-ui/http'
|
|
4
|
+
import { hasCodePermission } from '@origen-ui/permission/codes'
|
|
5
|
+
import { defineStore } from 'pinia'
|
|
6
|
+
import { apiClient, tokenManager } from '../../../api/client'
|
|
7
|
+
|
|
8
|
+
export interface AdminUser {
|
|
9
|
+
id: string
|
|
10
|
+
username: string
|
|
11
|
+
displayName: string
|
|
12
|
+
email?: string
|
|
13
|
+
avatar?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AdminSession {
|
|
17
|
+
token: string
|
|
18
|
+
user: AdminUser
|
|
19
|
+
permissions: string[]
|
|
20
|
+
roleIds: string[]
|
|
21
|
+
authorizationRevision: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface LoginCredentials {
|
|
25
|
+
username: string
|
|
26
|
+
password: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface LoginPayload {
|
|
30
|
+
token?: string
|
|
31
|
+
accessToken?: string
|
|
32
|
+
refreshToken?: string
|
|
33
|
+
user?: unknown
|
|
34
|
+
permissions?: unknown
|
|
35
|
+
roleIds?: unknown
|
|
36
|
+
authorizationRevision?: unknown
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const PROFILE_KEY = 'og-admin-session-profile'
|
|
40
|
+
|
|
41
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
42
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function readString(value: unknown): string | undefined {
|
|
46
|
+
return typeof value === 'string' && value.trim() ? value : undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function readStrings(value: unknown): string[] {
|
|
50
|
+
return Array.isArray(value)
|
|
51
|
+
? value.filter((item): item is string => typeof item === 'string' && item.trim().length > 0)
|
|
52
|
+
: []
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function normalizeUser(value: unknown, fallbackUsername: string): AdminUser {
|
|
56
|
+
const record = isRecord(value) ? value : {}
|
|
57
|
+
const username = readString(record.username) ?? readString(record.name) ?? fallbackUsername
|
|
58
|
+
return {
|
|
59
|
+
id: readString(record.id) ?? username,
|
|
60
|
+
username,
|
|
61
|
+
displayName:
|
|
62
|
+
readString(record.displayName) ??
|
|
63
|
+
readString(record.nickname) ??
|
|
64
|
+
readString(record.name) ??
|
|
65
|
+
username,
|
|
66
|
+
email: readString(record.email),
|
|
67
|
+
avatar: readString(record.avatar),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function readCachedProfile(): Omit<AdminSession, 'token'> | undefined {
|
|
72
|
+
if (typeof localStorage === 'undefined') return undefined
|
|
73
|
+
try {
|
|
74
|
+
const parsed: unknown = JSON.parse(localStorage.getItem(PROFILE_KEY) ?? 'null')
|
|
75
|
+
if (!isRecord(parsed) || !isRecord(parsed.user)) return undefined
|
|
76
|
+
return {
|
|
77
|
+
user: normalizeUser(parsed.user, 'admin'),
|
|
78
|
+
permissions: readStrings(parsed.permissions),
|
|
79
|
+
roleIds: readStrings(parsed.roleIds),
|
|
80
|
+
authorizationRevision:
|
|
81
|
+
typeof parsed.authorizationRevision === 'number' ? parsed.authorizationRevision : 0,
|
|
82
|
+
}
|
|
83
|
+
} catch {
|
|
84
|
+
localStorage.removeItem(PROFILE_KEY)
|
|
85
|
+
return undefined
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function cacheProfile(session: AdminSession): void {
|
|
90
|
+
if (typeof localStorage !== 'undefined') {
|
|
91
|
+
localStorage.setItem(
|
|
92
|
+
PROFILE_KEY,
|
|
93
|
+
JSON.stringify({
|
|
94
|
+
user: session.user,
|
|
95
|
+
permissions: session.permissions,
|
|
96
|
+
roleIds: session.roleIds,
|
|
97
|
+
authorizationRevision: session.authorizationRevision,
|
|
98
|
+
}),
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function parseLoginPayload(value: unknown): LoginPayload {
|
|
104
|
+
if (!isRecord(value)) throw new Error('登录响应格式无效')
|
|
105
|
+
return {
|
|
106
|
+
token: readString(value.token),
|
|
107
|
+
accessToken: readString(value.accessToken),
|
|
108
|
+
refreshToken: readString(value.refreshToken),
|
|
109
|
+
user: value.user,
|
|
110
|
+
permissions: value.permissions,
|
|
111
|
+
roleIds: value.roleIds,
|
|
112
|
+
authorizationRevision: value.authorizationRevision,
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function parseProfile(value: unknown, fallbackUsername: string): Omit<AdminSession, 'token'> {
|
|
117
|
+
const record = isRecord(value) ? value : {}
|
|
118
|
+
const nestedUser = record.user
|
|
119
|
+
return {
|
|
120
|
+
user: normalizeUser(nestedUser ?? record, fallbackUsername),
|
|
121
|
+
permissions: readStrings(
|
|
122
|
+
record.permissions ?? (isRecord(nestedUser) ? nestedUser.permissions : undefined),
|
|
123
|
+
),
|
|
124
|
+
roleIds: readStrings(record.roleIds ?? (isRecord(nestedUser) ? nestedUser.roleIds : undefined)),
|
|
125
|
+
authorizationRevision:
|
|
126
|
+
typeof record.authorizationRevision === 'number' ? record.authorizationRevision : 0,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function errorMessage(error: unknown): string {
|
|
131
|
+
if (error instanceof ApiBusinessErrorClass || error instanceof Error) return error.message
|
|
132
|
+
return '请求失败'
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export const useAuthStore = defineStore('admin-auth', {
|
|
136
|
+
state: (): { session: AdminSession | null } => ({ session: null }),
|
|
137
|
+
getters: {
|
|
138
|
+
grantedPermissions(): Set<string> {
|
|
139
|
+
return new Set(this.session?.permissions ?? [])
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
actions: {
|
|
143
|
+
hasPermission(permission: Permission): boolean {
|
|
144
|
+
return hasCodePermission(this.session?.permissions, permission)
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
async login(credentials: LoginCredentials): Promise<AdminSession> {
|
|
148
|
+
try {
|
|
149
|
+
const response = await apiClient.post<unknown>('/auth/login', credentials, {
|
|
150
|
+
retry: 0,
|
|
151
|
+
silent: true,
|
|
152
|
+
})
|
|
153
|
+
const payload = parseLoginPayload(response)
|
|
154
|
+
const token = payload.accessToken ?? payload.token
|
|
155
|
+
if (!token) throw new Error('登录响应缺少访问令牌')
|
|
156
|
+
const session: AdminSession = {
|
|
157
|
+
token,
|
|
158
|
+
user: normalizeUser(payload.user, credentials.username),
|
|
159
|
+
permissions: readStrings(payload.permissions),
|
|
160
|
+
roleIds: readStrings(payload.roleIds),
|
|
161
|
+
authorizationRevision:
|
|
162
|
+
typeof payload.authorizationRevision === 'number' ? payload.authorizationRevision : 0,
|
|
163
|
+
}
|
|
164
|
+
tokenManager.setTokens(token, payload.refreshToken)
|
|
165
|
+
this.session = session
|
|
166
|
+
cacheProfile(session)
|
|
167
|
+
return session
|
|
168
|
+
} catch (error: unknown) {
|
|
169
|
+
throw new Error(errorMessage(error))
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
|
|
173
|
+
logout(): void {
|
|
174
|
+
tokenManager.clear()
|
|
175
|
+
this.session = null
|
|
176
|
+
if (typeof localStorage !== 'undefined') localStorage.removeItem(PROFILE_KEY)
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
async fetchSession(): Promise<AdminSession | null> {
|
|
180
|
+
const token = tokenManager.getAccessToken()
|
|
181
|
+
if (!token) {
|
|
182
|
+
this.session = null
|
|
183
|
+
return null
|
|
184
|
+
}
|
|
185
|
+
const cached = readCachedProfile()
|
|
186
|
+
if (token === 'mock-admin-token' || token === 'mock-token') {
|
|
187
|
+
this.logout()
|
|
188
|
+
return null
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const profile = parseProfile(
|
|
192
|
+
await apiClient.get<unknown>('/auth/profile', { retry: 0, silent: true }),
|
|
193
|
+
cached?.user.username ?? 'admin',
|
|
194
|
+
)
|
|
195
|
+
this.session = { token, ...profile }
|
|
196
|
+
cacheProfile(this.session)
|
|
197
|
+
return this.session
|
|
198
|
+
} catch {
|
|
199
|
+
this.logout()
|
|
200
|
+
return null
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
async refreshAuthorization(): Promise<AdminSession | null> {
|
|
205
|
+
return this.fetchSession()
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
export type AdminApiBusinessError = ApiBusinessError
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ElButton, ElResult } from 'element-plus'
|
|
3
|
+
import { useRouter } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
defineOptions({ name: 'ForbiddenPage' })
|
|
6
|
+
|
|
7
|
+
const router = useRouter()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<main class="error-page">
|
|
12
|
+
<ElResult icon="warning" title="403" sub-title="抱歉,你没有访问此页面的权限。">
|
|
13
|
+
<template #extra>
|
|
14
|
+
<ElButton type="primary" @click="router.push('/dashboard')"> 回到仪表盘 </ElButton>
|
|
15
|
+
</template>
|
|
16
|
+
</ElResult>
|
|
17
|
+
</main>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<style scoped>
|
|
21
|
+
.error-page {
|
|
22
|
+
display: grid;
|
|
23
|
+
min-height: 100vh;
|
|
24
|
+
place-items: center;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ElButton, ElResult } from 'element-plus'
|
|
3
|
+
import { useRouter } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
defineOptions({ name: 'NotFoundPage' })
|
|
6
|
+
|
|
7
|
+
const router = useRouter()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<main class="error-page">
|
|
12
|
+
<ElResult icon="warning" title="404" sub-title="你访问的页面不存在或已经被移除。">
|
|
13
|
+
<template #extra>
|
|
14
|
+
<ElButton type="primary" @click="router.push('/dashboard')"> 回到仪表盘 </ElButton>
|
|
15
|
+
</template>
|
|
16
|
+
</ElResult>
|
|
17
|
+
</main>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<style scoped>
|
|
21
|
+
.error-page {
|
|
22
|
+
display: grid;
|
|
23
|
+
min-height: 100vh;
|
|
24
|
+
place-items: center;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ElButton, ElResult } from 'element-plus'
|
|
3
|
+
import { useRouter } from 'vue-router'
|
|
4
|
+
|
|
5
|
+
defineOptions({ name: 'ServerErrorPage' })
|
|
6
|
+
|
|
7
|
+
const router = useRouter()
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<main class="error-page">
|
|
12
|
+
<ElResult icon="error" title="500" sub-title="服务暂时不可用,请稍后再试。">
|
|
13
|
+
<template #extra>
|
|
14
|
+
<ElButton type="primary" @click="router.push('/dashboard')"> 回到仪表盘 </ElButton>
|
|
15
|
+
</template>
|
|
16
|
+
</ElResult>
|
|
17
|
+
</main>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<style scoped>
|
|
21
|
+
.error-page {
|
|
22
|
+
display: grid;
|
|
23
|
+
min-height: 100vh;
|
|
24
|
+
place-items: center;
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { mount } from '@vue/test-utils'
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
+
import Forbidden from './Forbidden.vue'
|
|
4
|
+
import NotFound from './NotFound.vue'
|
|
5
|
+
import ServerError from './ServerError.vue'
|
|
6
|
+
|
|
7
|
+
const { push } = vi.hoisted(() => ({
|
|
8
|
+
push: vi.fn(),
|
|
9
|
+
}))
|
|
10
|
+
|
|
11
|
+
vi.mock('vue-router', () => ({
|
|
12
|
+
useRouter: () => ({ push }),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
describe('error page navigation', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
push.mockReset()
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it.each([
|
|
21
|
+
['403', Forbidden],
|
|
22
|
+
['404', NotFound],
|
|
23
|
+
['500', ServerError],
|
|
24
|
+
])('returns to the dashboard by path from the %s page', async (_status, component) => {
|
|
25
|
+
const wrapper = mount(component)
|
|
26
|
+
|
|
27
|
+
await wrapper.get('button').trigger('click')
|
|
28
|
+
|
|
29
|
+
expect(push).toHaveBeenCalledOnce()
|
|
30
|
+
expect(push).toHaveBeenCalledWith('/dashboard')
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
OgTableDataSource,
|
|
3
|
+
OgTableExportRequest,
|
|
4
|
+
OgTableQuery,
|
|
5
|
+
OgTableRequestContext,
|
|
6
|
+
OgTableRow,
|
|
7
|
+
} from '@origen-ui/table'
|
|
8
|
+
import { createPinia, setActivePinia } from 'pinia'
|
|
9
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
10
|
+
import { useTheme } from './appearance/composables/useTheme'
|
|
11
|
+
import { useAuditManagement } from './system/audit/composables/useAuditManagement'
|
|
12
|
+
import { useMenuManagement } from './system/menus/composables/useMenuManagement'
|
|
13
|
+
import { useRoleManagement } from './system/roles/composables/useRoleManagement'
|
|
14
|
+
import { useUserManagement } from './system/users/composables/useUserManagement'
|
|
15
|
+
|
|
16
|
+
vi.mock('../api/client', () => {
|
|
17
|
+
function ensureActive(signal?: AbortSignal): void {
|
|
18
|
+
if (signal?.aborted) throw new DOMException('The operation was aborted.', 'AbortError')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const page = (list: unknown[]) => ({ list, total: list.length, page: 1, pageSize: 10 })
|
|
22
|
+
const apiClient = {
|
|
23
|
+
delete: vi.fn(),
|
|
24
|
+
get: vi.fn(async (url: string, options?: { signal?: AbortSignal }) => {
|
|
25
|
+
ensureActive(options?.signal)
|
|
26
|
+
if (url === '/system/audit') {
|
|
27
|
+
return page([
|
|
28
|
+
{
|
|
29
|
+
action: 'view',
|
|
30
|
+
actorName: 'Admin',
|
|
31
|
+
at: '2026-01-01T00:00:00.000Z',
|
|
32
|
+
detail: 'Viewed audit log',
|
|
33
|
+
id: 'audit-1',
|
|
34
|
+
targetName: 'Audit log',
|
|
35
|
+
targetType: 'authorization',
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
}
|
|
39
|
+
if (url === '/system/users') {
|
|
40
|
+
return page([
|
|
41
|
+
{
|
|
42
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
43
|
+
department: 'Operations',
|
|
44
|
+
email: 'admin@example.com',
|
|
45
|
+
id: 'user-1',
|
|
46
|
+
lastActiveAt: '2026-01-01T00:00:00.000Z',
|
|
47
|
+
name: 'Admin',
|
|
48
|
+
roleIds: ['role-1'],
|
|
49
|
+
status: 'active',
|
|
50
|
+
username: 'admin',
|
|
51
|
+
},
|
|
52
|
+
])
|
|
53
|
+
}
|
|
54
|
+
if (url === '/system/roles') {
|
|
55
|
+
return page([
|
|
56
|
+
{
|
|
57
|
+
code: 'admin',
|
|
58
|
+
createdAt: '2026-01-01T00:00:00.000Z',
|
|
59
|
+
description: 'Administrator',
|
|
60
|
+
id: 'role-1',
|
|
61
|
+
memberCount: 1,
|
|
62
|
+
name: 'Admin',
|
|
63
|
+
permissions: ['*'],
|
|
64
|
+
status: 'active',
|
|
65
|
+
updatedAt: '2026-01-01T00:00:00.000Z',
|
|
66
|
+
},
|
|
67
|
+
])
|
|
68
|
+
}
|
|
69
|
+
if (url === '/system/menus') {
|
|
70
|
+
return page([
|
|
71
|
+
{
|
|
72
|
+
cache: false,
|
|
73
|
+
code: 'users',
|
|
74
|
+
componentKey: 'user-list',
|
|
75
|
+
id: 'menu-1',
|
|
76
|
+
kind: 'page',
|
|
77
|
+
order: 10,
|
|
78
|
+
path: '/system/users',
|
|
79
|
+
status: 'active',
|
|
80
|
+
tabHidden: false,
|
|
81
|
+
title: 'Users',
|
|
82
|
+
visible: true,
|
|
83
|
+
},
|
|
84
|
+
])
|
|
85
|
+
}
|
|
86
|
+
if (url === '/system/roles/options') return [{ label: 'Admin', value: 'role-1' }]
|
|
87
|
+
if (url === '/system/permissions/tree') return []
|
|
88
|
+
throw new Error(`Unexpected request: ${url}`)
|
|
89
|
+
}),
|
|
90
|
+
patch: vi.fn(),
|
|
91
|
+
post: vi.fn(),
|
|
92
|
+
put: vi.fn(),
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
apiClient,
|
|
97
|
+
tokenManager: { clear: vi.fn(), getAccessToken: vi.fn(), setTokens: vi.fn() },
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
vi.mock('@origen-ui/dialog', async () => {
|
|
102
|
+
const actual =
|
|
103
|
+
await vi.importActual<typeof import('@origen-ui/dialog')>('@origen-ui/dialog')
|
|
104
|
+
return { ...actual, useDialog: () => ({ open: vi.fn() }) }
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
function createTableQuery<TQuery extends object>(): OgTableQuery<TQuery> {
|
|
108
|
+
return {
|
|
109
|
+
page: 1,
|
|
110
|
+
pageSize: 10,
|
|
111
|
+
keyword: '',
|
|
112
|
+
query: {},
|
|
113
|
+
filters: {},
|
|
114
|
+
sort: { prop: null, order: null },
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function createExportRequest<TQuery extends object>(): OgTableExportRequest<TQuery> {
|
|
119
|
+
return {
|
|
120
|
+
query: createTableQuery<TQuery>(),
|
|
121
|
+
columns: [],
|
|
122
|
+
mode: 'all',
|
|
123
|
+
source: 'display',
|
|
124
|
+
watermark: false,
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createRequestContext(signal: AbortSignal): OgTableRequestContext {
|
|
129
|
+
return { signal, requestId: 1 }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function expectCancellableList<T extends OgTableRow, TQuery extends object>(
|
|
133
|
+
dataSource: Pick<OgTableDataSource<T, TQuery>, 'list'>,
|
|
134
|
+
): Promise<void> {
|
|
135
|
+
const result = await dataSource.list(
|
|
136
|
+
createTableQuery<TQuery>(),
|
|
137
|
+
createRequestContext(new AbortController().signal),
|
|
138
|
+
)
|
|
139
|
+
expect(result.total).toBeGreaterThan(0)
|
|
140
|
+
|
|
141
|
+
const controller = new AbortController()
|
|
142
|
+
controller.abort()
|
|
143
|
+
await expect(
|
|
144
|
+
dataSource.list(createTableQuery<TQuery>(), createRequestContext(controller.signal)),
|
|
145
|
+
).rejects.toMatchObject({ name: 'AbortError' })
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
describe('feature composables', () => {
|
|
149
|
+
beforeEach(() => {
|
|
150
|
+
setActivePinia(createPinia())
|
|
151
|
+
localStorage.clear()
|
|
152
|
+
window.matchMedia = (() => ({
|
|
153
|
+
matches: false,
|
|
154
|
+
media: '',
|
|
155
|
+
onchange: null,
|
|
156
|
+
addListener: () => {},
|
|
157
|
+
removeListener: () => {},
|
|
158
|
+
addEventListener: () => {},
|
|
159
|
+
removeEventListener: () => {},
|
|
160
|
+
dispatchEvent: () => false,
|
|
161
|
+
})) as typeof window.matchMedia
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('persists appearance changes through the feature composable', () => {
|
|
165
|
+
const theme = useTheme()
|
|
166
|
+
theme.setMode('dark')
|
|
167
|
+
theme.setPrimary('#abc')
|
|
168
|
+
|
|
169
|
+
expect(theme.mode.value).toBe('dark')
|
|
170
|
+
expect(theme.primary.value).toBe('#AABBCC')
|
|
171
|
+
expect(JSON.parse(localStorage.getItem('og-admin-theme') ?? '{}')).toMatchObject({
|
|
172
|
+
mode: 'dark',
|
|
173
|
+
primary: '#AABBCC',
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
|
|
177
|
+
it('exposes audit loading and export configuration', async () => {
|
|
178
|
+
const { config, dataSource } = useAuditManagement()
|
|
179
|
+
const result = await dataSource.list(
|
|
180
|
+
createTableQuery(),
|
|
181
|
+
createRequestContext(new AbortController().signal),
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
expect(result.total).toBeGreaterThanOrEqual(0)
|
|
185
|
+
expect(config.toolbar?.export).toBe('system:audit:export')
|
|
186
|
+
expect(
|
|
187
|
+
await dataSource.export?.(createExportRequest(), { signal: new AbortController().signal }),
|
|
188
|
+
).toBeInstanceOf(Blob)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('keeps CRUD feature data sources cancellable', async () => {
|
|
192
|
+
const refresh = vi.fn(async () => undefined)
|
|
193
|
+
const refreshAuthorization = vi.fn(async () => undefined)
|
|
194
|
+
await expectCancellableList(useUserManagement({ refresh, refreshAuthorization }).dataSource)
|
|
195
|
+
await expectCancellableList(useRoleManagement({ refresh, refreshAuthorization }).dataSource)
|
|
196
|
+
await expectCancellableList(useMenuManagement({ refresh, refreshAuthorization }).dataSource)
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it('uses a four-column search baseline for every system management page', () => {
|
|
200
|
+
const refresh = vi.fn(async () => undefined)
|
|
201
|
+
const refreshAuthorization = vi.fn(async () => undefined)
|
|
202
|
+
|
|
203
|
+
expect(useUserManagement({ refresh, refreshAuthorization }).config.search?.columns).toBe(4)
|
|
204
|
+
expect(useRoleManagement({ refresh, refreshAuthorization }).config.search?.columns).toBe(4)
|
|
205
|
+
expect(useMenuManagement({ refresh, refreshAuthorization }).config.search?.columns).toBe(4)
|
|
206
|
+
expect(useAuditManagement().config.search?.columns).toBe(4)
|
|
207
|
+
})
|
|
208
|
+
})
|
package/templates/current/examples/src/features/security/components/DevtoolsProtectionOverlay.vue
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { nextTick, useTemplateRef, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
defineOptions({ name: 'DevtoolsProtectionOverlay' })
|
|
5
|
+
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
blocked: boolean
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
const overlay = useTemplateRef<HTMLElement>('overlay')
|
|
11
|
+
|
|
12
|
+
watch(
|
|
13
|
+
() => props.blocked,
|
|
14
|
+
async (blocked) => {
|
|
15
|
+
if (!blocked) return
|
|
16
|
+
await nextTick()
|
|
17
|
+
overlay.value?.focus()
|
|
18
|
+
},
|
|
19
|
+
{ immediate: true },
|
|
20
|
+
)
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<Teleport to="body">
|
|
25
|
+
<section
|
|
26
|
+
v-if="blocked"
|
|
27
|
+
ref="overlay"
|
|
28
|
+
class="devtools-protection-overlay"
|
|
29
|
+
role="alertdialog"
|
|
30
|
+
aria-label="当前页面暂不可用"
|
|
31
|
+
aria-modal="true"
|
|
32
|
+
tabindex="-1"
|
|
33
|
+
>
|
|
34
|
+
<p>当前页面暂不可用</p>
|
|
35
|
+
</section>
|
|
36
|
+
</Teleport>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<style scoped>
|
|
40
|
+
.devtools-protection-overlay {
|
|
41
|
+
position: fixed;
|
|
42
|
+
z-index: 2147483647;
|
|
43
|
+
inset: 0;
|
|
44
|
+
display: grid;
|
|
45
|
+
place-items: center;
|
|
46
|
+
margin: 0;
|
|
47
|
+
background: var(--el-bg-color, #fff);
|
|
48
|
+
color: var(--el-text-color-primary, #303133);
|
|
49
|
+
cursor: not-allowed;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.devtools-protection-overlay p {
|
|
53
|
+
margin: 0;
|
|
54
|
+
font-size: 16px;
|
|
55
|
+
}
|
|
56
|
+
</style>
|