cx-chat 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursor/rules/i18n-cn-gloss-comments.mdc +31 -0
- package/.cursor/rules/list-page-view-pageconfig.mdc +32 -0
- package/.cursor/rules/no-over-defensive-programming.mdc +90 -0
- package/.cursor/rules/requirement-description-for-agent.mdc +33 -0
- package/.cursor/rules/use-showToast-not-antd-message.mdc +28 -0
- package/.docker/Dockerfile +7 -0
- package/.env +9 -0
- package/.env.development +7 -0
- package/.env.production +7 -0
- package/.gitlab-ci/docker-build.yaml +28 -0
- package/.gitlab-ci/k8s-deploy-dev-master.yaml +42 -0
- package/.gitlab-ci/npm-build.yaml +17 -0
- package/.gitlab-ci.yml +8 -0
- package/.k8s/0-namespace.yaml +6 -0
- package/.k8s/1-configmap-web.yaml +7 -0
- package/.k8s/1-nginx-conf-dev.yaml +110 -0
- package/.k8s/2-deployment.yaml +27 -0
- package/.k8s/3-service.yaml +16 -0
- package/.k8s/4-ingress-dev.yaml +30 -0
- package/.lingma/rules/use-showToast-not-antd-message.md +34 -0
- package/.nginx/nginx.conf +52 -0
- package/.prettierrc +9 -0
- package/README.md +1 -0
- package/eslint.config.js +32 -0
- package/index.html +13 -0
- package/package.json +67 -0
- package/postcss.config.js +6 -0
- package/public/favicon.ico +0 -0
- package/public/vite.svg +1 -0
- package/src/App.tsx +96 -0
- package/src/_doc/0.docs-overview.md +28 -0
- package/src/_doc/cx-ui/0.docs-overview.md +30 -0
- package/src/_doc/cx-ui/comp.1.cx-ui-overview.md +82 -0
- package/src/_doc/cx-ui/comp.2.cx-modal.md +82 -0
- package/src/_doc/cx-ui/comp.3.cx-button.md +89 -0
- package/src/_doc/cx-ui/comp.4.cx-form.md +72 -0
- package/src/_doc/cx-ui/comp.5.cx-fields.md +76 -0
- package/src/_doc/cx-ui/comp.6.cx-tag.md +57 -0
- package/src/_doc/cx-ui/comp.7.cx-empty-state.md +29 -0
- package/src/_doc/meta/0.docs-overview.md +24 -0
- package/src/_doc/meta/comp.1.enum-runtime.md +33 -0
- package/src/_doc/meta/comp.2.dict-runtime.md +39 -0
- package/src/_doc/router/0.docs-overview.md +14 -0
- package/src/_doc/router/guide.1.menu-component-config.md +181 -0
- package/src/_doc/router/guide.2.router-auto-registration.md +114 -0
- package/src/_doc/table-view/0.docs-overview.md +30 -0
- package/src/_doc/table-view/comp.1.table-view.md +542 -0
- package/src/_doc/table-view/props.1.create-table-view-config.md +193 -0
- package/src/_doc/table-view/props.2.table-view-search-fields.md +106 -0
- package/src/api/_mock/README.md +340 -0
- package/src/api/_mock/api.ts +1642 -0
- package/src/api/_mock/bundle-shim.ts +16 -0
- package/src/api/_mock/handler-shim.ts +6 -0
- package/src/api/_mock/handler.ts +458 -0
- package/src/api/_mock/index.ts +711 -0
- package/src/api/_mock/interceptor.ts +15 -0
- package/src/api/_mock/mod.ts +12 -0
- package/src/api/_mock/utils.ts +65 -0
- package/src/api/base/memory.js +24 -0
- package/src/api/chat.js +210 -0
- package/src/api/common/auth.js +70 -0
- package/src/api/menus/business-rules.js +76 -0
- package/src/api/menus/feedback.js +102 -0
- package/src/api/menus/knowledge.js +159 -0
- package/src/api/menus/model-metadata/manage.js +70 -0
- package/src/api/menus/model-metadata/role.js +50 -0
- package/src/api/menus/model-metadata/training-detail-mock-data.js +569 -0
- package/src/api/menus/model-metadata/training.js +28 -0
- package/src/api/menus/skill.js +40 -0
- package/src/api/system/agent-config.js +16 -0
- package/src/api/system/department.js +94 -0
- package/src/api/system/dict.js +86 -0
- package/src/api/system/menu.js +37 -0
- package/src/api/system/permission.js +26 -0
- package/src/api/system/role.js +34 -0
- package/src/api/system/sys-config.js +16 -0
- package/src/api/system/sys-log.js +17 -0
- package/src/api/system/user.js +75 -0
- package/src/api/upload.js +39 -0
- package/src/assets/react.svg +1 -0
- package/src/components/auth/current-user-avatar.tsx +77 -0
- package/src/components/common/code-view.tsx +149 -0
- package/src/components/common/detail-link.tsx +67 -0
- package/src/components/common/error-boundary.tsx +98 -0
- package/src/components/common/language-switcher.tsx +91 -0
- package/src/components/common/lite-table/index.tsx +135 -0
- package/src/components/common/md-editor.tsx +126 -0
- package/src/components/common/modal/confirm-dialog.tsx +113 -0
- package/src/components/common/modal/dep-user-select-multi.tsx +324 -0
- package/src/components/common/modal/dep-user-select.tsx +249 -0
- package/src/components/common/modal/user-select-multi.tsx +266 -0
- package/src/components/common/pagination.tsx +472 -0
- package/src/components/common/path.tsx +175 -0
- package/src/components/common/system-logo-mark.tsx +48 -0
- package/src/components/cx-ui/button/index.less +208 -0
- package/src/components/cx-ui/button/index.tsx +611 -0
- package/src/components/cx-ui/checkbox/index.tsx +78 -0
- package/src/components/cx-ui/date-picker/index.less +17 -0
- package/src/components/cx-ui/date-picker/index.tsx +193 -0
- package/src/components/cx-ui/drawer/index.tsx +47 -0
- package/src/components/cx-ui/empty-state/index.tsx +20 -0
- package/src/components/cx-ui/floating-shell/CxFloatingShell.tsx +89 -0
- package/src/components/cx-ui/floating-shell/cx-floating-shell.less +283 -0
- package/src/components/cx-ui/floating-shell/has-floating-value.ts +41 -0
- package/src/components/cx-ui/form/CxForm.tsx +15 -0
- package/src/components/cx-ui/form/index.tsx +20 -0
- package/src/components/cx-ui/form-item/index.less +26 -0
- package/src/components/cx-ui/form-item/index.tsx +36 -0
- package/src/components/cx-ui/index.ts +70 -0
- package/src/components/cx-ui/input/auto-complete.tsx +134 -0
- package/src/components/cx-ui/input/index.tsx +259 -0
- package/src/components/cx-ui/input-number/index.jsx +66 -0
- package/src/components/cx-ui/modal/index.jsx +212 -0
- package/src/components/cx-ui/modal/index.less +144 -0
- package/src/components/cx-ui/modal/useCxModal.ts +125 -0
- package/src/components/cx-ui/multi-select/index.jsx +74 -0
- package/src/components/cx-ui/multi-select/index.less +40 -0
- package/src/components/cx-ui/multi-select/index2.tsx +361 -0
- package/src/components/cx-ui/radio/index.tsx +33 -0
- package/src/components/cx-ui/range-picker/index.less +65 -0
- package/src/components/cx-ui/range-picker/index.tsx +219 -0
- package/src/components/cx-ui/select/index.less +34 -0
- package/src/components/cx-ui/select/index.tsx +196 -0
- package/src/components/cx-ui/skeleton/index.tsx +12 -0
- package/src/components/cx-ui/steps/index.tsx +14 -0
- package/src/components/cx-ui/styles/_tokens.less +79 -0
- package/src/components/cx-ui/styles/index.less +246 -0
- package/src/components/cx-ui/switch/index.less +106 -0
- package/src/components/cx-ui/switch/index.tsx +120 -0
- package/src/components/cx-ui/table/index.less +160 -0
- package/src/components/cx-ui/table/index.tsx +152 -0
- package/src/components/cx-ui/tabs/index.less +15 -0
- package/src/components/cx-ui/tabs/index.tsx +34 -0
- package/src/components/cx-ui/tag/index.less +51 -0
- package/src/components/cx-ui/tag/index.tsx +140 -0
- package/src/components/cx-ui/timeline/index.tsx +14 -0
- package/src/components/cx-ui/tooltip/index.tsx +67 -0
- package/src/components/cx-ui/tree/index.tsx +193 -0
- package/src/components/cx-ui/tree-select/index.jsx +91 -0
- package/src/components/cx-ui/tree-select/index.less +27 -0
- package/src/components/cx-ui/upload-file/index.less +223 -0
- package/src/components/cx-ui/upload-file/index.tsx +640 -0
- package/src/components/cx-ui/upload-img/index.tsx +291 -0
- package/src/components/layout/components/Header.tsx +216 -0
- package/src/components/layout/components/Sidebar.tsx +717 -0
- package/src/components/layout/index.tsx +95 -0
- package/src/components/table-view/components/search-area.tsx +411 -0
- package/src/components/table-view/components/table-view-config.tsx +528 -0
- package/src/components/table-view/components/table-view.types.ts +478 -0
- package/src/components/table-view/components/tree-api-normalize.ts +38 -0
- package/src/components/table-view/components/tree-data-annotate.ts +31 -0
- package/src/components/table-view/components/tree-sidebar.tsx +74 -0
- package/src/components/table-view/index.tsx +61 -0
- package/src/components/table-view/list-page-view.tsx +1049 -0
- package/src/components/table-view/select-table-view.tsx +1094 -0
- package/src/components/table-view/styles/select-table-view.less +51 -0
- package/src/config/default-system-name.ts +9 -0
- package/src/config/system.ts +165 -0
- package/src/constants/countryCodes.ts +3 -0
- package/src/contexts/AuthContext.tsx +256 -0
- package/src/contexts/ChatContext.tsx +839 -0
- package/src/contexts/MenuContext.tsx +62 -0
- package/src/contexts/ToastContext.tsx +181 -0
- package/src/hooks/useCopyToClipboard.ts +47 -0
- package/src/hooks/useModalSubmit.ts +104 -0
- package/src/hooks/useRouter.ts +240 -0
- package/src/hooks/useStepForm.ts +46 -0
- package/src/hooks/useStickyHeader.ts +42 -0
- package/src/hooks/useThreadActions.ts +105 -0
- package/src/hooks/useUserPreferences.ts +101 -0
- package/src/http/axios.js +372 -0
- package/src/http/mock.interceptor.ts +9 -0
- package/src/http/obfuscationKey.ts +41 -0
- package/src/i18n.ts +60 -0
- package/src/index.js +1 -0
- package/src/index.less +169 -0
- package/src/locales/en/auth.ts +70 -0
- package/src/locales/en/base/memory.ts +28 -0
- package/src/locales/en/base/settings.ts +41 -0
- package/src/locales/en/chat.ts +40 -0
- package/src/locales/en/common.ts +173 -0
- package/src/locales/en/enum.ts +27 -0
- package/src/locales/en/menus/business-rules.ts +48 -0
- package/src/locales/en/menus/feedback.ts +62 -0
- package/src/locales/en/menus/knowledge.ts +120 -0
- package/src/locales/en/menus/model-metadata/index.ts +10 -0
- package/src/locales/en/menus/model-metadata/manage.ts +151 -0
- package/src/locales/en/menus/model-metadata/role.ts +48 -0
- package/src/locales/en/menus/model-metadata/training.ts +65 -0
- package/src/locales/en/menus/skill.ts +34 -0
- package/src/locales/en/system/agent-config.ts +34 -0
- package/src/locales/en/system/department.ts +68 -0
- package/src/locales/en/system/dict.ts +44 -0
- package/src/locales/en/system/menu.ts +45 -0
- package/src/locales/en/system/permission.ts +89 -0
- package/src/locales/en/system/role.ts +25 -0
- package/src/locales/en/system/sys-config.ts +33 -0
- package/src/locales/en/system/sys-log.ts +38 -0
- package/src/locales/en/system/user.ts +113 -0
- package/src/locales/en.ts +68 -0
- package/src/locales/zh/auth.ts +70 -0
- package/src/locales/zh/base/memory.ts +29 -0
- package/src/locales/zh/base/settings.ts +41 -0
- package/src/locales/zh/chat.ts +47 -0
- package/src/locales/zh/common.ts +178 -0
- package/src/locales/zh/enum.ts +28 -0
- package/src/locales/zh/menus/business-rules.ts +47 -0
- package/src/locales/zh/menus/feedback.ts +62 -0
- package/src/locales/zh/menus/knowledge.ts +117 -0
- package/src/locales/zh/menus/model-metadata/index.ts +10 -0
- package/src/locales/zh/menus/model-metadata/manage.ts +151 -0
- package/src/locales/zh/menus/model-metadata/role.ts +47 -0
- package/src/locales/zh/menus/model-metadata/training.ts +64 -0
- package/src/locales/zh/menus/skill.ts +34 -0
- package/src/locales/zh/system/agent-config.ts +33 -0
- package/src/locales/zh/system/department.ts +69 -0
- package/src/locales/zh/system/dict.ts +44 -0
- package/src/locales/zh/system/menu.ts +47 -0
- package/src/locales/zh/system/permission.ts +94 -0
- package/src/locales/zh/system/role.ts +25 -0
- package/src/locales/zh/system/sys-config.ts +32 -0
- package/src/locales/zh/system/sys-log.ts +38 -0
- package/src/locales/zh/system/user.ts +114 -0
- package/src/locales/zh.ts +67 -0
- package/src/main.tsx +50 -0
- package/src/meta/const/index.ts +40 -0
- package/src/meta/index-dict.ts +56 -0
- package/src/meta/index-enum.ts +95 -0
- package/src/meta/index.ts +14 -0
- package/src/meta/module/dict-data/runtime.ts +199 -0
- package/src/meta/module/dict-data/types.ts +17 -0
- package/src/meta/module/enum-data/runtime.ts +75 -0
- package/src/meta/module/enum-data/types.ts +18 -0
- package/src/router/index.tsx +312 -0
- package/src/styles/AntdThemeProvider.tsx +40 -0
- package/src/styles/antd-theme.ts +20 -0
- package/src/styles/global.less +107 -0
- package/src/styles/variable.less +103 -0
- package/src/types/feedback.ts +43 -0
- package/src/types/index.ts +85 -0
- package/src/types/menu.ts +43 -0
- package/src/utils/aesUtil.ts +123 -0
- package/src/utils/chatUtils.ts +524 -0
- package/src/utils/cn.ts +6 -0
- package/src/utils/crypto.ts +164 -0
- package/src/utils/date.ts +72 -0
- package/src/utils/file-icons.tsx +79 -0
- package/src/utils/index.ts +168 -0
- package/src/utils/markdown-math-plugins.ts +21 -0
- package/src/utils/menuI18n.ts +305 -0
- package/src/utils/menuRouteRegistry.ts +78 -0
- package/src/utils/permission-crud.ts +147 -0
- package/src/utils/routeConfig.ts +350 -0
- package/src/utils/storage.ts +135 -0
- package/src/utils/toastBridge.ts +26 -0
- package/src/utils/url.ts +38 -0
- package/src/utils/validation.ts +16 -0
- package/src/views/auth/auth-code/index.less +169 -0
- package/src/views/auth/auth-code/index.module.less +174 -0
- package/src/views/auth/auth-code/index.tsx +233 -0
- package/src/views/auth/login.tsx +498 -0
- package/src/views/auth/register.tsx +388 -0
- package/src/views/base/memory/index.tsx +136 -0
- package/src/views/base/memory/modal/detail-modal.tsx +89 -0
- package/src/views/base/memory/modal/submit-modal.tsx +134 -0
- package/src/views/base/settings/index.tsx +657 -0
- package/src/views/chat/chat.less +323 -0
- package/src/views/chat/components/chat-input.tsx +298 -0
- package/src/views/chat/components/header-thread-title.tsx +210 -0
- package/src/views/chat/components/message-list/content-answer.tsx +100 -0
- package/src/views/chat/components/message-list/content-question.tsx +18 -0
- package/src/views/chat/components/message-list/index.tsx +520 -0
- package/src/views/chat/components/message-list/message-item.tsx +199 -0
- package/src/views/chat/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/chat/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/chat/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/chat/components/message-list/thinking-process.tsx +49 -0
- package/src/views/chat/components/message-list/toolbar.tsx +224 -0
- package/src/views/chat/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/chat/components/references-knowledge/context.tsx +57 -0
- package/src/views/chat/components/references-knowledge/index.ts +9 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-detail-drawer.tsx +556 -0
- package/src/views/chat/components/references-knowledge/modal/knowledge-doc-detail-drawer.tsx +529 -0
- package/src/views/chat/components/references-knowledge/panel.tsx +115 -0
- package/src/views/chat/hooks/use-chat-common.ts +19 -0
- package/src/views/chat/index-session.tsx +647 -0
- package/src/views/chat/index.tsx +127 -0
- package/src/views/page-error/401.tsx +56 -0
- package/src/views/page-error/404.tsx +56 -0
- package/src/views/page-menus/business-rules/index.tsx +376 -0
- package/src/views/page-menus/business-rules/modal/detail-modal.tsx +186 -0
- package/src/views/page-menus/business-rules/modal/scope-modal.tsx +272 -0
- package/src/views/page-menus/business-rules/modal/submit-modal.tsx +142 -0
- package/src/views/page-menus/feedback/components/feedback-dataset-list.tsx +471 -0
- package/src/views/page-menus/feedback/index.tsx +166 -0
- package/src/views/page-menus/feedback/modal/export-feedback-modal.tsx +367 -0
- package/src/views/page-menus/knowledge/components/doc-editor-by-type.tsx +32 -0
- package/src/views/page-menus/knowledge/components/doc-editor-type-file.tsx +330 -0
- package/src/views/page-menus/knowledge/detail.tsx +600 -0
- package/src/views/page-menus/knowledge/index.tsx +337 -0
- package/src/views/page-menus/knowledge/modal/detail-modal.tsx +618 -0
- package/src/views/page-menus/knowledge/modal/doc-detail-modal.tsx +550 -0
- package/src/views/page-menus/knowledge/modal/doc-parse.ts +99 -0
- package/src/views/page-menus/knowledge/modal/doc-submit-modal.tsx +349 -0
- package/src/views/page-menus/knowledge/modal/doc-type-picker-modal.tsx +88 -0
- package/src/views/page-menus/knowledge/modal/knowledge-user-select-modal.tsx +283 -0
- package/src/views/page-menus/knowledge/modal/submit-modal.tsx +179 -0
- package/src/views/page-menus/model-metadata/manage/components/metadata-detail-schema-tab.tsx +114 -0
- package/src/views/page-menus/model-metadata/manage/components/step1-basic-info.tsx +232 -0
- package/src/views/page-menus/model-metadata/manage/components/step2-schema.tsx +316 -0
- package/src/views/page-menus/model-metadata/manage/components/step3-permissions.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step4-documents.tsx +134 -0
- package/src/views/page-menus/model-metadata/manage/components/step5-example-sql.tsx +101 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-add.tsx +338 -0
- package/src/views/page-menus/model-metadata/manage/components/submit-edit.tsx +276 -0
- package/src/views/page-menus/model-metadata/manage/detail.tsx +298 -0
- package/src/views/page-menus/model-metadata/manage/hooks/model-metadata-submit-shared.ts +113 -0
- package/src/views/page-menus/model-metadata/manage/hooks/use-model-metadata-item-state.ts +20 -0
- package/src/views/page-menus/model-metadata/manage/index.tsx +304 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/table-schema.ts +374 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-detail-tabs.tsx +151 -0
- package/src/views/page-menus/model-metadata/manage/modal/components/use-table-submit-tabs.tsx +423 -0
- package/src/views/page-menus/model-metadata/manage/modal/detail-modal.tsx +218 -0
- package/src/views/page-menus/model-metadata/manage/modal/submit-modal.tsx +261 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-detail-modal.tsx +196 -0
- package/src/views/page-menus/model-metadata/manage/modal/table-submit-modal.tsx +229 -0
- package/src/views/page-menus/model-metadata/manage/submit.tsx +31 -0
- package/src/views/page-menus/model-metadata/role/index.tsx +207 -0
- package/src/views/page-menus/model-metadata/role/modal/detail-modal.tsx +97 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-modal.tsx +254 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-panel.tsx +393 -0
- package/src/views/page-menus/model-metadata/role/modal/role-assign-users-utils.ts +120 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-assign-panel.tsx +698 -0
- package/src/views/page-menus/model-metadata/role/modal/role-permission-modal.tsx +237 -0
- package/src/views/page-menus/model-metadata/role/modal/submit-modal.tsx +135 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/index.ts +4 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/node-card.tsx +72 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts +196 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/summary-list.tsx +153 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/timeline.tsx +103 -0
- package/src/views/page-menus/model-metadata/training/components/detail-records/types.ts +82 -0
- package/src/views/page-menus/model-metadata/training/detail.tsx +159 -0
- package/src/views/page-menus/model-metadata/training/index.tsx +236 -0
- package/src/views/page-menus/model-metadata/training/modal/update-detail-modal.tsx +154 -0
- package/src/views/page-menus/skill/index.tsx +201 -0
- package/src/views/page-menus/skill/modal/detail-modal.tsx +156 -0
- package/src/views/page-menus/skill/modal/submit-modal.tsx +214 -0
- package/src/views/page-system/agent-config/index.tsx +370 -0
- package/src/views/page-system/department/departmentFormShared.ts +36 -0
- package/src/views/page-system/department/index.tsx +541 -0
- package/src/views/page-system/department/modal/detail-modal.tsx +94 -0
- package/src/views/page-system/department/modal/member-role-modal.tsx +128 -0
- package/src/views/page-system/department/modal/submit-modal.tsx +265 -0
- package/src/views/page-system/dict/index.tsx +440 -0
- package/src/views/page-system/dict/modal/cate-submit-modal.tsx +315 -0
- package/src/views/page-system/dict/modal/submit-modal.tsx +184 -0
- package/src/views/page-system/logs/components/index.ts +3 -0
- package/src/views/page-system/logs/components/log-message-demo.tsx +30 -0
- package/src/views/page-system/logs/components/log-message-stream.ts +184 -0
- package/src/views/page-system/logs/components/message-list/content-answer.tsx +100 -0
- package/src/views/page-system/logs/components/message-list/content-question.tsx +18 -0
- package/src/views/page-system/logs/components/message-list/index.tsx +515 -0
- package/src/views/page-system/logs/components/message-list/message-item.tsx +193 -0
- package/src/views/page-system/logs/components/message-list/preparation-demo-items.ts +147 -0
- package/src/views/page-system/logs/components/message-list/preparation-steps.tsx +506 -0
- package/src/views/page-system/logs/components/message-list/suggestion-list.tsx +36 -0
- package/src/views/page-system/logs/components/message-list/thinking-process.tsx +49 -0
- package/src/views/page-system/logs/components/message-list/toolbar.tsx +134 -0
- package/src/views/page-system/logs/components/message-list/use-message-list-scroll.ts +214 -0
- package/src/views/page-system/logs/components/message-modal.tsx +239 -0
- package/src/views/page-system/logs/index.tsx +132 -0
- package/src/views/page-system/logs/modal/detail-modal.tsx +157 -0
- package/src/views/page-system/menu/components/menuFormShared.ts +283 -0
- package/src/views/page-system/menu/index.less +12 -0
- package/src/views/page-system/menu/index.tsx +410 -0
- package/src/views/page-system/menu/modal/icon-modal.less +51 -0
- package/src/views/page-system/menu/modal/icon-modal.tsx +87 -0
- package/src/views/page-system/menu/modal/submit-modal.tsx +263 -0
- package/src/views/page-system/permission/index.tsx +562 -0
- package/src/views/page-system/permission/modal/detail-modal.tsx +179 -0
- package/src/views/page-system/permission/modal/submit-modal.less +146 -0
- package/src/views/page-system/permission/modal/submit-modal.tsx +650 -0
- package/src/views/page-system/role/index.tsx +163 -0
- package/src/views/page-system/role/modal/detail-modal.tsx +127 -0
- package/src/views/page-system/role/modal/permission-assign-group-rules.ts +86 -0
- package/src/views/page-system/role/modal/permission-modal.tsx +111 -0
- package/src/views/page-system/role/modal/role-modal-shell-styles.ts +21 -0
- package/src/views/page-system/role/modal/role-permission-assign-panel.tsx +916 -0
- package/src/views/page-system/role/modal/role-permission-assign-shared.ts +1047 -0
- package/src/views/page-system/role/modal/submit-modal.tsx +193 -0
- package/src/views/page-system/sys-config/index.tsx +294 -0
- package/src/views/page-system/user/components/user-role-column.tsx +87 -0
- package/src/views/page-system/user/index.tsx +439 -0
- package/src/views/page-system/user/modal/assign-roles-modal.tsx +389 -0
- package/src/views/page-system/user/modal/detail-modal.tsx +72 -0
- package/src/views/page-system/user/modal/modal-style/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.less +40 -0
- package/src/views/page-system/user/modal/submit-modal.tsx +287 -0
- package/src/views/page-system/user/userFormShared.ts +51 -0
- package/tailwind.config.js +17 -0
- package/tsconfig.app.json +48 -0
- package/tsconfig.json +11 -0
- package/tsconfig.node.json +26 -0
- package/vite.config.ts +264 -0
|
@@ -0,0 +1,388 @@
|
|
|
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;
|
|
@@ -0,0 +1,136 @@
|
|
|
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
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|