@gadmin2n/schematics 0.0.70 → 0.0.71
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/dist/lib/application/files/gadmin2-game-angle-demo/web/.npmrc +1 -0
- package/package.json +1 -1
- package/src/lib/application/application.schema.d.ts +59 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/.dockerignore +33 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/.gitignore +46 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/.husky/_/.gitignore +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/.husky/_/husky.sh +36 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/.husky/pre-commit +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/Dockerfile +63 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/Jenkinsfile +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/.types.d.ts +143 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/prisma/canvas.prisma +45 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/prisma/example.prisma +34 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/prisma/system.prisma +173 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Audit.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Event.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Game.ts +58 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/ITActivityDay.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Log.ts +56 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Page.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/PageResource.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Resource.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/Role.ts +58 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/RolePages.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/RoleResource.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/SavedQuery.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/User.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/config/ui/_common.ts +16 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/readme.md +142 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/.env +31 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/.env.local +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/.eslintrc.js +28 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/.prettierignore +7 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/.prettierrc +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/README.md +55 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/config/ac.config.ts +24 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/config/index.ts +58 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/gadmin-cli.json +25 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/migrate-between-pg-schemas.js +1232 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/package.json +143 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/prisma/.generator.prisma +34 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/prisma.config.ts +16 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/scripts/lib/page-helpers.ts +157 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/scripts/page-manage.ts +290 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/scripts/permission-manage.ts +184 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/scripts/prismaModels.ts +143 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/scripts/sync-resources.ts +100 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/scripts/syncDataMngtPages.ts +119 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/seed/games.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/seed/index.ts +21 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/seed/permissions.ts +244 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/seed/users.ts +7 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/alias.config.ts +7 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/app.controller.spec.ts +22 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/app.controller.ts +192 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/app.module.ts +91 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/app.service.ts +189 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/auth.guard.ts +154 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/http-cache.interceptor.ts +21 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/logger.ts +19 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/roles.guard.ts +47 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/safe-log.util.ts +176 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/taihu.ts +175 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/tracing.ts +174 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/trim.pipe.ts +51 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/utils.ts +145 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/lib/woaAuth.ts +95 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/main.ts +132 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.controller.ts +190 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.service.spec.ts +338 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/audit/audit.service.ts +83 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/canvas/canvas.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/canvas/canvas.controller.ts +81 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/canvas/canvas.dto.ts +49 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/canvas/canvas.module.ts +11 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/canvas/canvas.service.spec.ts +334 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/canvas/canvas.service.ts +249 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.controller.ts +188 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/game/game.service.ts +83 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/index.ts +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.controller.ts +250 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/page/page.service.ts +1051 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.controller.ts +196 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.module.ts +13 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/pageResource/pageResource.service.ts +219 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.controller.ts +196 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/resource/resource.service.ts +199 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.controller.ts +210 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.module.ts +12 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/role.service.ts +862 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/role/roles-refresher.service.ts +133 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.controller.ts +196 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/rolePages/rolePages.service.ts +201 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.controller.ts +196 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/roleResource/roleResource.service.ts +216 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.controller.spec.ts +20 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.controller.ts +198 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.module.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.service.spec.ts +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/src/modules/user/user.service.ts +104 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/start-prod.sh +130 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/test/app.e2e-spec.ts +24 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/test/jest-e2e.json +9 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/tsconfig.build.json +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/tsconfig.json +36 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/server/yarn.lock +7737 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/.env +2 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/.eslintrc.json +38 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/.npmrc +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/.prettierignore +2 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/.prettierrc +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/README.MD +48 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/dev-shell-entry.html +49 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/index.html +19 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/package.json +92 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/postcss.config.cjs +6 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/public/favicon.ico +0 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/public/images/flags/en.svg +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/public/images/flags/zh_CN.svg +11 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/App.tsx +137 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/auditLogProvider.ts +89 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/authProvider.ts +144 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/BulkActions.tsx +287 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/ListPageHeader.tsx +56 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/RowActions.tsx +318 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/SearchBar.tsx +323 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/SqlModal.tsx +495 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/VanillaJSONEditor/index.css +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/VanillaJSONEditor/index.jsx +53 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/AgentContext.tsx +375 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/ElementInspector.tsx +1133 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/agentAttributes.ts +70 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/index.ts +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/inspectorActions.ts +1034 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/pagePathUtils.ts +66 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/promptGenerator.ts +135 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/agentPanel/propPatcher.ts +84 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/eventList/index.tsx +58 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/index.ts +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/logButton/index.tsx +96 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/logList/index.tsx +72 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/components/modalDiffViewer/index.tsx +104 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/auditLog/index.tsx +2 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/BarChart/index.tsx +896 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/ChartSwitcher/index.tsx +219 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/ChartViewer/index.tsx +159 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/Filter/index.tsx +192 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/LineChart/index.tsx +1034 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/NumCard/NumCard.module.css +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/NumCard/index.tsx +509 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/NumLineCard/index.tsx +66 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/PieChart/index.tsx +552 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/RadarChart/index.tsx +263 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/Section/index.tsx +35 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/Table/index.tsx +207 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/TreemapChart/index.tsx +382 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/WorldMap/index.tsx +135 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/chart-constants.ts +53 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/icon/InfoIcon.tsx +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/icon/index.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/map/config.ts +31 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/map/nameMap.json +9 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/map/world.geo.json +39349 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/canvas/metric-info-tooltip/index.tsx +19 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/business/index.tsx +65 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/color-mode/index.tsx +54 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/custom-avatar.tsx +42 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/index.ts +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/header.tsx +106 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/index.ts +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/layout.tsx +32 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/logo.tsx +19 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/sider.tsx +431 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/layout/title.tsx +61 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/offLayoutArea/index.tsx +5 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/pagination-total.tsx +21 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/tags/index.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/tags/role-tag.tsx +44 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/components/text.tsx +78 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/config/http.ts +49 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +428 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/constants/layout.ts +16 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddDataModal.tsx +199 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/AddPageModal.tsx +335 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/DeleteDataConfirm.tsx +56 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/DevShell.tsx +401 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/EditDataModal.tsx +129 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/SkillMenu.tsx +202 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/UndoConfirm.tsx +36 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/index.tsx +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/dev-shell/style.css +835 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/enums/audit-log.enum.ts +13 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/enums/index.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/form.tsx +471 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/get-name-initials.ts +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/get-random-color.ts +27 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/http.ts +84 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/index.tsx +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/list.tsx +491 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/login.ts +82 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/page-tree.ts +74 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/show.tsx +226 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/utils.tsx +9 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/index.ts +7 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/types.ts +138 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchDelete.ts +191 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchOperations.ts +153 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchOperationsCore.ts +193 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useBatchUpdate.ts +182 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useDynamicResources.tsx +220 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useECharts.tsx +144 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useFetchData.ts +33 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useListPageState.ts +303 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useRoles.ts +34 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useRowSelection.ts +38 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/hooks/useUserPageAccess.ts +353 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/i18n.ts +23 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/index.tsx +27 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/locales/en/common.json +321 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/locales/zh_CN/common.json +324 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/meta.json +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/plugins/devShellPlugin.ts +81 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/components/action-cell.css +3 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/components/action-cell.tsx +134 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/create.tsx +105 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/edit.tsx +121 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/index.ts +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/index.tsx +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/list.tsx +220 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/show.tsx +74 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasCell.tsx +87 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasEditPage.tsx +192 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasListPage.tsx +409 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasPage.tsx +1372 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasToolbar.tsx +384 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CodeFloatWindow.tsx +476 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/ComponentThumbnail.tsx +137 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/IsolatedLivePreview.tsx +101 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/LivePreview.tsx +236 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/PublishModal.tsx +200 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasApi.ts +92 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasConfigRegistry.tsx +25 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasContextMenuRegistry.tsx +875 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasDefaults.ts +126 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/canvasI18n.ts +11 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/BarChartDataSourceModal.tsx +115 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/ChartViewerConfigModal.tsx +217 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/LineChartDataSourceModal.tsx +153 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/NumCardDataSourceModal.tsx +211 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/PromptModal.tsx +90 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/RadarChartDataSourceModal.tsx +87 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/components/TableDataSourceModal.tsx +204 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/demos.ts +1153 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/index.tsx +2 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/sectionCompactor.ts +45 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/types.ts +45 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas-page/index.tsx +108 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/create.tsx +105 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/edit.tsx +121 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/index.tsx +4 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/list.tsx +237 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/game/show.tsx +74 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/AssignRolesModal.tsx +177 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/CreatePageModal.tsx +42 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/EditPageModal.tsx +46 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/PageDetailDrawer.tsx +136 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/PageFormModal.tsx +815 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/hooks/usePageManagement.ts +40 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/index.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/list.tsx +1370 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/queries.ts +17 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/types.ts +45 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/permissionReadme/index.tsx +1090 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/CreateModal.tsx +25 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/EditModal.tsx +28 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/ResourceDetailDrawer.tsx +177 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/modal.tsx +230 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/index.ts +2 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/list.tsx +250 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/queries.ts +10 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/types.ts +9 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/CreateModal.tsx +30 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/EditModal.tsx +47 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/RoleDetailDrawer.tsx +66 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/modal.tsx +300 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/hooks/useRolePage.ts +35 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/index.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/list.tsx +405 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/queries.ts +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/types.ts +8 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/create-modal.tsx +17 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/edit-modal.tsx +19 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/form-modal.tsx +194 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/index.ts +5 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/role-tag.tsx +48 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/show-drawer.tsx +145 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/index.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/list.tsx +377 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/queries.ts +14 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/setupTests.ts +5 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/styles/antd.css +132 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/styles/fc.css +58 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/styles/index.css +128 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/styles/show-drawer.module.css +18 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/styles/show-page.module.css +21 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/types/audit-log.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/types/index.ts +3 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/types/role.ts +7 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/types/user.ts +1 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/src/vite-env.d.ts +13 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/tsconfig.json +28 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/vite.config.ts +48 -0
- package/src/lib/application/files/gadmin2-game-angle-demo/web/yarn.lock +9482 -0
- package/src/lib/class/class.schema.d.ts +32 -0
- package/src/lib/class/files/js/__name__.js +1 -0
- package/src/lib/class/files/js/__name__.spec.js +7 -0
- package/src/lib/class/files/ts/__name__.spec.ts +7 -0
- package/src/lib/class/files/ts/__name__.ts +1 -0
- package/src/lib/client-app/angular/angular.schema.d.ts +32 -0
- package/src/lib/client-app/angular/files/angular.constants.ts +4 -0
- package/src/lib/client-app/angular/files/angular.module.ts +41 -0
- package/src/lib/client-app/angular/files/angular.providers.ts +27 -0
- package/src/lib/client-app/angular/files/angular.utils.ts +19 -0
- package/src/lib/client-app/angular/files/interfaces/angular-options.interface.ts +87 -0
- package/src/lib/client-app/angular/files/loaders/abstract.loader.ts +16 -0
- package/src/lib/client-app/angular/files/loaders/express.loader.ts +25 -0
- package/src/lib/client-app/angular/files/loaders/fastify.loader.ts +34 -0
- package/src/lib/client-app/angular/files/loaders/noop.loader.ts +12 -0
- package/src/lib/configuration/configuration.schema.d.ts +18 -0
- package/src/lib/configuration/files/js/nest-cli.json +6 -0
- package/src/lib/configuration/files/ts/nest-cli.json +5 -0
- package/src/lib/controller/controller.schema.d.ts +45 -0
- package/src/lib/controller/files/js/__name__.controller.js +4 -0
- package/src/lib/controller/files/js/__name__.controller.spec.js +18 -0
- package/src/lib/controller/files/ts/__name__.controller.spec.ts +18 -0
- package/src/lib/controller/files/ts/__name__.controller.ts +137 -0
- package/src/lib/decorator/decorator.schema.d.ts +24 -0
- package/src/lib/decorator/files/js/__name__.decorator.js +3 -0
- package/src/lib/decorator/files/ts/__name__.decorator.ts +3 -0
- package/src/lib/filter/files/js/__name__.filter.js +6 -0
- package/src/lib/filter/files/js/__name__.filter.spec.js +7 -0
- package/src/lib/filter/files/ts/__name__.filter.spec.ts +7 -0
- package/src/lib/filter/files/ts/__name__.filter.ts +6 -0
- package/src/lib/filter/filter.schema.d.ts +28 -0
- package/src/lib/gateway/files/js/__name__.gateway.js +9 -0
- package/src/lib/gateway/files/js/__name__.gateway.spec.js +18 -0
- package/src/lib/gateway/files/ts/__name__.gateway.spec.ts +18 -0
- package/src/lib/gateway/files/ts/__name__.gateway.ts +9 -0
- package/src/lib/gateway/gateway.schema.d.ts +36 -0
- package/src/lib/guard/files/js/__name__.guard.js +8 -0
- package/src/lib/guard/files/js/__name__.guard.spec.js +7 -0
- package/src/lib/guard/files/ts/__name__.guard.spec.ts +7 -0
- package/src/lib/guard/files/ts/__name__.guard.ts +11 -0
- package/src/lib/guard/guard.schema.d.ts +28 -0
- package/src/lib/interceptor/files/js/__name__.interceptor.js +8 -0
- package/src/lib/interceptor/files/js/__name__.interceptor.spec.js +7 -0
- package/src/lib/interceptor/files/ts/default/__name__.interceptor.spec.ts +7 -0
- package/src/lib/interceptor/files/ts/default/__name__.interceptor.ts +9 -0
- package/src/lib/interceptor/files/ts/generated/__name__.interceptor.spec.ts +7 -0
- package/src/lib/interceptor/files/ts/generated/__name__.interceptor.ts +13 -0
- package/src/lib/interceptor/interceptor.schema.d.ts +35 -0
- package/src/lib/interface/files/__name__.interface.ts +1 -0
- package/src/lib/interface/interface.schema.d.ts +20 -0
- package/src/lib/library/files/js/.babelrc +4 -0
- package/src/lib/library/files/js/jsconfig.json +9 -0
- package/src/lib/library/files/js/src/__name__.module.js +8 -0
- package/src/lib/library/files/js/src/__name__.service.js +4 -0
- package/src/lib/library/files/js/src/__name__.service.spec.js +18 -0
- package/src/lib/library/files/js/src/index.js +2 -0
- package/src/lib/library/files/ts/src/__name__.module.ts +8 -0
- package/src/lib/library/files/ts/src/__name__.service.spec.ts +18 -0
- package/src/lib/library/files/ts/src/__name__.service.ts +4 -0
- package/src/lib/library/files/ts/src/index.ts +2 -0
- package/src/lib/library/files/ts/tsconfig.lib.json +9 -0
- package/src/lib/library/library.schema.d.ts +24 -0
- package/src/lib/middleware/files/js/__name__.middleware.js +8 -0
- package/src/lib/middleware/files/js/__name__.middleware.spec.js +7 -0
- package/src/lib/middleware/files/ts/__name__.middleware.spec.ts +7 -0
- package/src/lib/middleware/files/ts/__name__.middleware.ts +8 -0
- package/src/lib/middleware/middleware.schema.d.ts +28 -0
- package/src/lib/module/files/js/__name__.module.js +4 -0
- package/src/lib/module/files/ts/__name__.module.ts +4 -0
- package/src/lib/module/module.schema.d.ts +40 -0
- package/src/lib/pipe/files/js/__name__.pipe.js +8 -0
- package/src/lib/pipe/files/js/__name__.pipe.spec.js +7 -0
- package/src/lib/pipe/files/ts/__name__.pipe.spec.ts +7 -0
- package/src/lib/pipe/files/ts/__name__.pipe.ts +8 -0
- package/src/lib/pipe/pipe.schema.d.ts +28 -0
- package/src/lib/prisma-resource/files/ts/__name__.controller.spec.ts +20 -0
- package/src/lib/prisma-resource/files/ts/__name__.controller.ts +63 -0
- package/src/lib/prisma-resource/files/ts/__name__.module.ts +9 -0
- package/src/lib/prisma-resource/files/ts/__name__.service.spec.ts +18 -0
- package/src/lib/prisma-resource/files/ts/__name__.service.ts +28 -0
- package/src/lib/prisma-resource/files/ts/dto/create-__name@singular__.dto.ts +1 -0
- package/src/lib/prisma-resource/files/ts/dto/create-__name@singular__.input.ts +7 -0
- package/src/lib/prisma-resource/files/ts/dto/update-__name@singular__.dto.ts +6 -0
- package/src/lib/prisma-resource/files/ts/dto/update-__name@singular__.input.ts +13 -0
- package/src/lib/prisma-resource/files/ts/entities/__name@singular@ent__.ts +7 -0
- package/src/lib/prisma-resource/prisma-resource.schema.d.ts +57 -0
- package/src/lib/provider/files/js/__name__.js +4 -0
- package/src/lib/provider/files/js/__name__.spec.js +18 -0
- package/src/lib/provider/files/ts/__name__.spec.ts +18 -0
- package/src/lib/provider/files/ts/__name__.ts +4 -0
- package/src/lib/provider/provider.schema.d.ts +48 -0
- package/src/lib/resolver/files/js/__name__.resolver.js +4 -0
- package/src/lib/resolver/files/js/__name__.resolver.spec.js +18 -0
- package/src/lib/resolver/files/ts/__name__.resolver.spec.ts +18 -0
- package/src/lib/resolver/files/ts/__name__.resolver.ts +4 -0
- package/src/lib/resolver/resolver.schema.d.ts +36 -0
- package/src/lib/resource/files/ts/__name__.controller.spec.ts +20 -0
- package/src/lib/resource/files/ts/__name__.controller.ts +63 -0
- package/src/lib/resource/files/ts/__name__.gateway.spec.ts +19 -0
- package/src/lib/resource/files/ts/__name__.gateway.ts +34 -0
- package/src/lib/resource/files/ts/__name__.graphql +24 -0
- package/src/lib/resource/files/ts/__name__.module.ts +9 -0
- package/src/lib/resource/files/ts/__name__.resolver.spec.ts +19 -0
- package/src/lib/resource/files/ts/__name__.resolver.ts +60 -0
- package/src/lib/resource/files/ts/__name__.service.spec.ts +18 -0
- package/src/lib/resource/files/ts/__name__.service.ts +28 -0
- package/src/lib/resource/files/ts/dto/create-__name@singular__.dto.ts +1 -0
- package/src/lib/resource/files/ts/dto/create-__name@singular__.input.ts +7 -0
- package/src/lib/resource/files/ts/dto/update-__name@singular__.dto.ts +6 -0
- package/src/lib/resource/files/ts/dto/update-__name@singular__.input.ts +13 -0
- package/src/lib/resource/files/ts/entities/__name@singular@ent__.ts +7 -0
- package/src/lib/resource/resource.schema.d.ts +57 -0
- package/src/lib/service/files/js/__name__.service.js +4 -0
- package/src/lib/service/files/js/__name__.service.spec.js +18 -0
- package/src/lib/service/files/ts/__name__.service.spec.ts +18 -0
- package/src/lib/service/files/ts/__name__.service.ts +4 -0
- package/src/lib/service/service.schema.d.ts +44 -0
- package/src/lib/sub-app/files/js/.babelrc +4 -0
- package/src/lib/sub-app/files/js/index.js +2 -0
- package/src/lib/sub-app/files/js/jsconfig.json +10 -0
- package/src/lib/sub-app/files/js/src/app.controller.js +15 -0
- package/src/lib/sub-app/files/js/src/app.controller.spec.js +22 -0
- package/src/lib/sub-app/files/js/src/app.module.js +10 -0
- package/src/lib/sub-app/files/js/src/app.service.js +8 -0
- package/src/lib/sub-app/files/js/src/main.js +8 -0
- package/src/lib/sub-app/files/js/test/app.e2e-spec.js +23 -0
- package/src/lib/sub-app/files/js/test/jest-e2e.json +5 -0
- package/src/lib/sub-app/files/ts/src/__name__.controller.spec.ts +22 -0
- package/src/lib/sub-app/files/ts/src/__name__.controller.ts +12 -0
- package/src/lib/sub-app/files/ts/src/__name__.module.ts +10 -0
- package/src/lib/sub-app/files/ts/src/__name__.service.ts +8 -0
- package/src/lib/sub-app/files/ts/src/main.ts +8 -0
- package/src/lib/sub-app/files/ts/test/app.e2e-spec.ts +24 -0
- package/src/lib/sub-app/files/ts/test/jest-e2e.json +9 -0
- package/src/lib/sub-app/files/ts/tsconfig.app.json +9 -0
- package/src/lib/sub-app/sub-app.schema.d.ts +21 -0
- package/src/lib/sub-app/workspace/js/.babelrc +4 -0
- package/src/lib/sub-app/workspace/js/index.js +2 -0
- package/src/lib/sub-app/workspace/js/jsconfig.json +10 -0
- package/src/lib/sub-app/workspace/ts/tsconfig.app.json +9 -0
package/src/lib/application/files/gadmin2-game-angle-demo/web/src/routes/canvas/CanvasPage.tsx
ADDED
|
@@ -0,0 +1,1372 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
useState,
|
|
3
|
+
useCallback,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useEffect,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import { GridLayout, useContainerWidth } from 'react-grid-layout';
|
|
9
|
+
import type { LayoutItem } from 'react-grid-layout';
|
|
10
|
+
import { Dropdown, Modal, Checkbox, Input, Button, Space } from 'antd';
|
|
11
|
+
import type { MenuProps } from 'antd';
|
|
12
|
+
import {
|
|
13
|
+
PlusOutlined,
|
|
14
|
+
DeleteOutlined,
|
|
15
|
+
EditOutlined,
|
|
16
|
+
CopyOutlined,
|
|
17
|
+
SettingOutlined,
|
|
18
|
+
PlusCircleOutlined,
|
|
19
|
+
DatabaseOutlined,
|
|
20
|
+
MinusCircleOutlined,
|
|
21
|
+
} from '@ant-design/icons';
|
|
22
|
+
import CanvasCell from './CanvasCell';
|
|
23
|
+
import CodeFloatWindow from './CodeFloatWindow';
|
|
24
|
+
import CanvasToolbar from './CanvasToolbar';
|
|
25
|
+
import { CANVAS_COMPONENTS, CANVAS_DEFAULTS } from './canvasDefaults';
|
|
26
|
+
import { CANVAS_CONFIG_REGISTRY } from './canvasConfigRegistry';
|
|
27
|
+
import { useAgent } from '@/components/agentPanel/AgentContext';
|
|
28
|
+
import { generatePrompt } from '@/components/agentPanel/promptGenerator';
|
|
29
|
+
import { CANVAS_CONTEXT_MENU_REGISTRY } from './canvasContextMenuRegistry';
|
|
30
|
+
import type { MenuActionContext } from './canvasContextMenuRegistry';
|
|
31
|
+
import type { CanvasConfigModalProps } from './canvasConfigRegistry';
|
|
32
|
+
import NumCardDataSourceModal from './components/NumCardDataSourceModal';
|
|
33
|
+
import TableDataSourceModal from './components/TableDataSourceModal';
|
|
34
|
+
import BarChartDataSourceModal from './components/BarChartDataSourceModal';
|
|
35
|
+
import LineChartDataSourceModal from './components/LineChartDataSourceModal';
|
|
36
|
+
import RadarChartDataSourceModal from './components/RadarChartDataSourceModal';
|
|
37
|
+
import PromptModal from './components/PromptModal';
|
|
38
|
+
import { createSectionCompactor } from './sectionCompactor';
|
|
39
|
+
import type { CanvasItem as CanvasItemType } from './types';
|
|
40
|
+
import { useTranslation } from 'react-i18next';
|
|
41
|
+
import 'react-grid-layout/css/styles.css';
|
|
42
|
+
import 'react-resizable/css/styles.css';
|
|
43
|
+
|
|
44
|
+
// ─── ID 生成 ─────────────────────────────────────────────────────────────────
|
|
45
|
+
|
|
46
|
+
let _id = 0;
|
|
47
|
+
const genId = () => `canvas-${Date.now()}-${++_id}`;
|
|
48
|
+
|
|
49
|
+
// ─── Constants ───────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
const COLS = 48;
|
|
52
|
+
const ROW_HEIGHT = 10;
|
|
53
|
+
const MARGIN_Y = 8;
|
|
54
|
+
|
|
55
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
/** Compute the pixel height a component should fill given a grid row count. */
|
|
58
|
+
function gridRowsToPx(h: number): number {
|
|
59
|
+
return h * ROW_HEIGHT + (h - 1) * MARGIN_Y;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function syncCodeHeight(code: string, h: number): string {
|
|
63
|
+
const px = Math.max(50, gridRowsToPx(h));
|
|
64
|
+
|
|
65
|
+
// Table 组件用 height:100% 自适应外层容器,不需要注入固定高度
|
|
66
|
+
if (/^<Table[\s\n]/.test(code.trim())) {
|
|
67
|
+
return code;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// withChart variant 不需要固定高度(自适应外层容器)
|
|
71
|
+
if (/variant\s*=\s*"withChart"/.test(code)) {
|
|
72
|
+
let cleaned = code;
|
|
73
|
+
// 移除可能残留的 contentHeight prop
|
|
74
|
+
cleaned = cleaned.replace(/\s*contentHeight\s*=\s*\{[^}]*\}/, '');
|
|
75
|
+
// 移除 style={{ height: X }} (固定高度会阻止自适应)
|
|
76
|
+
cleaned = cleaned.replace(
|
|
77
|
+
/\s*style\s*=\s*\{\{\s*height\s*:\s*\d+\s*\}\}/,
|
|
78
|
+
'',
|
|
79
|
+
);
|
|
80
|
+
return cleaned;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// contentHeight={X} — NumLineCard inner chart area (subtract Card padding 32px)
|
|
84
|
+
if (/contentHeight\s*=\s*\{[^}]*\}/.test(code)) {
|
|
85
|
+
const inner = Math.max(40, px - 32);
|
|
86
|
+
return code.replace(
|
|
87
|
+
/contentHeight\s*=\s*\{[^}]*\}/g,
|
|
88
|
+
`contentHeight={${inner}}`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
if (/height\s*=\s*\{[^}]*\}/.test(code)) {
|
|
92
|
+
return code.replace(/height\s*=\s*\{[^}]*\}/g, `height={${px}}`);
|
|
93
|
+
}
|
|
94
|
+
if (/style\s*=\s*\{\{[^}]*height\s*:/.test(code)) {
|
|
95
|
+
return code.replace(/(height\s*:\s*)\d+/g, `$1${px}`);
|
|
96
|
+
}
|
|
97
|
+
if (/\/>\s*$/.test(code)) {
|
|
98
|
+
return code.replace(/\/>\s*$/, ` style={{ height: ${px} }}\n/>`);
|
|
99
|
+
}
|
|
100
|
+
return code;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ─── Props ───────────────────────────────────────────────────────────────────
|
|
104
|
+
|
|
105
|
+
interface CanvasPageProps {
|
|
106
|
+
items: CanvasItemType[];
|
|
107
|
+
layout: LayoutItem[];
|
|
108
|
+
isDirty: boolean;
|
|
109
|
+
canvasName: string;
|
|
110
|
+
isPublished: boolean;
|
|
111
|
+
onItemsChange: (items: CanvasItemType[]) => void;
|
|
112
|
+
onLayoutChange: (layout: LayoutItem[]) => void;
|
|
113
|
+
onBothChange: (items: CanvasItemType[], layout: LayoutItem[]) => void;
|
|
114
|
+
onSave: () => void;
|
|
115
|
+
onBack: () => void;
|
|
116
|
+
onPublish: () => void;
|
|
117
|
+
onUnpublish: () => void;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ─── CanvasPage ────────────────────────────────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
const CanvasPage: React.FC<CanvasPageProps> = ({
|
|
123
|
+
items,
|
|
124
|
+
layout,
|
|
125
|
+
isDirty,
|
|
126
|
+
canvasName,
|
|
127
|
+
isPublished,
|
|
128
|
+
onItemsChange,
|
|
129
|
+
onLayoutChange,
|
|
130
|
+
onBothChange,
|
|
131
|
+
onSave,
|
|
132
|
+
onBack,
|
|
133
|
+
onPublish,
|
|
134
|
+
onUnpublish,
|
|
135
|
+
}) => {
|
|
136
|
+
const { t } = useTranslation();
|
|
137
|
+
|
|
138
|
+
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
139
|
+
const [isPreview, setIsPreview] = useState(false);
|
|
140
|
+
const [editingId, setEditingId] = useState<string | null>(null);
|
|
141
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
142
|
+
const [configModal, setConfigModal] = useState<{
|
|
143
|
+
id: string;
|
|
144
|
+
componentType: string;
|
|
145
|
+
} | null>(null);
|
|
146
|
+
|
|
147
|
+
const [dataSourceModal, setDataSourceModal] = useState<{
|
|
148
|
+
id: string;
|
|
149
|
+
componentType: string;
|
|
150
|
+
code: string;
|
|
151
|
+
mode: 'api' | 'sql';
|
|
152
|
+
} | null>(null);
|
|
153
|
+
|
|
154
|
+
// ── PromptModal state(通用文本输入弹窗)──
|
|
155
|
+
const [promptModal, setPromptModal] = useState<{
|
|
156
|
+
label: string;
|
|
157
|
+
placeholder?: string;
|
|
158
|
+
defaultValue?: string;
|
|
159
|
+
onConfirm: (value: string) => void;
|
|
160
|
+
} | null>(null);
|
|
161
|
+
|
|
162
|
+
const menuActionContext: MenuActionContext = useMemo(
|
|
163
|
+
() => ({
|
|
164
|
+
showPrompt: (opts) => setPromptModal(opts),
|
|
165
|
+
}),
|
|
166
|
+
[],
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const agent = useAgent();
|
|
170
|
+
|
|
171
|
+
// 触发 agent 修改数据来源
|
|
172
|
+
const triggerDataSourceAgent = useCallback(
|
|
173
|
+
(
|
|
174
|
+
id: string,
|
|
175
|
+
componentType: string,
|
|
176
|
+
code: string,
|
|
177
|
+
userPrompt?: string,
|
|
178
|
+
skill?: string,
|
|
179
|
+
) => {
|
|
180
|
+
const prompt = generatePrompt({
|
|
181
|
+
skill: skill ?? 'canvas-data-query',
|
|
182
|
+
pageInfo: agent?.pageInfo ?? {
|
|
183
|
+
resourceName: '',
|
|
184
|
+
pageType: 'unknown',
|
|
185
|
+
path: '',
|
|
186
|
+
sourceFilePath: null,
|
|
187
|
+
},
|
|
188
|
+
userPrompt: userPrompt || '修改数据来源',
|
|
189
|
+
inspectedElement: {
|
|
190
|
+
type: 'canvas-component' as any,
|
|
191
|
+
resource: 'canvas',
|
|
192
|
+
x: 0,
|
|
193
|
+
y: 0,
|
|
194
|
+
meta: { componentType, canvasItemId: id, code },
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
agent?.sendPrompt(prompt);
|
|
198
|
+
},
|
|
199
|
+
[agent],
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
const { width: containerWidth, containerRef, mounted } = useContainerWidth();
|
|
203
|
+
|
|
204
|
+
const liveRef = useRef({
|
|
205
|
+
items,
|
|
206
|
+
layout,
|
|
207
|
+
onItemsChange,
|
|
208
|
+
onLayoutChange,
|
|
209
|
+
onBothChange,
|
|
210
|
+
selectedId,
|
|
211
|
+
editingId,
|
|
212
|
+
});
|
|
213
|
+
liveRef.current = {
|
|
214
|
+
items,
|
|
215
|
+
layout,
|
|
216
|
+
onItemsChange,
|
|
217
|
+
onLayoutChange,
|
|
218
|
+
onBothChange,
|
|
219
|
+
selectedId,
|
|
220
|
+
editingId,
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// 自定义 compactor:Section 与普通组件之间允许重叠
|
|
224
|
+
const sectionCompactor = useMemo(
|
|
225
|
+
() => createSectionCompactor(() => liveRef.current.items),
|
|
226
|
+
[],
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
// 添加组件
|
|
230
|
+
const addComponent = useCallback((type: string) => {
|
|
231
|
+
const { items, layout, onBothChange } = liveRef.current;
|
|
232
|
+
const def = CANVAS_DEFAULTS[type];
|
|
233
|
+
if (!def) return;
|
|
234
|
+
const id = genId();
|
|
235
|
+
const maxY = layout.reduce((m, l) => Math.max(m, l.y + l.h), 0);
|
|
236
|
+
const h = def.layout.h;
|
|
237
|
+
onBothChange(
|
|
238
|
+
[
|
|
239
|
+
...items,
|
|
240
|
+
{ id, componentType: type, code: syncCodeHeight(def.code, h) },
|
|
241
|
+
],
|
|
242
|
+
[
|
|
243
|
+
...layout,
|
|
244
|
+
{
|
|
245
|
+
i: id,
|
|
246
|
+
x: 0,
|
|
247
|
+
y: maxY,
|
|
248
|
+
w: def.layout.w,
|
|
249
|
+
h,
|
|
250
|
+
minW: def.layout.minW,
|
|
251
|
+
minH: def.layout.minH ?? 2,
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
);
|
|
255
|
+
}, []);
|
|
256
|
+
|
|
257
|
+
// 删除组件
|
|
258
|
+
const removeComponent = useCallback((id: string) => {
|
|
259
|
+
const { items, layout, onBothChange } = liveRef.current;
|
|
260
|
+
onBothChange(
|
|
261
|
+
items.filter((item) => item.id !== id),
|
|
262
|
+
layout.filter((l) => l.i !== id),
|
|
263
|
+
);
|
|
264
|
+
setSelectedId((prev) => (prev === id ? null : prev));
|
|
265
|
+
setEditingId((prev) => (prev === id ? null : prev));
|
|
266
|
+
}, []);
|
|
267
|
+
|
|
268
|
+
// 复制组件
|
|
269
|
+
const duplicateComponent = useCallback((id: string) => {
|
|
270
|
+
const { items, layout, onBothChange } = liveRef.current;
|
|
271
|
+
const item = items.find((i) => i.id === id);
|
|
272
|
+
const itemLayout = layout.find((l) => l.i === id);
|
|
273
|
+
if (!item || !itemLayout) return;
|
|
274
|
+
const newId = genId();
|
|
275
|
+
const maxY = layout.reduce((m, l) => Math.max(m, l.y + l.h), 0);
|
|
276
|
+
onBothChange(
|
|
277
|
+
[...items, { ...item, id: newId }],
|
|
278
|
+
[...layout, { ...itemLayout, i: newId, y: maxY }],
|
|
279
|
+
);
|
|
280
|
+
}, []);
|
|
281
|
+
|
|
282
|
+
// 更新组件代码
|
|
283
|
+
const updateCode = useCallback((id: string, code: string) => {
|
|
284
|
+
const { items, onItemsChange } = liveRef.current;
|
|
285
|
+
onItemsChange(
|
|
286
|
+
items.map((item) => (item.id === id ? { ...item, code } : item)),
|
|
287
|
+
);
|
|
288
|
+
}, []);
|
|
289
|
+
|
|
290
|
+
// ── canvas:patch HMR 监听 — agent 通过 POST /canvas-patch 触发画布实时更新 ──
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
if (!import.meta.hot) return;
|
|
293
|
+
const handler = ({ itemId, code }: { itemId: string; code: string }) => {
|
|
294
|
+
updateCode(itemId, code);
|
|
295
|
+
};
|
|
296
|
+
import.meta.hot.on('canvas:patch', handler);
|
|
297
|
+
return () => {
|
|
298
|
+
import.meta.hot?.off('canvas:patch', handler);
|
|
299
|
+
};
|
|
300
|
+
}, [updateCode]);
|
|
301
|
+
|
|
302
|
+
const handleDragStop = useCallback((_layout: readonly LayoutItem[]) => {
|
|
303
|
+
setIsDragging(false);
|
|
304
|
+
if (_layout.some((l) => l.i === '__dropping-elem__')) return;
|
|
305
|
+
const { layout, onLayoutChange } = liveRef.current;
|
|
306
|
+
const hasChanged = _layout.some((l) => {
|
|
307
|
+
const existing = layout.find((e) => e.i === l.i);
|
|
308
|
+
return (
|
|
309
|
+
!existing ||
|
|
310
|
+
l.x !== existing.x ||
|
|
311
|
+
l.y !== existing.y ||
|
|
312
|
+
l.w !== existing.w ||
|
|
313
|
+
l.h !== existing.h
|
|
314
|
+
);
|
|
315
|
+
});
|
|
316
|
+
if (!hasChanged) return;
|
|
317
|
+
const merged = _layout.map((l) => {
|
|
318
|
+
const existing = layout.find((e) => e.i === l.i);
|
|
319
|
+
return existing?.minW !== undefined || existing?.minH !== undefined
|
|
320
|
+
? { ...l, minW: existing?.minW, minH: existing?.minH }
|
|
321
|
+
: l;
|
|
322
|
+
});
|
|
323
|
+
onLayoutChange(merged);
|
|
324
|
+
}, []);
|
|
325
|
+
|
|
326
|
+
const handleResizeStop = useCallback(
|
|
327
|
+
(_layout: readonly LayoutItem[], _oldItem: any, newItem: any) => {
|
|
328
|
+
const { layout, items, onItemsChange, onLayoutChange } = liveRef.current;
|
|
329
|
+
|
|
330
|
+
if (
|
|
331
|
+
_layout.length > 0 &&
|
|
332
|
+
!_layout.some((l) => l.i === '__dropping-elem__')
|
|
333
|
+
) {
|
|
334
|
+
const merged = _layout.map((l) => {
|
|
335
|
+
const existing = layout.find((e) => e.i === l.i);
|
|
336
|
+
return existing?.minW !== undefined || existing?.minH !== undefined
|
|
337
|
+
? { ...l, minW: existing?.minW, minH: existing?.minH }
|
|
338
|
+
: l;
|
|
339
|
+
});
|
|
340
|
+
onLayoutChange(merged);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (!newItem?.i) return;
|
|
344
|
+
const { i: itemId, h } = newItem;
|
|
345
|
+
onItemsChange(
|
|
346
|
+
items.map((item) => {
|
|
347
|
+
if (item.id !== itemId) return item;
|
|
348
|
+
return { ...item, code: syncCodeHeight(item.code, h) };
|
|
349
|
+
}),
|
|
350
|
+
);
|
|
351
|
+
},
|
|
352
|
+
[],
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
// ── 外部拖拽放入 ──
|
|
356
|
+
|
|
357
|
+
const handleDrop = useCallback(
|
|
358
|
+
(
|
|
359
|
+
_layout: readonly LayoutItem[],
|
|
360
|
+
item: LayoutItem | undefined,
|
|
361
|
+
e: Event,
|
|
362
|
+
) => {
|
|
363
|
+
const type = (e as DragEvent).dataTransfer?.getData('componentType');
|
|
364
|
+
if (!type) return;
|
|
365
|
+
const def = CANVAS_DEFAULTS[type];
|
|
366
|
+
if (!def) return;
|
|
367
|
+
const { items, onBothChange } = liveRef.current;
|
|
368
|
+
const id = genId();
|
|
369
|
+
const h = def.layout.h;
|
|
370
|
+
const cleanLayout = _layout.filter((l) => l.i !== '__dropping-elem__');
|
|
371
|
+
|
|
372
|
+
// 优先使用 variant 代码(来自 Popover 拖拽),fallback 到 def.code
|
|
373
|
+
const rawVariantCode = (e as DragEvent).dataTransfer?.getData(
|
|
374
|
+
'variantCode',
|
|
375
|
+
);
|
|
376
|
+
const baseCode = rawVariantCode
|
|
377
|
+
? rawVariantCode.replace(
|
|
378
|
+
/testId="demo-([^"]+)"/g,
|
|
379
|
+
`testId="canvas-$1-${Date.now()}"`,
|
|
380
|
+
)
|
|
381
|
+
: def.code;
|
|
382
|
+
|
|
383
|
+
onBothChange(
|
|
384
|
+
[
|
|
385
|
+
...items,
|
|
386
|
+
{ id, componentType: type, code: syncCodeHeight(baseCode, h) },
|
|
387
|
+
],
|
|
388
|
+
[
|
|
389
|
+
...cleanLayout,
|
|
390
|
+
{
|
|
391
|
+
i: id,
|
|
392
|
+
x: item?.x ?? 0,
|
|
393
|
+
y: item?.y ?? 0,
|
|
394
|
+
w: def.layout.w,
|
|
395
|
+
h,
|
|
396
|
+
minW: def.layout.minW,
|
|
397
|
+
minH: def.layout.minH ?? 2,
|
|
398
|
+
},
|
|
399
|
+
],
|
|
400
|
+
);
|
|
401
|
+
},
|
|
402
|
+
[],
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
// ── 右键菜单 ──
|
|
406
|
+
|
|
407
|
+
const [itemMenu, setItemMenu] = useState<{
|
|
408
|
+
x: number;
|
|
409
|
+
y: number;
|
|
410
|
+
id: string;
|
|
411
|
+
} | null>(null);
|
|
412
|
+
|
|
413
|
+
const handleItemContextMenu = useCallback(
|
|
414
|
+
(e: React.MouseEvent, id: string) => {
|
|
415
|
+
setItemMenu({ x: e.clientX, y: e.clientY, id });
|
|
416
|
+
},
|
|
417
|
+
[],
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
const itemMenuItems: MenuProps['items'] = itemMenu
|
|
421
|
+
? (() => {
|
|
422
|
+
const item = items.find((i) => i.id === itemMenu.id);
|
|
423
|
+
const componentType = item?.componentType ?? '';
|
|
424
|
+
const hasConfig = componentType in CANVAS_CONFIG_REGISTRY;
|
|
425
|
+
|
|
426
|
+
// ── 第 1 层:组件特有操作 ──
|
|
427
|
+
const specificActionsFactory =
|
|
428
|
+
CANVAS_CONTEXT_MENU_REGISTRY[componentType];
|
|
429
|
+
const specificActions = specificActionsFactory
|
|
430
|
+
? specificActionsFactory(
|
|
431
|
+
item?.code ?? '',
|
|
432
|
+
(newCode) => {
|
|
433
|
+
updateCode(itemMenu.id, newCode);
|
|
434
|
+
},
|
|
435
|
+
() => setItemMenu(null),
|
|
436
|
+
menuActionContext,
|
|
437
|
+
t,
|
|
438
|
+
)
|
|
439
|
+
: [];
|
|
440
|
+
|
|
441
|
+
// ── 第 2 层:通用操作(检查元素) ──
|
|
442
|
+
const commonActions: MenuProps['items'] = [
|
|
443
|
+
...(hasConfig
|
|
444
|
+
? [
|
|
445
|
+
{
|
|
446
|
+
key: 'config',
|
|
447
|
+
icon: <SettingOutlined />,
|
|
448
|
+
label: t('canvas.config'),
|
|
449
|
+
onClick: () => {
|
|
450
|
+
setConfigModal({ id: itemMenu.id, componentType });
|
|
451
|
+
setItemMenu(null);
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
]
|
|
455
|
+
: []),
|
|
456
|
+
{
|
|
457
|
+
key: 'data-source',
|
|
458
|
+
icon: <DatabaseOutlined />,
|
|
459
|
+
label: t('canvas.dataSource.api'),
|
|
460
|
+
onClick: () => {
|
|
461
|
+
if (
|
|
462
|
+
componentType === 'NumCard' ||
|
|
463
|
+
componentType === 'Table' ||
|
|
464
|
+
componentType === 'BarChart' ||
|
|
465
|
+
componentType === 'LineChart' ||
|
|
466
|
+
componentType === 'RadarChart'
|
|
467
|
+
) {
|
|
468
|
+
setDataSourceModal({
|
|
469
|
+
id: itemMenu.id,
|
|
470
|
+
componentType,
|
|
471
|
+
code: item?.code ?? '',
|
|
472
|
+
mode: 'api',
|
|
473
|
+
});
|
|
474
|
+
} else {
|
|
475
|
+
// 其他组件:弹 modal 收集描述后触发 agent
|
|
476
|
+
menuActionContext.showPrompt({
|
|
477
|
+
label: t('canvas.dataSource.api'),
|
|
478
|
+
placeholder: t('canvas.dataSource.apiPlaceholder'),
|
|
479
|
+
defaultValue: '',
|
|
480
|
+
onConfirm: (value) => {
|
|
481
|
+
if (!value.trim()) return;
|
|
482
|
+
triggerDataSourceAgent(
|
|
483
|
+
itemMenu.id,
|
|
484
|
+
componentType,
|
|
485
|
+
item?.code ?? '',
|
|
486
|
+
value.trim(),
|
|
487
|
+
);
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
setItemMenu(null);
|
|
492
|
+
},
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
key: 'data-source-sql',
|
|
496
|
+
icon: <DatabaseOutlined />,
|
|
497
|
+
label: t('canvas.dataSource.sql'),
|
|
498
|
+
onClick: () => {
|
|
499
|
+
if (
|
|
500
|
+
componentType === 'NumCard' ||
|
|
501
|
+
componentType === 'Table' ||
|
|
502
|
+
componentType === 'BarChart' ||
|
|
503
|
+
componentType === 'LineChart' ||
|
|
504
|
+
componentType === 'RadarChart'
|
|
505
|
+
) {
|
|
506
|
+
setDataSourceModal({
|
|
507
|
+
id: itemMenu.id,
|
|
508
|
+
componentType,
|
|
509
|
+
code: item?.code ?? '',
|
|
510
|
+
mode: 'sql',
|
|
511
|
+
});
|
|
512
|
+
} else {
|
|
513
|
+
// 其他组件:弹通用输入 modal
|
|
514
|
+
menuActionContext.showPrompt({
|
|
515
|
+
label: t('canvas.dataSource.sql'),
|
|
516
|
+
placeholder: t('canvas.dataSource.sqlPlaceholder'),
|
|
517
|
+
defaultValue: '',
|
|
518
|
+
onConfirm: (value) => {
|
|
519
|
+
if (!value.trim()) return;
|
|
520
|
+
const prompt = generatePrompt({
|
|
521
|
+
skill: 'canvas-sql-query',
|
|
522
|
+
pageInfo: agent?.pageInfo ?? {
|
|
523
|
+
resourceName: '',
|
|
524
|
+
pageType: 'unknown',
|
|
525
|
+
path: '',
|
|
526
|
+
sourceFilePath: null,
|
|
527
|
+
},
|
|
528
|
+
userPrompt: `为此 ${componentType} 组件用 SQL 查询真实数据并填充:${value.trim()}`,
|
|
529
|
+
inspectedElement: {
|
|
530
|
+
type: 'canvas-component' as any,
|
|
531
|
+
resource: 'canvas',
|
|
532
|
+
x: 0,
|
|
533
|
+
y: 0,
|
|
534
|
+
meta: {
|
|
535
|
+
componentType,
|
|
536
|
+
canvasItemId: itemMenu.id,
|
|
537
|
+
code: item?.code ?? '',
|
|
538
|
+
},
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
agent?.sendPrompt(prompt);
|
|
542
|
+
},
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
setItemMenu(null);
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
key: 'custom-agent',
|
|
550
|
+
icon: <EditOutlined />,
|
|
551
|
+
label: t('canvas.custom'),
|
|
552
|
+
onClick: () => {
|
|
553
|
+
setItemMenu(null);
|
|
554
|
+
menuActionContext.showPrompt({
|
|
555
|
+
label: t('canvas.customAction'),
|
|
556
|
+
placeholder: t('canvas.customPlaceholder'),
|
|
557
|
+
defaultValue: '',
|
|
558
|
+
onConfirm: (value) => {
|
|
559
|
+
if (!value.trim()) return;
|
|
560
|
+
const prompt = generatePrompt({
|
|
561
|
+
skill: null,
|
|
562
|
+
pageInfo: agent?.pageInfo ?? {
|
|
563
|
+
resourceName: '',
|
|
564
|
+
pageType: 'unknown',
|
|
565
|
+
path: '',
|
|
566
|
+
sourceFilePath: null,
|
|
567
|
+
},
|
|
568
|
+
userPrompt: value.trim(),
|
|
569
|
+
inspectedElement: {
|
|
570
|
+
type: 'canvas-component' as any,
|
|
571
|
+
resource: 'canvas',
|
|
572
|
+
x: 0,
|
|
573
|
+
y: 0,
|
|
574
|
+
meta: {
|
|
575
|
+
componentType,
|
|
576
|
+
canvasItemId: itemMenu.id,
|
|
577
|
+
code: item?.code ?? '',
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
});
|
|
581
|
+
agent?.sendPrompt(prompt);
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
];
|
|
587
|
+
|
|
588
|
+
// ── 第 3 层:代码级操作 ──
|
|
589
|
+
const codeActions: MenuProps['items'] = [
|
|
590
|
+
{
|
|
591
|
+
key: 'edit',
|
|
592
|
+
icon: <EditOutlined />,
|
|
593
|
+
label: t('canvas.editCode'),
|
|
594
|
+
onClick: () => {
|
|
595
|
+
setEditingId(itemMenu.id);
|
|
596
|
+
setItemMenu(null);
|
|
597
|
+
},
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
key: 'copy',
|
|
601
|
+
icon: <CopyOutlined />,
|
|
602
|
+
label: t('canvas.duplicate'),
|
|
603
|
+
onClick: () => {
|
|
604
|
+
duplicateComponent(itemMenu.id);
|
|
605
|
+
setItemMenu(null);
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
key: 'delete',
|
|
610
|
+
icon: <DeleteOutlined />,
|
|
611
|
+
label: t('canvas.delete'),
|
|
612
|
+
danger: true,
|
|
613
|
+
onClick: () => {
|
|
614
|
+
removeComponent(itemMenu.id);
|
|
615
|
+
setItemMenu(null);
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
];
|
|
619
|
+
|
|
620
|
+
// ── 组装三层 ──
|
|
621
|
+
const result: MenuProps['items'] = [];
|
|
622
|
+
if (specificActions && specificActions.length > 0) {
|
|
623
|
+
result.push(...specificActions);
|
|
624
|
+
result.push({ type: 'divider' as const });
|
|
625
|
+
}
|
|
626
|
+
result.push(...commonActions);
|
|
627
|
+
result.push({ type: 'divider' as const });
|
|
628
|
+
result.push(...codeActions);
|
|
629
|
+
|
|
630
|
+
return result;
|
|
631
|
+
})()
|
|
632
|
+
: [];
|
|
633
|
+
|
|
634
|
+
const handleCanvasClick = useCallback(() => {
|
|
635
|
+
setSelectedId(null);
|
|
636
|
+
setItemMenu(null);
|
|
637
|
+
}, []);
|
|
638
|
+
|
|
639
|
+
const editingItem = editingId ? items.find((i) => i.id === editingId) : null;
|
|
640
|
+
const editingDef = editingItem
|
|
641
|
+
? CANVAS_DEFAULTS[editingItem.componentType]
|
|
642
|
+
: null;
|
|
643
|
+
|
|
644
|
+
const dropConfig = useMemo(
|
|
645
|
+
() => ({
|
|
646
|
+
enabled: true,
|
|
647
|
+
defaultItem: { w: 12, h: 12 },
|
|
648
|
+
onDragOver: (e: DragEvent) => {
|
|
649
|
+
const typeKey = Array.from(
|
|
650
|
+
(e as unknown as React.DragEvent).dataTransfer?.types ??
|
|
651
|
+
e.dataTransfer?.types ??
|
|
652
|
+
[],
|
|
653
|
+
).find((t: string) => t.startsWith('x-component-type/'));
|
|
654
|
+
if (!typeKey) return;
|
|
655
|
+
const componentType = CANVAS_COMPONENTS.find(
|
|
656
|
+
(t) => `x-component-type/${t.toLowerCase()}` === typeKey,
|
|
657
|
+
);
|
|
658
|
+
if (!componentType) return;
|
|
659
|
+
const def = CANVAS_DEFAULTS[componentType];
|
|
660
|
+
if (!def) return;
|
|
661
|
+
return { w: def.layout.w, h: def.layout.h };
|
|
662
|
+
},
|
|
663
|
+
}),
|
|
664
|
+
[],
|
|
665
|
+
);
|
|
666
|
+
|
|
667
|
+
return (
|
|
668
|
+
<div
|
|
669
|
+
style={{
|
|
670
|
+
display: 'flex',
|
|
671
|
+
flexDirection: 'column',
|
|
672
|
+
...(isPreview ? {} : { height: 'calc(100vh - 64px - 64px)' }),
|
|
673
|
+
}}
|
|
674
|
+
>
|
|
675
|
+
{/* ── 顶部工具栏(固定在画布外面,不参与滚动) ── */}
|
|
676
|
+
{!isPreview && (
|
|
677
|
+
<CanvasToolbar
|
|
678
|
+
isDirty={isDirty}
|
|
679
|
+
canvasName={canvasName}
|
|
680
|
+
isPublished={isPublished}
|
|
681
|
+
onSave={onSave}
|
|
682
|
+
onBack={onBack}
|
|
683
|
+
onPublish={onPublish}
|
|
684
|
+
onUnpublish={onUnpublish}
|
|
685
|
+
onPreview={() => setIsPreview(true)}
|
|
686
|
+
/>
|
|
687
|
+
)}
|
|
688
|
+
|
|
689
|
+
{/* ── 画布 ── */}
|
|
690
|
+
<div
|
|
691
|
+
ref={containerRef as React.RefObject<HTMLDivElement>}
|
|
692
|
+
onClick={handleCanvasClick}
|
|
693
|
+
style={{
|
|
694
|
+
flex: 1,
|
|
695
|
+
overflow: isPreview ? 'visible' : 'auto',
|
|
696
|
+
position: 'relative',
|
|
697
|
+
background: isDragging
|
|
698
|
+
? `
|
|
699
|
+
radial-gradient(circle, #1677ff 1.5px, transparent 1.5px) 0 0 / 90px 90px,
|
|
700
|
+
radial-gradient(circle, #1677ff 0.8px, transparent 0.8px) 0 0 / 18px 18px,
|
|
701
|
+
#f0f2f5
|
|
702
|
+
`
|
|
703
|
+
: '#f0f2f5',
|
|
704
|
+
transition: 'background 0.15s',
|
|
705
|
+
}}
|
|
706
|
+
>
|
|
707
|
+
{/* 空画布提示 */}
|
|
708
|
+
{items.length === 0 && (
|
|
709
|
+
<div
|
|
710
|
+
style={{
|
|
711
|
+
position: 'absolute',
|
|
712
|
+
inset: 0,
|
|
713
|
+
display: 'flex',
|
|
714
|
+
flexDirection: 'column',
|
|
715
|
+
alignItems: 'center',
|
|
716
|
+
justifyContent: 'center',
|
|
717
|
+
gap: 12,
|
|
718
|
+
userSelect: 'none',
|
|
719
|
+
pointerEvents: 'none',
|
|
720
|
+
}}
|
|
721
|
+
>
|
|
722
|
+
<PlusCircleOutlined style={{ fontSize: 48, color: '#d9d9d9' }} />
|
|
723
|
+
<span style={{ fontSize: 16, color: '#8c8c8c' }}>
|
|
724
|
+
{t('canvas.emptyHint')}
|
|
725
|
+
</span>
|
|
726
|
+
<span style={{ fontSize: 13, color: '#bfbfbf' }}>
|
|
727
|
+
或右键画布添加组件
|
|
728
|
+
</span>
|
|
729
|
+
</div>
|
|
730
|
+
)}
|
|
731
|
+
|
|
732
|
+
{/* 网格布局 */}
|
|
733
|
+
{mounted && (
|
|
734
|
+
<div style={{ maxWidth: 1600, margin: '0 auto', width: '100%' }}>
|
|
735
|
+
<GridLayout
|
|
736
|
+
className="layout"
|
|
737
|
+
layout={layout}
|
|
738
|
+
width={Math.min(containerWidth, 1600)}
|
|
739
|
+
style={{
|
|
740
|
+
minHeight: Math.max(
|
|
741
|
+
// 根据 layout 内容底部动态延伸 + 额外空间
|
|
742
|
+
layout.reduce(
|
|
743
|
+
(max, item) =>
|
|
744
|
+
Math.max(
|
|
745
|
+
max,
|
|
746
|
+
(item.y + item.h) * (ROW_HEIGHT + MARGIN_Y),
|
|
747
|
+
),
|
|
748
|
+
0,
|
|
749
|
+
) + (isDragging ? 600 : 300),
|
|
750
|
+
// 至少占满一屏
|
|
751
|
+
window.innerHeight - 200,
|
|
752
|
+
),
|
|
753
|
+
}}
|
|
754
|
+
gridConfig={{
|
|
755
|
+
cols: COLS,
|
|
756
|
+
rowHeight: ROW_HEIGHT,
|
|
757
|
+
margin: [MARGIN_Y, MARGIN_Y] as const,
|
|
758
|
+
}}
|
|
759
|
+
dragConfig={{
|
|
760
|
+
enabled: !isPreview,
|
|
761
|
+
handle: '.canvas-item-drag',
|
|
762
|
+
}}
|
|
763
|
+
resizeConfig={{
|
|
764
|
+
enabled: !isPreview,
|
|
765
|
+
}}
|
|
766
|
+
dropConfig={isPreview ? undefined : dropConfig}
|
|
767
|
+
onDrop={isPreview ? undefined : handleDrop}
|
|
768
|
+
compactor={sectionCompactor}
|
|
769
|
+
onResizeStop={handleResizeStop}
|
|
770
|
+
onDragStart={() => setIsDragging(true)}
|
|
771
|
+
onDragStop={handleDragStop}
|
|
772
|
+
>
|
|
773
|
+
{items.map((item) => (
|
|
774
|
+
<CanvasCell
|
|
775
|
+
key={item.id}
|
|
776
|
+
className="canvas-item-drag"
|
|
777
|
+
style={{ zIndex: item.componentType === 'Section' ? 0 : 1 }}
|
|
778
|
+
componentType={item.componentType}
|
|
779
|
+
isPreview={isPreview}
|
|
780
|
+
data-grid-id={item.id}
|
|
781
|
+
data-agent-type="canvas-component"
|
|
782
|
+
data-agent-resource="canvas"
|
|
783
|
+
data-agent-meta={JSON.stringify({
|
|
784
|
+
componentType: item.componentType,
|
|
785
|
+
canvasItemId: item.id,
|
|
786
|
+
code: item.code,
|
|
787
|
+
})}
|
|
788
|
+
code={item.code}
|
|
789
|
+
selected={selectedId === item.id}
|
|
790
|
+
onClick={() => setSelectedId(item.id)}
|
|
791
|
+
onDoubleClick={() => setEditingId(item.id)}
|
|
792
|
+
onContextMenu={(e: React.MouseEvent) =>
|
|
793
|
+
handleItemContextMenu(e, item.id)
|
|
794
|
+
}
|
|
795
|
+
/>
|
|
796
|
+
))}
|
|
797
|
+
</GridLayout>
|
|
798
|
+
</div>
|
|
799
|
+
)}
|
|
800
|
+
|
|
801
|
+
{/* 预览模式退出按钮 */}
|
|
802
|
+
{isPreview && (
|
|
803
|
+
<Button
|
|
804
|
+
onClick={() => setIsPreview(false)}
|
|
805
|
+
style={{
|
|
806
|
+
position: 'fixed',
|
|
807
|
+
top: 68,
|
|
808
|
+
left: '58%',
|
|
809
|
+
transform: 'translateX(-50%)',
|
|
810
|
+
zIndex: 1000,
|
|
811
|
+
borderRadius: 8,
|
|
812
|
+
background: '#fff',
|
|
813
|
+
border: '1px solid #e0e0e0',
|
|
814
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.08)',
|
|
815
|
+
fontWeight: 500,
|
|
816
|
+
color: '#555',
|
|
817
|
+
}}
|
|
818
|
+
>
|
|
819
|
+
{t('canvas.exitPreview')}
|
|
820
|
+
</Button>
|
|
821
|
+
)}
|
|
822
|
+
|
|
823
|
+
{/* 组件右键菜单 */}
|
|
824
|
+
{itemMenu && (
|
|
825
|
+
<Dropdown
|
|
826
|
+
menu={{ items: itemMenuItems }}
|
|
827
|
+
open
|
|
828
|
+
trigger={['click']}
|
|
829
|
+
onOpenChange={(open) => {
|
|
830
|
+
if (!open) setItemMenu(null);
|
|
831
|
+
}}
|
|
832
|
+
>
|
|
833
|
+
<div
|
|
834
|
+
style={{
|
|
835
|
+
position: 'fixed',
|
|
836
|
+
left: itemMenu.x,
|
|
837
|
+
top: itemMenu.y,
|
|
838
|
+
width: 1,
|
|
839
|
+
height: 1,
|
|
840
|
+
}}
|
|
841
|
+
/>
|
|
842
|
+
</Dropdown>
|
|
843
|
+
)}
|
|
844
|
+
|
|
845
|
+
{/* 组件配置 Modal */}
|
|
846
|
+
{configModal &&
|
|
847
|
+
(() => {
|
|
848
|
+
const ConfigModal = CANVAS_CONFIG_REGISTRY[
|
|
849
|
+
configModal.componentType
|
|
850
|
+
] as React.FC<CanvasConfigModalProps> | undefined;
|
|
851
|
+
const item = items.find((i) => i.id === configModal.id);
|
|
852
|
+
if (!ConfigModal || !item) return null;
|
|
853
|
+
return (
|
|
854
|
+
<ConfigModal
|
|
855
|
+
code={item.code}
|
|
856
|
+
onConfirm={(newCode) => {
|
|
857
|
+
updateCode(configModal.id, newCode);
|
|
858
|
+
setConfigModal(null);
|
|
859
|
+
}}
|
|
860
|
+
onCancel={() => setConfigModal(null)}
|
|
861
|
+
/>
|
|
862
|
+
);
|
|
863
|
+
})()}
|
|
864
|
+
|
|
865
|
+
{/* 浮动代码窗口 */}
|
|
866
|
+
{!isPreview && editingItem && editingDef && (
|
|
867
|
+
<CodeFloatWindow
|
|
868
|
+
componentType={editingItem.componentType}
|
|
869
|
+
imports={editingDef.imports}
|
|
870
|
+
code={editingItem.code}
|
|
871
|
+
props={editingDef.props}
|
|
872
|
+
variants={editingDef.variants}
|
|
873
|
+
onChange={(code) => updateCode(editingItem.id, code)}
|
|
874
|
+
onClose={() => setEditingId(null)}
|
|
875
|
+
/>
|
|
876
|
+
)}
|
|
877
|
+
|
|
878
|
+
{/* NumCard 修改数据来源 Modal */}
|
|
879
|
+
<NumCardDataSourceModal
|
|
880
|
+
open={
|
|
881
|
+
!!dataSourceModal && dataSourceModal.componentType === 'NumCard'
|
|
882
|
+
}
|
|
883
|
+
code={dataSourceModal?.code ?? ''}
|
|
884
|
+
onConfirm={({
|
|
885
|
+
wantChart,
|
|
886
|
+
chartRange,
|
|
887
|
+
wantComparisons,
|
|
888
|
+
comparisonLabels,
|
|
889
|
+
dataDescription,
|
|
890
|
+
code: origCode,
|
|
891
|
+
}) => {
|
|
892
|
+
if (!dataSourceModal) return;
|
|
893
|
+
let newCode = origCode;
|
|
894
|
+
|
|
895
|
+
// 处理折线图
|
|
896
|
+
const curHasChart = /variant\s*=\s*"withChart"/.test(newCode);
|
|
897
|
+
if (wantChart && !curHasChart) {
|
|
898
|
+
// 添加 withChart
|
|
899
|
+
if (/variant\s*=\s*"[^"]*"/.test(newCode)) {
|
|
900
|
+
newCode = newCode.replace(
|
|
901
|
+
/variant\s*=\s*"[^"]*"/,
|
|
902
|
+
'variant="withChart"',
|
|
903
|
+
);
|
|
904
|
+
} else {
|
|
905
|
+
newCode = newCode.replace(
|
|
906
|
+
/(<NumCard)/,
|
|
907
|
+
'$1\n variant="withChart"',
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
if (!/chartData\s*=/.test(newCode)) {
|
|
911
|
+
const tpl = `chartData={[]}\n chartTestId="canvas-numcard-chart"`;
|
|
912
|
+
newCode = newCode.replace(
|
|
913
|
+
/([ \t]*)(testId\s*=)/,
|
|
914
|
+
`$1${tpl}\n$1$2`,
|
|
915
|
+
);
|
|
916
|
+
}
|
|
917
|
+
} else if (!wantChart && curHasChart) {
|
|
918
|
+
// 移除 withChart
|
|
919
|
+
newCode = newCode.replace(
|
|
920
|
+
/variant\s*=\s*"withChart"/,
|
|
921
|
+
'variant="default"',
|
|
922
|
+
);
|
|
923
|
+
newCode = newCode.replace(
|
|
924
|
+
/\s*chartData\s*=\s*\{[\s\S]*?\]\s*\}/,
|
|
925
|
+
'',
|
|
926
|
+
);
|
|
927
|
+
newCode = newCode.replace(/\s*chartTestId\s*=\s*"[^"]*"/, '');
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
// 处理比较数据
|
|
931
|
+
const curHasComp = /comparisons\s*=\s*\{\[/.test(newCode);
|
|
932
|
+
if (wantComparisons && comparisonLabels.length > 0) {
|
|
933
|
+
const compStr = comparisonLabels
|
|
934
|
+
.map((l) => `{ label: "${l}", value: "0%", isUp: true }`)
|
|
935
|
+
.join(',\n ');
|
|
936
|
+
const compProp = `comparisons={[\n ${compStr},\n ]}`;
|
|
937
|
+
if (curHasComp) {
|
|
938
|
+
newCode = newCode.replace(
|
|
939
|
+
/comparisons\s*=\s*\{\[[\s\S]*?\]\}/,
|
|
940
|
+
compProp,
|
|
941
|
+
);
|
|
942
|
+
} else {
|
|
943
|
+
if (/testId\s*=/.test(newCode)) {
|
|
944
|
+
newCode = newCode.replace(
|
|
945
|
+
/([ \t]*)(testId\s*=)/,
|
|
946
|
+
`$1${compProp}\n$1$2`,
|
|
947
|
+
);
|
|
948
|
+
} else {
|
|
949
|
+
newCode = newCode.replace(/\/>/, ` ${compProp}\n/>`);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
} else if (!wantComparisons && curHasComp) {
|
|
953
|
+
newCode = newCode.replace(
|
|
954
|
+
/\s*comparisons\s*=\s*\{\[[\s\S]*?\]\}/,
|
|
955
|
+
'',
|
|
956
|
+
);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
updateCode(dataSourceModal.id, newCode);
|
|
960
|
+
setDataSourceModal(null);
|
|
961
|
+
|
|
962
|
+
// 构造描述发给 agent
|
|
963
|
+
const parts: string[] = [];
|
|
964
|
+
if (dataDescription) parts.push(dataDescription);
|
|
965
|
+
if (wantChart)
|
|
966
|
+
parts.push(`需要右侧折线图数据,显示范围:${chartRange}`);
|
|
967
|
+
if (wantComparisons && comparisonLabels.length > 0) {
|
|
968
|
+
parts.push(`需要比较数据:${comparisonLabels.join('、')}`);
|
|
969
|
+
}
|
|
970
|
+
const userPrompt = parts.join('。');
|
|
971
|
+
triggerDataSourceAgent(
|
|
972
|
+
dataSourceModal.id,
|
|
973
|
+
dataSourceModal.componentType,
|
|
974
|
+
newCode,
|
|
975
|
+
userPrompt || undefined,
|
|
976
|
+
dataSourceModal.mode === 'sql'
|
|
977
|
+
? 'canvas-sql-query'
|
|
978
|
+
: 'canvas-data-query',
|
|
979
|
+
);
|
|
980
|
+
}}
|
|
981
|
+
onCancel={() => setDataSourceModal(null)}
|
|
982
|
+
/>
|
|
983
|
+
|
|
984
|
+
{/* Table 修改数据来源 Modal */}
|
|
985
|
+
<TableDataSourceModal
|
|
986
|
+
open={!!dataSourceModal && dataSourceModal.componentType === 'Table'}
|
|
987
|
+
code={dataSourceModal?.code ?? ''}
|
|
988
|
+
onConfirm={({
|
|
989
|
+
columns,
|
|
990
|
+
wantPagination,
|
|
991
|
+
pageSize,
|
|
992
|
+
dataDescription,
|
|
993
|
+
code: origCode,
|
|
994
|
+
}) => {
|
|
995
|
+
if (!dataSourceModal) return;
|
|
996
|
+
let newCode = origCode;
|
|
997
|
+
|
|
998
|
+
// 根据用户选择更新 columns
|
|
999
|
+
const colsStr = columns
|
|
1000
|
+
.map(
|
|
1001
|
+
(c) => ` { title: "${c}", dataIndex: "${c}", key: "${c}" }`,
|
|
1002
|
+
)
|
|
1003
|
+
.join(',\n');
|
|
1004
|
+
if (/columns\s*=\s*\{\[/.test(newCode)) {
|
|
1005
|
+
newCode = newCode.replace(
|
|
1006
|
+
/columns\s*=\s*\{\[[\s\S]*?\]\}/,
|
|
1007
|
+
`columns={[\n${colsStr},\n ]}`,
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// 处理分页
|
|
1012
|
+
const curHasPagination = /pagination\s*=\s*\{\{/.test(newCode);
|
|
1013
|
+
if (wantPagination && !curHasPagination) {
|
|
1014
|
+
const paginationTpl = `pagination={{ current: 1, pageSize: ${pageSize}, total: 0 }}`;
|
|
1015
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1016
|
+
newCode = newCode.replace(
|
|
1017
|
+
/([ \t]*)(testId\s*=)/,
|
|
1018
|
+
`$1${paginationTpl}\n$1$2`,
|
|
1019
|
+
);
|
|
1020
|
+
} else {
|
|
1021
|
+
newCode = newCode.replace(/\/>/, ` ${paginationTpl}\n/>`);
|
|
1022
|
+
}
|
|
1023
|
+
} else if (wantPagination && curHasPagination) {
|
|
1024
|
+
// 更新已有的 pageSize
|
|
1025
|
+
newCode = newCode.replace(
|
|
1026
|
+
/pageSize\s*:\s*\d+/,
|
|
1027
|
+
`pageSize: ${pageSize}`,
|
|
1028
|
+
);
|
|
1029
|
+
} else if (!wantPagination && curHasPagination) {
|
|
1030
|
+
newCode = newCode.replace(
|
|
1031
|
+
/\s*pagination\s*=\s*\{\{[\s\S]*?\}\}/,
|
|
1032
|
+
'',
|
|
1033
|
+
);
|
|
1034
|
+
newCode = newCode.replace(/\s*entityName\s*=\s*"[^"]*"/, '');
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
updateCode(dataSourceModal.id, newCode);
|
|
1038
|
+
setDataSourceModal(null);
|
|
1039
|
+
|
|
1040
|
+
// 构造描述发给 agent
|
|
1041
|
+
const parts: string[] = [];
|
|
1042
|
+
if (dataDescription) parts.push(dataDescription);
|
|
1043
|
+
parts.push(`表格列:${columns.join('、')}`);
|
|
1044
|
+
if (wantPagination) parts.push(`需要分页,每页 ${pageSize} 条`);
|
|
1045
|
+
const userPrompt = parts.join('。');
|
|
1046
|
+
triggerDataSourceAgent(
|
|
1047
|
+
dataSourceModal.id,
|
|
1048
|
+
dataSourceModal.componentType,
|
|
1049
|
+
newCode,
|
|
1050
|
+
userPrompt,
|
|
1051
|
+
dataSourceModal.mode === 'sql'
|
|
1052
|
+
? 'canvas-sql-query'
|
|
1053
|
+
: 'canvas-data-query',
|
|
1054
|
+
);
|
|
1055
|
+
}}
|
|
1056
|
+
onCancel={() => setDataSourceModal(null)}
|
|
1057
|
+
/>
|
|
1058
|
+
|
|
1059
|
+
{/* BarChart 修改数据来源 Modal */}
|
|
1060
|
+
<BarChartDataSourceModal
|
|
1061
|
+
open={
|
|
1062
|
+
!!dataSourceModal && dataSourceModal.componentType === 'BarChart'
|
|
1063
|
+
}
|
|
1064
|
+
code={dataSourceModal?.code ?? ''}
|
|
1065
|
+
onConfirm={(result) => {
|
|
1066
|
+
if (!dataSourceModal) return;
|
|
1067
|
+
let newCode = result.code;
|
|
1068
|
+
|
|
1069
|
+
// 修改 direction
|
|
1070
|
+
if (result.direction === 'horizontal') {
|
|
1071
|
+
if (!/direction\s*=/.test(newCode)) {
|
|
1072
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1073
|
+
newCode = newCode.replace(
|
|
1074
|
+
/([ \t]*)(testId\s*=)/,
|
|
1075
|
+
`$1direction="horizontal"\n$1$2`,
|
|
1076
|
+
);
|
|
1077
|
+
} else {
|
|
1078
|
+
newCode = newCode.replace(
|
|
1079
|
+
/\/>/,
|
|
1080
|
+
` direction="horizontal"\n/>`,
|
|
1081
|
+
);
|
|
1082
|
+
}
|
|
1083
|
+
} else {
|
|
1084
|
+
newCode = newCode.replace(
|
|
1085
|
+
/direction\s*=\s*"[^"]*"/,
|
|
1086
|
+
'direction="horizontal"',
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
} else {
|
|
1090
|
+
// vertical 是默认值,移除 direction prop
|
|
1091
|
+
newCode = newCode.replace(/\s*direction\s*=\s*"[^"]*"/, '');
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
// 修改 showGrid
|
|
1095
|
+
if (!result.showGrid) {
|
|
1096
|
+
if (!/showGrid\s*=/.test(newCode)) {
|
|
1097
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1098
|
+
newCode = newCode.replace(
|
|
1099
|
+
/([ \t]*)(testId\s*=)/,
|
|
1100
|
+
`$1showGrid={false}\n$1$2`,
|
|
1101
|
+
);
|
|
1102
|
+
} else {
|
|
1103
|
+
newCode = newCode.replace(/\/>/, ` showGrid={false}\n/>`);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
} else {
|
|
1107
|
+
newCode = newCode.replace(/\s*showGrid\s*=\s*\{false\}/, '');
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
// 修改 showLabel
|
|
1111
|
+
if (!result.showLabel) {
|
|
1112
|
+
if (!/showLabel\s*=/.test(newCode)) {
|
|
1113
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1114
|
+
newCode = newCode.replace(
|
|
1115
|
+
/([ \t]*)(testId\s*=)/,
|
|
1116
|
+
`$1showLabel={false}\n$1$2`,
|
|
1117
|
+
);
|
|
1118
|
+
} else {
|
|
1119
|
+
newCode = newCode.replace(/\/>/, ` showLabel={false}\n/>`);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
newCode = newCode.replace(/\s*showLabel\s*=\s*\{false\}/, '');
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
// 更新画布
|
|
1127
|
+
updateCode(dataSourceModal.id, newCode);
|
|
1128
|
+
setDataSourceModal(null);
|
|
1129
|
+
|
|
1130
|
+
// 构造 prompt 并触发 agent
|
|
1131
|
+
const dirLabel =
|
|
1132
|
+
result.direction === 'horizontal' ? '横向' : '纵向';
|
|
1133
|
+
const parts: string[] = [];
|
|
1134
|
+
if (result.dataDescription) parts.push(result.dataDescription);
|
|
1135
|
+
parts.push(`方向: ${dirLabel}`);
|
|
1136
|
+
if (!result.showGrid) parts.push('隐藏网格线');
|
|
1137
|
+
if (!result.showLabel) parts.push('隐藏数据标签');
|
|
1138
|
+
const userPrompt = parts.join('。');
|
|
1139
|
+
triggerDataSourceAgent(
|
|
1140
|
+
dataSourceModal.id,
|
|
1141
|
+
'BarChart',
|
|
1142
|
+
newCode,
|
|
1143
|
+
userPrompt,
|
|
1144
|
+
dataSourceModal.mode === 'sql'
|
|
1145
|
+
? 'canvas-sql-query'
|
|
1146
|
+
: 'canvas-data-query',
|
|
1147
|
+
);
|
|
1148
|
+
}}
|
|
1149
|
+
onCancel={() => setDataSourceModal(null)}
|
|
1150
|
+
/>
|
|
1151
|
+
|
|
1152
|
+
<LineChartDataSourceModal
|
|
1153
|
+
open={
|
|
1154
|
+
!!dataSourceModal && dataSourceModal.componentType === 'LineChart'
|
|
1155
|
+
}
|
|
1156
|
+
code={dataSourceModal?.code ?? ''}
|
|
1157
|
+
onConfirm={(result) => {
|
|
1158
|
+
if (!dataSourceModal) return;
|
|
1159
|
+
let newCode = result.code;
|
|
1160
|
+
|
|
1161
|
+
// ── legendShow ──
|
|
1162
|
+
if (!result.legendShow) {
|
|
1163
|
+
if (!/legendShow\s*=\s*\{/.test(newCode)) {
|
|
1164
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1165
|
+
newCode = newCode.replace(
|
|
1166
|
+
/([ \t]*)(testId\s*=)/,
|
|
1167
|
+
`$1legendShow={false}\n$1$2`,
|
|
1168
|
+
);
|
|
1169
|
+
} else {
|
|
1170
|
+
newCode = newCode.replace(/\/>/, ` legendShow={false}\n/>`);
|
|
1171
|
+
}
|
|
1172
|
+
} else {
|
|
1173
|
+
newCode = newCode.replace(
|
|
1174
|
+
/legendShow\s*=\s*\{true\}/,
|
|
1175
|
+
'legendShow={false}',
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
} else {
|
|
1179
|
+
newCode = newCode.replace(/\s*legendShow\s*=\s*\{false\}/, '');
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
// ── showGrid(默认 true,false 时注入)──
|
|
1183
|
+
if (!result.showGrid) {
|
|
1184
|
+
if (!/showGrid\s*=/.test(newCode)) {
|
|
1185
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1186
|
+
newCode = newCode.replace(
|
|
1187
|
+
/([ \t]*)(testId\s*=)/,
|
|
1188
|
+
`$1showGrid={false}\n$1$2`,
|
|
1189
|
+
);
|
|
1190
|
+
} else {
|
|
1191
|
+
newCode = newCode.replace(/\/>/, ` showGrid={false}\n/>`);
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
} else {
|
|
1195
|
+
newCode = newCode.replace(/\s*showGrid\s*=\s*\{false\}/, '');
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// ── showAxis(默认 true,false 时注入)──
|
|
1199
|
+
if (!result.showAxis) {
|
|
1200
|
+
if (!/showAxis\s*=/.test(newCode)) {
|
|
1201
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1202
|
+
newCode = newCode.replace(
|
|
1203
|
+
/([ \t]*)(testId\s*=)/,
|
|
1204
|
+
`$1showAxis={false}\n$1$2`,
|
|
1205
|
+
);
|
|
1206
|
+
} else {
|
|
1207
|
+
newCode = newCode.replace(/\/>/, ` showAxis={false}\n/>`);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
} else {
|
|
1211
|
+
newCode = newCode.replace(/\s*showAxis\s*=\s*\{false\}/, '');
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
// ── showDots(默认 false,true 时注入)──
|
|
1215
|
+
if (result.showDots) {
|
|
1216
|
+
if (!/showDots\s*=/.test(newCode)) {
|
|
1217
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1218
|
+
newCode = newCode.replace(
|
|
1219
|
+
/([ \t]*)(testId\s*=)/,
|
|
1220
|
+
`$1showDots={true}\n$1$2`,
|
|
1221
|
+
);
|
|
1222
|
+
} else {
|
|
1223
|
+
newCode = newCode.replace(/\/>/, ` showDots={true}\n/>`);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
} else {
|
|
1227
|
+
newCode = newCode.replace(/\s*showDots\s*=\s*\{true\}/, '');
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// ── showLabel(默认 false,true 时注入,仅 showDots 时有意义)──
|
|
1231
|
+
if (result.showDots && result.showLabel) {
|
|
1232
|
+
if (!/showLabel\s*=/.test(newCode)) {
|
|
1233
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1234
|
+
newCode = newCode.replace(
|
|
1235
|
+
/([ \t]*)(testId\s*=)/,
|
|
1236
|
+
`$1showLabel={true}\n$1$2`,
|
|
1237
|
+
);
|
|
1238
|
+
} else {
|
|
1239
|
+
newCode = newCode.replace(/\/>/, ` showLabel={true}\n/>`);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
} else {
|
|
1243
|
+
newCode = newCode.replace(/\s*showLabel\s*=\s*\{true\}/, '');
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// ── stacked(默认 false,true 时注入)──
|
|
1247
|
+
if (result.stacked) {
|
|
1248
|
+
if (!/stacked\s*=/.test(newCode)) {
|
|
1249
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1250
|
+
newCode = newCode.replace(
|
|
1251
|
+
/([ \t]*)(testId\s*=)/,
|
|
1252
|
+
`$1stacked={true}\n$1$2`,
|
|
1253
|
+
);
|
|
1254
|
+
} else {
|
|
1255
|
+
newCode = newCode.replace(/\/>/, ` stacked={true}\n/>`);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
} else {
|
|
1259
|
+
newCode = newCode.replace(/\s*stacked\s*=\s*\{true\}/, '');
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
// ── area(默认 false,true 时注入)──
|
|
1263
|
+
if (result.area) {
|
|
1264
|
+
if (!/area\s*=/.test(newCode)) {
|
|
1265
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1266
|
+
newCode = newCode.replace(
|
|
1267
|
+
/([ \t]*)(testId\s*=)/,
|
|
1268
|
+
`$1area={true}\n$1$2`,
|
|
1269
|
+
);
|
|
1270
|
+
} else {
|
|
1271
|
+
newCode = newCode.replace(/\/>/, ` area={true}\n/>`);
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
} else {
|
|
1275
|
+
newCode = newCode.replace(/\s*area\s*=\s*\{true\}/, '');
|
|
1276
|
+
}
|
|
1277
|
+
|
|
1278
|
+
// ── smooth(默认 false,true 时注入)──
|
|
1279
|
+
if (result.smooth) {
|
|
1280
|
+
if (!/smooth\s*=/.test(newCode)) {
|
|
1281
|
+
if (/testId\s*=/.test(newCode)) {
|
|
1282
|
+
newCode = newCode.replace(
|
|
1283
|
+
/([ \t]*)(testId\s*=)/,
|
|
1284
|
+
`$1smooth={true}\n$1$2`,
|
|
1285
|
+
);
|
|
1286
|
+
} else {
|
|
1287
|
+
newCode = newCode.replace(/\/>/, ` smooth={true}\n/>`);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
} else {
|
|
1291
|
+
newCode = newCode.replace(/\s*smooth\s*=\s*\{true\}/, '');
|
|
1292
|
+
newCode = newCode.replace(/\s*smooth\b(?!\s*=)/, '');
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// 更新画布
|
|
1296
|
+
updateCode(dataSourceModal.id, newCode);
|
|
1297
|
+
setDataSourceModal(null);
|
|
1298
|
+
|
|
1299
|
+
// 构造 prompt 并触发 agent
|
|
1300
|
+
const parts: string[] = [];
|
|
1301
|
+
if (result.dataDescription) parts.push(result.dataDescription);
|
|
1302
|
+
const flags: string[] = [];
|
|
1303
|
+
if (result.stacked) flags.push('堆叠');
|
|
1304
|
+
if (result.area) flags.push('面积填充');
|
|
1305
|
+
if (result.smooth) flags.push('拟合曲线');
|
|
1306
|
+
if (!result.showGrid) flags.push('无网格线');
|
|
1307
|
+
if (!result.showAxis) flags.push('无坐标轴');
|
|
1308
|
+
if (!result.legendShow) flags.push('隐藏图例');
|
|
1309
|
+
if (result.showDots) flags.push('显示坐标点');
|
|
1310
|
+
if (result.showDots && result.showLabel)
|
|
1311
|
+
flags.push('显示坐标点数据');
|
|
1312
|
+
if (flags.length) parts.push(`样式: ${flags.join(', ')}`);
|
|
1313
|
+
const userPrompt = parts.join('。');
|
|
1314
|
+
triggerDataSourceAgent(
|
|
1315
|
+
dataSourceModal.id,
|
|
1316
|
+
'LineChart',
|
|
1317
|
+
newCode,
|
|
1318
|
+
userPrompt || undefined,
|
|
1319
|
+
dataSourceModal.mode === 'sql'
|
|
1320
|
+
? 'canvas-sql-query'
|
|
1321
|
+
: 'canvas-data-query',
|
|
1322
|
+
);
|
|
1323
|
+
}}
|
|
1324
|
+
onCancel={() => setDataSourceModal(null)}
|
|
1325
|
+
/>
|
|
1326
|
+
|
|
1327
|
+
{/* RadarChart 修改数据来源 Modal */}
|
|
1328
|
+
<RadarChartDataSourceModal
|
|
1329
|
+
open={
|
|
1330
|
+
!!dataSourceModal && dataSourceModal.componentType === 'RadarChart'
|
|
1331
|
+
}
|
|
1332
|
+
code={dataSourceModal?.code ?? ''}
|
|
1333
|
+
onConfirm={({ dimensionCount, dataDescription }) => {
|
|
1334
|
+
if (!dataSourceModal) return;
|
|
1335
|
+
setDataSourceModal(null);
|
|
1336
|
+
|
|
1337
|
+
// 不修改代码,仅构建 prompt 发给 agent
|
|
1338
|
+
const parts: string[] = [];
|
|
1339
|
+
parts.push(`雷达图需要${dimensionCount}个维度`);
|
|
1340
|
+
if (dataDescription) parts.push(dataDescription);
|
|
1341
|
+
const userPrompt = parts.join(',');
|
|
1342
|
+
triggerDataSourceAgent(
|
|
1343
|
+
dataSourceModal.id,
|
|
1344
|
+
dataSourceModal.componentType,
|
|
1345
|
+
dataSourceModal.code,
|
|
1346
|
+
userPrompt,
|
|
1347
|
+
dataSourceModal.mode === 'sql'
|
|
1348
|
+
? 'canvas-sql-query'
|
|
1349
|
+
: 'canvas-data-query',
|
|
1350
|
+
);
|
|
1351
|
+
}}
|
|
1352
|
+
onCancel={() => setDataSourceModal(null)}
|
|
1353
|
+
/>
|
|
1354
|
+
|
|
1355
|
+
{/* ── 通用文本输入弹窗(如修改标题) ── */}
|
|
1356
|
+
<PromptModal
|
|
1357
|
+
open={!!promptModal}
|
|
1358
|
+
label={promptModal?.label ?? ''}
|
|
1359
|
+
placeholder={promptModal?.placeholder}
|
|
1360
|
+
defaultValue={promptModal?.defaultValue ?? ''}
|
|
1361
|
+
onConfirm={(value) => {
|
|
1362
|
+
promptModal?.onConfirm(value);
|
|
1363
|
+
setPromptModal(null);
|
|
1364
|
+
}}
|
|
1365
|
+
onCancel={() => setPromptModal(null)}
|
|
1366
|
+
/>
|
|
1367
|
+
</div>
|
|
1368
|
+
</div>
|
|
1369
|
+
);
|
|
1370
|
+
};
|
|
1371
|
+
|
|
1372
|
+
export default CanvasPage;
|