cx-chat 0.0.1
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/.cursor/rules/i18n-cn-gloss-comments.mdc +31 -0
- package/.cursor/rules/list-page-view-pageconfig.mdc +32 -0
- package/.cursor/rules/no-over-defensive-programming.mdc +90 -0
- package/.cursor/rules/requirement-description-for-agent.mdc +33 -0
- package/.cursor/rules/use-showToast-not-antd-message.mdc +28 -0
- package/.docker/Dockerfile +7 -0
- package/.env +9 -0
- package/.env.development +7 -0
- package/.env.production +7 -0
- package/.gitlab-ci/docker-build.yaml +28 -0
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +42 -0
- package/.gitlab-ci/npm-build.yaml +17 -0
- package/.gitlab-ci.yml +8 -0
- package/.k8s/0-namespace.yaml +6 -0
- package/.k8s/1-configmap-web.yaml +7 -0
- package/.k8s/1-nginx-conf-dev.yaml +110 -0
- package/.k8s/2-deployment.yaml +27 -0
- package/.k8s/3-service.yaml +16 -0
- package/.k8s/4-ingress-dev.yaml +30 -0
- package/.lingma/rules/use-showToast-not-antd-message.md +34 -0
- package/.nginx/nginx.conf +52 -0
- package/.prettierrc +9 -0
- package/README.md +1 -0
- package/eslint.config.js +32 -0
- package/index.html +13 -0
- package/package.json +67 -0
- package/postcss.config.js +6 -0
- package/public/favicon.ico +0 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +96 -0
- package/src/_doc/0.docs-overview.md +28 -0
- package/src/_doc/cx-ui/0.docs-overview.md +30 -0
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +82 -0
- package/src/_doc/cx-ui/comp.2.cx-modal.md +82 -0
- package/src/_doc/cx-ui/comp.3.cx-button.md +89 -0
- package/src/_doc/cx-ui/comp.4.cx-form.md +72 -0
- package/src/_doc/cx-ui/comp.5.cx-fields.md +76 -0
- package/src/_doc/cx-ui/comp.6.cx-tag.md +57 -0
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +29 -0
- package/src/_doc/meta/0.docs-overview.md +24 -0
- package/src/_doc/meta/comp.1.enum-runtime.md +33 -0
- package/src/_doc/meta/comp.2.dict-runtime.md +39 -0
- package/src/_doc/router/0.docs-overview.md +14 -0
- package/src/_doc/router/guide.1.menu-component-config.md +181 -0
- package/src/_doc/router/guide.2.router-auto-registration.md +114 -0
- package/src/_doc/table-view/0.docs-overview.md +30 -0
- package/src/_doc/table-view/comp.1.table-view.md +542 -0
- package/src/_doc/table-view/props.1.create-table-view-config.md +193 -0
- package/src/_doc/table-view/props.2.table-view-search-fields.md +106 -0
- package/src/api/_mock/README.md +340 -0
- package/src/api/_mock/api.ts +1642 -0
- package/src/api/_mock/bundle-shim.ts +16 -0
- package/src/api/_mock/handler-shim.ts +6 -0
- package/src/api/_mock/handler.ts +458 -0
- package/src/api/_mock/index.ts +711 -0
- package/src/api/_mock/interceptor.ts +15 -0
- package/src/api/_mock/mod.ts +12 -0
- package/src/api/_mock/utils.ts +65 -0
- package/src/api/base/memory.js +24 -0
- package/src/api/chat.js +210 -0
- package/src/api/common/auth.js +70 -0
- package/src/api/menus/business-rules.js +76 -0
- package/src/api/menus/feedback.js +102 -0
- package/src/api/menus/knowledge.js +159 -0
- package/src/api/menus/model-metadata/manage.js +70 -0
- package/src/api/menus/model-metadata/role.js +50 -0
- package/src/api/menus/model-metadata/training-detail-mock-data.js +569 -0
- package/src/api/menus/model-metadata/training.js +28 -0
- package/src/api/menus/skill.js +40 -0
- package/src/api/system/agent-config.js +16 -0
- package/src/api/system/department.js +94 -0
- package/src/api/system/dict.js +86 -0
- package/src/api/system/menu.js +37 -0
- package/src/api/system/permission.js +26 -0
- package/src/api/system/role.js +34 -0
- package/src/api/system/sys-config.js +16 -0
- package/src/api/system/sys-log.js +17 -0
- package/src/api/system/user.js +75 -0
- package/src/api/upload.js +39 -0
- package/src/assets/react.svg +1 -0
- package/src/components/auth/current-user-avatar.tsx +77 -0
- package/src/components/common/code-view.tsx +149 -0
- package/src/components/common/detail-link.tsx +67 -0
- package/src/components/common/error-boundary.tsx +98 -0
- package/src/components/common/language-switcher.tsx +91 -0
- package/src/components/common/lite-table/index.tsx +135 -0
- package/src/components/common/md-editor.tsx +126 -0
- package/src/components/common/modal/confirm-dialog.tsx +113 -0
- package/src/components/common/modal/dep-user-select-multi.tsx +324 -0
- package/src/components/common/modal/dep-user-select.tsx +249 -0
- package/src/components/common/modal/user-select-multi.tsx +266 -0
- package/src/components/common/pagination.tsx +472 -0
- package/src/components/common/path.tsx +175 -0
- package/src/components/common/system-logo-mark.tsx +48 -0
- package/src/components/cx-ui/button/index.less +208 -0
- package/src/components/cx-ui/button/index.tsx +611 -0
- package/src/components/cx-ui/checkbox/index.tsx +78 -0
- package/src/components/cx-ui/date-picker/index.less +17 -0
- package/src/components/cx-ui/date-picker/index.tsx +193 -0
- package/src/components/cx-ui/drawer/index.tsx +47 -0
- package/src/components/cx-ui/empty-state/index.tsx +20 -0
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +89 -0
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +283 -0
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +41 -0
- package/src/components/cx-ui/form/CxForm.tsx +15 -0
- package/src/components/cx-ui/form/index.tsx +20 -0
- package/src/components/cx-ui/form-item/index.less +26 -0
- package/src/components/cx-ui/form-item/index.tsx +36 -0
- package/src/components/cx-ui/index.ts +70 -0
- package/src/components/cx-ui/input/auto-complete.tsx +134 -0
- package/src/components/cx-ui/input/index.tsx +259 -0
- package/src/components/cx-ui/input-number/index.jsx +66 -0
- package/src/components/cx-ui/modal/index.jsx +212 -0
- package/src/components/cx-ui/modal/index.less +144 -0
- package/src/components/cx-ui/modal/useCxModal.ts +125 -0
- package/src/components/cx-ui/multi-select/index.jsx +74 -0
- package/src/components/cx-ui/multi-select/index.less +40 -0
- package/src/components/cx-ui/multi-select/index2.tsx +361 -0
- package/src/components/cx-ui/radio/index.tsx +33 -0
- package/src/components/cx-ui/range-picker/index.less +65 -0
- package/src/components/cx-ui/range-picker/index.tsx +219 -0
- package/src/components/cx-ui/select/index.less +34 -0
- package/src/components/cx-ui/select/index.tsx +196 -0
- package/src/components/cx-ui/skeleton/index.tsx +12 -0
- package/src/components/cx-ui/steps/index.tsx +14 -0
- package/src/components/cx-ui/styles/_tokens.less +79 -0
- package/src/components/cx-ui/styles/index.less +246 -0
- package/src/components/cx-ui/switch/index.less +106 -0
- package/src/components/cx-ui/switch/index.tsx +120 -0
- package/src/components/cx-ui/table/index.less +160 -0
- package/src/components/cx-ui/table/index.tsx +152 -0
- package/src/components/cx-ui/tabs/index.less +15 -0
- package/src/components/cx-ui/tabs/index.tsx +34 -0
- package/src/components/cx-ui/tag/index.less +51 -0
- package/src/components/cx-ui/tag/index.tsx +140 -0
- package/src/components/cx-ui/timeline/index.tsx +14 -0
- package/src/components/cx-ui/tooltip/index.tsx +67 -0
- package/src/components/cx-ui/tree/index.tsx +193 -0
- package/src/components/cx-ui/tree-select/index.jsx +91 -0
- package/src/components/cx-ui/tree-select/index.less +27 -0
- package/src/components/cx-ui/upload-file/index.less +223 -0
- package/src/components/cx-ui/upload-file/index.tsx +640 -0
- package/src/components/cx-ui/upload-img/index.tsx +291 -0
- package/src/components/layout/components/Header.tsx +216 -0
- package/src/components/layout/components/Sidebar.tsx +717 -0
- package/src/components/layout/index.tsx +95 -0
- package/src/components/table-view/components/search-area.tsx +411 -0
- package/src/components/table-view/components/table-view-config.tsx +528 -0
- package/src/components/table-view/components/table-view.types.ts +478 -0
- package/src/components/table-view/components/tree-api-normalize.ts +38 -0
- package/src/components/table-view/components/tree-data-annotate.ts +31 -0
- package/src/components/table-view/components/tree-sidebar.tsx +74 -0
- package/src/components/table-view/index.tsx +61 -0
- package/src/components/table-view/list-page-view.tsx +1049 -0
- package/src/components/table-view/select-table-view.tsx +1094 -0
- package/src/components/table-view/styles/select-table-view.less +51 -0
- package/src/config/default-system-name.ts +9 -0
- package/src/config/system.ts +165 -0
- package/src/constants/countryCodes.ts +3 -0
- package/src/contexts/AuthContext.tsx +256 -0
- package/src/contexts/ChatContext.tsx +839 -0
- package/src/contexts/MenuContext.tsx +62 -0
- package/src/contexts/ToastContext.tsx +181 -0
- package/src/hooks/useCopyToClipboard.ts +47 -0
- package/src/hooks/useModalSubmit.ts +104 -0
- package/src/hooks/useRouter.ts +240 -0
- package/src/hooks/useStepForm.ts +46 -0
- package/src/hooks/useStickyHeader.ts +42 -0
- package/src/hooks/useThreadActions.ts +105 -0
- package/src/hooks/useUserPreferences.ts +101 -0
- package/src/http/axios.js +372 -0
- package/src/http/mock.interceptor.ts +9 -0
- package/src/http/obfuscationKey.ts +41 -0
- package/src/i18n.ts +60 -0
- package/src/index.js +1 -0
- package/src/index.less +169 -0
- package/src/locales/en/auth.ts +70 -0
- package/src/locales/en/base/memory.ts +28 -0
- package/src/locales/en/base/settings.ts +41 -0
- package/src/locales/en/chat.ts +40 -0
- package/src/locales/en/common.ts +173 -0
- package/src/locales/en/enum.ts +27 -0
- package/src/locales/en/menus/business-rules.ts +48 -0
- package/src/locales/en/menus/feedback.ts +62 -0
- package/src/locales/en/menus/knowledge.ts +120 -0
- package/src/locales/en/menus/model-metadata/index.ts +10 -0
- package/src/locales/en/menus/model-metadata/manage.ts +151 -0
- package/src/locales/en/menus/model-metadata/role.ts +48 -0
- package/src/locales/en/menus/model-metadata/training.ts +65 -0
- package/src/locales/en/menus/skill.ts +34 -0
- package/src/locales/en/system/agent-config.ts +34 -0
- package/src/locales/en/system/department.ts +68 -0
- package/src/locales/en/system/dict.ts +44 -0
- package/src/locales/en/system/menu.ts +45 -0
- package/src/locales/en/system/permission.ts +89 -0
- package/src/locales/en/system/role.ts +25 -0
- package/src/locales/en/system/sys-config.ts +33 -0
- package/src/locales/en/system/sys-log.ts +38 -0
- package/src/locales/en/system/user.ts +113 -0
- package/src/locales/en.ts +68 -0
- package/src/locales/zh/auth.ts +70 -0
- package/src/locales/zh/base/memory.ts +29 -0
- package/src/locales/zh/base/settings.ts +41 -0
- package/src/locales/zh/chat.ts +47 -0
- package/src/locales/zh/common.ts +178 -0
- package/src/locales/zh/enum.ts +28 -0
- package/src/locales/zh/menus/business-rules.ts +47 -0
- package/src/locales/zh/menus/feedback.ts +62 -0
- package/src/locales/zh/menus/knowledge.ts +117 -0
- package/src/locales/zh/menus/model-metadata/index.ts +10 -0
- package/src/locales/zh/menus/model-metadata/manage.ts +151 -0
- package/src/locales/zh/menus/model-metadata/role.ts +47 -0
- package/src/locales/zh/menus/model-metadata/training.ts +64 -0
- package/src/locales/zh/menus/skill.ts +34 -0
- package/src/locales/zh/system/agent-config.ts +33 -0
- package/src/locales/zh/system/department.ts +69 -0
- package/src/locales/zh/system/dict.ts +44 -0
- package/src/locales/zh/system/menu.ts +47 -0
- package/src/locales/zh/system/permission.ts +94 -0
- package/src/locales/zh/system/role.ts +25 -0
- package/src/locales/zh/system/sys-config.ts +32 -0
- package/src/locales/zh/system/sys-log.ts +38 -0
- package/src/locales/zh/system/user.ts +114 -0
- package/src/locales/zh.ts +67 -0
- package/src/main.tsx +50 -0
- package/src/meta/const/index.ts +40 -0
- package/src/meta/index-dict.ts +56 -0
- package/src/meta/index-enum.ts +95 -0
- package/src/meta/index.ts +14 -0
- package/src/meta/module/dict-data/runtime.ts +199 -0
- package/src/meta/module/dict-data/types.ts +17 -0
- package/src/meta/module/enum-data/runtime.ts +75 -0
- package/src/meta/module/enum-data/types.ts +18 -0
- package/src/router/index.tsx +312 -0
- package/src/styles/AntdThemeProvider.tsx +40 -0
- package/src/styles/antd-theme.ts +20 -0
- package/src/styles/global.less +107 -0
- package/src/styles/variable.less +103 -0
- package/src/types/feedback.ts +43 -0
- package/src/types/index.ts +85 -0
- package/src/types/menu.ts +43 -0
- package/src/utils/aesUtil.ts +123 -0
- package/src/utils/chatUtils.ts +524 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/crypto.ts +164 -0
- package/src/utils/date.ts +72 -0
- package/src/utils/file-icons.tsx +79 -0
- package/src/utils/index.ts +168 -0
- package/src/utils/markdown-math-plugins.ts +21 -0
- package/src/utils/menuI18n.ts +305 -0
- package/src/utils/menuRouteRegistry.ts +78 -0
- package/src/utils/permission-crud.ts +147 -0
- package/src/utils/routeConfig.ts +350 -0
- package/src/utils/storage.ts +135 -0
- package/src/utils/toastBridge.ts +26 -0
- package/src/utils/url.ts +38 -0
- package/src/utils/validation.ts +16 -0
- package/src/views/auth/auth-code/index.less +169 -0
- package/src/views/auth/auth-code/index.module.less +174 -0
- package/src/views/auth/auth-code/index.tsx +233 -0
- package/src/views/auth/login.tsx +498 -0
- package/src/views/auth/register.tsx +388 -0
- package/src/views/base/memory/index.tsx +136 -0
- package/src/views/base/memory/modal/detail-modal.tsx +89 -0
- package/src/views/base/memory/modal/submit-modal.tsx +134 -0
- package/src/views/base/settings/index.tsx +657 -0
- package/src/views/chat/chat.less +323 -0
- package/src/views/chat/components/chat-input.tsx +298 -0
- package/src/views/chat/components/header-thread-title.tsx +210 -0
- package/src/views/chat/components/message-list/content-answer.tsx +100 -0
- package/src/views/chat/components/message-list/content-question.tsx +18 -0
- package/src/views/chat/components/message-list/index.tsx +520 -0
- package/src/views/chat/components/message-list/message-item.tsx +199 -0
- package/src/views/chat/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/chat/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/chat/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/chat/components/message-list/thinking-process.tsx +49 -0
- package/src/views/chat/components/message-list/toolbar.tsx +224 -0
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/chat/components/references-knowledge/context.tsx +57 -0
- package/src/views/chat/components/references-knowledge/index.ts +9 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +556 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +529 -0
- package/src/views/chat/components/references-knowledge/panel.tsx +115 -0
- package/src/views/chat/hooks/use-chat-common.ts +19 -0
- package/src/views/chat/index-session.tsx +647 -0
- package/src/views/chat/index.tsx +127 -0
- package/src/views/page-error/401.tsx +56 -0
- package/src/views/page-error/404.tsx +56 -0
- package/src/views/page-menus/business-rules/index.tsx +376 -0
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +186 -0
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +272 -0
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +142 -0
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +471 -0
- package/src/views/page-menus/feedback/index.tsx +166 -0
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +367 -0
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +32 -0
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +330 -0
- package/src/views/page-menus/knowledge/detail.tsx +600 -0
- package/src/views/page-menus/knowledge/index.tsx +337 -0
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +618 -0
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +550 -0
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +99 -0
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +349 -0
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +88 -0
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +283 -0
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +179 -0
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +114 -0
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +232 -0
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +316 -0
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +101 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +338 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +276 -0
- package/src/views/page-menus/model-metadata/manage/detail.tsx +298 -0
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +113 -0
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +20 -0
- package/src/views/page-menus/model-metadata/manage/index.tsx +304 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +374 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +151 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +423 -0
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +218 -0
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +261 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +196 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +229 -0
- package/src/views/page-menus/model-metadata/manage/submit.tsx +31 -0
- package/src/views/page-menus/model-metadata/role/index.tsx +207 -0
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +97 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +254 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +393 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +120 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +698 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +237 -0
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +135 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +4 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +72 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +196 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +153 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +103 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +82 -0
- package/src/views/page-menus/model-metadata/training/detail.tsx +159 -0
- package/src/views/page-menus/model-metadata/training/index.tsx +236 -0
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +154 -0
- package/src/views/page-menus/skill/index.tsx +201 -0
- package/src/views/page-menus/skill/modal/detail-modal.tsx +156 -0
- package/src/views/page-menus/skill/modal/submit-modal.tsx +214 -0
- package/src/views/page-system/agent-config/index.tsx +370 -0
- package/src/views/page-system/department/departmentFormShared.ts +36 -0
- package/src/views/page-system/department/index.tsx +541 -0
- package/src/views/page-system/department/modal/detail-modal.tsx +94 -0
- package/src/views/page-system/department/modal/member-role-modal.tsx +128 -0
- package/src/views/page-system/department/modal/submit-modal.tsx +265 -0
- package/src/views/page-system/dict/index.tsx +440 -0
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +315 -0
- package/src/views/page-system/dict/modal/submit-modal.tsx +184 -0
- package/src/views/page-system/logs/components/index.ts +3 -0
- package/src/views/page-system/logs/components/log-message-demo.tsx +30 -0
- package/src/views/page-system/logs/components/log-message-stream.ts +184 -0
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +100 -0
- package/src/views/page-system/logs/components/message-list/content-question.tsx +18 -0
- package/src/views/page-system/logs/components/message-list/index.tsx +515 -0
- package/src/views/page-system/logs/components/message-list/message-item.tsx +193 -0
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +49 -0
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +134 -0
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/page-system/logs/components/message-modal.tsx +239 -0
- package/src/views/page-system/logs/index.tsx +132 -0
- package/src/views/page-system/logs/modal/detail-modal.tsx +157 -0
- package/src/views/page-system/menu/components/menuFormShared.ts +283 -0
- package/src/views/page-system/menu/index.less +12 -0
- package/src/views/page-system/menu/index.tsx +410 -0
- package/src/views/page-system/menu/modal/icon-modal.less +51 -0
- package/src/views/page-system/menu/modal/icon-modal.tsx +87 -0
- package/src/views/page-system/menu/modal/submit-modal.tsx +263 -0
- package/src/views/page-system/permission/index.tsx +562 -0
- package/src/views/page-system/permission/modal/detail-modal.tsx +179 -0
- package/src/views/page-system/permission/modal/submit-modal.less +146 -0
- package/src/views/page-system/permission/modal/submit-modal.tsx +650 -0
- package/src/views/page-system/role/index.tsx +163 -0
- package/src/views/page-system/role/modal/detail-modal.tsx +127 -0
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +86 -0
- package/src/views/page-system/role/modal/permission-modal.tsx +111 -0
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +21 -0
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +916 -0
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +1047 -0
- package/src/views/page-system/role/modal/submit-modal.tsx +193 -0
- package/src/views/page-system/sys-config/index.tsx +294 -0
- package/src/views/page-system/user/components/user-role-column.tsx +87 -0
- package/src/views/page-system/user/index.tsx +439 -0
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +389 -0
- package/src/views/page-system/user/modal/detail-modal.tsx +72 -0
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.tsx +287 -0
- package/src/views/page-system/user/userFormShared.ts +51 -0
- package/tailwind.config.js +17 -0
- package/tsconfig.app.json +48 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +264 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getModelMetadataDetailAPI,
|
|
3
|
+
getModelMetadataItemInfoAPI,
|
|
4
|
+
updateModelMetadataItemInfoAPI,
|
|
5
|
+
} from '@api/menus/model-metadata/manage'
|
|
6
|
+
import { useToast } from '@/contexts/ToastContext'
|
|
7
|
+
import { useModalSubmit } from '@/hooks/useModalSubmit'
|
|
8
|
+
import { CxButton, CxTabs } from '@cx-ui'
|
|
9
|
+
import { Spin } from 'antd'
|
|
10
|
+
import { ChevronLeft, Database } from 'lucide-react'
|
|
11
|
+
import { useCallback, useEffect, useMemo, useState } from 'react'
|
|
12
|
+
import { useTranslation } from 'react-i18next'
|
|
13
|
+
import { useNavigate, useParams } from 'react-router-dom'
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
buildModelMetadataPayloadParts,
|
|
17
|
+
validateModelMetadataItemDetail,
|
|
18
|
+
} from '../hooks/model-metadata-submit-shared'
|
|
19
|
+
import { useModelMetadataItemState } from '../hooks/use-model-metadata-item-state'
|
|
20
|
+
import Step2Schema from './step2-schema'
|
|
21
|
+
import Step3Permissions from './step3-permissions'
|
|
22
|
+
import Step4Documents from './step4-documents'
|
|
23
|
+
import Step5ExampleSql from './step5-example-sql'
|
|
24
|
+
|
|
25
|
+
type SubmitEditProps = {
|
|
26
|
+
/** 由 submit 入口从 path/useParams 解析后传入,避免扁平动态路由下 useParams 为空 */
|
|
27
|
+
metadataId?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function ModelMetadataSubmitEditView({ metadataId: metadataIdProp }: SubmitEditProps) {
|
|
31
|
+
const { showToast } = useToast()
|
|
32
|
+
const { t } = useTranslation()
|
|
33
|
+
const navigate = useNavigate()
|
|
34
|
+
const { id: paramId } = useParams<{ id: string }>()
|
|
35
|
+
const id = metadataIdProp ?? paramId
|
|
36
|
+
const { submitting, handleSubmit } = useModalSubmit()
|
|
37
|
+
|
|
38
|
+
const [detailLoading, setDetailLoading] = useState(false)
|
|
39
|
+
const [subject, setSubject] = useState('')
|
|
40
|
+
const [basicFields, setBasicFields] = useState<Record<string, any>>({})
|
|
41
|
+
const {
|
|
42
|
+
tables,
|
|
43
|
+
setTables,
|
|
44
|
+
permissions,
|
|
45
|
+
setPermissions,
|
|
46
|
+
documents,
|
|
47
|
+
setDocuments,
|
|
48
|
+
exampleSqlList,
|
|
49
|
+
setExampleSqlList,
|
|
50
|
+
} = useModelMetadataItemState()
|
|
51
|
+
const [activeTab, setActiveTab] = useState('schema')
|
|
52
|
+
|
|
53
|
+
const loadData = useCallback(async () => {
|
|
54
|
+
if (!id) return
|
|
55
|
+
setDetailLoading(true)
|
|
56
|
+
try {
|
|
57
|
+
const [basicRes, itemRes] = await Promise.all([
|
|
58
|
+
getModelMetadataDetailAPI(id),
|
|
59
|
+
getModelMetadataItemInfoAPI(id),
|
|
60
|
+
])
|
|
61
|
+
const data = (basicRes as any)?.data
|
|
62
|
+
const item = (itemRes as any)?.data
|
|
63
|
+
if (data) {
|
|
64
|
+
setSubject(String(data.subject ?? '').trim())
|
|
65
|
+
setBasicFields({
|
|
66
|
+
subject: data.subject,
|
|
67
|
+
databaseName: data.databaseName,
|
|
68
|
+
dbType: data.dbType,
|
|
69
|
+
host: data.host,
|
|
70
|
+
port: data.port,
|
|
71
|
+
dbSchema: data.dbSchema,
|
|
72
|
+
username: data.username,
|
|
73
|
+
charsetName: data.charsetName,
|
|
74
|
+
optionsJson: data.optionsJson,
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
if (item) {
|
|
78
|
+
setTables(item.tables || [])
|
|
79
|
+
setPermissions(
|
|
80
|
+
(item.permissions || []).map((p: any) => ({
|
|
81
|
+
id: p.id,
|
|
82
|
+
permissionName: p.permissionName ?? '',
|
|
83
|
+
permissionColumns: Array.isArray(p.permissionColumns) ? p.permissionColumns : [],
|
|
84
|
+
})),
|
|
85
|
+
)
|
|
86
|
+
setDocuments(item.documents || [])
|
|
87
|
+
setExampleSqlList(item.exampleSqlList || [])
|
|
88
|
+
} else {
|
|
89
|
+
setTables([])
|
|
90
|
+
setPermissions([])
|
|
91
|
+
setDocuments([])
|
|
92
|
+
setExampleSqlList([])
|
|
93
|
+
}
|
|
94
|
+
} catch (e) {
|
|
95
|
+
console.error(e)
|
|
96
|
+
showToast(t('common.operation_failed'), 'error')
|
|
97
|
+
} finally {
|
|
98
|
+
setDetailLoading(false)
|
|
99
|
+
}
|
|
100
|
+
}, [id, showToast, t])
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
void loadData()
|
|
104
|
+
}, [loadData])
|
|
105
|
+
|
|
106
|
+
const handleBack = () => {
|
|
107
|
+
navigate(-1)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const onSubmit = async () => {
|
|
111
|
+
if (!id) return
|
|
112
|
+
|
|
113
|
+
const detailErr = validateModelMetadataItemDetail({
|
|
114
|
+
tables,
|
|
115
|
+
permissions,
|
|
116
|
+
documents,
|
|
117
|
+
exampleSqlList,
|
|
118
|
+
})
|
|
119
|
+
if (detailErr) {
|
|
120
|
+
showToast(t(`menus.model_metadata.manage.rules.${detailErr}`), 'warning')
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const { tablesPayload, permissionsPayload, documents: docOut, exampleSqlList: sqlOut } =
|
|
125
|
+
buildModelMetadataPayloadParts({
|
|
126
|
+
tables,
|
|
127
|
+
permissions,
|
|
128
|
+
documents,
|
|
129
|
+
exampleSqlList,
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const itemBody = {
|
|
133
|
+
tables: tablesPayload,
|
|
134
|
+
permissions: permissionsPayload,
|
|
135
|
+
documents: docOut,
|
|
136
|
+
exampleSqlList: sqlOut,
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
await handleSubmit({
|
|
140
|
+
opeType: 'edit',
|
|
141
|
+
validate: async () => itemBody,
|
|
142
|
+
editAPI: (payload) => updateModelMetadataItemInfoAPI({ ...payload, id }),
|
|
143
|
+
successMessage: {
|
|
144
|
+
edit: t('common.edit_success'),
|
|
145
|
+
},
|
|
146
|
+
onSuccess: async () => {
|
|
147
|
+
navigate(-1)
|
|
148
|
+
},
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const tabItems = useMemo(
|
|
153
|
+
() => [
|
|
154
|
+
{
|
|
155
|
+
key: 'schema',
|
|
156
|
+
label: t('menus.model_metadata.manage.step2_title'),
|
|
157
|
+
children: (
|
|
158
|
+
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden">
|
|
159
|
+
<Step2Schema
|
|
160
|
+
connectionParams={basicFields}
|
|
161
|
+
tables={tables}
|
|
162
|
+
onTablesChange={setTables}
|
|
163
|
+
isEdit
|
|
164
|
+
currentStep={1}
|
|
165
|
+
previewNonce={0}
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
),
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
key: 'perm',
|
|
172
|
+
label: t('menus.model_metadata.manage.step3_title'),
|
|
173
|
+
children: (
|
|
174
|
+
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden">
|
|
175
|
+
<Step3Permissions
|
|
176
|
+
permissions={permissions}
|
|
177
|
+
onPermissionsChange={setPermissions}
|
|
178
|
+
tables={tables}
|
|
179
|
+
/>
|
|
180
|
+
</div>
|
|
181
|
+
),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
key: 'doc',
|
|
185
|
+
label: t('menus.model_metadata.manage.step4_title'),
|
|
186
|
+
children: (
|
|
187
|
+
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden">
|
|
188
|
+
<Step4Documents documents={documents} onDocumentsChange={setDocuments} />
|
|
189
|
+
</div>
|
|
190
|
+
),
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
key: 'sql',
|
|
194
|
+
label: t('menus.model_metadata.manage.step5_title'),
|
|
195
|
+
children: (
|
|
196
|
+
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden">
|
|
197
|
+
<Step5ExampleSql
|
|
198
|
+
exampleSqlList={exampleSqlList}
|
|
199
|
+
onExampleSqlListChange={setExampleSqlList}
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
),
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
[t, basicFields, tables, permissions, documents, exampleSqlList],
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
if (!id) {
|
|
209
|
+
return (
|
|
210
|
+
<div className="flex flex-1 items-center justify-center p-8 text-sm text-gray-500">
|
|
211
|
+
{t('common.no_data')}
|
|
212
|
+
</div>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
<div className="flex h-full min-h-0 w-full min-w-0 flex-col bg-white">
|
|
218
|
+
<div className="w-full min-w-0 shrink-0 bg-white px-6 pb-2 pt-5">
|
|
219
|
+
<div className="flex items-center justify-between gap-3">
|
|
220
|
+
<div className="flex min-w-0 flex-1 items-center gap-3">
|
|
221
|
+
<CxButton.Icon
|
|
222
|
+
className="!p-2.5 shrink-0 rounded-lg border border-solid border-gray-300 bg-white shadow-sm"
|
|
223
|
+
type="default"
|
|
224
|
+
icon={<ChevronLeft size={22} strokeWidth={2.25} />}
|
|
225
|
+
onClick={handleBack}
|
|
226
|
+
title={t('common.back')}
|
|
227
|
+
tooltipTone="default"
|
|
228
|
+
/>
|
|
229
|
+
<h1 className="flex min-w-0 flex-wrap items-center gap-3 bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-3xl font-bold text-transparent">
|
|
230
|
+
<Database className="shrink-0 text-blue-400" size={32} aria-hidden />
|
|
231
|
+
<span className="min-w-0">{t('menus.model_metadata.manage.edit')}</span>
|
|
232
|
+
{subject ? (
|
|
233
|
+
<span className="text-lg font-normal text-gray-600 dark:text-gray-300" title={subject}>
|
|
234
|
+
({subject})
|
|
235
|
+
</span>
|
|
236
|
+
) : null}
|
|
237
|
+
</h1>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
<div className="flex min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden bg-white px-5 pb-3 pt-0">
|
|
243
|
+
{detailLoading ? (
|
|
244
|
+
<div className="flex flex-1 items-center justify-center py-16">
|
|
245
|
+
<Spin size="large" />
|
|
246
|
+
</div>
|
|
247
|
+
) : (
|
|
248
|
+
<div className="mx-auto flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden rounded-lg bg-white px-3 pb-3 pt-0 md:px-4 md:pb-4">
|
|
249
|
+
<CxTabs
|
|
250
|
+
activeKey={activeTab}
|
|
251
|
+
onChange={setActiveTab}
|
|
252
|
+
items={tabItems}
|
|
253
|
+
className="flex min-h-0 flex-1 flex-col [&_.ant-tabs-nav]:!mt-0 [&_.ant-tabs-nav]:shrink-0 [&_.ant-tabs-content-holder]:min-h-0 [&_.ant-tabs-content-holder]:flex-1 [&_.ant-tabs-content]:h-full [&_.ant-tabs-content]:min-h-0 [&_.ant-tabs-tabpane:not(.ant-tabs-tabpane-hidden)]:flex [&_.ant-tabs-tabpane:not(.ant-tabs-tabpane-hidden)]:min-h-0 [&_.ant-tabs-tabpane:not(.ant-tabs-tabpane-hidden)]:h-full [&_.ant-tabs-tabpane:not(.ant-tabs-tabpane-hidden)]:flex-1 [&_.ant-tabs-tabpane:not(.ant-tabs-tabpane-hidden)]:flex-col"
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
|
|
259
|
+
<div className="shrink-0 border-t border-gray-200 bg-white px-5 py-3">
|
|
260
|
+
<div className="mx-auto flex max-w-6xl justify-between">
|
|
261
|
+
<CxButton onClick={handleBack}>{t('common.cancel')}</CxButton>
|
|
262
|
+
<CxButton
|
|
263
|
+
type="primary"
|
|
264
|
+
disabled={detailLoading}
|
|
265
|
+
loading={submitting}
|
|
266
|
+
onClick={() => void onSubmit()}
|
|
267
|
+
>
|
|
268
|
+
{t('common.submit')}
|
|
269
|
+
</CxButton>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export default ModelMetadataSubmitEditView
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getModelMetadataDetailAPI,
|
|
3
|
+
getModelMetadataItemInfoAPI,
|
|
4
|
+
} from '@api/menus/model-metadata/manage'
|
|
5
|
+
import { useAuth } from '@/contexts/AuthContext'
|
|
6
|
+
import { useRouter } from '@/hooks/useRouter'
|
|
7
|
+
import { CxButton, CxTable, CxTabs } from '@cx-ui'
|
|
8
|
+
import { Spin } from 'antd'
|
|
9
|
+
import { ChevronLeft, Database } from 'lucide-react'
|
|
10
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
11
|
+
import { useTranslation } from 'react-i18next'
|
|
12
|
+
import { useNavigate, useParams } from 'react-router-dom'
|
|
13
|
+
import { CodeView } from '@/components/common/code-view'
|
|
14
|
+
import MetadataDetailSchemaTab from './components/metadata-detail-schema-tab'
|
|
15
|
+
|
|
16
|
+
type ItemBundle = {
|
|
17
|
+
tables: any[]
|
|
18
|
+
permissions: any[]
|
|
19
|
+
documents: any[]
|
|
20
|
+
exampleSqlList: any[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function ModelMetadataDetailView() {
|
|
24
|
+
const { t } = useTranslation()
|
|
25
|
+
const { id } = useParams<{ id: string }>()
|
|
26
|
+
const navigate = useNavigate()
|
|
27
|
+
const router = useRouter()
|
|
28
|
+
const { hasPermission } = useAuth()
|
|
29
|
+
const [loading, setLoading] = useState(() => Boolean(id))
|
|
30
|
+
const [subject, setSubject] = useState('')
|
|
31
|
+
/** 与列表编辑一致:启用态不展示编辑 */
|
|
32
|
+
const [rowStatus, setRowStatus] = useState<number | undefined>(undefined)
|
|
33
|
+
const [itemBundle, setItemBundle] = useState<ItemBundle>({
|
|
34
|
+
tables: [],
|
|
35
|
+
permissions: [],
|
|
36
|
+
documents: [],
|
|
37
|
+
exampleSqlList: [],
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!id) return
|
|
42
|
+
let cancelled = false
|
|
43
|
+
;(async () => {
|
|
44
|
+
setLoading(true)
|
|
45
|
+
try {
|
|
46
|
+
const [basicRes, itemRes] = await Promise.all([
|
|
47
|
+
getModelMetadataDetailAPI(id),
|
|
48
|
+
getModelMetadataItemInfoAPI(id),
|
|
49
|
+
])
|
|
50
|
+
const basic = (basicRes as any)?.data
|
|
51
|
+
const item = (itemRes as any)?.data
|
|
52
|
+
if (cancelled) return
|
|
53
|
+
setSubject(String(basic?.subject ?? '').trim())
|
|
54
|
+
setRowStatus(
|
|
55
|
+
basic?.status !== undefined && basic?.status !== null ? Number(basic.status) : undefined,
|
|
56
|
+
)
|
|
57
|
+
setItemBundle({
|
|
58
|
+
tables: Array.isArray(item?.tables) ? item.tables : [],
|
|
59
|
+
permissions: Array.isArray(item?.permissions) ? item.permissions : [],
|
|
60
|
+
documents: Array.isArray(item?.documents) ? item.documents : [],
|
|
61
|
+
exampleSqlList: Array.isArray(item?.exampleSqlList) ? item.exampleSqlList : [],
|
|
62
|
+
})
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error(e)
|
|
65
|
+
if (!cancelled) {
|
|
66
|
+
setSubject('')
|
|
67
|
+
setRowStatus(undefined)
|
|
68
|
+
setItemBundle({ tables: [], permissions: [], documents: [], exampleSqlList: [] })
|
|
69
|
+
}
|
|
70
|
+
} finally {
|
|
71
|
+
if (!cancelled) setLoading(false)
|
|
72
|
+
}
|
|
73
|
+
})()
|
|
74
|
+
return () => {
|
|
75
|
+
cancelled = true
|
|
76
|
+
}
|
|
77
|
+
}, [id])
|
|
78
|
+
|
|
79
|
+
const handleBack = () => {
|
|
80
|
+
navigate(-1)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const isEnabled = rowStatus !== undefined && Number(rowStatus) === 1
|
|
84
|
+
const canShowEdit =
|
|
85
|
+
(hasPermission('model-metadata:edit') || hasPermission('model-metadata:edit-item')) &&
|
|
86
|
+
Boolean(id) &&
|
|
87
|
+
!loading &&
|
|
88
|
+
!isEnabled
|
|
89
|
+
|
|
90
|
+
const permissionColumns = useMemo(
|
|
91
|
+
() => [
|
|
92
|
+
{
|
|
93
|
+
title: t('menus.model_metadata.manage.fields.permissionName'),
|
|
94
|
+
key: 'permissionName',
|
|
95
|
+
width: 200,
|
|
96
|
+
render: (v: unknown) => v ?? '-',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
title: t('menus.model_metadata.manage.fields.permissionColumns'),
|
|
100
|
+
key: 'permissionColumns',
|
|
101
|
+
minWidth: 280,
|
|
102
|
+
render: (_: unknown, row: any) =>
|
|
103
|
+
Array.isArray(row.permissionColumns) && row.permissionColumns.length
|
|
104
|
+
? row.permissionColumns.join(', ')
|
|
105
|
+
: '—',
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
[t],
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
const documentColumns = useMemo(
|
|
112
|
+
() => [
|
|
113
|
+
{
|
|
114
|
+
title: t('menus.model_metadata.manage.fields.docName'),
|
|
115
|
+
key: 'name',
|
|
116
|
+
width: 140,
|
|
117
|
+
render: (v: unknown) => v ?? '-',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
title: t('menus.model_metadata.manage.fields.docCode'),
|
|
121
|
+
key: 'code',
|
|
122
|
+
width: 120,
|
|
123
|
+
render: (v: unknown) => v ?? '-',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
title: t('menus.model_metadata.manage.fields.docDescription'),
|
|
127
|
+
key: 'description',
|
|
128
|
+
width: 180,
|
|
129
|
+
ellipsis: true,
|
|
130
|
+
render: (v: unknown) => v ?? '-',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
title: t('menus.model_metadata.manage.fields.docText'),
|
|
134
|
+
key: 'text',
|
|
135
|
+
minWidth: 240,
|
|
136
|
+
render: (v: unknown) => (
|
|
137
|
+
<div className="max-h-24 overflow-auto whitespace-pre-wrap break-words text-sm text-gray-800 dark:text-gray-100">
|
|
138
|
+
{String(v ?? '—')}
|
|
139
|
+
</div>
|
|
140
|
+
),
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
[t],
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
const exampleSqlColumns = useMemo(
|
|
147
|
+
() => [
|
|
148
|
+
{
|
|
149
|
+
title: t('menus.model_metadata.manage.fields.exampleSql'),
|
|
150
|
+
key: 'exampleSql',
|
|
151
|
+
minWidth: 320,
|
|
152
|
+
render: (v: unknown) => (
|
|
153
|
+
<div className="max-h-80 min-w-0 max-w-full overflow-hidden">
|
|
154
|
+
<CodeView.SQL maxHeight={280}>{String(v ?? '—')}</CodeView.SQL>
|
|
155
|
+
</div>
|
|
156
|
+
),
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
title: t('menus.model_metadata.manage.fields.exampleSqlDescription'),
|
|
160
|
+
key: 'description',
|
|
161
|
+
width: 200,
|
|
162
|
+
ellipsis: true,
|
|
163
|
+
render: (v: unknown) => v ?? '-',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
[t],
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
const tabItems = useMemo(
|
|
170
|
+
() => [
|
|
171
|
+
{
|
|
172
|
+
key: 'schema',
|
|
173
|
+
label: t('menus.model_metadata.manage.step2_title'),
|
|
174
|
+
children: (
|
|
175
|
+
<div className="flex h-full min-h-0 flex-1 flex-col overflow-hidden">
|
|
176
|
+
<MetadataDetailSchemaTab tables={itemBundle.tables} />
|
|
177
|
+
</div>
|
|
178
|
+
),
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
key: 'perm',
|
|
182
|
+
label: t('menus.model_metadata.manage.step3_title'),
|
|
183
|
+
children: (
|
|
184
|
+
<div className="min-h-0 flex-1 overflow-hidden">
|
|
185
|
+
{itemBundle.permissions.length ? (
|
|
186
|
+
<CxTable
|
|
187
|
+
className="min-w-0 w-full"
|
|
188
|
+
autoScrollY
|
|
189
|
+
minScrollY={200}
|
|
190
|
+
columns={permissionColumns}
|
|
191
|
+
dataSource={itemBundle.permissions}
|
|
192
|
+
rowKey={(r: any, i: number) => String(r.id ?? i)}
|
|
193
|
+
pagination={false}
|
|
194
|
+
scroll={{ x: true }}
|
|
195
|
+
/>
|
|
196
|
+
) : (
|
|
197
|
+
<div className="rounded-lg border border-dashed border-gray-300 py-12 text-center text-sm text-gray-400 dark:border-gray-600">
|
|
198
|
+
{t('common.no_data')}
|
|
199
|
+
</div>
|
|
200
|
+
)}
|
|
201
|
+
</div>
|
|
202
|
+
),
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
key: 'doc',
|
|
206
|
+
label: t('menus.model_metadata.manage.step4_title'),
|
|
207
|
+
children: (
|
|
208
|
+
<div className="min-h-0 flex-1 overflow-hidden">
|
|
209
|
+
<CxTable
|
|
210
|
+
className="min-w-0 w-full"
|
|
211
|
+
autoScrollY
|
|
212
|
+
minScrollY={200}
|
|
213
|
+
columns={documentColumns}
|
|
214
|
+
dataSource={itemBundle.documents}
|
|
215
|
+
rowKey={(r: any, i: number) => String(r.id ?? i)}
|
|
216
|
+
pagination={false}
|
|
217
|
+
scroll={{ x: true }}
|
|
218
|
+
/>
|
|
219
|
+
</div>
|
|
220
|
+
),
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
key: 'sql',
|
|
224
|
+
label: t('menus.model_metadata.manage.step5_title'),
|
|
225
|
+
children: (
|
|
226
|
+
<div className="min-h-0 flex-1 overflow-hidden">
|
|
227
|
+
<CxTable
|
|
228
|
+
className="min-w-0 w-full"
|
|
229
|
+
autoScrollY
|
|
230
|
+
minScrollY={200}
|
|
231
|
+
columns={exampleSqlColumns}
|
|
232
|
+
dataSource={itemBundle.exampleSqlList}
|
|
233
|
+
rowKey={(r: any, i: number) => String(r.id ?? i)}
|
|
234
|
+
pagination={false}
|
|
235
|
+
scroll={{ x: true }}
|
|
236
|
+
/>
|
|
237
|
+
</div>
|
|
238
|
+
),
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
[t, itemBundle, permissionColumns, documentColumns, exampleSqlColumns],
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
return (
|
|
245
|
+
<div className="flex h-full w-full min-w-0 flex-col bg-white">
|
|
246
|
+
<div className="w-full min-w-0 shrink-0 bg-white px-6 pb-2 pt-5">
|
|
247
|
+
<div className="flex items-center justify-between gap-3">
|
|
248
|
+
<div className="flex min-w-0 flex-1 items-center gap-3">
|
|
249
|
+
<CxButton.Icon
|
|
250
|
+
className="!p-2.5 shrink-0 rounded-lg border border-solid border-gray-300 bg-white shadow-sm"
|
|
251
|
+
type="default"
|
|
252
|
+
icon={<ChevronLeft size={22} strokeWidth={2.25} />}
|
|
253
|
+
onClick={handleBack}
|
|
254
|
+
title={t('common.back')}
|
|
255
|
+
tooltipTone="default"
|
|
256
|
+
/>
|
|
257
|
+
<h1 className="flex min-w-0 flex-wrap items-center gap-3 bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text text-3xl font-bold text-transparent">
|
|
258
|
+
<Database className="shrink-0 text-blue-400" size={32} aria-hidden />
|
|
259
|
+
<span className="min-w-0">{t('menus.model_metadata.manage.detail')}</span>
|
|
260
|
+
{subject ? (
|
|
261
|
+
<span className="text-lg font-normal text-gray-600 dark:text-gray-300" title={subject}>
|
|
262
|
+
({subject})
|
|
263
|
+
</span>
|
|
264
|
+
) : null}
|
|
265
|
+
</h1>
|
|
266
|
+
</div>
|
|
267
|
+
{canShowEdit ? (
|
|
268
|
+
<CxButton
|
|
269
|
+
type="primary"
|
|
270
|
+
className="shrink-0"
|
|
271
|
+
onClick={() => router.toEdit({ state: { editId: id } })}
|
|
272
|
+
>
|
|
273
|
+
{t('common.edit')}
|
|
274
|
+
</CxButton>
|
|
275
|
+
) : null}
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
|
|
279
|
+
<div className="flex w-full min-w-0 flex-1 flex-col overflow-hidden bg-white px-5 pb-3 pt-0">
|
|
280
|
+
{loading ? (
|
|
281
|
+
<div className="flex flex-1 items-center justify-center py-16">
|
|
282
|
+
<Spin size="large" />
|
|
283
|
+
</div>
|
|
284
|
+
) : (
|
|
285
|
+
<div className="mx-auto flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden rounded-lg bg-white px-3 pb-3 pt-0 md:px-4 md:pb-4">
|
|
286
|
+
<CxTabs
|
|
287
|
+
defaultActiveKey="schema"
|
|
288
|
+
items={tabItems}
|
|
289
|
+
className="flex min-h-0 flex-1 flex-col [&_.ant-tabs-nav]:!mt-0 [&_.ant-tabs-content-holder]:min-h-0 [&_.ant-tabs-content-holder]:flex-1 [&_.ant-tabs-content]:h-full [&_.ant-tabs-tabpane]:h-full"
|
|
290
|
+
/>
|
|
291
|
+
</div>
|
|
292
|
+
)}
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export default ModelMetadataDetailView
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { validPermissionColumnValues } from '../components/step3-permissions'
|
|
2
|
+
import {
|
|
3
|
+
isEmptyForeignKeyRow,
|
|
4
|
+
isEmptyIndexRow,
|
|
5
|
+
normalizeFkColumnsForSubmit,
|
|
6
|
+
normalizeIndexColumnsForSubmit,
|
|
7
|
+
validateForeignKeysInTables,
|
|
8
|
+
validateIndexesInTables,
|
|
9
|
+
} from '../modal/table-submit-modal'
|
|
10
|
+
|
|
11
|
+
function isBlank(v: unknown) {
|
|
12
|
+
return v == null || String(v).trim() === ''
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** 允许 0 行;只要有行则 name / code / text 必填 */
|
|
16
|
+
export function validateDocumentsForSubmit(documents: { name?: string; code?: string; text?: string }[]) {
|
|
17
|
+
for (const d of documents) {
|
|
18
|
+
if (isBlank(d.name)) return 'doc_name_required'
|
|
19
|
+
if (isBlank(d.code)) return 'doc_code_required'
|
|
20
|
+
if (isBlank(d.text)) return 'doc_text_required'
|
|
21
|
+
}
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** 允许 0 行;只要有行则 exampleSql 必填 */
|
|
26
|
+
export function validateExampleSqlListForSubmit(list: { exampleSql?: string }[]) {
|
|
27
|
+
for (const row of list) {
|
|
28
|
+
if (isBlank(row.exampleSql)) return 'example_sql_required'
|
|
29
|
+
}
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** 允许 0 行;只要有行则 permissionName 必填 */
|
|
34
|
+
export function validatePermissionsForSubmit(rows: { permissionName?: string }[]) {
|
|
35
|
+
for (const row of rows) {
|
|
36
|
+
if (isBlank(row.permissionName)) return 'permission_name_required'
|
|
37
|
+
}
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** 新增第一步汇总后的主表字段是否齐全 */
|
|
42
|
+
export function validateAddBasicFieldsPresent(basicFields: Record<string, any>) {
|
|
43
|
+
const requiredKeys = ['subject', 'databaseName', 'dbType', 'host', 'port']
|
|
44
|
+
return !requiredKeys.some((k) => basicFields[k] === undefined || basicFields[k] === '')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type ModelMetadataItemDetailInput = {
|
|
48
|
+
tables: any[]
|
|
49
|
+
permissions: any[]
|
|
50
|
+
documents: any[]
|
|
51
|
+
exampleSqlList: any[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** 权限 / 文档 / 示例 SQL / 索引 / 外键 等明细校验,通过返回 `null`,否则为 `menus.model_metadata.manage.rules.*` 的 key 后缀 */
|
|
55
|
+
export function validateModelMetadataItemDetail(input: ModelMetadataItemDetailInput): string | null {
|
|
56
|
+
const permErr = validatePermissionsForSubmit(input.permissions)
|
|
57
|
+
if (permErr) return permErr
|
|
58
|
+
const docErr = validateDocumentsForSubmit(input.documents)
|
|
59
|
+
if (docErr) return docErr
|
|
60
|
+
const sqlErr = validateExampleSqlListForSubmit(input.exampleSqlList)
|
|
61
|
+
if (sqlErr) return sqlErr
|
|
62
|
+
const ixErr = validateIndexesInTables(input.tables)
|
|
63
|
+
if (ixErr) return ixErr
|
|
64
|
+
const fkErr = validateForeignKeysInTables(input.tables)
|
|
65
|
+
if (fkErr) return fkErr
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 组装提交用 tables / permissions(与新增、编辑明细接口一致) */
|
|
70
|
+
export function buildModelMetadataPayloadParts(input: ModelMetadataItemDetailInput) {
|
|
71
|
+
const { tables, permissions, documents, exampleSqlList } = input
|
|
72
|
+
const validPermCols = validPermissionColumnValues(tables)
|
|
73
|
+
const permissionsPayload = permissions.map((p: any) => {
|
|
74
|
+
const cols = (p.permissionColumns || []).filter((c: string) => validPermCols.has(c))
|
|
75
|
+
const row: Record<string, unknown> = {
|
|
76
|
+
permissionName: p.permissionName,
|
|
77
|
+
permissionColumns: cols,
|
|
78
|
+
}
|
|
79
|
+
if (p.id != null && String(p.id).trim() !== '') row.id = p.id
|
|
80
|
+
return row
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const tablesPayload = tables.map((tb: any) => {
|
|
84
|
+
const { _clientId: _c, ...rest } = tb
|
|
85
|
+
return {
|
|
86
|
+
...rest,
|
|
87
|
+
columns: (tb.columns || []).map((col: any) => ({
|
|
88
|
+
...col,
|
|
89
|
+
privacyFlag: col.privacyFlag === 1 ? 1 : 0,
|
|
90
|
+
})),
|
|
91
|
+
indexes: (tb.indexes || [])
|
|
92
|
+
.filter((ix: any) => !isEmptyIndexRow(ix))
|
|
93
|
+
.map((ix: any) => ({
|
|
94
|
+
...ix,
|
|
95
|
+
isUnique: (ix as any).isUnique === 1 ? 1 : 0,
|
|
96
|
+
indexColumns: normalizeIndexColumnsForSubmit(ix.indexColumns),
|
|
97
|
+
})),
|
|
98
|
+
foreignKeys: (tb.foreignKeys || [])
|
|
99
|
+
.filter((fk: any) => !isEmptyForeignKeyRow(fk))
|
|
100
|
+
.map((fk: any) => ({
|
|
101
|
+
...fk,
|
|
102
|
+
fkColumns: normalizeFkColumnsForSubmit(fk.fkColumns),
|
|
103
|
+
})),
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
tablesPayload,
|
|
109
|
+
permissionsPayload,
|
|
110
|
+
documents,
|
|
111
|
+
exampleSqlList,
|
|
112
|
+
}
|
|
113
|
+
}
|