@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('/workspace')"> 回到工作台 </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('/workspace')"> 回到工作台 </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('/workspace')"> 回到工作台 </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('clean 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 empty workspace 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('/workspace')
|
|
31
|
+
})
|
|
32
|
+
})
|
package/templates/current/clean/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>
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
createDevtoolsProtection,
|
|
4
|
+
type DevtoolsDetector,
|
|
5
|
+
type KeyboardEventTarget,
|
|
6
|
+
type StorageLike,
|
|
7
|
+
} from './devtoolsProtection'
|
|
8
|
+
|
|
9
|
+
type TestDetector = DevtoolsDetector & {
|
|
10
|
+
callbacks?: { onClose: () => void, onError?: () => void, onOpen: () => void }
|
|
11
|
+
start: ReturnType<typeof vi.fn>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function createDetector(): TestDetector {
|
|
15
|
+
const detector: TestDetector = {
|
|
16
|
+
start: vi.fn(),
|
|
17
|
+
stop: vi.fn(),
|
|
18
|
+
}
|
|
19
|
+
detector.start.mockImplementation((callbacks) => {
|
|
20
|
+
detector.callbacks = callbacks
|
|
21
|
+
})
|
|
22
|
+
return detector
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createKeyboardTarget(): KeyboardEventTarget & {
|
|
26
|
+
dispatch: (type: 'keydown' | 'keyup', event: Partial<KeyboardEvent>) => void
|
|
27
|
+
} {
|
|
28
|
+
const listeners = new Map<string, EventListener>()
|
|
29
|
+
return {
|
|
30
|
+
addEventListener(type, listener) {
|
|
31
|
+
listeners.set(type, listener)
|
|
32
|
+
},
|
|
33
|
+
dispatch(type, event) {
|
|
34
|
+
listeners.get(type)?.(event as Event)
|
|
35
|
+
},
|
|
36
|
+
removeEventListener(type) {
|
|
37
|
+
listeners.delete(type)
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function keyboardEvent(key: string, options: Partial<KeyboardEvent> = {}): Partial<KeyboardEvent> {
|
|
43
|
+
return { isComposing: false, repeat: false, shiftKey: false, key, ...options }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('devtools protection', () => {
|
|
47
|
+
it('blocks when DevTools opens and unblocks after it closes', () => {
|
|
48
|
+
const detector = createDetector()
|
|
49
|
+
const protection = createDevtoolsProtection({
|
|
50
|
+
detector,
|
|
51
|
+
enabled: true,
|
|
52
|
+
keyboardTarget: createKeyboardTarget(),
|
|
53
|
+
storage: null,
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
protection.start()
|
|
57
|
+
detector.callbacks?.onOpen()
|
|
58
|
+
expect(protection.blocked.value).toBe(true)
|
|
59
|
+
|
|
60
|
+
detector.callbacks?.onClose()
|
|
61
|
+
expect(protection.blocked.value).toBe(false)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
it('does not initialize the detector outside protected builds', () => {
|
|
65
|
+
const detector = createDetector()
|
|
66
|
+
const protection = createDevtoolsProtection({
|
|
67
|
+
detector,
|
|
68
|
+
enabled: false,
|
|
69
|
+
keyboardTarget: createKeyboardTarget(),
|
|
70
|
+
storage: null,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
protection.start()
|
|
74
|
+
expect(detector.start).not.toHaveBeenCalled()
|
|
75
|
+
expect(protection.blocked.value).toBe(false)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('blocks when the detector fails to initialize', () => {
|
|
79
|
+
const detector = createDetector()
|
|
80
|
+
const protection = createDevtoolsProtection({
|
|
81
|
+
detector,
|
|
82
|
+
enabled: true,
|
|
83
|
+
keyboardTarget: createKeyboardTarget(),
|
|
84
|
+
storage: null,
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
protection.start()
|
|
88
|
+
detector.callbacks?.onError?.()
|
|
89
|
+
|
|
90
|
+
expect(protection.blocked.value).toBe(true)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
it('unlocks only when Shift is held while K then M are pressed within two seconds', () => {
|
|
94
|
+
const detector = createDetector()
|
|
95
|
+
const keyboardTarget = createKeyboardTarget()
|
|
96
|
+
let time = 0
|
|
97
|
+
const protection = createDevtoolsProtection({
|
|
98
|
+
detector,
|
|
99
|
+
enabled: true,
|
|
100
|
+
keyboardTarget,
|
|
101
|
+
now: () => time,
|
|
102
|
+
storage: null,
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
protection.start()
|
|
106
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true }))
|
|
107
|
+
time = 1_999
|
|
108
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('M', { shiftKey: true }))
|
|
109
|
+
|
|
110
|
+
expect(protection.unlocked.value).toBe(true)
|
|
111
|
+
expect(protection.blocked.value).toBe(false)
|
|
112
|
+
expect(detector.stop).toHaveBeenCalledOnce()
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('resets the unlock sequence for invalid input, Shift release, repeated keys, composition, and timeout', () => {
|
|
116
|
+
const detector = createDetector()
|
|
117
|
+
const keyboardTarget = createKeyboardTarget()
|
|
118
|
+
let time = 0
|
|
119
|
+
const protection = createDevtoolsProtection({
|
|
120
|
+
detector,
|
|
121
|
+
enabled: true,
|
|
122
|
+
keyboardTarget,
|
|
123
|
+
now: () => time,
|
|
124
|
+
storage: null,
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
protection.start()
|
|
128
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true }))
|
|
129
|
+
keyboardTarget.dispatch('keyup', keyboardEvent('Shift'))
|
|
130
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('M', { shiftKey: true }))
|
|
131
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true, repeat: true }))
|
|
132
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true, isComposing: true }))
|
|
133
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true }))
|
|
134
|
+
time = 2_001
|
|
135
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('M', { shiftKey: true }))
|
|
136
|
+
|
|
137
|
+
expect(protection.unlocked.value).toBe(false)
|
|
138
|
+
expect(detector.stop).not.toHaveBeenCalled()
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
it('persists the unlocked session and falls back to in-memory state if storage fails', () => {
|
|
142
|
+
const storage: StorageLike = {
|
|
143
|
+
getItem: vi.fn(() => null),
|
|
144
|
+
setItem: vi.fn(),
|
|
145
|
+
}
|
|
146
|
+
const detector = createDetector()
|
|
147
|
+
const keyboardTarget = createKeyboardTarget()
|
|
148
|
+
const protection = createDevtoolsProtection({
|
|
149
|
+
detector,
|
|
150
|
+
enabled: true,
|
|
151
|
+
keyboardTarget,
|
|
152
|
+
storage,
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
protection.start()
|
|
156
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true }))
|
|
157
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('M', { shiftKey: true }))
|
|
158
|
+
expect(storage.setItem).toHaveBeenCalledWith('og-admin-devtools-unlocked', 'true')
|
|
159
|
+
|
|
160
|
+
const stored = createDevtoolsProtection({
|
|
161
|
+
detector: createDetector(),
|
|
162
|
+
enabled: true,
|
|
163
|
+
keyboardTarget: createKeyboardTarget(),
|
|
164
|
+
storage: { getItem: () => 'true', setItem: vi.fn() },
|
|
165
|
+
})
|
|
166
|
+
stored.start()
|
|
167
|
+
expect(stored.unlocked.value).toBe(true)
|
|
168
|
+
|
|
169
|
+
const unavailableKeyboardTarget = createKeyboardTarget()
|
|
170
|
+
const unavailableWithKeyboard = createDevtoolsProtection({
|
|
171
|
+
detector: createDetector(),
|
|
172
|
+
enabled: true,
|
|
173
|
+
keyboardTarget: unavailableKeyboardTarget,
|
|
174
|
+
storage: {
|
|
175
|
+
getItem: () => {
|
|
176
|
+
throw new Error('unavailable')
|
|
177
|
+
},
|
|
178
|
+
setItem: () => {
|
|
179
|
+
throw new Error('unavailable')
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
})
|
|
183
|
+
unavailableWithKeyboard.start()
|
|
184
|
+
unavailableKeyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true }))
|
|
185
|
+
unavailableKeyboardTarget.dispatch('keydown', keyboardEvent('M', { shiftKey: true }))
|
|
186
|
+
expect(unavailableWithKeyboard.unlocked.value).toBe(true)
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it('starts once and removes listeners and detector state on cleanup', () => {
|
|
190
|
+
const detector = createDetector()
|
|
191
|
+
const keyboardTarget = createKeyboardTarget()
|
|
192
|
+
const protection = createDevtoolsProtection({
|
|
193
|
+
detector,
|
|
194
|
+
enabled: true,
|
|
195
|
+
keyboardTarget,
|
|
196
|
+
storage: null,
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
protection.start()
|
|
200
|
+
protection.start()
|
|
201
|
+
expect(detector.start).toHaveBeenCalledOnce()
|
|
202
|
+
|
|
203
|
+
protection.stop()
|
|
204
|
+
protection.stop()
|
|
205
|
+
expect(detector.stop).toHaveBeenCalledOnce()
|
|
206
|
+
|
|
207
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('K', { shiftKey: true }))
|
|
208
|
+
keyboardTarget.dispatch('keydown', keyboardEvent('M', { shiftKey: true }))
|
|
209
|
+
expect(protection.unlocked.value).toBe(false)
|
|
210
|
+
})
|
|
211
|
+
})
|