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,218 @@
|
|
|
1
|
+
import { useAuth } from '@/contexts/AuthContext'
|
|
2
|
+
import { getModelMetadataDetailAPI } from '@api/menus/model-metadata/manage'
|
|
3
|
+
import { CxButton, CxModal, CxTag, useCxModal } from '@cx-ui'
|
|
4
|
+
import { Form, Spin } from 'antd'
|
|
5
|
+
import { forwardRef, useImperativeHandle, useMemo, useState } from 'react'
|
|
6
|
+
import { useTranslation } from 'react-i18next'
|
|
7
|
+
|
|
8
|
+
type OpenPayload = {
|
|
9
|
+
opeType?: string
|
|
10
|
+
opeId?: string | number
|
|
11
|
+
data?: any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
onCancel?: () => void
|
|
16
|
+
/** 编辑主表:打开列表侧 SubmitModal(editModelMetadataAPI) */
|
|
17
|
+
onEditMain?: (id: string | number) => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** 仅基础字段,窄弹窗 + 两列只读表单项 */
|
|
21
|
+
const DETAIL_MODAL_WIDTH = 680
|
|
22
|
+
|
|
23
|
+
const DetailModal = forwardRef<
|
|
24
|
+
{ close: () => void; open: (payload?: OpenPayload) => void },
|
|
25
|
+
Props
|
|
26
|
+
>(function DetailModal(props, ref) {
|
|
27
|
+
const { onCancel, onEditMain } = props
|
|
28
|
+
const { t } = useTranslation()
|
|
29
|
+
const { hasPermission } = useAuth()
|
|
30
|
+
const [loading, setLoading] = useState(false)
|
|
31
|
+
|
|
32
|
+
const modal = useCxModal({
|
|
33
|
+
onOpen: async (payload) => {
|
|
34
|
+
const id = payload?.opeId ?? payload?.data?.id
|
|
35
|
+
setLoading(true)
|
|
36
|
+
modal.setFormData(null)
|
|
37
|
+
if (id == null || `${id}`.trim() === '') {
|
|
38
|
+
setLoading(false)
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const res = await getModelMetadataDetailAPI(id)
|
|
43
|
+
const row = (res as any)?.data ?? payload?.data ?? null
|
|
44
|
+
modal.setFormData(row)
|
|
45
|
+
} finally {
|
|
46
|
+
setLoading(false)
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
onClose: () => {
|
|
50
|
+
onCancel?.()
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const { isOpen, close } = modal
|
|
55
|
+
const record = modal.formData as Record<string, any> | null
|
|
56
|
+
|
|
57
|
+
const isEnabled =
|
|
58
|
+
record != null &&
|
|
59
|
+
record.status !== undefined &&
|
|
60
|
+
record.status !== null &&
|
|
61
|
+
Number(record.status) === 1
|
|
62
|
+
|
|
63
|
+
const title = useMemo(() => t('menus.model_metadata.manage.detail'), [t])
|
|
64
|
+
|
|
65
|
+
const canEditMain =
|
|
66
|
+
!loading &&
|
|
67
|
+
record != null &&
|
|
68
|
+
record.id != null &&
|
|
69
|
+
(hasPermission('model-metadata:edit') || hasPermission('model-metadata:edit-item')) &&
|
|
70
|
+
!isEnabled &&
|
|
71
|
+
onEditMain != null
|
|
72
|
+
|
|
73
|
+
const footerActions = useMemo(() => {
|
|
74
|
+
if (!canEditMain || !record || !onEditMain) return undefined
|
|
75
|
+
const id = record.id
|
|
76
|
+
return (
|
|
77
|
+
<div className="flex w-full justify-end gap-2">
|
|
78
|
+
<CxButton
|
|
79
|
+
type="primary"
|
|
80
|
+
onClick={() => {
|
|
81
|
+
onEditMain(id)
|
|
82
|
+
close()
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{t('common.edit')}
|
|
86
|
+
</CxButton>
|
|
87
|
+
<CxButton type="text" onClick={close}>
|
|
88
|
+
{t('common.close')}
|
|
89
|
+
</CxButton>
|
|
90
|
+
</div>
|
|
91
|
+
)
|
|
92
|
+
}, [canEditMain, record, onEditMain, close, t])
|
|
93
|
+
|
|
94
|
+
useImperativeHandle(
|
|
95
|
+
ref,
|
|
96
|
+
() => ({
|
|
97
|
+
open: modal.open,
|
|
98
|
+
close,
|
|
99
|
+
}),
|
|
100
|
+
[modal.open, close],
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<CxModal
|
|
105
|
+
title={title}
|
|
106
|
+
isOpen={isOpen}
|
|
107
|
+
onClose={close}
|
|
108
|
+
opeType="detail"
|
|
109
|
+
modalConfig={{
|
|
110
|
+
width: DETAIL_MODAL_WIDTH,
|
|
111
|
+
styles: {
|
|
112
|
+
container: { backgroundColor: '#ffffff' },
|
|
113
|
+
body: { backgroundColor: '#ffffff' },
|
|
114
|
+
},
|
|
115
|
+
}}
|
|
116
|
+
{...(footerActions != null ? { actions: footerActions } : {})}
|
|
117
|
+
>
|
|
118
|
+
{loading ? (
|
|
119
|
+
<div className="flex justify-center py-12">
|
|
120
|
+
<Spin size="large" />
|
|
121
|
+
</div>
|
|
122
|
+
) : !record ? (
|
|
123
|
+
<div className="flex justify-center py-10 text-sm text-gray-500">
|
|
124
|
+
{t('common.no_data')}
|
|
125
|
+
</div>
|
|
126
|
+
) : (
|
|
127
|
+
<Form layout="horizontal" colon className="pb-1">
|
|
128
|
+
<div className="grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2">
|
|
129
|
+
<Form.Item
|
|
130
|
+
label={t('menus.model_metadata.manage.fields.subject')}
|
|
131
|
+
className="!mb-0"
|
|
132
|
+
>
|
|
133
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
134
|
+
{record.subject ?? '-'}
|
|
135
|
+
</div>
|
|
136
|
+
</Form.Item>
|
|
137
|
+
<Form.Item
|
|
138
|
+
label={t('menus.model_metadata.manage.fields.databaseName')}
|
|
139
|
+
className="!mb-0"
|
|
140
|
+
>
|
|
141
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
142
|
+
{record.databaseName ?? '-'}
|
|
143
|
+
</div>
|
|
144
|
+
</Form.Item>
|
|
145
|
+
<Form.Item
|
|
146
|
+
label={t('menus.model_metadata.manage.fields.dbType')}
|
|
147
|
+
className="!mb-0"
|
|
148
|
+
>
|
|
149
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
150
|
+
{record.dbType ?? '-'}
|
|
151
|
+
</div>
|
|
152
|
+
</Form.Item>
|
|
153
|
+
<Form.Item label={t('menus.model_metadata.manage.fields.status')} className="!mb-0">
|
|
154
|
+
<CxTag.Enabled value={record.status} />
|
|
155
|
+
</Form.Item>
|
|
156
|
+
<Form.Item
|
|
157
|
+
label={t('menus.model_metadata.manage.fields.host')}
|
|
158
|
+
className="!mb-0"
|
|
159
|
+
>
|
|
160
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
161
|
+
{record.host ?? '-'}:{record.port ?? '-'}
|
|
162
|
+
</div>
|
|
163
|
+
</Form.Item>
|
|
164
|
+
<Form.Item
|
|
165
|
+
label={t('menus.model_metadata.manage.fields.dbSchema')}
|
|
166
|
+
className="!mb-0"
|
|
167
|
+
>
|
|
168
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
169
|
+
{record.dbSchema ?? '-'}
|
|
170
|
+
</div>
|
|
171
|
+
</Form.Item>
|
|
172
|
+
<Form.Item
|
|
173
|
+
label={t('menus.model_metadata.manage.fields.username')}
|
|
174
|
+
className="!mb-0"
|
|
175
|
+
>
|
|
176
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
177
|
+
{record.username ?? '-'}
|
|
178
|
+
</div>
|
|
179
|
+
</Form.Item>
|
|
180
|
+
<Form.Item
|
|
181
|
+
label={t('menus.model_metadata.manage.fields.passwordMasked')}
|
|
182
|
+
className="!mb-0"
|
|
183
|
+
>
|
|
184
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
185
|
+
{record.passwordMasked ?? '-'}
|
|
186
|
+
</div>
|
|
187
|
+
</Form.Item>
|
|
188
|
+
<Form.Item
|
|
189
|
+
label={t('menus.model_metadata.manage.fields.charsetName')}
|
|
190
|
+
className="!mb-0"
|
|
191
|
+
>
|
|
192
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
193
|
+
{record.charsetName ?? '-'}
|
|
194
|
+
</div>
|
|
195
|
+
</Form.Item>
|
|
196
|
+
<Form.Item label={t('common.creator')} className="!mb-0">
|
|
197
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
198
|
+
{record.createBy ?? '-'}
|
|
199
|
+
</div>
|
|
200
|
+
</Form.Item>
|
|
201
|
+
<Form.Item label={t('common.create_time')} className="!mb-0">
|
|
202
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
203
|
+
{record.createTime ?? '-'}
|
|
204
|
+
</div>
|
|
205
|
+
</Form.Item>
|
|
206
|
+
<Form.Item label={t('common.update_time')} className="!mb-0">
|
|
207
|
+
<div className="break-words text-sm text-gray-900 dark:text-gray-100">
|
|
208
|
+
{record.updateTime ?? '-'}
|
|
209
|
+
</div>
|
|
210
|
+
</Form.Item>
|
|
211
|
+
</div>
|
|
212
|
+
</Form>
|
|
213
|
+
)}
|
|
214
|
+
</CxModal>
|
|
215
|
+
)
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
export default DetailModal
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { useAuth } from '@/contexts/AuthContext'
|
|
2
|
+
import { useModalSubmit } from '@/hooks/useModalSubmit'
|
|
3
|
+
import { DICT_DATA, DICT_KEY, ENUM_DATA } from '@/meta'
|
|
4
|
+
import { addModelMetadataAPI, editModelMetadataAPI, getModelMetadataDetailAPI } from '@api/menus/model-metadata/manage'
|
|
5
|
+
import { forwardRef, useImperativeHandle, useMemo } from 'react'
|
|
6
|
+
import { useTranslation } from 'react-i18next'
|
|
7
|
+
|
|
8
|
+
import { CxForm, CxFormItem, CxInput, CxModal, CxSelect, useCxModal } from '@cx-ui'
|
|
9
|
+
|
|
10
|
+
type OpenPayload = {
|
|
11
|
+
opeType?: string
|
|
12
|
+
opeId?: string | number
|
|
13
|
+
data?: any
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
onCancel?: () => void
|
|
18
|
+
onOk?: (values: any) => void | Promise<void>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SUBMIT_MODAL_WIDTH = 1120
|
|
22
|
+
const SUBMIT_MODAL_HEIGHT = '95vh'
|
|
23
|
+
|
|
24
|
+
const submitModalShellStyles = {
|
|
25
|
+
container: {
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flexDirection: 'column' as const,
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
height: SUBMIT_MODAL_HEIGHT,
|
|
30
|
+
maxHeight: SUBMIT_MODAL_HEIGHT,
|
|
31
|
+
backgroundColor: '#ffffff',
|
|
32
|
+
},
|
|
33
|
+
body: {
|
|
34
|
+
flex: '1 1 0%',
|
|
35
|
+
minHeight: 0,
|
|
36
|
+
overflowY: 'auto',
|
|
37
|
+
overflowX: 'hidden',
|
|
38
|
+
padding: '20px 32px',
|
|
39
|
+
backgroundColor: '#ffffff',
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SubmitModal = forwardRef<
|
|
44
|
+
{ close: () => void; open: (payload?: OpenPayload) => void },
|
|
45
|
+
Props
|
|
46
|
+
>(function SubmitModal(props, ref) {
|
|
47
|
+
const { onCancel, onOk } = props
|
|
48
|
+
const { t } = useTranslation()
|
|
49
|
+
const { commonDictRevision } = useAuth()
|
|
50
|
+
|
|
51
|
+
const dbTypeOptions = useMemo(
|
|
52
|
+
() => DICT_DATA[DICT_KEY.dbType]?.option ?? [],
|
|
53
|
+
[commonDictRevision],
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const modal = useCxModal({
|
|
57
|
+
onOpen: async (payload) => {
|
|
58
|
+
form.resetFields()
|
|
59
|
+
const type = payload?.opeType ?? 'add'
|
|
60
|
+
if (type === 'edit' && payload?.opeId) {
|
|
61
|
+
try {
|
|
62
|
+
const res = await getModelMetadataDetailAPI(payload.opeId)
|
|
63
|
+
const data = res?.data
|
|
64
|
+
if (data) {
|
|
65
|
+
form.setFieldsValue({
|
|
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
|
+
} catch (error) {
|
|
78
|
+
console.error('Failed to fetch model metadata detail:', error)
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
form.setFieldsValue({
|
|
82
|
+
subject: '',
|
|
83
|
+
databaseName: '',
|
|
84
|
+
dbType: '',
|
|
85
|
+
host: '',
|
|
86
|
+
port: undefined,
|
|
87
|
+
dbSchema: '',
|
|
88
|
+
username: '',
|
|
89
|
+
optionsJson: '',
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onClose: () => {
|
|
94
|
+
onCancel?.()
|
|
95
|
+
},
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const { isOpen, close, form, opeType, opeId } = modal
|
|
99
|
+
const { submitting, handleSubmit } = useModalSubmit()
|
|
100
|
+
|
|
101
|
+
// rules.* 中文:locales/zh/menus/model-metadata.ts
|
|
102
|
+
const formRules = useMemo(
|
|
103
|
+
() => ({
|
|
104
|
+
subject: [
|
|
105
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.subject_required') }, // 主题必填
|
|
106
|
+
{ whitespace: true, message: t('menus.model_metadata.manage.rules.subject_required') },
|
|
107
|
+
],
|
|
108
|
+
databaseName: [
|
|
109
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.databaseName_required') }, // 库名必填
|
|
110
|
+
{ whitespace: true, message: t('menus.model_metadata.manage.rules.databaseName_required') },
|
|
111
|
+
],
|
|
112
|
+
dbType: [
|
|
113
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.dbType_required') }, // 库类型必填
|
|
114
|
+
],
|
|
115
|
+
host: [
|
|
116
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.host_required') }, // 主机必填
|
|
117
|
+
{ whitespace: true, message: t('menus.model_metadata.manage.rules.host_required') },
|
|
118
|
+
],
|
|
119
|
+
port: [
|
|
120
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.port_required') }, // 端口必填
|
|
121
|
+
],
|
|
122
|
+
username: [
|
|
123
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.username_required') }, // 用户名必填
|
|
124
|
+
{ whitespace: true, message: t('menus.model_metadata.manage.rules.username_required') },
|
|
125
|
+
],
|
|
126
|
+
password: opeType === 'add'
|
|
127
|
+
? [
|
|
128
|
+
{ required: true, message: t('menus.model_metadata.manage.rules.password_required') }, // 密码必填
|
|
129
|
+
{ whitespace: true, message: t('menus.model_metadata.manage.rules.password_required') },
|
|
130
|
+
]
|
|
131
|
+
: [],
|
|
132
|
+
}),
|
|
133
|
+
[t, opeType],
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
// 弹窗标题:新增 / 更新
|
|
137
|
+
const title = useMemo(
|
|
138
|
+
() =>
|
|
139
|
+
opeType === 'add' ? t('menus.model_metadata.manage.add') : t('menus.model_metadata.manage.edit'),
|
|
140
|
+
[opeType, t],
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
const onOkClick = async () => {
|
|
144
|
+
const result = await handleSubmit({
|
|
145
|
+
opeType,
|
|
146
|
+
validate: () => form.validateFields(),
|
|
147
|
+
addAPI: addModelMetadataAPI,
|
|
148
|
+
editAPI: editModelMetadataAPI,
|
|
149
|
+
transform: (values) => ({
|
|
150
|
+
...(opeType === 'edit' ? { id: opeId } : {}),
|
|
151
|
+
subject: values.subject,
|
|
152
|
+
databaseName: values.databaseName,
|
|
153
|
+
dbType: values.dbType,
|
|
154
|
+
host: values.host,
|
|
155
|
+
port: values.port,
|
|
156
|
+
dbSchema: values.dbSchema,
|
|
157
|
+
username: values.username,
|
|
158
|
+
password: values.password,
|
|
159
|
+
charsetName: values.charsetName,
|
|
160
|
+
optionsJson: values.optionsJson,
|
|
161
|
+
}),
|
|
162
|
+
onSuccess: async ({ payload }) => {
|
|
163
|
+
await onOk?.(payload)
|
|
164
|
+
},
|
|
165
|
+
})
|
|
166
|
+
if (result) close()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
useImperativeHandle(
|
|
170
|
+
ref,
|
|
171
|
+
() => ({
|
|
172
|
+
open: modal.open,
|
|
173
|
+
close,
|
|
174
|
+
}),
|
|
175
|
+
[modal.open, close],
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<CxModal
|
|
180
|
+
isOpen={isOpen}
|
|
181
|
+
modalConfig={{
|
|
182
|
+
width: SUBMIT_MODAL_WIDTH,
|
|
183
|
+
styles: {
|
|
184
|
+
...submitModalShellStyles,
|
|
185
|
+
},
|
|
186
|
+
rootClassName: 'cx-modal-content-fill scroll',
|
|
187
|
+
}}
|
|
188
|
+
opeType={opeType}
|
|
189
|
+
submitting={submitting}
|
|
190
|
+
title={title}
|
|
191
|
+
onClose={close}
|
|
192
|
+
onSubmit={onOkClick}
|
|
193
|
+
>
|
|
194
|
+
<CxForm form={form} rules={formRules} layout="vertical" className="flex h-full min-h-0 flex-col bg-white">
|
|
195
|
+
{/* fields / placeholders:zh/menus/model-metadata.ts */}
|
|
196
|
+
<div className="flex flex-col gap-3">
|
|
197
|
+
<div className="grid grid-cols-2 gap-4">
|
|
198
|
+
{/* 主题 */}
|
|
199
|
+
<CxFormItem label={t('menus.model_metadata.manage.fields.subject')} name="subject">
|
|
200
|
+
<CxInput placeholder={t('menus.model_metadata.manage.placeholders.subject')} />
|
|
201
|
+
</CxFormItem>
|
|
202
|
+
{/* 数据库名 */}
|
|
203
|
+
<CxFormItem label={t('menus.model_metadata.manage.fields.databaseName')} name="databaseName">
|
|
204
|
+
<CxInput placeholder={t('menus.model_metadata.manage.placeholders.databaseName')} />
|
|
205
|
+
</CxFormItem>
|
|
206
|
+
</div>
|
|
207
|
+
<div className="grid grid-cols-2 gap-4">
|
|
208
|
+
{/* 库类型 */}
|
|
209
|
+
<CxFormItem label={t('menus.model_metadata.manage.fields.dbType')} name="dbType">
|
|
210
|
+
<CxSelect
|
|
211
|
+
placeholder={t('menus.model_metadata.manage.placeholders.dbType')}
|
|
212
|
+
options={dbTypeOptions}
|
|
213
|
+
fieldNames={{ label: 'name', value: 'value' }}
|
|
214
|
+
/>
|
|
215
|
+
</CxFormItem>
|
|
216
|
+
{/* 字符集 */}
|
|
217
|
+
<CxFormItem label={t('menus.model_metadata.manage.fields.charsetName')} name="charsetName">
|
|
218
|
+
<CxSelect
|
|
219
|
+
allowClear
|
|
220
|
+
placeholder={t('menus.model_metadata.manage.placeholders.charsetName')}
|
|
221
|
+
options={ENUM_DATA.dbCharset.option}
|
|
222
|
+
/>
|
|
223
|
+
</CxFormItem>
|
|
224
|
+
</div>
|
|
225
|
+
<div className="grid grid-cols-4 gap-4">
|
|
226
|
+
{/* 主机 */}
|
|
227
|
+
<CxFormItem className="col-span-3" label={t('menus.model_metadata.manage.fields.host')} name="host">
|
|
228
|
+
<CxInput placeholder={t('menus.model_metadata.manage.placeholders.host')} />
|
|
229
|
+
</CxFormItem>
|
|
230
|
+
{/* 端口 */}
|
|
231
|
+
<CxFormItem label={t('menus.model_metadata.manage.fields.port')} name="port">
|
|
232
|
+
<CxInput placeholder={t('menus.model_metadata.manage.placeholders.port')} />
|
|
233
|
+
</CxFormItem>
|
|
234
|
+
</div>
|
|
235
|
+
<div className="grid grid-cols-4 gap-4">
|
|
236
|
+
{/* Schema */}
|
|
237
|
+
<CxFormItem className="col-span-4" label={t('menus.model_metadata.manage.fields.dbSchema')} name="dbSchema">
|
|
238
|
+
<CxInput placeholder={t('menus.model_metadata.manage.placeholders.dbSchema')} />
|
|
239
|
+
</CxFormItem>
|
|
240
|
+
</div>
|
|
241
|
+
<div className="grid grid-cols-4 gap-4">
|
|
242
|
+
{/* 用户名 */}
|
|
243
|
+
<CxFormItem className="col-span-2" label={t('menus.model_metadata.manage.fields.username')} name="username">
|
|
244
|
+
<CxInput placeholder={t('menus.model_metadata.manage.placeholders.username')} />
|
|
245
|
+
</CxFormItem>
|
|
246
|
+
{/* 密码 */}
|
|
247
|
+
<CxFormItem className="col-span-2" label={t('menus.model_metadata.manage.fields.password')} name="password">
|
|
248
|
+
<CxInput type="password" autoComplete="new-password" placeholder={t('menus.model_metadata.manage.placeholders.password')} />
|
|
249
|
+
</CxFormItem>
|
|
250
|
+
</div>
|
|
251
|
+
{/* 配置 JSON */}
|
|
252
|
+
<CxFormItem label={t('menus.model_metadata.manage.fields.optionsJson')} name="optionsJson">
|
|
253
|
+
<CxInput.Textarea rows={4} placeholder={t('menus.model_metadata.manage.placeholders.optionsJson')} />
|
|
254
|
+
</CxFormItem>
|
|
255
|
+
</div>
|
|
256
|
+
</CxForm>
|
|
257
|
+
</CxModal>
|
|
258
|
+
)
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
export default SubmitModal
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { CxModalRef } from '@cx-ui/modal/useCxModal'
|
|
2
|
+
import { useCxModal } from '@cx-ui/modal/useCxModal'
|
|
3
|
+
import { CxModal, CxTable, CxTabs } from '@cx-ui'
|
|
4
|
+
import { Form } from 'antd'
|
|
5
|
+
import { forwardRef, useImperativeHandle, useState } from 'react'
|
|
6
|
+
import { useTranslation } from 'react-i18next'
|
|
7
|
+
import {
|
|
8
|
+
TABLE_SUBMIT_MODAL_WIDTH,
|
|
9
|
+
clonePart,
|
|
10
|
+
normalizeForeignKeyColumnsInput,
|
|
11
|
+
normalizeIndexColumnsInput,
|
|
12
|
+
tableSubmitModalShellStyles,
|
|
13
|
+
} from './components/table-schema'
|
|
14
|
+
import type { Column, ForeignKey, Index, TableDetail } from './components/table-schema'
|
|
15
|
+
import { useTableDetailTabs } from './components/use-table-detail-tabs'
|
|
16
|
+
|
|
17
|
+
const TableDetailModal = forwardRef<CxModalRef, {}>(function TableDetailModal(_props, ref) {
|
|
18
|
+
const { t } = useTranslation()
|
|
19
|
+
const [activeTab, setActiveTab] = useState('columns')
|
|
20
|
+
const [viewColumns, setViewColumns] = useState<Column[]>([])
|
|
21
|
+
const [viewIndexes, setViewIndexes] = useState<Index[]>([])
|
|
22
|
+
const [viewForeignKeys, setViewForeignKeys] = useState<ForeignKey[]>([])
|
|
23
|
+
const [headerSnapshot, setHeaderSnapshot] = useState<{
|
|
24
|
+
tableSchema?: string
|
|
25
|
+
tableName?: string
|
|
26
|
+
tableComment?: string
|
|
27
|
+
tableType?: string
|
|
28
|
+
}>({})
|
|
29
|
+
|
|
30
|
+
const { columnsTabColumns, indexesTabColumns, foreignKeysTabColumns } = useTableDetailTabs({ t })
|
|
31
|
+
|
|
32
|
+
const modal = useCxModal({
|
|
33
|
+
onOpen: (payload: any) => {
|
|
34
|
+
setActiveTab('columns')
|
|
35
|
+
if (payload.data) {
|
|
36
|
+
modal.setFormData(payload.data)
|
|
37
|
+
setViewColumns(clonePart(payload.data.columns || []))
|
|
38
|
+
setViewIndexes(
|
|
39
|
+
(clonePart(payload.data.indexes || []) as Index[]).map((idx) => ({
|
|
40
|
+
...idx,
|
|
41
|
+
indexColumns: normalizeIndexColumnsInput(idx.indexColumns),
|
|
42
|
+
})),
|
|
43
|
+
)
|
|
44
|
+
setViewForeignKeys(
|
|
45
|
+
(clonePart(payload.data.foreignKeys || []) as ForeignKey[]).map((fk) => ({
|
|
46
|
+
...fk,
|
|
47
|
+
fkColumns: normalizeForeignKeyColumnsInput(fk.fkColumns),
|
|
48
|
+
})),
|
|
49
|
+
)
|
|
50
|
+
setHeaderSnapshot({
|
|
51
|
+
tableSchema: payload.data.tableSchema,
|
|
52
|
+
tableName: payload.data.tableName,
|
|
53
|
+
tableComment: payload.data.tableComment,
|
|
54
|
+
tableType: payload.data.tableType,
|
|
55
|
+
})
|
|
56
|
+
} else {
|
|
57
|
+
setViewColumns([])
|
|
58
|
+
setViewIndexes([])
|
|
59
|
+
setViewForeignKeys([])
|
|
60
|
+
setHeaderSnapshot({})
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const { isOpen, close, open } = modal
|
|
66
|
+
const data = modal.formData as TableDetail | null
|
|
67
|
+
const modalTitle = `${t('common.view')}: ${data?.tableName || headerSnapshot.tableName || ''}`
|
|
68
|
+
|
|
69
|
+
useImperativeHandle(
|
|
70
|
+
ref,
|
|
71
|
+
() => ({
|
|
72
|
+
open,
|
|
73
|
+
close,
|
|
74
|
+
}),
|
|
75
|
+
[open, close],
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
const tabItems = [
|
|
79
|
+
{
|
|
80
|
+
key: 'columns',
|
|
81
|
+
label: `${t('menus.model_metadata.manage.tab_columns')} (${viewColumns.length})`,
|
|
82
|
+
children: (
|
|
83
|
+
<div className="flex h-full min-h-0 flex-col">
|
|
84
|
+
<div className="min-h-0 flex-1 overflow-hidden rounded border border-gray-200 dark:border-gray-700">
|
|
85
|
+
<CxTable<Column>
|
|
86
|
+
size="mini"
|
|
87
|
+
autoScrollY
|
|
88
|
+
minScrollY={120}
|
|
89
|
+
columns={columnsTabColumns}
|
|
90
|
+
dataSource={viewColumns}
|
|
91
|
+
rowKey={(_, index) => String(index)}
|
|
92
|
+
scroll={{ x: 844 }}
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
),
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
key: 'indexes',
|
|
100
|
+
label: `${t('menus.model_metadata.manage.tab_indexes')} (${viewIndexes.length})`,
|
|
101
|
+
children: (
|
|
102
|
+
<div className="flex h-full min-h-0 flex-col">
|
|
103
|
+
<div className="min-h-0 flex-1 overflow-hidden rounded border border-gray-200 dark:border-gray-700">
|
|
104
|
+
<CxTable<Index>
|
|
105
|
+
size="mini"
|
|
106
|
+
autoScrollY
|
|
107
|
+
minScrollY={120}
|
|
108
|
+
columns={indexesTabColumns}
|
|
109
|
+
dataSource={viewIndexes}
|
|
110
|
+
rowKey={(_, index) => String(index)}
|
|
111
|
+
scroll={{ x: 800 }}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
key: 'foreignKeys',
|
|
119
|
+
label: `${t('menus.model_metadata.manage.tab_foreignKeys')} (${viewForeignKeys.length})`,
|
|
120
|
+
children: (
|
|
121
|
+
<div className="flex h-full min-h-0 flex-col">
|
|
122
|
+
<div className="min-h-0 flex-1 overflow-hidden rounded border border-gray-200 dark:border-gray-700">
|
|
123
|
+
<CxTable<ForeignKey>
|
|
124
|
+
size="mini"
|
|
125
|
+
autoScrollY
|
|
126
|
+
minScrollY={120}
|
|
127
|
+
columns={foreignKeysTabColumns}
|
|
128
|
+
dataSource={viewForeignKeys}
|
|
129
|
+
rowKey={(_, index) => String(index)}
|
|
130
|
+
scroll={{ x: 1108 }}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
),
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<CxModal
|
|
140
|
+
title={modalTitle}
|
|
141
|
+
isOpen={isOpen}
|
|
142
|
+
onClose={close}
|
|
143
|
+
opeType="detail"
|
|
144
|
+
modalConfig={{
|
|
145
|
+
width: TABLE_SUBMIT_MODAL_WIDTH,
|
|
146
|
+
styles: { ...tableSubmitModalShellStyles },
|
|
147
|
+
rootClassName: 'cx-modal-content-fill scroll',
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<div className="flex h-full min-h-0 flex-1 flex-col gap-0 overflow-hidden">
|
|
151
|
+
<div className="shrink-0 border-b border-gray-200 pb-4 dark:border-gray-700">
|
|
152
|
+
<Form layout="horizontal" colon className="w-full">
|
|
153
|
+
<div className="grid grid-cols-1 gap-x-4 gap-y-2 md:grid-cols-3">
|
|
154
|
+
<Form.Item label={t('menus.model_metadata.manage.fields.tableSchema')} className="!mb-0">
|
|
155
|
+
<div className="text-sm text-gray-900 dark:text-gray-100">
|
|
156
|
+
{headerSnapshot.tableSchema ?? '—'}
|
|
157
|
+
</div>
|
|
158
|
+
</Form.Item>
|
|
159
|
+
<Form.Item label={t('menus.model_metadata.manage.fields.tableName')} className="!mb-0">
|
|
160
|
+
<div className="text-sm text-gray-900 dark:text-gray-100">
|
|
161
|
+
{headerSnapshot.tableName ?? '—'}
|
|
162
|
+
</div>
|
|
163
|
+
</Form.Item>
|
|
164
|
+
<Form.Item label={t('menus.model_metadata.manage.fields.tableType')} className="!mb-0">
|
|
165
|
+
<div className="text-sm text-gray-900 dark:text-gray-100">
|
|
166
|
+
{headerSnapshot.tableType ?? '—'}
|
|
167
|
+
</div>
|
|
168
|
+
</Form.Item>
|
|
169
|
+
<Form.Item
|
|
170
|
+
label={t('menus.model_metadata.manage.fields.tableComment')}
|
|
171
|
+
className="!mb-0 md:col-span-3"
|
|
172
|
+
>
|
|
173
|
+
<div className="text-sm text-gray-900 dark:text-gray-100">
|
|
174
|
+
{headerSnapshot.tableComment ?? '—'}
|
|
175
|
+
</div>
|
|
176
|
+
</Form.Item>
|
|
177
|
+
</div>
|
|
178
|
+
</Form>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div className="flex min-h-0 flex-1 flex-col overflow-hidden pt-4">
|
|
182
|
+
<CxTabs
|
|
183
|
+
activeKey={activeTab}
|
|
184
|
+
onChange={setActiveTab}
|
|
185
|
+
items={tabItems}
|
|
186
|
+
className="flex min-h-0 flex-1 flex-col [&_.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-tabpane]:h-full"
|
|
187
|
+
/>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</CxModal>
|
|
191
|
+
)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
TableDetailModal.displayName = 'TableDetailModal'
|
|
195
|
+
|
|
196
|
+
export default TableDetailModal
|