cx-chat 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cx-chat.css +1 -0
- package/dist/cx-chat.es.js +97326 -0
- package/dist/cx-chat.umd.js +734 -0
- package/package.json +21 -1
- package/.cursor/rules/i18n-cn-gloss-comments.mdc +0 -31
- package/.cursor/rules/list-page-view-pageconfig.mdc +0 -32
- package/.cursor/rules/no-over-defensive-programming.mdc +0 -90
- package/.cursor/rules/requirement-description-for-agent.mdc +0 -33
- package/.cursor/rules/use-showToast-not-antd-message.mdc +0 -28
- package/.docker/Dockerfile +0 -7
- package/.env +0 -9
- package/.env.development +0 -7
- package/.env.production +0 -7
- package/.gitlab-ci/docker-build.yaml +0 -28
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +0 -42
- package/.gitlab-ci/npm-build.yaml +0 -17
- package/.gitlab-ci.yml +0 -8
- package/.k8s/0-namespace.yaml +0 -6
- package/.k8s/1-configmap-web.yaml +0 -7
- package/.k8s/1-nginx-conf-dev.yaml +0 -110
- package/.k8s/2-deployment.yaml +0 -27
- package/.k8s/3-service.yaml +0 -16
- package/.k8s/4-ingress-dev.yaml +0 -30
- package/.lingma/rules/use-showToast-not-antd-message.md +0 -34
- package/.nginx/nginx.conf +0 -52
- package/.prettierrc +0 -9
- package/eslint.config.js +0 -32
- package/index.html +0 -13
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -96
- package/src/_doc/0.docs-overview.md +0 -28
- package/src/_doc/cx-ui/0.docs-overview.md +0 -30
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +0 -82
- package/src/_doc/cx-ui/comp.2.cx-modal.md +0 -82
- package/src/_doc/cx-ui/comp.3.cx-button.md +0 -89
- package/src/_doc/cx-ui/comp.4.cx-form.md +0 -72
- package/src/_doc/cx-ui/comp.5.cx-fields.md +0 -76
- package/src/_doc/cx-ui/comp.6.cx-tag.md +0 -57
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +0 -29
- package/src/_doc/meta/0.docs-overview.md +0 -24
- package/src/_doc/meta/comp.1.enum-runtime.md +0 -33
- package/src/_doc/meta/comp.2.dict-runtime.md +0 -39
- package/src/_doc/router/0.docs-overview.md +0 -14
- package/src/_doc/router/guide.1.menu-component-config.md +0 -181
- package/src/_doc/router/guide.2.router-auto-registration.md +0 -114
- package/src/_doc/table-view/0.docs-overview.md +0 -30
- package/src/_doc/table-view/comp.1.table-view.md +0 -542
- package/src/_doc/table-view/props.1.create-table-view-config.md +0 -193
- package/src/_doc/table-view/props.2.table-view-search-fields.md +0 -106
- package/src/api/_mock/README.md +0 -340
- package/src/api/_mock/api.ts +0 -1642
- package/src/api/_mock/bundle-shim.ts +0 -16
- package/src/api/_mock/handler-shim.ts +0 -6
- package/src/api/_mock/handler.ts +0 -458
- package/src/api/_mock/index.ts +0 -711
- package/src/api/_mock/interceptor.ts +0 -15
- package/src/api/_mock/mod.ts +0 -12
- package/src/api/_mock/utils.ts +0 -65
- package/src/api/base/memory.js +0 -24
- package/src/api/chat.js +0 -210
- package/src/api/common/auth.js +0 -70
- package/src/api/menus/business-rules.js +0 -76
- package/src/api/menus/feedback.js +0 -102
- package/src/api/menus/knowledge.js +0 -159
- package/src/api/menus/model-metadata/manage.js +0 -70
- package/src/api/menus/model-metadata/role.js +0 -50
- package/src/api/menus/model-metadata/training-detail-mock-data.js +0 -569
- package/src/api/menus/model-metadata/training.js +0 -28
- package/src/api/menus/skill.js +0 -40
- package/src/api/system/agent-config.js +0 -16
- package/src/api/system/department.js +0 -94
- package/src/api/system/dict.js +0 -86
- package/src/api/system/menu.js +0 -37
- package/src/api/system/permission.js +0 -26
- package/src/api/system/role.js +0 -34
- package/src/api/system/sys-config.js +0 -16
- package/src/api/system/sys-log.js +0 -17
- package/src/api/system/user.js +0 -75
- package/src/api/upload.js +0 -39
- package/src/assets/react.svg +0 -1
- package/src/components/auth/current-user-avatar.tsx +0 -77
- package/src/components/common/code-view.tsx +0 -149
- package/src/components/common/detail-link.tsx +0 -67
- package/src/components/common/error-boundary.tsx +0 -98
- package/src/components/common/language-switcher.tsx +0 -91
- package/src/components/common/lite-table/index.tsx +0 -135
- package/src/components/common/md-editor.tsx +0 -126
- package/src/components/common/modal/confirm-dialog.tsx +0 -113
- package/src/components/common/modal/dep-user-select-multi.tsx +0 -324
- package/src/components/common/modal/dep-user-select.tsx +0 -249
- package/src/components/common/modal/user-select-multi.tsx +0 -266
- package/src/components/common/pagination.tsx +0 -472
- package/src/components/common/path.tsx +0 -175
- package/src/components/common/system-logo-mark.tsx +0 -48
- package/src/components/cx-ui/button/index.less +0 -208
- package/src/components/cx-ui/button/index.tsx +0 -611
- package/src/components/cx-ui/checkbox/index.tsx +0 -78
- package/src/components/cx-ui/date-picker/index.less +0 -17
- package/src/components/cx-ui/date-picker/index.tsx +0 -193
- package/src/components/cx-ui/drawer/index.tsx +0 -47
- package/src/components/cx-ui/empty-state/index.tsx +0 -20
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +0 -89
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +0 -283
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +0 -41
- package/src/components/cx-ui/form/CxForm.tsx +0 -15
- package/src/components/cx-ui/form/index.tsx +0 -20
- package/src/components/cx-ui/form-item/index.less +0 -26
- package/src/components/cx-ui/form-item/index.tsx +0 -36
- package/src/components/cx-ui/index.ts +0 -70
- package/src/components/cx-ui/input/auto-complete.tsx +0 -134
- package/src/components/cx-ui/input/index.tsx +0 -259
- package/src/components/cx-ui/input-number/index.jsx +0 -66
- package/src/components/cx-ui/modal/index.jsx +0 -212
- package/src/components/cx-ui/modal/index.less +0 -144
- package/src/components/cx-ui/modal/useCxModal.ts +0 -125
- package/src/components/cx-ui/multi-select/index.jsx +0 -74
- package/src/components/cx-ui/multi-select/index.less +0 -40
- package/src/components/cx-ui/multi-select/index2.tsx +0 -361
- package/src/components/cx-ui/radio/index.tsx +0 -33
- package/src/components/cx-ui/range-picker/index.less +0 -65
- package/src/components/cx-ui/range-picker/index.tsx +0 -219
- package/src/components/cx-ui/select/index.less +0 -34
- package/src/components/cx-ui/select/index.tsx +0 -196
- package/src/components/cx-ui/skeleton/index.tsx +0 -12
- package/src/components/cx-ui/steps/index.tsx +0 -14
- package/src/components/cx-ui/styles/_tokens.less +0 -79
- package/src/components/cx-ui/styles/index.less +0 -246
- package/src/components/cx-ui/switch/index.less +0 -106
- package/src/components/cx-ui/switch/index.tsx +0 -120
- package/src/components/cx-ui/table/index.less +0 -160
- package/src/components/cx-ui/table/index.tsx +0 -152
- package/src/components/cx-ui/tabs/index.less +0 -15
- package/src/components/cx-ui/tabs/index.tsx +0 -34
- package/src/components/cx-ui/tag/index.less +0 -51
- package/src/components/cx-ui/tag/index.tsx +0 -140
- package/src/components/cx-ui/timeline/index.tsx +0 -14
- package/src/components/cx-ui/tooltip/index.tsx +0 -67
- package/src/components/cx-ui/tree/index.tsx +0 -193
- package/src/components/cx-ui/tree-select/index.jsx +0 -91
- package/src/components/cx-ui/tree-select/index.less +0 -27
- package/src/components/cx-ui/upload-file/index.less +0 -223
- package/src/components/cx-ui/upload-file/index.tsx +0 -640
- package/src/components/cx-ui/upload-img/index.tsx +0 -291
- package/src/components/layout/components/Header.tsx +0 -216
- package/src/components/layout/components/Sidebar.tsx +0 -717
- package/src/components/layout/index.tsx +0 -95
- package/src/components/table-view/components/search-area.tsx +0 -411
- package/src/components/table-view/components/table-view-config.tsx +0 -528
- package/src/components/table-view/components/table-view.types.ts +0 -478
- package/src/components/table-view/components/tree-api-normalize.ts +0 -38
- package/src/components/table-view/components/tree-data-annotate.ts +0 -31
- package/src/components/table-view/components/tree-sidebar.tsx +0 -74
- package/src/components/table-view/index.tsx +0 -61
- package/src/components/table-view/list-page-view.tsx +0 -1049
- package/src/components/table-view/select-table-view.tsx +0 -1094
- package/src/components/table-view/styles/select-table-view.less +0 -51
- package/src/config/default-system-name.ts +0 -9
- package/src/config/system.ts +0 -165
- package/src/constants/countryCodes.ts +0 -3
- package/src/contexts/AuthContext.tsx +0 -256
- package/src/contexts/ChatContext.tsx +0 -839
- package/src/contexts/MenuContext.tsx +0 -62
- package/src/contexts/ToastContext.tsx +0 -181
- package/src/hooks/useCopyToClipboard.ts +0 -47
- package/src/hooks/useModalSubmit.ts +0 -104
- package/src/hooks/useRouter.ts +0 -240
- package/src/hooks/useStepForm.ts +0 -46
- package/src/hooks/useStickyHeader.ts +0 -42
- package/src/hooks/useThreadActions.ts +0 -105
- package/src/hooks/useUserPreferences.ts +0 -101
- package/src/http/axios.js +0 -372
- package/src/http/mock.interceptor.ts +0 -9
- package/src/http/obfuscationKey.ts +0 -41
- package/src/i18n.ts +0 -60
- package/src/index.js +0 -1
- package/src/index.less +0 -169
- package/src/locales/en/auth.ts +0 -70
- package/src/locales/en/base/memory.ts +0 -28
- package/src/locales/en/base/settings.ts +0 -41
- package/src/locales/en/chat.ts +0 -40
- package/src/locales/en/common.ts +0 -173
- package/src/locales/en/enum.ts +0 -27
- package/src/locales/en/menus/business-rules.ts +0 -48
- package/src/locales/en/menus/feedback.ts +0 -62
- package/src/locales/en/menus/knowledge.ts +0 -120
- package/src/locales/en/menus/model-metadata/index.ts +0 -10
- package/src/locales/en/menus/model-metadata/manage.ts +0 -151
- package/src/locales/en/menus/model-metadata/role.ts +0 -48
- package/src/locales/en/menus/model-metadata/training.ts +0 -65
- package/src/locales/en/menus/skill.ts +0 -34
- package/src/locales/en/system/agent-config.ts +0 -34
- package/src/locales/en/system/department.ts +0 -68
- package/src/locales/en/system/dict.ts +0 -44
- package/src/locales/en/system/menu.ts +0 -45
- package/src/locales/en/system/permission.ts +0 -89
- package/src/locales/en/system/role.ts +0 -25
- package/src/locales/en/system/sys-config.ts +0 -33
- package/src/locales/en/system/sys-log.ts +0 -38
- package/src/locales/en/system/user.ts +0 -113
- package/src/locales/en.ts +0 -68
- package/src/locales/zh/auth.ts +0 -70
- package/src/locales/zh/base/memory.ts +0 -29
- package/src/locales/zh/base/settings.ts +0 -41
- package/src/locales/zh/chat.ts +0 -47
- package/src/locales/zh/common.ts +0 -178
- package/src/locales/zh/enum.ts +0 -28
- package/src/locales/zh/menus/business-rules.ts +0 -47
- package/src/locales/zh/menus/feedback.ts +0 -62
- package/src/locales/zh/menus/knowledge.ts +0 -117
- package/src/locales/zh/menus/model-metadata/index.ts +0 -10
- package/src/locales/zh/menus/model-metadata/manage.ts +0 -151
- package/src/locales/zh/menus/model-metadata/role.ts +0 -47
- package/src/locales/zh/menus/model-metadata/training.ts +0 -64
- package/src/locales/zh/menus/skill.ts +0 -34
- package/src/locales/zh/system/agent-config.ts +0 -33
- package/src/locales/zh/system/department.ts +0 -69
- package/src/locales/zh/system/dict.ts +0 -44
- package/src/locales/zh/system/menu.ts +0 -47
- package/src/locales/zh/system/permission.ts +0 -94
- package/src/locales/zh/system/role.ts +0 -25
- package/src/locales/zh/system/sys-config.ts +0 -32
- package/src/locales/zh/system/sys-log.ts +0 -38
- package/src/locales/zh/system/user.ts +0 -114
- package/src/locales/zh.ts +0 -67
- package/src/main.tsx +0 -50
- package/src/meta/const/index.ts +0 -40
- package/src/meta/index-dict.ts +0 -56
- package/src/meta/index-enum.ts +0 -95
- package/src/meta/index.ts +0 -14
- package/src/meta/module/dict-data/runtime.ts +0 -199
- package/src/meta/module/dict-data/types.ts +0 -17
- package/src/meta/module/enum-data/runtime.ts +0 -75
- package/src/meta/module/enum-data/types.ts +0 -18
- package/src/router/index.tsx +0 -312
- package/src/styles/AntdThemeProvider.tsx +0 -40
- package/src/styles/antd-theme.ts +0 -20
- package/src/styles/global.less +0 -107
- package/src/styles/variable.less +0 -103
- package/src/types/feedback.ts +0 -43
- package/src/types/index.ts +0 -85
- package/src/types/menu.ts +0 -43
- package/src/utils/aesUtil.ts +0 -123
- package/src/utils/chatUtils.ts +0 -524
- package/src/utils/cn.ts +0 -6
- package/src/utils/crypto.ts +0 -164
- package/src/utils/date.ts +0 -72
- package/src/utils/file-icons.tsx +0 -79
- package/src/utils/index.ts +0 -168
- package/src/utils/markdown-math-plugins.ts +0 -21
- package/src/utils/menuI18n.ts +0 -305
- package/src/utils/menuRouteRegistry.ts +0 -78
- package/src/utils/permission-crud.ts +0 -147
- package/src/utils/routeConfig.ts +0 -350
- package/src/utils/storage.ts +0 -135
- package/src/utils/toastBridge.ts +0 -26
- package/src/utils/url.ts +0 -38
- package/src/utils/validation.ts +0 -16
- package/src/views/auth/auth-code/index.less +0 -169
- package/src/views/auth/auth-code/index.module.less +0 -174
- package/src/views/auth/auth-code/index.tsx +0 -233
- package/src/views/auth/login.tsx +0 -498
- package/src/views/auth/register.tsx +0 -388
- package/src/views/base/memory/index.tsx +0 -136
- package/src/views/base/memory/modal/detail-modal.tsx +0 -89
- package/src/views/base/memory/modal/submit-modal.tsx +0 -134
- package/src/views/base/settings/index.tsx +0 -657
- package/src/views/chat/chat.less +0 -323
- package/src/views/chat/components/chat-input.tsx +0 -298
- package/src/views/chat/components/header-thread-title.tsx +0 -210
- package/src/views/chat/components/message-list/content-answer.tsx +0 -100
- package/src/views/chat/components/message-list/content-question.tsx +0 -18
- package/src/views/chat/components/message-list/index.tsx +0 -520
- package/src/views/chat/components/message-list/message-item.tsx +0 -199
- package/src/views/chat/components/message-list/preparation-demo-items.ts +0 -147
- package/src/views/chat/components/message-list/preparation-steps.tsx +0 -506
- package/src/views/chat/components/message-list/suggestion-list.tsx +0 -36
- package/src/views/chat/components/message-list/thinking-process.tsx +0 -49
- package/src/views/chat/components/message-list/toolbar.tsx +0 -224
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +0 -214
- package/src/views/chat/components/references-knowledge/context.tsx +0 -57
- package/src/views/chat/components/references-knowledge/index.ts +0 -9
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +0 -556
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +0 -529
- package/src/views/chat/components/references-knowledge/panel.tsx +0 -115
- package/src/views/chat/hooks/use-chat-common.ts +0 -19
- package/src/views/chat/index-session.tsx +0 -647
- package/src/views/chat/index.tsx +0 -127
- package/src/views/page-error/401.tsx +0 -56
- package/src/views/page-error/404.tsx +0 -56
- package/src/views/page-menus/business-rules/index.tsx +0 -376
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +0 -186
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +0 -272
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +0 -142
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +0 -471
- package/src/views/page-menus/feedback/index.tsx +0 -166
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +0 -367
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +0 -32
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +0 -330
- package/src/views/page-menus/knowledge/detail.tsx +0 -600
- package/src/views/page-menus/knowledge/index.tsx +0 -337
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +0 -618
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +0 -550
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +0 -99
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +0 -349
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +0 -88
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +0 -283
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +0 -179
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +0 -114
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +0 -232
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +0 -316
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +0 -134
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +0 -134
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +0 -101
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +0 -338
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +0 -276
- package/src/views/page-menus/model-metadata/manage/detail.tsx +0 -298
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +0 -113
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +0 -20
- package/src/views/page-menus/model-metadata/manage/index.tsx +0 -304
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +0 -374
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +0 -151
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +0 -423
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +0 -218
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +0 -261
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +0 -196
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +0 -229
- package/src/views/page-menus/model-metadata/manage/submit.tsx +0 -31
- package/src/views/page-menus/model-metadata/role/index.tsx +0 -207
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +0 -97
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +0 -254
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +0 -393
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +0 -120
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +0 -698
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +0 -237
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +0 -135
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +0 -4
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +0 -72
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +0 -196
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +0 -153
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +0 -103
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +0 -82
- package/src/views/page-menus/model-metadata/training/detail.tsx +0 -159
- package/src/views/page-menus/model-metadata/training/index.tsx +0 -236
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +0 -154
- package/src/views/page-menus/skill/index.tsx +0 -201
- package/src/views/page-menus/skill/modal/detail-modal.tsx +0 -156
- package/src/views/page-menus/skill/modal/submit-modal.tsx +0 -214
- package/src/views/page-system/agent-config/index.tsx +0 -370
- package/src/views/page-system/department/departmentFormShared.ts +0 -36
- package/src/views/page-system/department/index.tsx +0 -541
- package/src/views/page-system/department/modal/detail-modal.tsx +0 -94
- package/src/views/page-system/department/modal/member-role-modal.tsx +0 -128
- package/src/views/page-system/department/modal/submit-modal.tsx +0 -265
- package/src/views/page-system/dict/index.tsx +0 -440
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +0 -315
- package/src/views/page-system/dict/modal/submit-modal.tsx +0 -184
- package/src/views/page-system/logs/components/index.ts +0 -3
- package/src/views/page-system/logs/components/log-message-demo.tsx +0 -30
- package/src/views/page-system/logs/components/log-message-stream.ts +0 -184
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +0 -100
- package/src/views/page-system/logs/components/message-list/content-question.tsx +0 -18
- package/src/views/page-system/logs/components/message-list/index.tsx +0 -515
- package/src/views/page-system/logs/components/message-list/message-item.tsx +0 -193
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +0 -147
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +0 -506
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +0 -36
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +0 -49
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +0 -134
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +0 -214
- package/src/views/page-system/logs/components/message-modal.tsx +0 -239
- package/src/views/page-system/logs/index.tsx +0 -132
- package/src/views/page-system/logs/modal/detail-modal.tsx +0 -157
- package/src/views/page-system/menu/components/menuFormShared.ts +0 -283
- package/src/views/page-system/menu/index.less +0 -12
- package/src/views/page-system/menu/index.tsx +0 -410
- package/src/views/page-system/menu/modal/icon-modal.less +0 -51
- package/src/views/page-system/menu/modal/icon-modal.tsx +0 -87
- package/src/views/page-system/menu/modal/submit-modal.tsx +0 -263
- package/src/views/page-system/permission/index.tsx +0 -562
- package/src/views/page-system/permission/modal/detail-modal.tsx +0 -179
- package/src/views/page-system/permission/modal/submit-modal.less +0 -146
- package/src/views/page-system/permission/modal/submit-modal.tsx +0 -650
- package/src/views/page-system/role/index.tsx +0 -163
- package/src/views/page-system/role/modal/detail-modal.tsx +0 -127
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +0 -86
- package/src/views/page-system/role/modal/permission-modal.tsx +0 -111
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +0 -21
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +0 -916
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +0 -1047
- package/src/views/page-system/role/modal/submit-modal.tsx +0 -193
- package/src/views/page-system/sys-config/index.tsx +0 -294
- package/src/views/page-system/user/components/user-role-column.tsx +0 -87
- package/src/views/page-system/user/index.tsx +0 -439
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +0 -389
- package/src/views/page-system/user/modal/detail-modal.tsx +0 -72
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +0 -40
- package/src/views/page-system/user/modal/submit-modal.less +0 -40
- package/src/views/page-system/user/modal/submit-modal.tsx +0 -287
- package/src/views/page-system/user/userFormShared.ts +0 -51
- package/tailwind.config.js +0 -17
- package/tsconfig.app.json +0 -48
- package/tsconfig.json +0 -11
- package/tsconfig.node.json +0 -26
- package/vite.config.ts +0 -264
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { useAuth } from '@/contexts/AuthContext'
|
|
2
|
-
import { DICT_DATA, DICT_KEY, ENUM_DATA } from '@/meta'
|
|
3
|
-
import { CxForm, CxFormItem, CxInput, CxSelect } from '@cx-ui'
|
|
4
|
-
import { Form } from 'antd'
|
|
5
|
-
import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react'
|
|
6
|
-
import { useTranslation } from 'react-i18next'
|
|
7
|
-
|
|
8
|
-
// 第一步 i18n:menus.model_metadata.manage.fields / placeholders / rules → locales/zh/menus/model-metadata/manage.ts
|
|
9
|
-
|
|
10
|
-
/** 与测连接入参一致,用于判断连接相关字段是否相对上次成功测试有变化 */
|
|
11
|
-
export function modelMetadataConnectionDigest(v: Record<string, any>): string {
|
|
12
|
-
return JSON.stringify({
|
|
13
|
-
databaseName: v.databaseName ?? '',
|
|
14
|
-
dbType: v.dbType ?? '',
|
|
15
|
-
host: v.host ?? '',
|
|
16
|
-
port: v.port ?? '',
|
|
17
|
-
dbSchema: v.dbSchema ?? '',
|
|
18
|
-
username: v.username ?? '',
|
|
19
|
-
password: v.password ?? '',
|
|
20
|
-
charsetName: v.charsetName ?? '',
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type Step1BasicInfoHandle = {
|
|
25
|
-
validateForNext: () => Promise<Record<string, any>>
|
|
26
|
-
validateForConnectionTest: () => Promise<void>
|
|
27
|
-
getConnectionTestPayload: () => Record<string, any>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
type Step1BasicInfoProps = {
|
|
31
|
-
initialValues?: Record<string, any>
|
|
32
|
-
isEdit?: boolean
|
|
33
|
-
/** 连接相关字段摘要变化时回调(仅当与上次成功测试不一致时由父级清除「已测试」) */
|
|
34
|
-
onConnectionDigestChange?: (digest: string) => void
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const Step1BasicInfo = forwardRef<Step1BasicInfoHandle, Step1BasicInfoProps>(
|
|
38
|
-
function Step1BasicInfo(
|
|
39
|
-
{ initialValues, isEdit, onConnectionDigestChange },
|
|
40
|
-
ref,
|
|
41
|
-
) {
|
|
42
|
-
const { t } = useTranslation()
|
|
43
|
-
const { commonDictRevision } = useAuth()
|
|
44
|
-
const [form] = Form.useForm()
|
|
45
|
-
|
|
46
|
-
const dbTypeOptions = useMemo(
|
|
47
|
-
() => DICT_DATA[DICT_KEY.dbType]?.option ?? [],
|
|
48
|
-
[commonDictRevision],
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
// 校验文案:menus.model_metadata.manage.rules.* → locales/zh/menus/model-metadata/manage.ts
|
|
52
|
-
const formRules = useMemo(
|
|
53
|
-
() => ({
|
|
54
|
-
subject: [
|
|
55
|
-
{ required: true, message: t('menus.model_metadata.manage.rules.subject_required') }, // 主题必填
|
|
56
|
-
{ whitespace: true, message: t('menus.model_metadata.manage.rules.subject_required') },
|
|
57
|
-
],
|
|
58
|
-
databaseName: [
|
|
59
|
-
{ required: true, message: t('menus.model_metadata.manage.rules.databaseName_required') }, // 库名必填
|
|
60
|
-
{ whitespace: true, message: t('menus.model_metadata.manage.rules.databaseName_required') },
|
|
61
|
-
],
|
|
62
|
-
dbType: [{ required: true, message: t('menus.model_metadata.manage.rules.dbType_required') }], // 库类型必填
|
|
63
|
-
host: [
|
|
64
|
-
{ required: true, message: t('menus.model_metadata.manage.rules.host_required') }, // 主机必填
|
|
65
|
-
{ whitespace: true, message: t('menus.model_metadata.manage.rules.host_required') },
|
|
66
|
-
],
|
|
67
|
-
port: [{ required: true, message: t('menus.model_metadata.manage.rules.port_required') }], // 端口必填
|
|
68
|
-
username: [
|
|
69
|
-
{ required: true, message: t('menus.model_metadata.manage.rules.username_required') }, // 用户名必填
|
|
70
|
-
{ whitespace: true, message: t('menus.model_metadata.manage.rules.username_required') },
|
|
71
|
-
],
|
|
72
|
-
password: isEdit
|
|
73
|
-
? []
|
|
74
|
-
: [
|
|
75
|
-
{ required: true, message: t('menus.model_metadata.manage.rules.password_required') }, // 密码必填
|
|
76
|
-
{ whitespace: true, message: t('menus.model_metadata.manage.rules.password_required') },
|
|
77
|
-
],
|
|
78
|
-
}),
|
|
79
|
-
[t, isEdit],
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (initialValues && Object.keys(initialValues).length > 0) {
|
|
84
|
-
form.setFieldsValue(initialValues)
|
|
85
|
-
}
|
|
86
|
-
}, [form, initialValues])
|
|
87
|
-
|
|
88
|
-
// 开发:新增时空表单自动填基础信息,不需要时把下面整段 useEffect 注释掉即可
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
if (!import.meta.env.DEV) return
|
|
91
|
-
if (initialValues && Object.keys(initialValues).length > 0) return
|
|
92
|
-
form.setFieldsValue({
|
|
93
|
-
subject: 'dev-local-db',
|
|
94
|
-
databaseName: 'agent-forge',
|
|
95
|
-
dbType: 'mysql',
|
|
96
|
-
host: '10.101.1.128',
|
|
97
|
-
port: 13306,
|
|
98
|
-
dbSchema: '',
|
|
99
|
-
username: 'root',
|
|
100
|
-
password: 'Q95pRHWuOJTSAPJo',
|
|
101
|
-
optionsJson: '',
|
|
102
|
-
})
|
|
103
|
-
}, [form, initialValues])
|
|
104
|
-
|
|
105
|
-
const watched = Form.useWatch(
|
|
106
|
-
['databaseName', 'dbType', 'host', 'port', 'username', 'password', 'dbSchema', 'charsetName'],
|
|
107
|
-
form,
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
const v = form.getFieldsValue(true) as Record<string, any>
|
|
112
|
-
onConnectionDigestChange?.(modelMetadataConnectionDigest(v))
|
|
113
|
-
}, [watched, form, onConnectionDigestChange])
|
|
114
|
-
|
|
115
|
-
useImperativeHandle(
|
|
116
|
-
ref,
|
|
117
|
-
() => ({
|
|
118
|
-
validateForNext: async () => {
|
|
119
|
-
await form.validateFields(['subject', 'databaseName', 'dbType', 'host', 'port', 'username'])
|
|
120
|
-
return form.getFieldsValue(true) as Record<string, any>
|
|
121
|
-
},
|
|
122
|
-
validateForConnectionTest: () =>
|
|
123
|
-
form.validateFields([
|
|
124
|
-
'databaseName',
|
|
125
|
-
'dbType',
|
|
126
|
-
'host',
|
|
127
|
-
'port',
|
|
128
|
-
'username',
|
|
129
|
-
'password',
|
|
130
|
-
]),
|
|
131
|
-
getConnectionTestPayload: () => {
|
|
132
|
-
const v = form.getFieldsValue(true) as Record<string, any>
|
|
133
|
-
return {
|
|
134
|
-
databaseName: v.databaseName,
|
|
135
|
-
dbType: v.dbType,
|
|
136
|
-
host: v.host,
|
|
137
|
-
port: v.port,
|
|
138
|
-
dbSchema: v.dbSchema,
|
|
139
|
-
username: v.username,
|
|
140
|
-
password: v.password,
|
|
141
|
-
charsetName: v.charsetName,
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
}),
|
|
145
|
-
[form],
|
|
146
|
-
)
|
|
147
|
-
|
|
148
|
-
const fieldClass = 'w-full min-w-0'
|
|
149
|
-
const inputClass = 'w-full min-w-0 max-w-full'
|
|
150
|
-
|
|
151
|
-
// 标签/占位:menus.model_metadata.manage.fields.* / placeholders.* → zh/menus/model-metadata/manage.ts
|
|
152
|
-
return (
|
|
153
|
-
<CxForm form={form} rules={formRules} layout="vertical" className="w-full min-w-0">
|
|
154
|
-
<div className="grid w-full min-w-0 grid-cols-2 gap-x-6 gap-y-4">
|
|
155
|
-
{/* 主题 */}
|
|
156
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.subject')} name="subject">
|
|
157
|
-
<CxInput className={inputClass} placeholder={t('menus.model_metadata.manage.placeholders.subject')} />
|
|
158
|
-
</CxFormItem>
|
|
159
|
-
{/* 数据库名 */}
|
|
160
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.databaseName')} name="databaseName">
|
|
161
|
-
<CxInput className={inputClass} placeholder={t('menus.model_metadata.manage.placeholders.databaseName')} />
|
|
162
|
-
</CxFormItem>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
<div className="grid w-full min-w-0 grid-cols-2 gap-x-6 gap-y-4">
|
|
166
|
-
{/* 库类型 */}
|
|
167
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.dbType')} name="dbType">
|
|
168
|
-
<CxSelect
|
|
169
|
-
className={inputClass}
|
|
170
|
-
placeholder={t('menus.model_metadata.manage.placeholders.dbType')}
|
|
171
|
-
options={dbTypeOptions}
|
|
172
|
-
fieldNames={{ label: 'name', value: 'value' }}
|
|
173
|
-
/>
|
|
174
|
-
</CxFormItem>
|
|
175
|
-
{/* 字符集 */}
|
|
176
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.charsetName')} name="charsetName">
|
|
177
|
-
<CxSelect
|
|
178
|
-
className={inputClass}
|
|
179
|
-
allowClear
|
|
180
|
-
placeholder={t('menus.model_metadata.manage.placeholders.charsetName')}
|
|
181
|
-
options={ENUM_DATA.dbCharset.option}
|
|
182
|
-
/>
|
|
183
|
-
</CxFormItem>
|
|
184
|
-
</div>
|
|
185
|
-
|
|
186
|
-
<div className="grid w-full min-w-0 grid-cols-4 gap-x-6 gap-y-4">
|
|
187
|
-
{/* 主机 */}
|
|
188
|
-
<CxFormItem className={`${fieldClass} col-span-3`} label={t('menus.model_metadata.manage.fields.host')} name="host">
|
|
189
|
-
<CxInput className={inputClass} placeholder={t('menus.model_metadata.manage.placeholders.host')} />
|
|
190
|
-
</CxFormItem>
|
|
191
|
-
{/* 端口 */}
|
|
192
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.port')} name="port">
|
|
193
|
-
<CxInput className={inputClass} placeholder={t('menus.model_metadata.manage.placeholders.port')} />
|
|
194
|
-
</CxFormItem>
|
|
195
|
-
</div>
|
|
196
|
-
|
|
197
|
-
<div className="grid w-full min-w-0 grid-cols-4 gap-x-6 gap-y-4">
|
|
198
|
-
{/* Schema */}
|
|
199
|
-
<CxFormItem className={`${fieldClass} col-span-2`} label={t('menus.model_metadata.manage.fields.dbSchema')} name="dbSchema">
|
|
200
|
-
<CxInput className={inputClass} placeholder={t('menus.model_metadata.manage.placeholders.dbSchema')} />
|
|
201
|
-
</CxFormItem>
|
|
202
|
-
{/* 用户名 */}
|
|
203
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.username')} name="username">
|
|
204
|
-
<CxInput className={inputClass} placeholder={t('menus.model_metadata.manage.placeholders.username')} />
|
|
205
|
-
</CxFormItem>
|
|
206
|
-
{/* 密码 */}
|
|
207
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.password')} name="password">
|
|
208
|
-
<CxInput
|
|
209
|
-
className={inputClass}
|
|
210
|
-
type="password"
|
|
211
|
-
autoComplete="new-password"
|
|
212
|
-
placeholder={t('menus.model_metadata.manage.placeholders.password')}
|
|
213
|
-
/>
|
|
214
|
-
</CxFormItem>
|
|
215
|
-
</div>
|
|
216
|
-
|
|
217
|
-
<div className="mt-6 w-full min-w-0">
|
|
218
|
-
{/* 配置 JSON */}
|
|
219
|
-
<CxFormItem className={fieldClass} label={t('menus.model_metadata.manage.fields.optionsJson')} name="optionsJson">
|
|
220
|
-
<CxInput.Textarea
|
|
221
|
-
className={inputClass}
|
|
222
|
-
rows={4}
|
|
223
|
-
placeholder={t('menus.model_metadata.manage.placeholders.optionsJson')}
|
|
224
|
-
/>
|
|
225
|
-
</CxFormItem>
|
|
226
|
-
</div>
|
|
227
|
-
</CxForm>
|
|
228
|
-
)
|
|
229
|
-
},
|
|
230
|
-
)
|
|
231
|
-
|
|
232
|
-
export default Step1BasicInfo
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
import { introspectPreviewAPI } from '@api/menus/model-metadata/manage'
|
|
2
|
-
import { useToast } from '@/contexts/ToastContext'
|
|
3
|
-
import { useAuth } from '@/contexts/AuthContext'
|
|
4
|
-
import { CxButton, CxInput, CxTable } from '@cx-ui'
|
|
5
|
-
import type { CxModalRef } from '@cx-ui/modal/useCxModal'
|
|
6
|
-
import { Spin } from 'antd'
|
|
7
|
-
import axios from 'axios'
|
|
8
|
-
import { Plus, RefreshCw } from 'lucide-react'
|
|
9
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
10
|
-
import { useTranslation } from 'react-i18next'
|
|
11
|
-
import TableSubmitModal from '../modal/table-submit-modal'
|
|
12
|
-
|
|
13
|
-
/** 与 introspect/preview 接口一致的连接入参 */
|
|
14
|
-
function buildIntrospectPreviewParams(connection: Record<string, any>) {
|
|
15
|
-
return {
|
|
16
|
-
databaseName: connection.databaseName,
|
|
17
|
-
dbType: connection.dbType,
|
|
18
|
-
host: connection.host,
|
|
19
|
-
port: connection.port,
|
|
20
|
-
username: connection.username,
|
|
21
|
-
password: connection.password,
|
|
22
|
-
dbSchema: connection.dbSchema,
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** 反查结构预览(不落库),返回 tables 数组 */
|
|
27
|
-
async function fetchIntrospectPreviewTables(
|
|
28
|
-
connection: Record<string, any>,
|
|
29
|
-
options?: { signal?: AbortSignal },
|
|
30
|
-
) {
|
|
31
|
-
const res = await introspectPreviewAPI(buildIntrospectPreviewParams(connection), options)
|
|
32
|
-
return (res as any)?.data ?? []
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 本步 i18n:menus.model_metadata.manage.* → locales/zh/menus/model-metadata/manage.ts
|
|
36
|
-
|
|
37
|
-
type SchemaTable = {
|
|
38
|
-
_clientId?: string
|
|
39
|
-
tableSchema?: string
|
|
40
|
-
tableName?: string
|
|
41
|
-
tableComment?: string
|
|
42
|
-
tableType?: string
|
|
43
|
-
columns?: any[]
|
|
44
|
-
indexes?: any[]
|
|
45
|
-
foreignKeys?: any[]
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
type Step2SchemaProps = {
|
|
49
|
-
connectionParams: Record<string, any>
|
|
50
|
-
tables: SchemaTable[]
|
|
51
|
-
onTablesChange: (tables: SchemaTable[]) => void
|
|
52
|
-
isEdit?: boolean
|
|
53
|
-
currentStep?: number
|
|
54
|
-
/** 新增:每次从第一步点「下一步」进入本步时递增,用于强制重新拉取结构预览 */
|
|
55
|
-
previewNonce?: number
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function isAbortError(e: unknown) {
|
|
59
|
-
return axios.isCancel(e) || (e as any)?.code === 'ERR_CANCELED' || (e as any)?.name === 'CanceledError'
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function newClientId() {
|
|
63
|
-
return `c_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function emptySchemaTable(): SchemaTable {
|
|
67
|
-
return {
|
|
68
|
-
_clientId: newClientId(),
|
|
69
|
-
tableSchema: '',
|
|
70
|
-
tableName: '',
|
|
71
|
-
tableComment: '',
|
|
72
|
-
tableType: '',
|
|
73
|
-
columns: [],
|
|
74
|
-
indexes: [],
|
|
75
|
-
foreignKeys: [],
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function tableStableKey(r: SchemaTable) {
|
|
80
|
-
return r._clientId ?? `${r.tableSchema ?? ''}::${r.tableName ?? ''}`
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function removeSchemaTable(tables: SchemaTable[], target: SchemaTable): SchemaTable[] {
|
|
84
|
-
const tid = target._clientId
|
|
85
|
-
if (tid) return tables.filter((t) => t._clientId !== tid)
|
|
86
|
-
const k = tableStableKey(target)
|
|
87
|
-
let removed = false
|
|
88
|
-
return tables.filter((t) => {
|
|
89
|
-
if (t._clientId) return true
|
|
90
|
-
if (!removed && tableStableKey(t) === k) {
|
|
91
|
-
removed = true
|
|
92
|
-
return false
|
|
93
|
-
}
|
|
94
|
-
return true
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export default function Step2Schema({
|
|
99
|
-
connectionParams,
|
|
100
|
-
tables,
|
|
101
|
-
onTablesChange,
|
|
102
|
-
isEdit,
|
|
103
|
-
currentStep,
|
|
104
|
-
previewNonce = 0,
|
|
105
|
-
}: Step2SchemaProps) {
|
|
106
|
-
const { showToast } = useToast()
|
|
107
|
-
const { hasPermission } = useAuth()
|
|
108
|
-
const { t } = useTranslation()
|
|
109
|
-
const [previewLoading, setPreviewLoading] = useState(false)
|
|
110
|
-
const [tableNameQuery, setTableNameQuery] = useState('')
|
|
111
|
-
const tableSubmitModalRef = useRef<CxModalRef>(null)
|
|
112
|
-
|
|
113
|
-
const filteredTables = useMemo(() => {
|
|
114
|
-
const q = tableNameQuery.trim().toLowerCase()
|
|
115
|
-
if (!q) return tables
|
|
116
|
-
return tables.filter((row) => String(row.tableName ?? '').toLowerCase().includes(q))
|
|
117
|
-
}, [tables, tableNameQuery])
|
|
118
|
-
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
setTableNameQuery('')
|
|
121
|
-
}, [previewNonce])
|
|
122
|
-
|
|
123
|
-
const runIntrospectFetch = useCallback(
|
|
124
|
-
async (options?: { signal?: AbortSignal }) => {
|
|
125
|
-
return fetchIntrospectPreviewTables(connectionParams, options)
|
|
126
|
-
},
|
|
127
|
-
[connectionParams],
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
/** 仅随进入第二步 / previewNonce / 连接对象引用变化触发;勿把 showToast、t 等放进依赖,否则父级重渲染会反复 onTablesChange([]) 冲掉本地新增行 */
|
|
131
|
-
useEffect(() => {
|
|
132
|
-
if (isEdit) return
|
|
133
|
-
if (currentStep !== 1) return
|
|
134
|
-
if (!previewNonce) return
|
|
135
|
-
|
|
136
|
-
onTablesChange([])
|
|
137
|
-
|
|
138
|
-
const ac = new AbortController()
|
|
139
|
-
setPreviewLoading(true)
|
|
140
|
-
;(async () => {
|
|
141
|
-
try {
|
|
142
|
-
const data = await fetchIntrospectPreviewTables(connectionParams, { signal: ac.signal })
|
|
143
|
-
onTablesChange(Array.isArray(data) ? data : [])
|
|
144
|
-
} catch (error: any) {
|
|
145
|
-
if (isAbortError(error)) return
|
|
146
|
-
showToast(error?.message || t('menus.model_metadata.manage.preview_failed'), 'error') // 结构预览失败
|
|
147
|
-
} finally {
|
|
148
|
-
if (!ac.signal.aborted) {
|
|
149
|
-
setPreviewLoading(false)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
})()
|
|
153
|
-
|
|
154
|
-
return () => {
|
|
155
|
-
ac.abort()
|
|
156
|
-
}
|
|
157
|
-
// onTablesChange 为 setState 引用稳定;showToast/t 勿写入依赖以免每次渲染清空 tables
|
|
158
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- 见上
|
|
159
|
-
}, [isEdit, currentStep, previewNonce, connectionParams, onTablesChange])
|
|
160
|
-
|
|
161
|
-
useEffect(() => {
|
|
162
|
-
const handleTableUpdate = (e: CustomEvent<SchemaTable>) => {
|
|
163
|
-
const u = e.detail
|
|
164
|
-
const newTables = tables.map((row) => {
|
|
165
|
-
if (u._clientId && row._clientId && u._clientId === row._clientId) return u
|
|
166
|
-
if (
|
|
167
|
-
row.tableName === u.tableName &&
|
|
168
|
-
(row.tableSchema ?? '') === (u.tableSchema ?? '')
|
|
169
|
-
) {
|
|
170
|
-
return u
|
|
171
|
-
}
|
|
172
|
-
return row
|
|
173
|
-
})
|
|
174
|
-
onTablesChange(newTables)
|
|
175
|
-
showToast(t('menus.model_metadata.manage.table_updated'), 'success') // 表信息已更新
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
window.addEventListener('tableUpdated', handleTableUpdate as any)
|
|
179
|
-
return () => {
|
|
180
|
-
window.removeEventListener('tableUpdated', handleTableUpdate as any)
|
|
181
|
-
}
|
|
182
|
-
}, [tables, onTablesChange, showToast, t])
|
|
183
|
-
|
|
184
|
-
const handleRefetch = useCallback(async () => {
|
|
185
|
-
setPreviewLoading(true)
|
|
186
|
-
try {
|
|
187
|
-
const data = await runIntrospectFetch()
|
|
188
|
-
onTablesChange(Array.isArray(data) ? data : [])
|
|
189
|
-
showToast(t('menus.model_metadata.manage.preview_refreshed'), 'success') // 表结构已重新获取
|
|
190
|
-
} catch (error: any) {
|
|
191
|
-
showToast(error?.message || t('menus.model_metadata.manage.preview_failed'), 'error') // 结构预览失败
|
|
192
|
-
} finally {
|
|
193
|
-
setPreviewLoading(false)
|
|
194
|
-
}
|
|
195
|
-
}, [onTablesChange, runIntrospectFetch, showToast, t])
|
|
196
|
-
|
|
197
|
-
const handleAddTable = useCallback(() => {
|
|
198
|
-
setTableNameQuery('')
|
|
199
|
-
const row = emptySchemaTable()
|
|
200
|
-
const nextTables = [...tables, row]
|
|
201
|
-
onTablesChange(nextTables)
|
|
202
|
-
setTimeout(() => {
|
|
203
|
-
tableSubmitModalRef.current?.open({
|
|
204
|
-
opeType: 'add',
|
|
205
|
-
data: row,
|
|
206
|
-
schemaTables: nextTables,
|
|
207
|
-
})
|
|
208
|
-
}, 0)
|
|
209
|
-
}, [tables, onTablesChange])
|
|
210
|
-
|
|
211
|
-
const handleDeleteTable = useCallback(
|
|
212
|
-
(record: SchemaTable) => {
|
|
213
|
-
onTablesChange(removeSchemaTable(tables, record))
|
|
214
|
-
},
|
|
215
|
-
[tables, onTablesChange],
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
const handleEditTable = (record: SchemaTable) => {
|
|
219
|
-
tableSubmitModalRef.current?.open({
|
|
220
|
-
opeType: 'edit',
|
|
221
|
-
data: record,
|
|
222
|
-
schemaTables: tables,
|
|
223
|
-
})
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
// 表列表列标题:fields.* → zh/menus/model-metadata.ts
|
|
227
|
-
const columns = [
|
|
228
|
-
{
|
|
229
|
-
title: t('menus.model_metadata.manage.fields.tableName'), // 表名
|
|
230
|
-
dataIndex: 'tableName',
|
|
231
|
-
key: 'tableName',
|
|
232
|
-
width: 200,
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
title: t('menus.model_metadata.manage.fields.tableComment'), // 表注释
|
|
236
|
-
dataIndex: 'tableComment',
|
|
237
|
-
key: 'tableComment',
|
|
238
|
-
ellipsis: true,
|
|
239
|
-
minWidth: 200,
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
title: t('menus.model_metadata.manage.fields.columnCount'), // 字段数量
|
|
243
|
-
key: 'columnCount',
|
|
244
|
-
width: 120,
|
|
245
|
-
render: (_: unknown, record: SchemaTable) => record.columns?.length ?? 0,
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
title: t('common.actions'), // 操作
|
|
249
|
-
key: 'action',
|
|
250
|
-
width: 112,
|
|
251
|
-
render: (_: unknown, record: SchemaTable) => (
|
|
252
|
-
<div className="flex items-center justify-center gap-1">
|
|
253
|
-
<CxButton.IconEdit onClick={() => handleEditTable(record)} />
|
|
254
|
-
<CxButton.IconDelete onClick={() => handleDeleteTable(record)} />
|
|
255
|
-
</div>
|
|
256
|
-
),
|
|
257
|
-
},
|
|
258
|
-
]
|
|
259
|
-
|
|
260
|
-
return (
|
|
261
|
-
<div className="flex h-full min-h-0 w-full min-w-0 flex-1 flex-col">
|
|
262
|
-
{previewLoading ? (
|
|
263
|
-
<div className="flex min-h-[240px] flex-1 items-center justify-center py-8">
|
|
264
|
-
<Spin size="large" tip={t('common.loading')} />
|
|
265
|
-
</div>
|
|
266
|
-
) : (
|
|
267
|
-
<>
|
|
268
|
-
<div
|
|
269
|
-
className={`mb-3 flex w-full min-w-0 shrink-0 items-center gap-3 px-0.5 pt-px ${
|
|
270
|
-
tables.length > 0 ? 'justify-between' : 'justify-end'
|
|
271
|
-
}`}
|
|
272
|
-
>
|
|
273
|
-
{tables.length > 0 ? (
|
|
274
|
-
<CxInput
|
|
275
|
-
allowClear
|
|
276
|
-
className="max-w-sm min-w-0 flex-1"
|
|
277
|
-
value={tableNameQuery}
|
|
278
|
-
placeholder={t('menus.model_metadata.manage.filter_table_name_placeholder')} // 按表名筛选
|
|
279
|
-
onChange={(e) => setTableNameQuery(e.target.value)}
|
|
280
|
-
/>
|
|
281
|
-
) : null}
|
|
282
|
-
<div className="flex shrink-0 items-center gap-2">
|
|
283
|
-
<CxButton type="primary" htmlType="button" onClick={handleAddTable} icon={<Plus size={16} />}>
|
|
284
|
-
{t('menus.model_metadata.manage.add_schema_table')} {/* 新增表 */}
|
|
285
|
-
</CxButton>
|
|
286
|
-
{hasPermission('model-metadata:preview') ? (
|
|
287
|
-
<CxButton
|
|
288
|
-
type="default"
|
|
289
|
-
htmlType="button"
|
|
290
|
-
onClick={() => void handleRefetch()}
|
|
291
|
-
icon={<RefreshCw size={16} />}
|
|
292
|
-
>
|
|
293
|
-
{t('menus.model_metadata.manage.refetch_schema_preview')} {/* 重新获取 */}
|
|
294
|
-
</CxButton>
|
|
295
|
-
) : null}
|
|
296
|
-
</div>
|
|
297
|
-
</div>
|
|
298
|
-
<div className="min-h-0 w-full min-w-0 flex-1 overflow-hidden">
|
|
299
|
-
<CxTable
|
|
300
|
-
className="min-w-0 w-full"
|
|
301
|
-
autoScrollY
|
|
302
|
-
minScrollY={160}
|
|
303
|
-
columns={columns}
|
|
304
|
-
dataSource={filteredTables}
|
|
305
|
-
rowKey={(record) => tableStableKey(record)}
|
|
306
|
-
pagination={false}
|
|
307
|
-
scroll={{ x: true }}
|
|
308
|
-
/>
|
|
309
|
-
</div>
|
|
310
|
-
</>
|
|
311
|
-
)}
|
|
312
|
-
|
|
313
|
-
<TableSubmitModal ref={tableSubmitModalRef} />
|
|
314
|
-
</div>
|
|
315
|
-
)
|
|
316
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { CxButton, CxInput, CxSelect, CxTable } from '@cx-ui'
|
|
2
|
-
import { Plus } from 'lucide-react'
|
|
3
|
-
import { useMemo } from 'react'
|
|
4
|
-
import { useTranslation } from 'react-i18next'
|
|
5
|
-
import { tableEditSelectPopupMin } from '../modal/components/table-schema'
|
|
6
|
-
|
|
7
|
-
export type MetadataPermissionRow = {
|
|
8
|
-
id?: string
|
|
9
|
-
permissionName: string
|
|
10
|
-
permissionColumns: string[]
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type SchemaTableBriefForPermissions = {
|
|
14
|
-
tableName?: string
|
|
15
|
-
columns?: { columnName?: string }[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** 全表字段名去重,不含表名 */
|
|
19
|
-
function columnOptionsFromTables(tables: SchemaTableBriefForPermissions[]) {
|
|
20
|
-
const seen = new Set<string>()
|
|
21
|
-
for (const tb of tables || []) {
|
|
22
|
-
for (const col of tb.columns || []) {
|
|
23
|
-
const cn = String(col.columnName ?? '').trim()
|
|
24
|
-
if (!cn) continue
|
|
25
|
-
seen.add(cn)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return [...seen].sort((a, b) => a.localeCompare(b)).map((name) => ({ value: name, label: name }))
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type Step3PermissionsProps = {
|
|
32
|
-
permissions: MetadataPermissionRow[]
|
|
33
|
-
onPermissionsChange: (rows: MetadataPermissionRow[]) => void
|
|
34
|
-
tables: SchemaTableBriefForPermissions[]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function validPermissionColumnValues(tables: SchemaTableBriefForPermissions[]) {
|
|
38
|
-
return new Set(columnOptionsFromTables(tables).map((o) => o.value))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export default function Step3Permissions({
|
|
42
|
-
permissions,
|
|
43
|
-
onPermissionsChange,
|
|
44
|
-
tables,
|
|
45
|
-
}: Step3PermissionsProps) {
|
|
46
|
-
const { t } = useTranslation()
|
|
47
|
-
const columnOptions = useMemo(() => columnOptionsFromTables(tables), [tables])
|
|
48
|
-
|
|
49
|
-
const handleAdd = () => {
|
|
50
|
-
onPermissionsChange([...permissions, { permissionName: '', permissionColumns: [] }])
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const handleDelete = (index: number) => {
|
|
54
|
-
onPermissionsChange(permissions.filter((_, i) => i !== index))
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const handleChange = (index: number, patch: Partial<MetadataPermissionRow>) => {
|
|
58
|
-
const next = [...permissions]
|
|
59
|
-
next[index] = { ...next[index], ...patch }
|
|
60
|
-
onPermissionsChange(next)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const columns = [
|
|
64
|
-
{
|
|
65
|
-
title: t('menus.model_metadata.manage.fields.permissionName'),
|
|
66
|
-
key: 'permissionName',
|
|
67
|
-
width: 180,
|
|
68
|
-
render: (_: unknown, __: MetadataPermissionRow, index: number) => (
|
|
69
|
-
<div className="min-w-0 max-w-full">
|
|
70
|
-
<CxInput
|
|
71
|
-
className="w-full min-w-0"
|
|
72
|
-
value={permissions[index].permissionName}
|
|
73
|
-
onChange={(e) => handleChange(index, { permissionName: e.target.value })}
|
|
74
|
-
placeholder={t('menus.model_metadata.manage.placeholders.permissionName')}
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
),
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
title: t('menus.model_metadata.manage.fields.permissionColumns'),
|
|
81
|
-
key: 'permissionColumns',
|
|
82
|
-
minWidth: 360,
|
|
83
|
-
render: (_: unknown, __: MetadataPermissionRow, index: number) => (
|
|
84
|
-
<CxSelect
|
|
85
|
-
popupMatchSelectWidth={false}
|
|
86
|
-
styles={{ popup: { root: tableEditSelectPopupMin } }}
|
|
87
|
-
mode="multiple"
|
|
88
|
-
showSearch
|
|
89
|
-
allowClear
|
|
90
|
-
optionFilterProp="label"
|
|
91
|
-
className="w-full min-w-0 max-w-full !items-start [&_.ant-select-selector]:!h-auto [&_.ant-select-selector]:!min-h-8 [&_.ant-select-selector]:items-start [&_.ant-select-selection-overflow]:!flex-wrap [&_.ant-select-selection-overflow]:!gap-y-1 [&_.ant-select-selection-overflow]:!gap-x-1 [&_.ant-select-selection-item]:!m-0"
|
|
92
|
-
options={columnOptions}
|
|
93
|
-
value={permissions[index].permissionColumns || []}
|
|
94
|
-
placeholder={t('menus.model_metadata.manage.placeholders.permissionColumns')}
|
|
95
|
-
onChange={(v) =>
|
|
96
|
-
handleChange(index, {
|
|
97
|
-
permissionColumns: Array.isArray(v) ? (v as string[]) : [],
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
/>
|
|
101
|
-
),
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
title: t('common.actions'),
|
|
105
|
-
key: 'action',
|
|
106
|
-
width: 80,
|
|
107
|
-
render: (_: unknown, __: MetadataPermissionRow, index: number) => (
|
|
108
|
-
<CxButton.IconDelete onClick={() => handleDelete(index)} />
|
|
109
|
-
),
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
|
|
113
|
-
return (
|
|
114
|
-
<div className="flex h-full min-h-0 w-full min-w-0 flex-1 flex-col overflow-hidden">
|
|
115
|
-
<div className="mb-4 flex w-full min-w-0 shrink-0 items-center justify-between">
|
|
116
|
-
<h3 className="text-base font-medium">{t('menus.model_metadata.manage.permissions')}</h3>
|
|
117
|
-
<CxButton type="primary" onClick={handleAdd} icon={<Plus size={16} />}>
|
|
118
|
-
{t('menus.model_metadata.manage.add_permission')}
|
|
119
|
-
</CxButton>
|
|
120
|
-
</div>
|
|
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={permissions.map((row, index) => ({ ...row, key: index }))}
|
|
128
|
-
pagination={false}
|
|
129
|
-
scroll={{ x: true }}
|
|
130
|
-
/>
|
|
131
|
-
</div>
|
|
132
|
-
</div>
|
|
133
|
-
)
|
|
134
|
-
}
|