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,134 @@
|
|
|
1
|
+
import { CxButton, CxInput, CxTable } from '@cx-ui'
|
|
2
|
+
import { Plus } from 'lucide-react'
|
|
3
|
+
import { useTranslation } from 'react-i18next'
|
|
4
|
+
|
|
5
|
+
type Document = {
|
|
6
|
+
id?: string
|
|
7
|
+
name: string
|
|
8
|
+
code: string
|
|
9
|
+
description: string
|
|
10
|
+
text: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Step4DocumentsProps = {
|
|
14
|
+
documents: Document[]
|
|
15
|
+
onDocumentsChange: (documents: Document[]) => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default function Step4Documents({ documents, onDocumentsChange }: Step4DocumentsProps) {
|
|
19
|
+
const { t } = useTranslation()
|
|
20
|
+
|
|
21
|
+
const handleAdd = () => {
|
|
22
|
+
onDocumentsChange([
|
|
23
|
+
...documents,
|
|
24
|
+
{ name: '', code: '', description: '', text: '' },
|
|
25
|
+
])
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const handleDelete = (index: number) => {
|
|
29
|
+
onDocumentsChange(documents.filter((_, i) => i !== index))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const handleChange = (index: number, field: keyof Document, value: string) => {
|
|
33
|
+
const next = [...documents]
|
|
34
|
+
next[index] = { ...next[index], [field]: value }
|
|
35
|
+
onDocumentsChange(next)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const columns = [
|
|
39
|
+
{
|
|
40
|
+
title: t('menus.model_metadata.manage.fields.docName'),
|
|
41
|
+
key: 'name',
|
|
42
|
+
width: 150,
|
|
43
|
+
render: (_: unknown, __: Document, index: number) => (
|
|
44
|
+
<div className="min-w-0 max-w-full">
|
|
45
|
+
<CxInput
|
|
46
|
+
className="w-full min-w-0"
|
|
47
|
+
value={documents[index].name}
|
|
48
|
+
onChange={(e) => handleChange(index, 'name', e.target.value)}
|
|
49
|
+
placeholder={t('menus.model_metadata.manage.placeholders.docName')}
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: t('menus.model_metadata.manage.fields.docCode'),
|
|
56
|
+
key: 'code',
|
|
57
|
+
width: 150,
|
|
58
|
+
render: (_: unknown, __: Document, index: number) => (
|
|
59
|
+
<div className="min-w-0 max-w-full">
|
|
60
|
+
<CxInput
|
|
61
|
+
className="w-full min-w-0"
|
|
62
|
+
value={documents[index].code}
|
|
63
|
+
onChange={(e) => handleChange(index, 'code', e.target.value)}
|
|
64
|
+
placeholder={t('menus.model_metadata.manage.placeholders.docCode')}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
title: t('menus.model_metadata.manage.fields.docDescription'),
|
|
71
|
+
key: 'description',
|
|
72
|
+
ellipsis: true,
|
|
73
|
+
minWidth: 180,
|
|
74
|
+
render: (_: unknown, __: Document, index: number) => (
|
|
75
|
+
<div className="min-w-0 max-w-full">
|
|
76
|
+
<CxInput
|
|
77
|
+
className="w-full min-w-0"
|
|
78
|
+
value={documents[index].description}
|
|
79
|
+
onChange={(e) => handleChange(index, 'description', e.target.value)}
|
|
80
|
+
placeholder={t('menus.model_metadata.manage.placeholders.docDescription')}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
),
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
title: t('menus.model_metadata.manage.fields.docText'),
|
|
87
|
+
key: 'text',
|
|
88
|
+
ellipsis: true,
|
|
89
|
+
minWidth: 220,
|
|
90
|
+
render: (_: unknown, __: Document, index: number) => (
|
|
91
|
+
<div className="min-w-0 max-w-full">
|
|
92
|
+
<CxInput.Textarea
|
|
93
|
+
className="w-full min-w-0"
|
|
94
|
+
value={documents[index].text}
|
|
95
|
+
onChange={(e) => handleChange(index, 'text', e.target.value)}
|
|
96
|
+
placeholder={t('menus.model_metadata.manage.placeholders.docText')}
|
|
97
|
+
rows={2}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
title: t('common.actions'),
|
|
104
|
+
key: 'action',
|
|
105
|
+
width: 80,
|
|
106
|
+
render: (_: unknown, __: Document, index: number) => (
|
|
107
|
+
<CxButton.IconDelete onClick={() => handleDelete(index)} />
|
|
108
|
+
),
|
|
109
|
+
},
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div className="flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden">
|
|
114
|
+
<div className="mb-4 flex w-full min-w-0 shrink-0 items-center justify-between">
|
|
115
|
+
<h3 className="text-base font-medium">{t('menus.model_metadata.manage.documents')}</h3>
|
|
116
|
+
<CxButton type="primary" onClick={handleAdd} icon={<Plus size={16} />}>
|
|
117
|
+
{t('menus.model_metadata.manage.add_document')}
|
|
118
|
+
</CxButton>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<div className="min-h-0 w-full min-w-0 flex-1 overflow-hidden">
|
|
122
|
+
<CxTable
|
|
123
|
+
className="min-w-0 w-full"
|
|
124
|
+
autoScrollY
|
|
125
|
+
minScrollY={160}
|
|
126
|
+
columns={columns}
|
|
127
|
+
dataSource={documents.map((doc, index) => ({ ...doc, key: index }))}
|
|
128
|
+
pagination={false}
|
|
129
|
+
scroll={{ x: true }}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { CxButton, CxInput, CxTable } from '@cx-ui'
|
|
2
|
+
import { Plus } from 'lucide-react'
|
|
3
|
+
import { useTranslation } from 'react-i18next'
|
|
4
|
+
|
|
5
|
+
type ExampleSql = {
|
|
6
|
+
id?: string
|
|
7
|
+
exampleSql: string
|
|
8
|
+
description: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Step5ExampleSqlProps = {
|
|
12
|
+
exampleSqlList: ExampleSql[]
|
|
13
|
+
onExampleSqlListChange: (list: ExampleSql[]) => void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function Step5ExampleSql({
|
|
17
|
+
exampleSqlList,
|
|
18
|
+
onExampleSqlListChange,
|
|
19
|
+
}: Step5ExampleSqlProps) {
|
|
20
|
+
const { t } = useTranslation()
|
|
21
|
+
|
|
22
|
+
const handleAdd = () => {
|
|
23
|
+
onExampleSqlListChange([...exampleSqlList, { exampleSql: '', description: '' }])
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const handleDelete = (index: number) => {
|
|
27
|
+
onExampleSqlListChange(exampleSqlList.filter((_, i) => i !== index))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const handleChange = (index: number, field: keyof ExampleSql, value: string) => {
|
|
31
|
+
const next = [...exampleSqlList]
|
|
32
|
+
next[index] = { ...next[index], [field]: value }
|
|
33
|
+
onExampleSqlListChange(next)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const columns = [
|
|
37
|
+
{
|
|
38
|
+
title: t('menus.model_metadata.manage.fields.exampleSql'),
|
|
39
|
+
key: 'exampleSql',
|
|
40
|
+
minWidth: 280,
|
|
41
|
+
render: (_: unknown, __: ExampleSql, index: number) => (
|
|
42
|
+
<div className="min-w-0 max-w-full">
|
|
43
|
+
<CxInput.Textarea
|
|
44
|
+
className="w-full min-w-0"
|
|
45
|
+
value={exampleSqlList[index].exampleSql}
|
|
46
|
+
onChange={(e) => handleChange(index, 'exampleSql', e.target.value)}
|
|
47
|
+
placeholder={t('menus.model_metadata.manage.placeholders.exampleSql')}
|
|
48
|
+
rows={3}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
),
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: t('menus.model_metadata.manage.fields.exampleSqlDescription'),
|
|
55
|
+
key: 'description',
|
|
56
|
+
width: 250,
|
|
57
|
+
minWidth: 200,
|
|
58
|
+
render: (_: unknown, __: ExampleSql, index: number) => (
|
|
59
|
+
<div className="min-w-0 max-w-full">
|
|
60
|
+
<CxInput
|
|
61
|
+
className="w-full min-w-0"
|
|
62
|
+
value={exampleSqlList[index].description}
|
|
63
|
+
onChange={(e) => handleChange(index, 'description', e.target.value)}
|
|
64
|
+
placeholder={t('menus.model_metadata.manage.placeholders.exampleSqlDescription')}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
title: t('common.actions'),
|
|
71
|
+
key: 'action',
|
|
72
|
+
width: 80,
|
|
73
|
+
render: (_: unknown, __: ExampleSql, index: number) => (
|
|
74
|
+
<CxButton.IconDelete onClick={() => handleDelete(index)} />
|
|
75
|
+
),
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div className="flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden">
|
|
81
|
+
<div className="mb-4 flex w-full min-w-0 shrink-0 items-center justify-between">
|
|
82
|
+
<h3 className="text-base font-medium">{t('menus.model_metadata.manage.exampleSqlList')}</h3>
|
|
83
|
+
<CxButton type="primary" onClick={handleAdd} icon={<Plus size={16} />}>
|
|
84
|
+
{t('menus.model_metadata.manage.add_example_sql')}
|
|
85
|
+
</CxButton>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<div className="min-h-0 w-full min-w-0 flex-1 overflow-hidden">
|
|
89
|
+
<CxTable
|
|
90
|
+
className="min-w-0 w-full"
|
|
91
|
+
autoScrollY
|
|
92
|
+
minScrollY={160}
|
|
93
|
+
columns={columns}
|
|
94
|
+
dataSource={exampleSqlList.map((sql, index) => ({ ...sql, key: index }))}
|
|
95
|
+
pagination={false}
|
|
96
|
+
scroll={{ x: true }}
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { useToast } from '@/contexts/ToastContext'
|
|
2
|
+
import { useAuth } from '@/contexts/AuthContext'
|
|
3
|
+
import { useModalSubmit } from '@/hooks/useModalSubmit'
|
|
4
|
+
import { useStepForm } from '@/hooks/useStepForm'
|
|
5
|
+
import { addModelMetadataAPI, testConnectionAPI } from '@api/menus/model-metadata/manage'
|
|
6
|
+
import {
|
|
7
|
+
buildModelMetadataPayloadParts,
|
|
8
|
+
validateAddBasicFieldsPresent,
|
|
9
|
+
validateDocumentsForSubmit,
|
|
10
|
+
validateModelMetadataItemDetail,
|
|
11
|
+
validatePermissionsForSubmit,
|
|
12
|
+
} from '../hooks/model-metadata-submit-shared'
|
|
13
|
+
import { useModelMetadataItemState } from '../hooks/use-model-metadata-item-state'
|
|
14
|
+
import { CxButton, CxSteps } from '@cx-ui'
|
|
15
|
+
import { CheckCircle2, ChevronLeft, Database } from 'lucide-react'
|
|
16
|
+
import { useCallback, useEffect, useRef, useState } from 'react'
|
|
17
|
+
import { useTranslation } from 'react-i18next'
|
|
18
|
+
import { useNavigate } from 'react-router-dom'
|
|
19
|
+
|
|
20
|
+
import Step1BasicInfo, {
|
|
21
|
+
type Step1BasicInfoHandle,
|
|
22
|
+
modelMetadataConnectionDigest,
|
|
23
|
+
} from './step1-basic-info'
|
|
24
|
+
import Step2Schema from './step2-schema'
|
|
25
|
+
import Step3Permissions from './step3-permissions'
|
|
26
|
+
import Step4Documents from './step4-documents'
|
|
27
|
+
import Step5ExampleSql from './step5-example-sql'
|
|
28
|
+
|
|
29
|
+
// 步骤条 i18n → locales/zh/menus/model-metadata/manage.ts
|
|
30
|
+
const steps = [
|
|
31
|
+
{
|
|
32
|
+
title: 'menus.model_metadata.manage.step1_title',
|
|
33
|
+
description: 'menus.model_metadata.manage.step1_description',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: 'menus.model_metadata.manage.step2_title',
|
|
37
|
+
description: 'menus.model_metadata.manage.step2_description',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'menus.model_metadata.manage.step3_title',
|
|
41
|
+
description: 'menus.model_metadata.manage.step3_description',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'menus.model_metadata.manage.step4_title',
|
|
45
|
+
description: 'menus.model_metadata.manage.step4_description',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: 'menus.model_metadata.manage.step5_title',
|
|
49
|
+
description: 'menus.model_metadata.manage.step5_description',
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
function ModelMetadataSubmitAddView() {
|
|
54
|
+
const { showToast } = useToast()
|
|
55
|
+
const { hasPermission } = useAuth()
|
|
56
|
+
const { t } = useTranslation()
|
|
57
|
+
const navigate = useNavigate()
|
|
58
|
+
|
|
59
|
+
const { submitting, handleSubmit } = useModalSubmit()
|
|
60
|
+
|
|
61
|
+
const step1Ref = useRef<Step1BasicInfoHandle>(null)
|
|
62
|
+
const verifiedConnectionDigestRef = useRef<string | null>(null)
|
|
63
|
+
const [basicFields, setBasicFields] = useState<Record<string, any>>({})
|
|
64
|
+
const [schemaPreviewNonce, setSchemaPreviewNonce] = useState(0)
|
|
65
|
+
const {
|
|
66
|
+
tables,
|
|
67
|
+
setTables,
|
|
68
|
+
permissions,
|
|
69
|
+
setPermissions,
|
|
70
|
+
documents,
|
|
71
|
+
setDocuments,
|
|
72
|
+
exampleSqlList,
|
|
73
|
+
setExampleSqlList,
|
|
74
|
+
} = useModelMetadataItemState()
|
|
75
|
+
|
|
76
|
+
const {
|
|
77
|
+
current,
|
|
78
|
+
setCurrent,
|
|
79
|
+
connectionTested,
|
|
80
|
+
setConnectionTested,
|
|
81
|
+
testingConnection,
|
|
82
|
+
setTestingConnection,
|
|
83
|
+
} = useStepForm()
|
|
84
|
+
|
|
85
|
+
const handleConnectionDigestChange = useCallback(
|
|
86
|
+
(digest: string) => {
|
|
87
|
+
const verified = verifiedConnectionDigestRef.current
|
|
88
|
+
if (verified !== null && digest !== verified) {
|
|
89
|
+
setConnectionTested(false)
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[setConnectionTested],
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
setPermissions([
|
|
97
|
+
{ permissionName: '用户', permissionColumns: [] },
|
|
98
|
+
{ permissionName: '组织', permissionColumns: [] },
|
|
99
|
+
])
|
|
100
|
+
}, [])
|
|
101
|
+
|
|
102
|
+
const handleBack = () => {
|
|
103
|
+
navigate(-1)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const next = async () => {
|
|
107
|
+
try {
|
|
108
|
+
if (current === 0) {
|
|
109
|
+
const values = await step1Ref.current?.validateForNext()
|
|
110
|
+
if (!values) return
|
|
111
|
+
if (hasPermission('model-metadata:test') && !connectionTested) {
|
|
112
|
+
showToast(t('menus.model_metadata.manage.test_connection_required'), 'warning') // 须先测连接
|
|
113
|
+
return
|
|
114
|
+
}
|
|
115
|
+
setBasicFields(values)
|
|
116
|
+
setSchemaPreviewNonce((n) => n + 1)
|
|
117
|
+
} else if (current === 2) {
|
|
118
|
+
const permErr = validatePermissionsForSubmit(permissions)
|
|
119
|
+
if (permErr) {
|
|
120
|
+
showToast(t(`menus.model_metadata.manage.rules.${permErr}`), 'warning')
|
|
121
|
+
return
|
|
122
|
+
}
|
|
123
|
+
} else if (current === 3) {
|
|
124
|
+
const docErr = validateDocumentsForSubmit(documents)
|
|
125
|
+
if (docErr) {
|
|
126
|
+
showToast(t(`menus.model_metadata.manage.rules.${docErr}`), 'warning')
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
setCurrent(current + 1)
|
|
131
|
+
} catch {
|
|
132
|
+
showToast(t('common.form_validation_warning'), 'error')
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const handleTestConnection = async () => {
|
|
137
|
+
try {
|
|
138
|
+
await step1Ref.current?.validateForConnectionTest()
|
|
139
|
+
setTestingConnection(true)
|
|
140
|
+
const payload = step1Ref.current?.getConnectionTestPayload()
|
|
141
|
+
await testConnectionAPI(payload)
|
|
142
|
+
verifiedConnectionDigestRef.current = modelMetadataConnectionDigest(payload)
|
|
143
|
+
setConnectionTested(true)
|
|
144
|
+
showToast(t('menus.model_metadata.manage.connection_test_success'), 'success') // 连接测试成功
|
|
145
|
+
} catch (error: any) {
|
|
146
|
+
console.error('Connection test failed:', error)
|
|
147
|
+
setConnectionTested(false)
|
|
148
|
+
verifiedConnectionDigestRef.current = null
|
|
149
|
+
showToast(error?.message || t('menus.model_metadata.manage.connection_test_failed'), 'error') // 连接测试失败
|
|
150
|
+
} finally {
|
|
151
|
+
setTestingConnection(false)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const prev = () => {
|
|
156
|
+
setCurrent(current - 1)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const onSubmit = async () => {
|
|
160
|
+
if (!validateAddBasicFieldsPresent(basicFields)) {
|
|
161
|
+
showToast(t('common.form_validation_warning'), 'error')
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const detailErr = validateModelMetadataItemDetail({
|
|
166
|
+
tables,
|
|
167
|
+
permissions,
|
|
168
|
+
documents,
|
|
169
|
+
exampleSqlList,
|
|
170
|
+
})
|
|
171
|
+
if (detailErr) {
|
|
172
|
+
showToast(t(`menus.model_metadata.manage.rules.${detailErr}`), 'warning')
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const { tablesPayload, permissionsPayload, documents: docOut, exampleSqlList: sqlOut } =
|
|
177
|
+
buildModelMetadataPayloadParts({
|
|
178
|
+
tables,
|
|
179
|
+
permissions,
|
|
180
|
+
documents,
|
|
181
|
+
exampleSqlList,
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const body = {
|
|
185
|
+
...basicFields,
|
|
186
|
+
tables: tablesPayload,
|
|
187
|
+
permissions: permissionsPayload,
|
|
188
|
+
documents: docOut,
|
|
189
|
+
exampleSqlList: sqlOut,
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
await handleSubmit({
|
|
193
|
+
opeType: 'add',
|
|
194
|
+
validate: async () => body,
|
|
195
|
+
addAPI: addModelMetadataAPI,
|
|
196
|
+
successMessage: {
|
|
197
|
+
add: t('common.add_success'),
|
|
198
|
+
},
|
|
199
|
+
onSuccess: async () => {
|
|
200
|
+
navigate(-1)
|
|
201
|
+
},
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const renderStepContent = () => {
|
|
206
|
+
switch (current) {
|
|
207
|
+
case 0:
|
|
208
|
+
return (
|
|
209
|
+
<Step1BasicInfo
|
|
210
|
+
ref={step1Ref}
|
|
211
|
+
initialValues={basicFields}
|
|
212
|
+
onConnectionDigestChange={handleConnectionDigestChange}
|
|
213
|
+
/>
|
|
214
|
+
)
|
|
215
|
+
case 1:
|
|
216
|
+
return (
|
|
217
|
+
<Step2Schema
|
|
218
|
+
connectionParams={basicFields}
|
|
219
|
+
tables={tables}
|
|
220
|
+
onTablesChange={setTables}
|
|
221
|
+
isEdit={false}
|
|
222
|
+
currentStep={current}
|
|
223
|
+
previewNonce={schemaPreviewNonce}
|
|
224
|
+
/>
|
|
225
|
+
)
|
|
226
|
+
case 2:
|
|
227
|
+
return (
|
|
228
|
+
<Step3Permissions
|
|
229
|
+
permissions={permissions}
|
|
230
|
+
onPermissionsChange={setPermissions}
|
|
231
|
+
tables={tables}
|
|
232
|
+
/>
|
|
233
|
+
)
|
|
234
|
+
case 3:
|
|
235
|
+
return <Step4Documents documents={documents} onDocumentsChange={setDocuments} />
|
|
236
|
+
case 4:
|
|
237
|
+
return (
|
|
238
|
+
<Step5ExampleSql
|
|
239
|
+
exampleSqlList={exampleSqlList}
|
|
240
|
+
onExampleSqlListChange={setExampleSqlList}
|
|
241
|
+
/>
|
|
242
|
+
)
|
|
243
|
+
default:
|
|
244
|
+
return null
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<div className="flex h-full flex-col bg-white">
|
|
250
|
+
{/* 顶部:与知识库文档页 ListPageView 标题区一致(无副标题) */}
|
|
251
|
+
<div className="shrink-0 bg-white px-6 pb-3 pt-6">
|
|
252
|
+
<div className="flex items-center justify-between">
|
|
253
|
+
<div className="flex min-w-0 flex-1 items-center gap-3">
|
|
254
|
+
<CxButton.Icon
|
|
255
|
+
className="!p-2.5 shrink-0 rounded-lg border border-solid border-gray-300 bg-white shadow-sm"
|
|
256
|
+
type="default"
|
|
257
|
+
icon={<ChevronLeft size={22} strokeWidth={2.25} />}
|
|
258
|
+
onClick={handleBack}
|
|
259
|
+
title={t('common.back')}
|
|
260
|
+
tooltipTone="default"
|
|
261
|
+
/>
|
|
262
|
+
<h1 className="flex min-w-0 flex-wrap items-center gap-3 text-3xl font-bold text-transparent bg-gradient-to-r from-blue-400 to-purple-500 bg-clip-text">
|
|
263
|
+
<Database className="shrink-0 text-blue-400" size={32} aria-hidden />
|
|
264
|
+
<span className="min-w-0">{t('menus.model_metadata.manage.add')}</span>
|
|
265
|
+
{/* i18n:edit / add */}
|
|
266
|
+
</h1>
|
|
267
|
+
</div>
|
|
268
|
+
</div>
|
|
269
|
+
</div>
|
|
270
|
+
|
|
271
|
+
<div className="shrink-0 bg-white px-6 pb-1.5 pt-0">
|
|
272
|
+
<CxSteps
|
|
273
|
+
current={current}
|
|
274
|
+
items={steps.map((step, index) => ({
|
|
275
|
+
title: t(step.title),
|
|
276
|
+
description: t(step.description),
|
|
277
|
+
status: index < current ? 'finish' : index === current ? 'process' : 'wait',
|
|
278
|
+
}))}
|
|
279
|
+
className="[&_.ant-steps-item]:!pb-0 [&_.ant-steps-item-title]:!text-[13px] [&_.ant-steps-item-title]:!leading-snug [&_.ant-steps-item-description]:!mt-0.5 [&_.ant-steps-item-description]:!text-xs [&_.ant-steps-item-description]:!leading-snug"
|
|
280
|
+
/>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<div
|
|
284
|
+
className={
|
|
285
|
+
current >= 1 && current <= 4
|
|
286
|
+
? 'flex min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden bg-white px-5 py-4'
|
|
287
|
+
: 'flex-1 overflow-auto bg-white px-5 py-4'
|
|
288
|
+
}
|
|
289
|
+
>
|
|
290
|
+
<div
|
|
291
|
+
className={
|
|
292
|
+
current >= 1 && current <= 4
|
|
293
|
+
? 'mx-auto flex h-full min-h-0 w-full max-w-6xl flex-1 flex-col rounded-lg bg-white p-4'
|
|
294
|
+
: 'mx-auto max-w-6xl rounded-lg bg-white p-4'
|
|
295
|
+
}
|
|
296
|
+
>
|
|
297
|
+
{renderStepContent()}
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<div className="shrink-0 border-t border-gray-200 bg-white px-5 py-3">
|
|
302
|
+
<div className="mx-auto flex max-w-6xl justify-between">
|
|
303
|
+
<div>
|
|
304
|
+
<CxButton onClick={handleBack}>{t('common.cancel')}</CxButton>
|
|
305
|
+
</div>
|
|
306
|
+
<div className="flex gap-3">
|
|
307
|
+
{current > 0 && (
|
|
308
|
+
<CxButton onClick={prev}>{t('common.prev_step')}</CxButton>
|
|
309
|
+
)}
|
|
310
|
+
{current === 0 && hasPermission('model-metadata:test') && (
|
|
311
|
+
<CxButton
|
|
312
|
+
type={connectionTested ? 'primary' : 'default'}
|
|
313
|
+
loading={testingConnection}
|
|
314
|
+
icon={connectionTested ? <CheckCircle2 size={16} /> : undefined}
|
|
315
|
+
onClick={handleTestConnection}
|
|
316
|
+
>
|
|
317
|
+
{connectionTested
|
|
318
|
+
? t('menus.model_metadata.manage.connection_tested') // 已测试连接
|
|
319
|
+
: t('menus.model_metadata.manage.test_connection')} {/* 测试连接 */}
|
|
320
|
+
</CxButton>
|
|
321
|
+
)}
|
|
322
|
+
{current < steps.length - 1 ? (
|
|
323
|
+
<CxButton type="primary" onClick={next}>
|
|
324
|
+
{t('common.next')}
|
|
325
|
+
</CxButton>
|
|
326
|
+
) : (
|
|
327
|
+
<CxButton type="primary" loading={submitting} onClick={() => void onSubmit()}>
|
|
328
|
+
{t('common.submit')}
|
|
329
|
+
</CxButton>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export default ModelMetadataSubmitAddView
|