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,388 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
registerAPI,
|
|
3
|
-
sendEmailVerifyCodeAPI,
|
|
4
|
-
} from '@/api/common/auth';
|
|
5
|
-
import LanguageSwitcher from '@/components/common/language-switcher';
|
|
6
|
-
import { SystemLogoMark } from '@/components/common/system-logo-mark';
|
|
7
|
-
import { useSystemConfig } from '@/config/system';
|
|
8
|
-
import { DICT_KEY, getDictOptions, publicDictsReady } from '@/meta';
|
|
9
|
-
import { antdTheme } from '@/styles/antd-theme';
|
|
10
|
-
import { CxInput, CxSelect } from '@cx-ui';
|
|
11
|
-
import { ConfigProvider, theme as antdThemePreset, type ThemeConfig } from 'antd';
|
|
12
|
-
import { ArrowRight, Loader2, Lock, Mail, Phone, User } from 'lucide-react';
|
|
13
|
-
import React, { useEffect, useState } from 'react';
|
|
14
|
-
import { useTranslation } from 'react-i18next';
|
|
15
|
-
import { Link, useNavigate } from 'react-router-dom';
|
|
16
|
-
import { countryCodes } from '../../constants/countryCodes';
|
|
17
|
-
import { useToast } from '../../contexts/ToastContext';
|
|
18
|
-
import { validateEmail, validatePhoneNumber } from '../../utils/validation';
|
|
19
|
-
import AuthCode from './auth-code';
|
|
20
|
-
/** 注册落地页固定暗黑控件,与后台是否 `html.dark` 无关 */
|
|
21
|
-
const registerPageAntdTheme: ThemeConfig = {
|
|
22
|
-
...antdTheme,
|
|
23
|
-
algorithm: antdThemePreset.darkAlgorithm,
|
|
24
|
-
components: {
|
|
25
|
-
Input: {
|
|
26
|
-
colorBgContainer: 'rgba(19, 19, 20, 0.55)',
|
|
27
|
-
colorBorder: '#3f3f46',
|
|
28
|
-
hoverBorderColor: '#52525b',
|
|
29
|
-
activeBorderColor: '#52525b',
|
|
30
|
-
activeShadow: 'none',
|
|
31
|
-
},
|
|
32
|
-
Select: {
|
|
33
|
-
selectorBg: 'rgba(19, 19, 20, 0.55)',
|
|
34
|
-
colorBorder: '#3f3f46',
|
|
35
|
-
hoverBorderColor: '#52525b',
|
|
36
|
-
activeBorderColor: '#52525b',
|
|
37
|
-
activeOutlineColor: 'transparent',
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const RegisterPage: React.FC = () => {
|
|
43
|
-
const EMAIL_CODE_COOLDOWN_KEY = 'register_email_code_cooldown_until';
|
|
44
|
-
const [email, setEmail] = useState('');
|
|
45
|
-
const [password, setPassword] = useState('');
|
|
46
|
-
const [displayName, setDisplayName] = useState('');
|
|
47
|
-
const [countryCode, setCountryCode] = useState('+86');
|
|
48
|
-
const [phoneNumber, setPhoneNumber] = useState('');
|
|
49
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
50
|
-
const [isSendingCode, setIsSendingCode] = useState(false);
|
|
51
|
-
const [isCooldownLoading, setIsCooldownLoading] = useState(true);
|
|
52
|
-
const [cooldownSeconds, setCooldownSeconds] = useState(0);
|
|
53
|
-
const [emailCode, setEmailCode] = useState('');
|
|
54
|
-
const [phoneDialOptions, setPhoneDialOptions] = useState(() =>
|
|
55
|
-
countryCodes.map((c) => ({ value: c.dial_code, label: c.dial_code })),
|
|
56
|
-
);
|
|
57
|
-
const [isAuthCodeVisible, setIsAuthCodeVisible] = useState(false);
|
|
58
|
-
const { showToast, clearToasts } = useToast();
|
|
59
|
-
const navigate = useNavigate();
|
|
60
|
-
const { t } = useTranslation();
|
|
61
|
-
const { systemName } = useSystemConfig()
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
const cooldownUntil = Number(localStorage.getItem(EMAIL_CODE_COOLDOWN_KEY) || 0);
|
|
65
|
-
const left = Math.ceil((cooldownUntil - Date.now()) / 1000);
|
|
66
|
-
setCooldownSeconds(left > 0 ? left : 0);
|
|
67
|
-
setIsCooldownLoading(false);
|
|
68
|
-
}, []);
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
void publicDictsReady.then(() => {
|
|
72
|
-
const fromDict = getDictOptions(DICT_KEY.phoneArea);
|
|
73
|
-
if (fromDict.length > 0) {
|
|
74
|
-
const next = fromDict.map((o) => ({
|
|
75
|
-
value: String(o.value),
|
|
76
|
-
label: o.name,
|
|
77
|
-
}));
|
|
78
|
-
setPhoneDialOptions(next);
|
|
79
|
-
setCountryCode((prev) =>
|
|
80
|
-
next.some((r) => r.value === prev) ? prev : next[0]?.value ?? prev,
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}, []);
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
if (cooldownSeconds <= 0) return;
|
|
88
|
-
const timer = window.setInterval(() => {
|
|
89
|
-
setCooldownSeconds((prev) => {
|
|
90
|
-
const next = prev - 1;
|
|
91
|
-
if (next <= 0) {
|
|
92
|
-
localStorage.removeItem(EMAIL_CODE_COOLDOWN_KEY);
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
return next;
|
|
96
|
-
});
|
|
97
|
-
}, 1000);
|
|
98
|
-
|
|
99
|
-
return () => window.clearInterval(timer);
|
|
100
|
-
}, [cooldownSeconds]);
|
|
101
|
-
|
|
102
|
-
/** 校验邮箱是否可用(保持现有逻辑不变) */
|
|
103
|
-
/** 提交注册 */
|
|
104
|
-
const handleSubmit = async (e: React.FormEvent) => {
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
|
|
107
|
-
if (!validateEmail(email)) {
|
|
108
|
-
showToast(t('auth.register.invalid_email'), 'error');
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!validatePhoneNumber(countryCode, phoneNumber)) {
|
|
113
|
-
showToast(t('auth.register.invalid_phone_number'), 'error');
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (!emailCode.trim()) {
|
|
118
|
-
showToast(t('auth.register.email_code_required'), 'error');
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
setIsLoading(true);
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
await registerAPI({
|
|
126
|
-
name: displayName,
|
|
127
|
-
phone: phoneNumber,
|
|
128
|
-
areaCode: countryCode,
|
|
129
|
-
password,
|
|
130
|
-
email,
|
|
131
|
-
sex: 1,
|
|
132
|
-
emailCode: emailCode.trim(),
|
|
133
|
-
});
|
|
134
|
-
clearToasts();
|
|
135
|
-
navigate('/login');
|
|
136
|
-
showToast(t('auth.register.success', 'Registration successful! Please log in.'), 'success');
|
|
137
|
-
} catch (err: any) {
|
|
138
|
-
let message = t('auth.register.failed');
|
|
139
|
-
const detail = err.response?.data?.detail;
|
|
140
|
-
|
|
141
|
-
if (typeof detail === 'string') {
|
|
142
|
-
message = detail;
|
|
143
|
-
} else if (Array.isArray(detail)) {
|
|
144
|
-
// Handle FastAPI validation errors (422)
|
|
145
|
-
message = detail.map((d: any) => d.msg || JSON.stringify(d)).join(', ');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
console.log(message);
|
|
149
|
-
} finally {
|
|
150
|
-
setIsLoading(false);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const resetEmailCode = () => {
|
|
155
|
-
setEmailCode('');
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
/** 打开发送邮箱验证码前的滑动验证码 */
|
|
159
|
-
const handleOpenCaptchaModal = async () => {
|
|
160
|
-
if (isSendingCode || isCooldownLoading || cooldownSeconds > 0) return;
|
|
161
|
-
|
|
162
|
-
if (!validateEmail(email)) {
|
|
163
|
-
showToast(t('auth.register.invalid_email'), 'error');
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
setIsAuthCodeVisible(true);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/** 发送邮箱验证码(需先通过滑动验证码) */
|
|
171
|
-
const handleConfirmSendEmailCode = async (data: any, callback?: any) => {
|
|
172
|
-
setIsAuthCodeVisible(false);
|
|
173
|
-
try {
|
|
174
|
-
setIsSendingCode(true);
|
|
175
|
-
const resp: any = await sendEmailVerifyCodeAPI({
|
|
176
|
-
email,
|
|
177
|
-
captchaId: data?.uuid,
|
|
178
|
-
imageCaptchaTrack: data?.trackData,
|
|
179
|
-
});
|
|
180
|
-
const leftSeconds = resp?.data ?? resp?.data?.data;
|
|
181
|
-
const nextSeconds = typeof leftSeconds === 'number' ? leftSeconds : 120;
|
|
182
|
-
const cooldownUntil = Date.now() + nextSeconds * 1000;
|
|
183
|
-
localStorage.setItem(EMAIL_CODE_COOLDOWN_KEY, `${cooldownUntil}`);
|
|
184
|
-
setCooldownSeconds(nextSeconds);
|
|
185
|
-
resetEmailCode();
|
|
186
|
-
showToast(t('auth.register.email_code_sent_success'), 'success');
|
|
187
|
-
} catch (err: any) {
|
|
188
|
-
console.error('Send register email code failed', err);
|
|
189
|
-
showToast(t('auth.register.email_code_sent_failed'), 'error');
|
|
190
|
-
callback?.();
|
|
191
|
-
} finally {
|
|
192
|
-
setIsSendingCode(false);
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const stars = React.useMemo(() => {
|
|
197
|
-
return Array.from({ length: 30 }).map((_, i) => ({
|
|
198
|
-
id: i,
|
|
199
|
-
top: `${Math.random() * 40}%`, // Top 40%
|
|
200
|
-
left: `${Math.random() * 40}%`, // Left 40%
|
|
201
|
-
size: Math.random() * 2 + 1, // 1-3px
|
|
202
|
-
opacity: Math.random() * 0.7 + 0.3, // 0.3-1.0
|
|
203
|
-
delay: Math.random() * 5,
|
|
204
|
-
isBlue: Math.random() > 0.7 // 30% chance of blue tint
|
|
205
|
-
}));
|
|
206
|
-
}, []);
|
|
207
|
-
|
|
208
|
-
return (
|
|
209
|
-
<ConfigProvider theme={registerPageAntdTheme}>
|
|
210
|
-
<div className="auth-dark-cx min-h-screen w-full flex items-center justify-center bg-[#131314] relative overflow-hidden">
|
|
211
|
-
{/* Starry Background (Top Left) */}
|
|
212
|
-
<div className="absolute top-0 left-0 w-full h-full pointer-events-none z-0">
|
|
213
|
-
{stars.map((star) => (
|
|
214
|
-
<div
|
|
215
|
-
key={star.id}
|
|
216
|
-
className={`absolute rounded-full ${star.isBlue ? 'bg-blue-200' : 'bg-white'} animate-pulse`}
|
|
217
|
-
style={{
|
|
218
|
-
top: star.top,
|
|
219
|
-
left: star.left,
|
|
220
|
-
width: `${star.size}px`,
|
|
221
|
-
height: `${star.size}px`,
|
|
222
|
-
opacity: star.opacity,
|
|
223
|
-
animationDuration: `${3 + star.delay}s`,
|
|
224
|
-
boxShadow: star.isBlue ? `0 0 ${star.size * 2}px rgba(147, 197, 253, 0.6)` : `0 0 ${star.size}px rgba(255, 255, 255, 0.4)`
|
|
225
|
-
}}
|
|
226
|
-
/>
|
|
227
|
-
))}
|
|
228
|
-
</div>
|
|
229
|
-
|
|
230
|
-
{/* Background Gradients */}
|
|
231
|
-
<div className="absolute top-[-20%] left-[-10%] w-[50%] h-[50%] bg-blue-600/20 rounded-full blur-[120px] pointer-events-none" />
|
|
232
|
-
<div className="absolute bottom-[-20%] right-[-10%] w-[50%] h-[50%] bg-purple-600/20 rounded-full blur-[120px] pointer-events-none" />
|
|
233
|
-
|
|
234
|
-
{/* Language Switcher */}
|
|
235
|
-
<div className="absolute top-6 right-6 z-20">
|
|
236
|
-
<LanguageSwitcher direction="down" />
|
|
237
|
-
</div>
|
|
238
|
-
|
|
239
|
-
<div className="w-full max-w-md p-8 relative z-10 animate-fade-in-up">
|
|
240
|
-
{/* Logo / Header */}
|
|
241
|
-
<div className="text-center mb-10">
|
|
242
|
-
<div className="flex items-center justify-center gap-4 mb-6">
|
|
243
|
-
<SystemLogoMark className="w-12 h-12" fallbackShape="square" />
|
|
244
|
-
<h1 className="text-3xl font-extrabold text-white tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-white to-gray-400">
|
|
245
|
-
{systemName}
|
|
246
|
-
</h1>
|
|
247
|
-
</div>
|
|
248
|
-
<h2 className="text-lg text-gray-400 mb-3 font-medium">
|
|
249
|
-
{t('auth.register.title')}
|
|
250
|
-
</h2>
|
|
251
|
-
<p className="text-gray-500 text-sm">
|
|
252
|
-
{t('auth.register.has_account')}{' '}
|
|
253
|
-
<Link
|
|
254
|
-
to="/login"
|
|
255
|
-
onClick={() => clearToasts()}
|
|
256
|
-
className="text-blue-400 hover:text-blue-300 font-medium transition-colors hover:underline"
|
|
257
|
-
>
|
|
258
|
-
{t('auth.register.sign_in')}
|
|
259
|
-
</Link>
|
|
260
|
-
</p>
|
|
261
|
-
</div>
|
|
262
|
-
|
|
263
|
-
{/* Card */}
|
|
264
|
-
<div className="bg-[#1e1f20]/60 backdrop-blur-xl border border-gray-800 rounded-3xl p-8 shadow-2xl">
|
|
265
|
-
<form className="space-y-5" onSubmit={handleSubmit} autoComplete="new-password">
|
|
266
|
-
{/* Display Name */}
|
|
267
|
-
<CxInput
|
|
268
|
-
className="w-full"
|
|
269
|
-
required
|
|
270
|
-
autoComplete="off"
|
|
271
|
-
prefix={<User className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />}
|
|
272
|
-
placeholder={t('auth.register.display_name_placeholder')}
|
|
273
|
-
value={displayName}
|
|
274
|
-
onChange={(e) => setDisplayName(e.target.value)}
|
|
275
|
-
/>
|
|
276
|
-
|
|
277
|
-
{/* Phone Number */}
|
|
278
|
-
<div className="flex gap-2">
|
|
279
|
-
<CxSelect
|
|
280
|
-
className="w-28 shrink-0"
|
|
281
|
-
value={countryCode}
|
|
282
|
-
onChange={(v) => setCountryCode(`${v}`)}
|
|
283
|
-
options={phoneDialOptions.map((row) => ({
|
|
284
|
-
label: row.label,
|
|
285
|
-
value: row.value,
|
|
286
|
-
}))}
|
|
287
|
-
popupMatchSelectWidth={false}
|
|
288
|
-
/>
|
|
289
|
-
<CxInput
|
|
290
|
-
className="min-w-0 flex-1"
|
|
291
|
-
type="tel"
|
|
292
|
-
required
|
|
293
|
-
autoComplete="off"
|
|
294
|
-
prefix={<Phone className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />}
|
|
295
|
-
placeholder={t('auth.register.phone_placeholder')}
|
|
296
|
-
value={phoneNumber}
|
|
297
|
-
onChange={(e) => {
|
|
298
|
-
setPhoneNumber(e.target.value);
|
|
299
|
-
}}
|
|
300
|
-
/>
|
|
301
|
-
</div>
|
|
302
|
-
|
|
303
|
-
{/* Email */}
|
|
304
|
-
<div>
|
|
305
|
-
<CxInput
|
|
306
|
-
className="w-full"
|
|
307
|
-
type="email"
|
|
308
|
-
required
|
|
309
|
-
autoComplete="off"
|
|
310
|
-
prefix={<Mail className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />}
|
|
311
|
-
placeholder={t('auth.register.email_placeholder')}
|
|
312
|
-
value={email}
|
|
313
|
-
onChange={(e) => {
|
|
314
|
-
setEmail(e.target.value);
|
|
315
|
-
resetEmailCode();
|
|
316
|
-
}}
|
|
317
|
-
/>
|
|
318
|
-
</div>
|
|
319
|
-
|
|
320
|
-
<div className="flex items-center gap-2">
|
|
321
|
-
<button
|
|
322
|
-
type="button"
|
|
323
|
-
disabled={isSendingCode || isCooldownLoading || cooldownSeconds > 0}
|
|
324
|
-
onClick={handleOpenCaptchaModal}
|
|
325
|
-
className="shrink-0 px-4 py-2.5 border border-blue-500/60 text-blue-300 hover:text-white hover:bg-blue-500/20 rounded-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
|
326
|
-
>
|
|
327
|
-
{isCooldownLoading || isSendingCode ? (
|
|
328
|
-
<span className="flex items-center gap-2">
|
|
329
|
-
<Loader2 className="animate-spin h-4 w-4" />
|
|
330
|
-
{t('common.loading')}
|
|
331
|
-
</span>
|
|
332
|
-
) : cooldownSeconds > 0 ? (
|
|
333
|
-
t('auth.register.send_code_countdown', { count: cooldownSeconds })
|
|
334
|
-
) : (
|
|
335
|
-
t('auth.register.send_code')
|
|
336
|
-
)}
|
|
337
|
-
</button>
|
|
338
|
-
<CxInput
|
|
339
|
-
className="min-w-0 flex-1"
|
|
340
|
-
autoComplete="off"
|
|
341
|
-
placeholder={t('auth.register.email_code_placeholder')}
|
|
342
|
-
value={emailCode}
|
|
343
|
-
onChange={(e) => setEmailCode(e.target.value)}
|
|
344
|
-
/>
|
|
345
|
-
</div>
|
|
346
|
-
|
|
347
|
-
{/* Password */}
|
|
348
|
-
<CxInput
|
|
349
|
-
className="w-full"
|
|
350
|
-
type="password"
|
|
351
|
-
required
|
|
352
|
-
autoComplete="new-password"
|
|
353
|
-
prefix={<Lock className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />}
|
|
354
|
-
placeholder={t('auth.register.password_placeholder')}
|
|
355
|
-
value={password}
|
|
356
|
-
onChange={(e) => setPassword(e.target.value)}
|
|
357
|
-
/>
|
|
358
|
-
|
|
359
|
-
<button
|
|
360
|
-
type="submit"
|
|
361
|
-
disabled={isLoading || !emailCode.trim()}
|
|
362
|
-
className="w-full relative flex items-center justify-center py-3.5 px-4 bg-gradient-to-r from-blue-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 text-white font-semibold rounded-xl transition-all duration-200 shadow-lg shadow-blue-500/25 dark:shadow-none hover:shadow-blue-500/40 transform hover:-translate-y-0.5 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none mt-4"
|
|
363
|
-
>
|
|
364
|
-
{isLoading ? (
|
|
365
|
-
<Loader2 className="animate-spin h-5 w-5" />
|
|
366
|
-
) : (
|
|
367
|
-
<span className="flex items-center gap-2">
|
|
368
|
-
{t('auth.register.submit')} <ArrowRight size={18} />
|
|
369
|
-
</span>
|
|
370
|
-
)}
|
|
371
|
-
</button>
|
|
372
|
-
</form>
|
|
373
|
-
</div>
|
|
374
|
-
</div>
|
|
375
|
-
|
|
376
|
-
{isAuthCodeVisible ? (
|
|
377
|
-
<AuthCode
|
|
378
|
-
validImg={handleConfirmSendEmailCode}
|
|
379
|
-
close={() => setIsAuthCodeVisible(false)}
|
|
380
|
-
onReset={() => {}}
|
|
381
|
-
/>
|
|
382
|
-
) : null}
|
|
383
|
-
</div>
|
|
384
|
-
</ConfigProvider>
|
|
385
|
-
);
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
export default RegisterPage;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react'
|
|
2
|
-
|
|
3
|
-
import { DetailLink } from '@/components/common/detail-link'
|
|
4
|
-
import { useAuth } from '@/contexts/AuthContext'
|
|
5
|
-
import { ALIGN } from '@/meta'
|
|
6
|
-
import {
|
|
7
|
-
deleteMemoryAPI,
|
|
8
|
-
getMemoryPageAPI,
|
|
9
|
-
} from '@api/base/memory'
|
|
10
|
-
import ListPageView, { createListPageConfig } from '@components/table-view'
|
|
11
|
-
import { CxButton } from '@cx-ui'
|
|
12
|
-
|
|
13
|
-
import DetailModal from './modal/detail-modal'
|
|
14
|
-
import SubmitModal from './modal/submit-modal'
|
|
15
|
-
|
|
16
|
-
const useListPageConfig = createListPageConfig({
|
|
17
|
-
deleteAPI: deleteMemoryAPI,
|
|
18
|
-
deleteConfirm: {
|
|
19
|
-
cancelText: 'common.cancel',
|
|
20
|
-
content: 'base.memory.delete_confirm',
|
|
21
|
-
okText: 'common.delete',
|
|
22
|
-
title: 'base.memory.delete',
|
|
23
|
-
},
|
|
24
|
-
pageInfo: {
|
|
25
|
-
subTitle: 'base.memory.description',
|
|
26
|
-
title: 'base.memory.title',
|
|
27
|
-
},
|
|
28
|
-
searchFields: [
|
|
29
|
-
{
|
|
30
|
-
prop: 'title',
|
|
31
|
-
label: 'base.memory.search_title',
|
|
32
|
-
placeholder: 'base.memory.search_title_placeholder',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
submitAction: {
|
|
36
|
-
labelKey: 'base.memory.add',
|
|
37
|
-
permission: 'system:long-memory:add',
|
|
38
|
-
submitType: 'modal',
|
|
39
|
-
},
|
|
40
|
-
detailAction: {
|
|
41
|
-
detailType: 'modal',
|
|
42
|
-
labelKey: 'common.view',
|
|
43
|
-
},
|
|
44
|
-
/** 关闭横向 scroll.x,列宽在容器内分配,content 列 ellipsis 才能生效 */
|
|
45
|
-
table: { scrollX: false },
|
|
46
|
-
tableAPI: getMemoryPageAPI,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
function IndexView() {
|
|
50
|
-
const {hasPermission} = useAuth()
|
|
51
|
-
const pageConfig = useListPageConfig()
|
|
52
|
-
|
|
53
|
-
const columns = useMemo(
|
|
54
|
-
() => [
|
|
55
|
-
{
|
|
56
|
-
key: 'title',
|
|
57
|
-
title: 'base.memory.column_title',
|
|
58
|
-
align: ALIGN.LEFT,
|
|
59
|
-
minWidth: 200,
|
|
60
|
-
render: (value: string, data: any) => (
|
|
61
|
-
<DetailLink
|
|
62
|
-
text={value || '-'}
|
|
63
|
-
onClick={() =>
|
|
64
|
-
pageConfig.onDetail?.({
|
|
65
|
-
type: 'detail',
|
|
66
|
-
data,
|
|
67
|
-
config: pageConfig.detailAction,
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
/>
|
|
71
|
-
),
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
key: 'content',
|
|
75
|
-
title: 'base.memory.column_content',
|
|
76
|
-
align: ALIGN.LEFT,
|
|
77
|
-
ellipsis: true,
|
|
78
|
-
minWidth: 300,
|
|
79
|
-
ellipsisTooltipPlacement: 'right',
|
|
80
|
-
ellipsisTooltipWidth: 400,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
key: 'createTime',
|
|
84
|
-
title: 'base.memory.column_created',
|
|
85
|
-
align: ALIGN.CENTER,
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
key: 'action',
|
|
89
|
-
title: 'common.actions',
|
|
90
|
-
align: ALIGN.CENTER,
|
|
91
|
-
render: (_: unknown, data: any) =>
|
|
92
|
-
hasPermission('system:long-memory:edit') ? (
|
|
93
|
-
<div className="flex justify-center gap-2">
|
|
94
|
-
<CxButton.IconView
|
|
95
|
-
onClick={() =>
|
|
96
|
-
pageConfig.onDetail?.({
|
|
97
|
-
type: 'detail',
|
|
98
|
-
data,
|
|
99
|
-
config: pageConfig.detailAction,
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
/>
|
|
103
|
-
<CxButton.IconEdit
|
|
104
|
-
onClick={() =>
|
|
105
|
-
pageConfig.onEdit?.({
|
|
106
|
-
type: 'edit',
|
|
107
|
-
data,
|
|
108
|
-
config: pageConfig.submitAction,
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
/>
|
|
112
|
-
{hasPermission('system:long-memory:delete') && (
|
|
113
|
-
<CxButton.IconDelete
|
|
114
|
-
onClick={() => pageConfig.onDelete?.(data)}
|
|
115
|
-
/>
|
|
116
|
-
)}
|
|
117
|
-
</div>
|
|
118
|
-
) : null,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
[hasPermission, pageConfig],
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<>
|
|
126
|
-
<ListPageView
|
|
127
|
-
columns={columns}
|
|
128
|
-
pageConfig={pageConfig}
|
|
129
|
-
submitModalComponent={SubmitModal as any}
|
|
130
|
-
detailModalComponent={DetailModal as any}
|
|
131
|
-
/>
|
|
132
|
-
</>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export default IndexView
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useImperativeHandle, useMemo, useState } from 'react'
|
|
2
|
-
import { useTranslation } from 'react-i18next'
|
|
3
|
-
|
|
4
|
-
import { CxModal, useCxModal } from '@cx-ui'
|
|
5
|
-
|
|
6
|
-
type OpenPayload = {
|
|
7
|
-
opeType?: string
|
|
8
|
-
data?: any
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface DetailModalProps {
|
|
12
|
-
onCancel?: () => void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const DetailModal = forwardRef<
|
|
16
|
-
{ close: () => void; open: (payload?: OpenPayload) => void },
|
|
17
|
-
DetailModalProps
|
|
18
|
-
>(function DetailModal(_props, ref) {
|
|
19
|
-
const { onCancel } = _props
|
|
20
|
-
const { t } = useTranslation()
|
|
21
|
-
|
|
22
|
-
const modal = useCxModal({
|
|
23
|
-
onOpen: (payload) => {
|
|
24
|
-
modal.setFormData(payload?.data ?? null)
|
|
25
|
-
},
|
|
26
|
-
onClose: () => {
|
|
27
|
-
onCancel?.()
|
|
28
|
-
},
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const { isOpen, close } = modal
|
|
32
|
-
const record = modal.formData
|
|
33
|
-
|
|
34
|
-
const title = useMemo(() => t('base.memory.detail'), [t])
|
|
35
|
-
|
|
36
|
-
useImperativeHandle(
|
|
37
|
-
ref,
|
|
38
|
-
() => ({
|
|
39
|
-
open: modal.open,
|
|
40
|
-
close,
|
|
41
|
-
}),
|
|
42
|
-
[modal.open, close],
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
if (!record) return null
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<CxModal
|
|
49
|
-
isOpen={isOpen}
|
|
50
|
-
modalConfig={{ width: 560 }}
|
|
51
|
-
opeType="detail"
|
|
52
|
-
submitting={false}
|
|
53
|
-
title={title}
|
|
54
|
-
onClose={close}
|
|
55
|
-
actions={[]}
|
|
56
|
-
>
|
|
57
|
-
<div className="space-y-4">
|
|
58
|
-
<div>
|
|
59
|
-
<label className="mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300">
|
|
60
|
-
{t('base.memory.column_title')}
|
|
61
|
-
</label>
|
|
62
|
-
<div className="rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100">
|
|
63
|
-
{record.title || '-'}
|
|
64
|
-
</div>
|
|
65
|
-
</div>
|
|
66
|
-
<div>
|
|
67
|
-
<label className="mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300">
|
|
68
|
-
{t('base.memory.column_content')}
|
|
69
|
-
</label>
|
|
70
|
-
<div className="min-h-[100px] whitespace-pre-wrap rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100">
|
|
71
|
-
{record.content || '-'}
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
{record.createTime && (
|
|
75
|
-
<div>
|
|
76
|
-
<label className="mb-1 block text-sm font-medium text-gray-700 dark:text-gray-300">
|
|
77
|
-
{t('base.memory.column_created')}
|
|
78
|
-
</label>
|
|
79
|
-
<div className="rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-sm text-gray-900 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100">
|
|
80
|
-
{record.createTime}
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
|
-
</CxModal>
|
|
86
|
-
)
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
export default DetailModal
|