cx-chat 0.0.2 → 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 -272
- /package/{public → dist}/favicon.ico +0 -0
- /package/{public → dist}/vite.svg +0 -0
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react'
|
|
2
|
-
|
|
3
|
-
/** 模型元数据「明细」表单共用状态(表结构 / 权限 / 文档 / 示例 SQL) */
|
|
4
|
-
export function useModelMetadataItemState() {
|
|
5
|
-
const [tables, setTables] = useState<any[]>([])
|
|
6
|
-
const [permissions, setPermissions] = useState<any[]>([])
|
|
7
|
-
const [documents, setDocuments] = useState<any[]>([])
|
|
8
|
-
const [exampleSqlList, setExampleSqlList] = useState<any[]>([])
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
tables,
|
|
12
|
-
setTables,
|
|
13
|
-
permissions,
|
|
14
|
-
setPermissions,
|
|
15
|
-
documents,
|
|
16
|
-
setDocuments,
|
|
17
|
-
exampleSqlList,
|
|
18
|
-
setExampleSqlList,
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
import { useAuth } from '@/contexts/AuthContext'
|
|
2
|
-
import { ALIGN, DICT_DATA, DICT_KEY, ENUM_DATA } from '@/meta'
|
|
3
|
-
import {
|
|
4
|
-
deleteModelMetadataAPI,
|
|
5
|
-
disableModelMetadataAPI,
|
|
6
|
-
enableModelMetadataAPI,
|
|
7
|
-
getModelMetadataPageAPI,
|
|
8
|
-
} from '@api/menus/model-metadata/manage'
|
|
9
|
-
import { DetailLink } from '@components/common/detail-link'
|
|
10
|
-
import ListPageView, { createListPageConfig } from '@components/table-view'
|
|
11
|
-
import { CxButton, CxTag } from '@cx-ui'
|
|
12
|
-
import { useMemo, useRef } from 'react'
|
|
13
|
-
|
|
14
|
-
import DetailModal from './modal/detail-modal'
|
|
15
|
-
import SubmitModal from './modal/submit-modal'
|
|
16
|
-
|
|
17
|
-
// 列表页 i18n:menus.model_metadata.manage.* → locales/zh/menus/model-metadata/manage.ts
|
|
18
|
-
const useListPageConfig = createListPageConfig({
|
|
19
|
-
tableAPI: getModelMetadataPageAPI,
|
|
20
|
-
deleteAPI: deleteModelMetadataAPI,
|
|
21
|
-
updateStatusAPI: ({ id, status }) =>
|
|
22
|
-
Number(status) === 1 ? enableModelMetadataAPI(id) : disableModelMetadataAPI(id),
|
|
23
|
-
pageInfo: {
|
|
24
|
-
title: 'menus.model_metadata.manage.page_title', // 模型元数据管理
|
|
25
|
-
subTitle: 'menus.model_metadata.manage.page_subtitle', // 副标题
|
|
26
|
-
},
|
|
27
|
-
searchFields: [
|
|
28
|
-
{
|
|
29
|
-
prop: 'subject',
|
|
30
|
-
label: 'menus.model_metadata.manage.fields.subject', // 主题
|
|
31
|
-
placeholder: 'menus.model_metadata.manage.search_placeholder_subject', // 搜主题
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
prop: 'databaseName',
|
|
35
|
-
label: 'menus.model_metadata.manage.fields.databaseName', // 数据库名
|
|
36
|
-
placeholder: 'menus.model_metadata.manage.search_placeholder_databaseName', // 搜库名
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
prop: 'dbType',
|
|
40
|
-
label: 'menus.model_metadata.manage.fields.dbType', // 库类型
|
|
41
|
-
type: 'select',
|
|
42
|
-
options: [],
|
|
43
|
-
width: '120px',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
prop: 'status',
|
|
47
|
-
label: 'menus.model_metadata.manage.fields.status',
|
|
48
|
-
type: 'select',
|
|
49
|
-
placeholder: 'common.status',
|
|
50
|
-
options: ENUM_DATA.commonStatus.option.map(({ label, value }) => ({
|
|
51
|
-
label,
|
|
52
|
-
value,
|
|
53
|
-
})),
|
|
54
|
-
width: '120px',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
prop: 'createBy',
|
|
58
|
-
label: 'common.creator',
|
|
59
|
-
placeholder: 'menus.model_metadata.manage.search_placeholder_createBy', // 搜创建人
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
prop: 'createTime',
|
|
63
|
-
label: 'common.create_time',
|
|
64
|
-
type: 'dateRange',
|
|
65
|
-
rangeStartProp: 'createTimeStart',
|
|
66
|
-
rangeEndProp: 'createTimeEnd',
|
|
67
|
-
showTime: true,
|
|
68
|
-
format: 'YYYY-MM-DD HH:mm:ss',
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
statusToggle: {
|
|
72
|
-
dangerOnDisable: true,
|
|
73
|
-
disableConfirm: {
|
|
74
|
-
cancelText: 'common.cancel',
|
|
75
|
-
content: 'menus.model_metadata.manage.disable_confirm_content',
|
|
76
|
-
contentFields: 'subject',
|
|
77
|
-
okText: 'common.confirm',
|
|
78
|
-
title: 'menus.model_metadata.manage.disable_confirm_title',
|
|
79
|
-
},
|
|
80
|
-
enableConfirm: {
|
|
81
|
-
cancelText: 'common.cancel',
|
|
82
|
-
content: 'menus.model_metadata.manage.enable_confirm_content',
|
|
83
|
-
contentFields: 'subject',
|
|
84
|
-
okText: 'common.confirm',
|
|
85
|
-
title: 'menus.model_metadata.manage.enable_confirm_title',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
submitAction: {
|
|
89
|
-
permission: 'model-metadata:add',
|
|
90
|
-
submitType: 'page',
|
|
91
|
-
labelKey: 'menus.model_metadata.manage.add', // 新增
|
|
92
|
-
},
|
|
93
|
-
detailAction: {
|
|
94
|
-
detailType: 'page',
|
|
95
|
-
labelKey: 'common.view',
|
|
96
|
-
},
|
|
97
|
-
table: {
|
|
98
|
-
scrollX: 'max-content',
|
|
99
|
-
},
|
|
100
|
-
deleteConfirm: {
|
|
101
|
-
title: 'menus.model_metadata.manage.delete_confirm_title', // 删除确认标题
|
|
102
|
-
content: 'menus.model_metadata.manage.delete_confirm_content', // 删除确认正文
|
|
103
|
-
okText: 'common.delete',
|
|
104
|
-
cancelText: 'common.cancel',
|
|
105
|
-
},
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
function IndexView() {
|
|
109
|
-
const { hasPermission, commonDictRevision } = useAuth()
|
|
110
|
-
const pageConfig = useListPageConfig()
|
|
111
|
-
|
|
112
|
-
const dbTypeSearchOptions = useMemo(
|
|
113
|
-
() =>
|
|
114
|
-
(DICT_DATA[DICT_KEY.dbType]?.option ?? []).map((o) => ({
|
|
115
|
-
label: o.name,
|
|
116
|
-
value: o.value,
|
|
117
|
-
})),
|
|
118
|
-
[commonDictRevision],
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
const listPageConfig = useMemo(
|
|
122
|
-
() => ({
|
|
123
|
-
...pageConfig,
|
|
124
|
-
searchFields: pageConfig.searchFields.map((f: any) =>
|
|
125
|
-
f.prop === 'dbType' ? { ...f, options: dbTypeSearchOptions } : f,
|
|
126
|
-
),
|
|
127
|
-
}),
|
|
128
|
-
[pageConfig, dbTypeSearchOptions],
|
|
129
|
-
)
|
|
130
|
-
/** 与主题列「跳转详情页」分离:操作列查看走弹窗,不经过 listPageConfig.onDetail 的 page 默认逻辑 */
|
|
131
|
-
const detailModalRef = useRef<{
|
|
132
|
-
open: (p?: any) => void
|
|
133
|
-
close: () => void
|
|
134
|
-
} | null>(null)
|
|
135
|
-
const submitModalRef = useRef<{
|
|
136
|
-
open: (p?: any) => void
|
|
137
|
-
close: () => void
|
|
138
|
-
} | null>(null)
|
|
139
|
-
|
|
140
|
-
const columns = useMemo(
|
|
141
|
-
() => [
|
|
142
|
-
{
|
|
143
|
-
title: 'menus.model_metadata.manage.fields.subject', // 主题
|
|
144
|
-
key: 'subject',
|
|
145
|
-
align: ALIGN.LEFT,
|
|
146
|
-
minWidth: 160,
|
|
147
|
-
render: (value: unknown, data: any) => (
|
|
148
|
-
<DetailLink
|
|
149
|
-
text={String(value ?? data?.subject ?? '-')}
|
|
150
|
-
disabled={!hasPermission('model-metadata:detail')}
|
|
151
|
-
onClick={() =>
|
|
152
|
-
listPageConfig.onDetail?.({
|
|
153
|
-
type: 'detail',
|
|
154
|
-
data,
|
|
155
|
-
config: listPageConfig.detailAction,
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
/>
|
|
159
|
-
),
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
title: 'menus.model_metadata.manage.fields.databaseName', // 数据库名
|
|
163
|
-
key: 'databaseName',
|
|
164
|
-
align: ALIGN.LEFT,
|
|
165
|
-
minWidth: 150,
|
|
166
|
-
ellipsis: true,
|
|
167
|
-
render: (value: unknown) => value ?? '-',
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
title: 'menus.model_metadata.manage.fields.schemaVersion', // 元数据版本
|
|
171
|
-
key: 'schemaVersion',
|
|
172
|
-
align: ALIGN.CENTER,
|
|
173
|
-
width: 120,
|
|
174
|
-
render: (value: unknown) => value ?? '-',
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
title: 'menus.model_metadata.manage.fields.dbType', // 库类型
|
|
178
|
-
key: 'dbType',
|
|
179
|
-
align: ALIGN.CENTER,
|
|
180
|
-
width: 100,
|
|
181
|
-
render: (value: unknown) => value ?? '-',
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
title: 'menus.model_metadata.manage.fields.host',
|
|
185
|
-
key: 'host',
|
|
186
|
-
align: ALIGN.LEFT,
|
|
187
|
-
width: 230,
|
|
188
|
-
ellipsis: true,
|
|
189
|
-
render: (_: unknown, record: any) => `${record.host ?? ''}:${record.port ?? ''}`,
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
title: 'menus.model_metadata.manage.fields.tableCount', // 表数量
|
|
193
|
-
key: 'tableCount',
|
|
194
|
-
align: ALIGN.CENTER,
|
|
195
|
-
width: 100,
|
|
196
|
-
render: (value: unknown) => value ?? 0,
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
title: 'common.status',
|
|
200
|
-
key: 'status',
|
|
201
|
-
align: ALIGN.CENTER,
|
|
202
|
-
width: 100,
|
|
203
|
-
render: (value: unknown) => <CxTag.Enabled value={value as number} />,
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
title: 'common.creator',
|
|
207
|
-
key: 'createBy',
|
|
208
|
-
align: ALIGN.LEFT,
|
|
209
|
-
width: 120,
|
|
210
|
-
render: (value: unknown) => value ?? '-',
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
title: 'common.create_time',
|
|
214
|
-
key: 'createTime',
|
|
215
|
-
align: ALIGN.LEFT,
|
|
216
|
-
width: 170,
|
|
217
|
-
render: (value: unknown) => value ?? '-',
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
title: 'common.actions',
|
|
221
|
-
key: 'action',
|
|
222
|
-
align: ALIGN.LEFT,
|
|
223
|
-
width: 220,
|
|
224
|
-
render: (_: unknown, data: any) => {
|
|
225
|
-
const isEnabled = Number(data?.status) === 1
|
|
226
|
-
return (
|
|
227
|
-
<div className="flex flex-wrap gap-2">
|
|
228
|
-
{hasPermission('model-metadata:detail') && (
|
|
229
|
-
<CxButton.IconView
|
|
230
|
-
onClick={() =>
|
|
231
|
-
detailModalRef.current?.open({
|
|
232
|
-
opeType: 'detail',
|
|
233
|
-
opeId: data?.id,
|
|
234
|
-
data,
|
|
235
|
-
})
|
|
236
|
-
}
|
|
237
|
-
/>
|
|
238
|
-
)}
|
|
239
|
-
{hasPermission('model-metadata:enable') && !isEnabled && (
|
|
240
|
-
<CxButton.IconEnable
|
|
241
|
-
onClick={() =>
|
|
242
|
-
listPageConfig.onStatusToggle?.({
|
|
243
|
-
nextStatus: 1,
|
|
244
|
-
data,
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
|
-
/>
|
|
248
|
-
)}
|
|
249
|
-
{hasPermission('model-metadata:disable') && isEnabled && (
|
|
250
|
-
<CxButton.IconDisable
|
|
251
|
-
onClick={() =>
|
|
252
|
-
listPageConfig.onStatusToggle?.({
|
|
253
|
-
nextStatus: 0,
|
|
254
|
-
data,
|
|
255
|
-
})
|
|
256
|
-
}
|
|
257
|
-
/>
|
|
258
|
-
)}
|
|
259
|
-
{hasPermission('model-metadata:edit') && !isEnabled && (
|
|
260
|
-
<CxButton.IconEdit
|
|
261
|
-
onClick={() =>
|
|
262
|
-
listPageConfig.onEdit?.({
|
|
263
|
-
type: 'edit',
|
|
264
|
-
data,
|
|
265
|
-
config: listPageConfig.submitAction,
|
|
266
|
-
})
|
|
267
|
-
}
|
|
268
|
-
/>
|
|
269
|
-
)}
|
|
270
|
-
{hasPermission('model-metadata:delete') && !isEnabled && (
|
|
271
|
-
<CxButton.IconDelete onClick={() => listPageConfig.onDelete?.(data)} />
|
|
272
|
-
)}
|
|
273
|
-
</div>
|
|
274
|
-
)
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
],
|
|
278
|
-
[hasPermission, listPageConfig],
|
|
279
|
-
)
|
|
280
|
-
|
|
281
|
-
return (
|
|
282
|
-
<>
|
|
283
|
-
<ListPageView columns={columns} pageConfig={listPageConfig} />
|
|
284
|
-
<DetailModal
|
|
285
|
-
ref={detailModalRef}
|
|
286
|
-
onEditMain={(opeId) => {
|
|
287
|
-
submitModalRef.current?.open({
|
|
288
|
-
opeType: 'edit',
|
|
289
|
-
opeId,
|
|
290
|
-
data: { id: opeId },
|
|
291
|
-
})
|
|
292
|
-
}}
|
|
293
|
-
/>
|
|
294
|
-
<SubmitModal
|
|
295
|
-
ref={submitModalRef}
|
|
296
|
-
onOk={async () => {
|
|
297
|
-
await listPageConfig.fetchTableData?.()
|
|
298
|
-
}}
|
|
299
|
-
/>
|
|
300
|
-
</>
|
|
301
|
-
)
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
export default IndexView
|
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
/** 表结构弹窗:类型、常量、与提交/校验相关的纯函数(供 modal 与 submit 共用) */
|
|
2
|
-
|
|
3
|
-
export const TABLE_SUBMIT_MODAL_WIDTH = 1400
|
|
4
|
-
export const TABLE_SUBMIT_MODAL_HEIGHT = 'min(95dvh, 95vh)'
|
|
5
|
-
|
|
6
|
-
export const COMMON_DATA_TYPES = [
|
|
7
|
-
'bigint',
|
|
8
|
-
'binary',
|
|
9
|
-
'bit',
|
|
10
|
-
'blob',
|
|
11
|
-
'bool',
|
|
12
|
-
'char',
|
|
13
|
-
'date',
|
|
14
|
-
'datetime',
|
|
15
|
-
'decimal',
|
|
16
|
-
'double',
|
|
17
|
-
'float',
|
|
18
|
-
'int',
|
|
19
|
-
'json',
|
|
20
|
-
'longtext',
|
|
21
|
-
'mediumint',
|
|
22
|
-
'mediumtext',
|
|
23
|
-
'smallint',
|
|
24
|
-
'text',
|
|
25
|
-
'time',
|
|
26
|
-
'timestamp',
|
|
27
|
-
'tinyint',
|
|
28
|
-
'varbinary',
|
|
29
|
-
'varchar',
|
|
30
|
-
]
|
|
31
|
-
|
|
32
|
-
export const INDEX_KIND_OPTIONS = [
|
|
33
|
-
{ value: 'NORMAL', label: 'NORMAL' },
|
|
34
|
-
{ value: 'UNIQUE', label: 'UNIQUE' },
|
|
35
|
-
{ value: 'FULLTEXT', label: 'FULLTEXT' },
|
|
36
|
-
{ value: 'SPATIAL', label: 'SPATIAL' },
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
export const INDEX_METHOD_OPTIONS = [
|
|
40
|
-
{ value: 'BTREE', label: 'BTREE' },
|
|
41
|
-
{ value: 'HASH', label: 'HASH' },
|
|
42
|
-
{ value: 'RTREE', label: 'RTREE' },
|
|
43
|
-
]
|
|
44
|
-
|
|
45
|
-
export const FK_RULE_VALUES = ['CASCADE', 'RESTRICT', 'SET NULL', 'NO ACTION'] as const
|
|
46
|
-
export const FK_RULE_OPTIONS = FK_RULE_VALUES.map((v) => ({
|
|
47
|
-
value: v,
|
|
48
|
-
label: v,
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
export const tableEditSelectPopupMin = { minWidth: 120 } as const
|
|
52
|
-
export const cxSelectInTableProps = {
|
|
53
|
-
className: 'w-full min-w-0 max-w-full overflow-hidden',
|
|
54
|
-
popupMatchSelectWidth: false,
|
|
55
|
-
styles: { popup: { root: tableEditSelectPopupMin } },
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export const cxSelectFkProps = {
|
|
59
|
-
...cxSelectInTableProps,
|
|
60
|
-
showSearch: true,
|
|
61
|
-
allowClear: true,
|
|
62
|
-
optionFilterProp: 'label' as const,
|
|
63
|
-
filterOption: (input: string, option?: { label?: unknown; value?: string }) => {
|
|
64
|
-
const q = input.trim().toLowerCase()
|
|
65
|
-
if (!q) return true
|
|
66
|
-
const lv = String(option?.label ?? '').toLowerCase()
|
|
67
|
-
const vv = String(option?.value ?? '').toLowerCase()
|
|
68
|
-
return lv.includes(q) || vv.includes(q)
|
|
69
|
-
},
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const tableSubmitModalShellStyles = {
|
|
73
|
-
container: {
|
|
74
|
-
display: 'flex',
|
|
75
|
-
flexDirection: 'column' as const,
|
|
76
|
-
overflow: 'hidden',
|
|
77
|
-
height: TABLE_SUBMIT_MODAL_HEIGHT,
|
|
78
|
-
maxHeight: TABLE_SUBMIT_MODAL_HEIGHT,
|
|
79
|
-
},
|
|
80
|
-
body: {
|
|
81
|
-
flex: '1 1 0%',
|
|
82
|
-
minHeight: 0,
|
|
83
|
-
display: 'flex',
|
|
84
|
-
flexDirection: 'column' as const,
|
|
85
|
-
overflow: 'hidden',
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export type SchemaTableBrief = {
|
|
90
|
-
tableName?: string
|
|
91
|
-
tableComment?: string
|
|
92
|
-
columns?: { columnName?: string; COLUMN_NAME?: string }[]
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export type Column = {
|
|
96
|
-
columnName: string
|
|
97
|
-
dataType: string
|
|
98
|
-
/** 是否隐私:0 否,1 是 */
|
|
99
|
-
privacyFlag?: number
|
|
100
|
-
charLength?: number
|
|
101
|
-
numericPrecision?: number
|
|
102
|
-
numericScale?: number
|
|
103
|
-
isNullable?: number
|
|
104
|
-
columnDefault?: string
|
|
105
|
-
commentText?: string
|
|
106
|
-
valueType?: number
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export type IndexColumn = {
|
|
110
|
-
columnName: string
|
|
111
|
-
seqInIndex: number
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export type Index = {
|
|
115
|
-
indexName: string
|
|
116
|
-
isUnique?: number
|
|
117
|
-
indexType?: string
|
|
118
|
-
indexMethod?: string
|
|
119
|
-
indexColumns: IndexColumn[]
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export type ForeignKeyColumn = {
|
|
123
|
-
columnName: string
|
|
124
|
-
referencedColumnName: string
|
|
125
|
-
seqInFk: number
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export type ForeignKey = {
|
|
129
|
-
fkName: string
|
|
130
|
-
referencedTableSchema?: string
|
|
131
|
-
referencedTable: string
|
|
132
|
-
updateRule?: string
|
|
133
|
-
deleteRule?: string
|
|
134
|
-
fkColumns: ForeignKeyColumn[]
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export type TableDetail = {
|
|
138
|
-
tableSchema?: string
|
|
139
|
-
tableName: string
|
|
140
|
-
tableComment?: string
|
|
141
|
-
tableType?: string
|
|
142
|
-
columns: Column[]
|
|
143
|
-
indexes: Index[]
|
|
144
|
-
foreignKeys: ForeignKey[]
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function tableColumnNameList(table: SchemaTableBrief | undefined): string[] {
|
|
148
|
-
if (!table?.columns?.length) return []
|
|
149
|
-
const names = table.columns
|
|
150
|
-
.map((c) => c.columnName ?? c.COLUMN_NAME ?? '')
|
|
151
|
-
.filter(Boolean) as string[]
|
|
152
|
-
return [...new Set(names)]
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function clonePart<T>(x: T): T {
|
|
156
|
-
return JSON.parse(JSON.stringify(x)) as T
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function parseIndexColumnNames(s: string): IndexColumn[] {
|
|
160
|
-
const names = s
|
|
161
|
-
.split(',')
|
|
162
|
-
.map((x) => x.trim())
|
|
163
|
-
.filter(Boolean)
|
|
164
|
-
return names.map((columnName, i) => ({ columnName, seqInIndex: i + 1 }))
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** 反查预览 / 详情:indexColumns 为 { columnName, seqInIndex }[],seqInIndex 可能全为 0 */
|
|
168
|
-
export function normalizeIndexColumnsInput(raw: unknown): IndexColumn[] {
|
|
169
|
-
if (raw == null || raw === '') return []
|
|
170
|
-
if (!Array.isArray(raw) || raw.length === 0) return []
|
|
171
|
-
const mapped = (raw as { columnName?: string; seqInIndex?: number }[]).map((c, i) => ({
|
|
172
|
-
columnName: String(c.columnName ?? ''),
|
|
173
|
-
seqInIndex: typeof c.seqInIndex === 'number' ? c.seqInIndex : NaN,
|
|
174
|
-
_i: i,
|
|
175
|
-
}))
|
|
176
|
-
const rows = mapped.filter((x) => x.columnName)
|
|
177
|
-
if (rows.length === 0) return []
|
|
178
|
-
const hasPositiveSeq = rows.some((r) => Number(r.seqInIndex) > 0)
|
|
179
|
-
const ordered = hasPositiveSeq
|
|
180
|
-
? rows.slice().sort((a, b) => {
|
|
181
|
-
const sa = Number(a.seqInIndex) > 0 ? Number(a.seqInIndex) : 1e9 + a._i
|
|
182
|
-
const sb = Number(b.seqInIndex) > 0 ? Number(b.seqInIndex) : 1e9 + b._i
|
|
183
|
-
return sa - sb
|
|
184
|
-
})
|
|
185
|
-
: rows.slice().sort((a, b) => a._i - b._i)
|
|
186
|
-
return ordered.map((c, i) => ({ columnName: c.columnName, seqInIndex: i + 1 }))
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/** 提交:indexColumns 为 { columnName, seqInIndex }[],seqInIndex 为下标+1 */
|
|
190
|
-
export function normalizeIndexColumnsForSubmit(raw: unknown) {
|
|
191
|
-
return normalizeIndexColumnsInput(raw).map((c, i) => ({
|
|
192
|
-
columnName: c.columnName,
|
|
193
|
-
seqInIndex: i + 1,
|
|
194
|
-
}))
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function indexColumnNamesForMultiSelect(cols: IndexColumn[] | undefined): string[] {
|
|
198
|
-
if (!cols?.length) return []
|
|
199
|
-
return cols
|
|
200
|
-
.slice()
|
|
201
|
-
.map((c, i) => ({ ...c, _i: i }))
|
|
202
|
-
.sort((a, b) => {
|
|
203
|
-
const d = (a.seqInIndex ?? 0) - (b.seqInIndex ?? 0)
|
|
204
|
-
return d !== 0 ? d : a._i - b._i
|
|
205
|
-
})
|
|
206
|
-
.map((c) => c.columnName)
|
|
207
|
-
.filter(Boolean)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export function getIndexKind(idx: Index): string {
|
|
211
|
-
if (idx.isUnique === 1) return 'UNIQUE'
|
|
212
|
-
const t = (idx.indexType || '').toUpperCase()
|
|
213
|
-
if (t.includes('FULLTEXT')) return 'FULLTEXT'
|
|
214
|
-
if (t.includes('SPATIAL')) return 'SPATIAL'
|
|
215
|
-
if (t === 'UNIQUE') return 'UNIQUE'
|
|
216
|
-
return 'NORMAL'
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export function applyIndexKind(idx: Index, kind: string): Index {
|
|
220
|
-
if (kind === 'UNIQUE') {
|
|
221
|
-
return { ...idx, isUnique: 1, indexType: 'UNIQUE' }
|
|
222
|
-
}
|
|
223
|
-
return { ...idx, isUnique: 0, indexType: kind }
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export function fkColNamesForMultiSelect(
|
|
227
|
-
cols: ForeignKeyColumn[] | undefined,
|
|
228
|
-
key: 'columnName' | 'referencedColumnName',
|
|
229
|
-
): string[] {
|
|
230
|
-
if (!cols?.length) return []
|
|
231
|
-
return cols
|
|
232
|
-
.slice()
|
|
233
|
-
.map((c, i) => ({ ...c, _i: i }))
|
|
234
|
-
.sort((a, b) => {
|
|
235
|
-
const d = (a.seqInFk ?? 0) - (b.seqInFk ?? 0)
|
|
236
|
-
return d !== 0 ? d : a._i - b._i
|
|
237
|
-
})
|
|
238
|
-
.map((c) => String(c[key] ?? '').trim())
|
|
239
|
-
.filter(Boolean)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
export function zipFkPairColumns(localArr: string[], refArr: string[]): ForeignKeyColumn[] {
|
|
243
|
-
const n = Math.max(localArr.length, refArr.length)
|
|
244
|
-
if (n === 0) return []
|
|
245
|
-
return Array.from({ length: n }, (_, i) => ({
|
|
246
|
-
columnName: localArr[i] ?? '',
|
|
247
|
-
referencedColumnName: refArr[i] ?? '',
|
|
248
|
-
seqInFk: i + 1,
|
|
249
|
-
}))
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/** 反查预览 / 详情:fkColumns 为 { columnName, referencedColumnName, seqInFk }[],seqInFk 可能全为 0 */
|
|
253
|
-
export function normalizeForeignKeyColumnsInput(raw: unknown): ForeignKeyColumn[] {
|
|
254
|
-
if (raw == null || raw === '') return []
|
|
255
|
-
if (!Array.isArray(raw) || raw.length === 0) return []
|
|
256
|
-
if (typeof raw[0] !== 'object' || raw[0] == null) return []
|
|
257
|
-
const mapped = (raw as { columnName?: string; referencedColumnName?: string; seqInFk?: number }[]).map(
|
|
258
|
-
(c, i) => ({
|
|
259
|
-
columnName: String(c.columnName ?? ''),
|
|
260
|
-
referencedColumnName: String(c.referencedColumnName ?? ''),
|
|
261
|
-
seqInFk: typeof c.seqInFk === 'number' ? c.seqInFk : NaN,
|
|
262
|
-
_i: i,
|
|
263
|
-
}),
|
|
264
|
-
)
|
|
265
|
-
const hasPositiveSeq = mapped.some((r) => Number(r.seqInFk) > 0)
|
|
266
|
-
const ordered = hasPositiveSeq
|
|
267
|
-
? mapped.slice().sort((a, b) => {
|
|
268
|
-
const sa = Number(a.seqInFk) > 0 ? Number(a.seqInFk) : 1e9 + a._i
|
|
269
|
-
const sb = Number(b.seqInFk) > 0 ? Number(b.seqInFk) : 1e9 + b._i
|
|
270
|
-
return sa - sb
|
|
271
|
-
})
|
|
272
|
-
: mapped.slice().sort((a, b) => a._i - b._i)
|
|
273
|
-
return ordered.map((c, i) => ({
|
|
274
|
-
columnName: c.columnName,
|
|
275
|
-
referencedColumnName: c.referencedColumnName,
|
|
276
|
-
seqInFk: i + 1,
|
|
277
|
-
}))
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/** 提交:fkColumns 每项 seqInFk 为下标+1 */
|
|
281
|
-
export function normalizeFkColumnsForSubmit(raw: unknown) {
|
|
282
|
-
return normalizeForeignKeyColumnsInput(raw).map((c, i) => ({
|
|
283
|
-
columnName: c.columnName,
|
|
284
|
-
referencedColumnName: c.referencedColumnName,
|
|
285
|
-
seqInFk: i + 1,
|
|
286
|
-
}))
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export function validateForeignKeyRows(fks: unknown): string | null {
|
|
290
|
-
const list = Array.isArray(fks) ? fks : []
|
|
291
|
-
for (const fk of list) {
|
|
292
|
-
const cols = normalizeForeignKeyColumnsInput((fk as any)?.fkColumns)
|
|
293
|
-
const locs = cols.map((c) => String(c.columnName ?? '').trim()).filter(Boolean)
|
|
294
|
-
const refs = cols.map((c) => String(c.referencedColumnName ?? '').trim()).filter(Boolean)
|
|
295
|
-
const fkName = String((fk as any)?.fkName ?? '').trim()
|
|
296
|
-
const refTable = String((fk as any)?.referencedTable ?? '').trim()
|
|
297
|
-
const touched = Boolean(fkName || refTable || locs.length || refs.length)
|
|
298
|
-
if (!touched) continue
|
|
299
|
-
if (!fkName) return 'fk_name_required'
|
|
300
|
-
if (!refTable) return 'fk_referenced_table_required'
|
|
301
|
-
if (locs.length !== refs.length) return 'fk_columns_count_mismatch'
|
|
302
|
-
if (locs.length === 0) return 'fk_columns_required'
|
|
303
|
-
}
|
|
304
|
-
return null
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export function validateForeignKeysInTables(tables: unknown): string | null {
|
|
308
|
-
const list = Array.isArray(tables) ? tables : []
|
|
309
|
-
for (const tb of list) {
|
|
310
|
-
const err = validateForeignKeyRows((tb as any)?.foreignKeys)
|
|
311
|
-
if (err) return err
|
|
312
|
-
}
|
|
313
|
-
return null
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
export function validateIndexRows(indexes: unknown): string | null {
|
|
317
|
-
const list = Array.isArray(indexes) ? indexes : []
|
|
318
|
-
for (const ix of list) {
|
|
319
|
-
const name = String((ix as any)?.indexName ?? '').trim()
|
|
320
|
-
const cols = normalizeIndexColumnsInput((ix as any)?.indexColumns)
|
|
321
|
-
const colNames = cols.map((c) => String(c.columnName ?? '').trim()).filter(Boolean)
|
|
322
|
-
const touched = Boolean(name || colNames.length)
|
|
323
|
-
if (!touched) continue
|
|
324
|
-
if (!name) return 'index_name_required'
|
|
325
|
-
if (colNames.length === 0) return 'index_columns_required'
|
|
326
|
-
}
|
|
327
|
-
return null
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export function validateIndexesInTables(tables: unknown): string | null {
|
|
331
|
-
const list = Array.isArray(tables) ? tables : []
|
|
332
|
-
for (const tb of list) {
|
|
333
|
-
const err = validateIndexRows((tb as any)?.indexes)
|
|
334
|
-
if (err) return err
|
|
335
|
-
}
|
|
336
|
-
return null
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export function isEmptyIndexRow(ix: unknown): boolean {
|
|
340
|
-
const name = String((ix as any)?.indexName ?? '').trim()
|
|
341
|
-
if (name) return false
|
|
342
|
-
return normalizeIndexColumnsInput((ix as any)?.indexColumns).length === 0
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export function isEmptyForeignKeyRow(fk: unknown): boolean {
|
|
346
|
-
const fkName = String((fk as any)?.fkName ?? '').trim()
|
|
347
|
-
const refTable = String((fk as any)?.referencedTable ?? '').trim()
|
|
348
|
-
if (fkName || refTable) return false
|
|
349
|
-
return normalizeForeignKeyColumnsInput((fk as any)?.fkColumns).length === 0
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export const emptyColumn = (): Column => ({
|
|
353
|
-
columnName: '',
|
|
354
|
-
dataType: 'varchar',
|
|
355
|
-
privacyFlag: 0,
|
|
356
|
-
isNullable: 1,
|
|
357
|
-
commentText: '',
|
|
358
|
-
})
|
|
359
|
-
|
|
360
|
-
export const emptyIndex = (): Index => ({
|
|
361
|
-
indexName: '',
|
|
362
|
-
isUnique: 0,
|
|
363
|
-
indexType: 'NORMAL',
|
|
364
|
-
indexMethod: 'BTREE',
|
|
365
|
-
indexColumns: [],
|
|
366
|
-
})
|
|
367
|
-
|
|
368
|
-
export const emptyForeignKey = (): ForeignKey => ({
|
|
369
|
-
fkName: '',
|
|
370
|
-
referencedTable: '',
|
|
371
|
-
updateRule: 'NO ACTION',
|
|
372
|
-
deleteRule: 'NO ACTION',
|
|
373
|
-
fkColumns: [],
|
|
374
|
-
})
|