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,498 @@
|
|
|
1
|
+
import { loginAPI, recoverPasswordAPI, sendEmailVerifyCodeAPI } from '@/api/common/auth';
|
|
2
|
+
import { setUserCurrentLanguageAPI } from '@/api/system/user';
|
|
3
|
+
import LanguageSwitcher from '@/components/common/language-switcher';
|
|
4
|
+
import { SystemLogoMark } from '@/components/common/system-logo-mark';
|
|
5
|
+
import { useSystemConfig } from '@/config/system';
|
|
6
|
+
import { antdTheme } from '@/styles/antd-theme';
|
|
7
|
+
import { getStore } from '@/utils/storage';
|
|
8
|
+
import { CxInput } from '@cx-ui';
|
|
9
|
+
import aesUtil from '@utils/aesUtil';
|
|
10
|
+
import { ConfigProvider, theme as antdThemePreset, type ThemeConfig } from 'antd';
|
|
11
|
+
import { ArrowRight, Loader2, Lock, Phone } from 'lucide-react';
|
|
12
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
13
|
+
import { useTranslation } from 'react-i18next';
|
|
14
|
+
import { Link, useNavigate } from 'react-router-dom';
|
|
15
|
+
import { useAuth } from '../../contexts/AuthContext';
|
|
16
|
+
import { useMenu } from '../../contexts/MenuContext';
|
|
17
|
+
import { useToast } from '../../contexts/ToastContext';
|
|
18
|
+
import AuthCode from './auth-code';
|
|
19
|
+
|
|
20
|
+
const loginPageAntdTheme: ThemeConfig = {
|
|
21
|
+
...antdTheme,
|
|
22
|
+
algorithm: antdThemePreset.darkAlgorithm,
|
|
23
|
+
components: {
|
|
24
|
+
Input: {
|
|
25
|
+
colorBgContainer: 'rgba(19, 19, 20, 0.55)',
|
|
26
|
+
colorBorder: '#3f3f46',
|
|
27
|
+
hoverBorderColor: '#52525b',
|
|
28
|
+
activeBorderColor: '#52525b',
|
|
29
|
+
/** 去掉 antd 默认浅色 active 光晕,避免暗色表单聚焦闪白 */
|
|
30
|
+
activeShadow: 'none',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const LoginPage: React.FC = () => {
|
|
36
|
+
const { systemName } = useSystemConfig()
|
|
37
|
+
const [phone, setPhone] = useState('');
|
|
38
|
+
const [password, setPassword] = useState('');
|
|
39
|
+
const loginSnapshotRef = useRef({ phone: '', password: '' });
|
|
40
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
41
|
+
const { login, refreshUser, isAuthenticated, isLoading: authLoading } = useAuth();
|
|
42
|
+
const { refreshMenus } = useMenu()
|
|
43
|
+
const { showToast, clearToasts } = useToast();
|
|
44
|
+
const navigate = useNavigate();
|
|
45
|
+
const { t, i18n } = useTranslation();
|
|
46
|
+
const authRef = useRef<any>(null);
|
|
47
|
+
const [isAuthCodeVisible, setIsAuthCodeVisible] = useState(false);
|
|
48
|
+
|
|
49
|
+
const RECOVER_EMAIL_CODE_COOLDOWN_KEY = 'recover_email_code_cooldown_until';
|
|
50
|
+
const [isRecoverOpen, setIsRecoverOpen] = useState(false);
|
|
51
|
+
const [recoverEmail, setRecoverEmail] = useState('');
|
|
52
|
+
const [recoverEmailCode, setRecoverEmailCode] = useState('');
|
|
53
|
+
const [recoverNewPassword, setRecoverNewPassword] = useState('');
|
|
54
|
+
const [recoverConfirmPassword, setRecoverConfirmPassword] = useState('');
|
|
55
|
+
const [recoverCooldownSeconds, setRecoverCooldownSeconds] = useState(0);
|
|
56
|
+
const [recoverCooldownLoading, setRecoverCooldownLoading] = useState(true);
|
|
57
|
+
const [recoverSendingCode, setRecoverSendingCode] = useState(false);
|
|
58
|
+
const [recoverSubmitting, setRecoverSubmitting] = useState(false);
|
|
59
|
+
const recoverAuthSnapshotRef = useRef({ email: '' });
|
|
60
|
+
const [isRecoverAuthCodeVisible, setIsRecoverAuthCodeVisible] = useState(false);
|
|
61
|
+
|
|
62
|
+
/** 刷新落到登录页:token 有效则跳转默认路由,避免再次显示登录页 */
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const token = getStore('token');
|
|
65
|
+
if (!token) return;
|
|
66
|
+
if (authLoading) return;
|
|
67
|
+
if (isAuthenticated) {
|
|
68
|
+
clearToasts();
|
|
69
|
+
navigate('/chat', { replace: true });
|
|
70
|
+
}
|
|
71
|
+
}, [authLoading, isAuthenticated, navigate, clearToasts]);
|
|
72
|
+
const onReset = () => {
|
|
73
|
+
// loginForm.resetFields();
|
|
74
|
+
};
|
|
75
|
+
const close = () => {
|
|
76
|
+
setIsAuthCodeVisible(false);
|
|
77
|
+
};
|
|
78
|
+
/** 关闭找回密码弹框并清理输入 */
|
|
79
|
+
const closeRecover = () => {
|
|
80
|
+
setIsRecoverOpen(false);
|
|
81
|
+
setRecoverEmail('');
|
|
82
|
+
setRecoverEmailCode('');
|
|
83
|
+
setRecoverNewPassword('');
|
|
84
|
+
setRecoverConfirmPassword('');
|
|
85
|
+
setIsRecoverAuthCodeVisible(false);
|
|
86
|
+
};
|
|
87
|
+
/** 登录前快照当前界面语言:避免登录流程覆盖 localStorage 后丢失用户选择。 */
|
|
88
|
+
const resolvePendingLanguageForLoginSync = () => {
|
|
89
|
+
console.log('getStore(i18nextLng)', getStore('i18nextLng'));
|
|
90
|
+
const raw = i18n.language || getStore('i18nextLng') || 'zh'
|
|
91
|
+
return raw.toLowerCase().startsWith('zh') ? 'zh' : 'en'
|
|
92
|
+
}
|
|
93
|
+
const validImg = async (data: any, callback: any) => {
|
|
94
|
+
const { phone: submitPhone, password: submitPassword } = loginSnapshotRef.current;
|
|
95
|
+
const isSuper = submitPhone === 'super';
|
|
96
|
+
const isValidPhone = /^1\d{10}$/.test(submitPhone);
|
|
97
|
+
if (!isSuper && !isValidPhone) {
|
|
98
|
+
showToast(t('auth.login.invalid_phone'), 'error');
|
|
99
|
+
callback?.();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
setIsLoading(true);
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const body: any = await loginAPI({
|
|
107
|
+
phone: aesUtil.encrypt(submitPhone),
|
|
108
|
+
password: aesUtil.encrypt(submitPassword),
|
|
109
|
+
captchaId: data.uuid,
|
|
110
|
+
imageCaptchaTrack: data.trackData,
|
|
111
|
+
});
|
|
112
|
+
if (!body?.success) {
|
|
113
|
+
console.log(body?.message || t('auth.login.failed'));
|
|
114
|
+
callback?.();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const nextLng = resolvePendingLanguageForLoginSync()
|
|
119
|
+
await login(body.data.token);
|
|
120
|
+
await refreshMenus()
|
|
121
|
+
|
|
122
|
+
// 登录页语言切换仅本地;登录成功后将当前语言同步到服务端
|
|
123
|
+
try {
|
|
124
|
+
await setUserCurrentLanguageAPI({
|
|
125
|
+
language: nextLng,
|
|
126
|
+
lang: nextLng,
|
|
127
|
+
code: nextLng,
|
|
128
|
+
} as any);
|
|
129
|
+
await refreshUser();
|
|
130
|
+
} catch (e) {
|
|
131
|
+
// 语言同步失败不影响登录主流程
|
|
132
|
+
}
|
|
133
|
+
setIsAuthCodeVisible(false);
|
|
134
|
+
clearToasts();
|
|
135
|
+
navigate('/chat');
|
|
136
|
+
} catch (err: any) {
|
|
137
|
+
console.error('Login failed', err);
|
|
138
|
+
showToast(err?.message || t('auth.login.failed'), 'error');
|
|
139
|
+
callback?.();
|
|
140
|
+
} finally {
|
|
141
|
+
setIsLoading(false);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
if (isLoading) return;
|
|
148
|
+
|
|
149
|
+
const submitPhone = `${phone || ''}`.trim();
|
|
150
|
+
const submitPassword = `${password || ''}`;
|
|
151
|
+
loginSnapshotRef.current = {
|
|
152
|
+
phone: submitPhone,
|
|
153
|
+
password: submitPassword,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const isSuper = submitPhone === 'super';
|
|
157
|
+
const isValidPhone = /^1\d{10}$/.test(submitPhone);
|
|
158
|
+
if (!isSuper && !isValidPhone) {
|
|
159
|
+
showToast(t('auth.login.invalid_phone'), 'error');
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setIsAuthCodeVisible(true);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
/** 初始化找回密码邮箱验证码倒计时(刷新页面继续) */
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
const raw = localStorage.getItem(RECOVER_EMAIL_CODE_COOLDOWN_KEY) || '0';
|
|
169
|
+
const cooldownUntil = Number(raw);
|
|
170
|
+
const left = Math.ceil((cooldownUntil - Date.now()) / 1000);
|
|
171
|
+
setRecoverCooldownSeconds(left > 0 ? left : 0);
|
|
172
|
+
setRecoverCooldownLoading(false);
|
|
173
|
+
}, []);
|
|
174
|
+
|
|
175
|
+
/** 找回密码倒计时每秒递减 */
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (recoverCooldownSeconds <= 0) return;
|
|
178
|
+
const timer = window.setInterval(() => {
|
|
179
|
+
setRecoverCooldownSeconds((prev) => {
|
|
180
|
+
const next = prev - 1;
|
|
181
|
+
if (next <= 0) {
|
|
182
|
+
localStorage.removeItem(RECOVER_EMAIL_CODE_COOLDOWN_KEY);
|
|
183
|
+
return 0;
|
|
184
|
+
}
|
|
185
|
+
return next;
|
|
186
|
+
});
|
|
187
|
+
}, 1000);
|
|
188
|
+
return () => window.clearInterval(timer);
|
|
189
|
+
}, [recoverCooldownSeconds]);
|
|
190
|
+
|
|
191
|
+
/** 打开滑动验证码后发送邮箱验证码 */
|
|
192
|
+
const handleRecoverSendEmailCode = async (data: any, callback?: any) => {
|
|
193
|
+
const email = recoverAuthSnapshotRef.current.email;
|
|
194
|
+
setIsRecoverAuthCodeVisible(false);
|
|
195
|
+
try {
|
|
196
|
+
setRecoverSendingCode(true);
|
|
197
|
+
const resp: any = await sendEmailVerifyCodeAPI({
|
|
198
|
+
email,
|
|
199
|
+
captchaId: data?.uuid,
|
|
200
|
+
imageCaptchaTrack: data?.trackData,
|
|
201
|
+
});
|
|
202
|
+
const leftSeconds = resp?.data ?? resp?.data?.data;
|
|
203
|
+
const nextSeconds = typeof leftSeconds === 'number' ? leftSeconds : 120;
|
|
204
|
+
const cooldownUntil = Date.now() + nextSeconds * 1000;
|
|
205
|
+
localStorage.setItem(RECOVER_EMAIL_CODE_COOLDOWN_KEY, `${cooldownUntil}`);
|
|
206
|
+
setRecoverCooldownSeconds(nextSeconds);
|
|
207
|
+
setRecoverEmailCode('');
|
|
208
|
+
showToast(t('auth.recover.email_code_sent_success'), 'success');
|
|
209
|
+
} catch (e: any) {
|
|
210
|
+
showToast(e?.message || t('auth.recover.email_code_sent_failed'), 'error');
|
|
211
|
+
callback?.();
|
|
212
|
+
} finally {
|
|
213
|
+
setRecoverSendingCode(false);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/** 触发找回密码发送验证码:先弹出滑动验证码 */
|
|
218
|
+
const openRecoverSendCode = () => {
|
|
219
|
+
if (recoverSendingCode || recoverCooldownLoading || recoverCooldownSeconds > 0) return;
|
|
220
|
+
const email = `${recoverEmail || ''}`.trim();
|
|
221
|
+
if (!email) {
|
|
222
|
+
showToast(t('auth.recover.email_required'), 'error');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
recoverAuthSnapshotRef.current = { email };
|
|
226
|
+
setIsRecoverAuthCodeVisible(true);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
/** 提交找回密码 */
|
|
230
|
+
const submitRecoverPassword = async (e: React.FormEvent) => {
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
if (recoverSubmitting) return;
|
|
233
|
+
const email = `${recoverEmail || ''}`.trim();
|
|
234
|
+
if (!email) {
|
|
235
|
+
showToast(t('auth.recover.email_required'), 'error');
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (!recoverEmailCode.trim()) {
|
|
239
|
+
showToast(t('auth.recover.email_code_required'), 'error');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!recoverNewPassword) {
|
|
243
|
+
showToast(t('auth.recover.new_password_required'), 'error');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (!recoverConfirmPassword) {
|
|
247
|
+
showToast(t('auth.recover.confirm_password_required'), 'error');
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (recoverNewPassword !== recoverConfirmPassword) {
|
|
251
|
+
showToast(t('auth.recover.password_mismatch'), 'error');
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
setRecoverSubmitting(true);
|
|
256
|
+
await recoverPasswordAPI({
|
|
257
|
+
email,
|
|
258
|
+
emailCode: recoverEmailCode.trim(),
|
|
259
|
+
newPassword: recoverNewPassword,
|
|
260
|
+
confirmPassword: recoverConfirmPassword,
|
|
261
|
+
});
|
|
262
|
+
showToast(t('auth.recover.success'), 'success');
|
|
263
|
+
closeRecover();
|
|
264
|
+
} catch (e: any) {
|
|
265
|
+
showToast(e?.message || t('auth.recover.failed'), 'error');
|
|
266
|
+
} finally {
|
|
267
|
+
setRecoverSubmitting(false);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const stars = React.useMemo(() => {
|
|
272
|
+
return Array.from({ length: 30 }).map((_, i) => ({
|
|
273
|
+
id: i,
|
|
274
|
+
top: `${Math.random() * 40}%`,
|
|
275
|
+
left: `${Math.random() * 40}%`,
|
|
276
|
+
size: Math.random() * 2 + 1,
|
|
277
|
+
opacity: Math.random() * 0.7 + 0.3,
|
|
278
|
+
delay: Math.random() * 5,
|
|
279
|
+
isBlue: Math.random() > 0.7,
|
|
280
|
+
}));
|
|
281
|
+
}, []);
|
|
282
|
+
|
|
283
|
+
const hasToken = !!getStore('token');
|
|
284
|
+
|
|
285
|
+
if (hasToken && authLoading) {
|
|
286
|
+
return (
|
|
287
|
+
<div className="min-h-screen w-full flex items-center justify-center bg-[#131314]">
|
|
288
|
+
<Loader2 className="animate-spin h-8 w-8 text-blue-600" />
|
|
289
|
+
</div>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<ConfigProvider theme={loginPageAntdTheme}>
|
|
295
|
+
<div className="auth-dark-cx min-h-screen w-full flex items-center justify-center bg-[#131314] relative overflow-hidden">
|
|
296
|
+
<div className="absolute top-0 left-0 w-full h-full pointer-events-none z-0">
|
|
297
|
+
{stars.map((star) => (
|
|
298
|
+
<div
|
|
299
|
+
key={star.id}
|
|
300
|
+
className={`absolute rounded-full ${star.isBlue ? 'bg-blue-200' : 'bg-white'} animate-pulse`}
|
|
301
|
+
style={{
|
|
302
|
+
top: star.top,
|
|
303
|
+
left: star.left,
|
|
304
|
+
width: `${star.size}px`,
|
|
305
|
+
height: `${star.size}px`,
|
|
306
|
+
opacity: star.opacity,
|
|
307
|
+
animationDuration: `${3 + star.delay}s`,
|
|
308
|
+
boxShadow: star.isBlue
|
|
309
|
+
? `0 0 ${star.size * 2}px rgba(147, 197, 253, 0.6)`
|
|
310
|
+
: `0 0 ${star.size}px rgba(255, 255, 255, 0.4)`,
|
|
311
|
+
}}
|
|
312
|
+
/>
|
|
313
|
+
))}
|
|
314
|
+
</div>
|
|
315
|
+
|
|
316
|
+
<div className="absolute top-[-20%] left-[-10%] w-[50%] h-[50%] bg-blue-600/20 rounded-full blur-[120px] pointer-events-none" />
|
|
317
|
+
<div className="absolute bottom-[-20%] right-[-10%] w-[50%] h-[50%] bg-purple-600/20 rounded-full blur-[120px] pointer-events-none" />
|
|
318
|
+
|
|
319
|
+
<div className="absolute top-6 right-6 z-20">
|
|
320
|
+
<LanguageSwitcher direction="down" localOnly />
|
|
321
|
+
</div>
|
|
322
|
+
|
|
323
|
+
<div className="w-full max-w-md p-8 relative z-10 animate-fade-in-up" style={{ marginTop: '20px' }}>
|
|
324
|
+
<div className="text-center mb-10">
|
|
325
|
+
<div className="flex items-center justify-center gap-4 mb-6">
|
|
326
|
+
<SystemLogoMark className="w-12 h-12" fallbackShape="square" />
|
|
327
|
+
<h1 className="text-3xl font-extrabold text-white tracking-tight bg-clip-text text-transparent bg-gradient-to-r from-white to-gray-400">
|
|
328
|
+
{systemName}
|
|
329
|
+
</h1>
|
|
330
|
+
</div>
|
|
331
|
+
<h2 className="text-lg text-gray-400 mb-3 font-medium">{t('auth.login.title')}</h2>
|
|
332
|
+
<p className="text-gray-500 text-sm">
|
|
333
|
+
{t('auth.login.no_account')}{' '}
|
|
334
|
+
<Link
|
|
335
|
+
to="/register"
|
|
336
|
+
onClick={() => clearToasts()}
|
|
337
|
+
className="text-blue-400 hover:text-blue-300 font-medium transition-colors hover:underline"
|
|
338
|
+
>
|
|
339
|
+
{t('auth.login.create_account')}
|
|
340
|
+
</Link>
|
|
341
|
+
</p>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<div className="bg-[#1e1f20]/60 backdrop-blur-xl border border-gray-800 rounded-3xl px-8 pb-8 pt-7 shadow-2xl">
|
|
345
|
+
{!isRecoverOpen ? (
|
|
346
|
+
<form className="space-y-6" onSubmit={handleSubmit}>
|
|
347
|
+
<div className="space-y-4">
|
|
348
|
+
<CxInput
|
|
349
|
+
className="w-full"
|
|
350
|
+
required
|
|
351
|
+
prefix={<Phone className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />}
|
|
352
|
+
placeholder={t('auth.login.phone_placeholder')}
|
|
353
|
+
value={phone}
|
|
354
|
+
onChange={(e) => setPhone(e.target.value)}
|
|
355
|
+
style={{ height: '54px' }}
|
|
356
|
+
/>
|
|
357
|
+
<CxInput
|
|
358
|
+
className="w-full"
|
|
359
|
+
type="password"
|
|
360
|
+
required
|
|
361
|
+
prefix={<Lock className="h-5 w-5 shrink-0 text-gray-500" aria-hidden />}
|
|
362
|
+
placeholder={t('auth.login.password_placeholder')}
|
|
363
|
+
value={password}
|
|
364
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
365
|
+
style={{ height: '54px' }}
|
|
366
|
+
/>
|
|
367
|
+
</div>
|
|
368
|
+
|
|
369
|
+
<button
|
|
370
|
+
type="submit"
|
|
371
|
+
disabled={isLoading}
|
|
372
|
+
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"
|
|
373
|
+
>
|
|
374
|
+
{isLoading ? (
|
|
375
|
+
<Loader2 className="animate-spin h-5 w-5" />
|
|
376
|
+
) : (
|
|
377
|
+
<span className="flex items-center gap-2">
|
|
378
|
+
{t('auth.login.submit')} <ArrowRight size={18} />
|
|
379
|
+
</span>
|
|
380
|
+
)}
|
|
381
|
+
</button>
|
|
382
|
+
|
|
383
|
+
<div className="text-center" style={{ marginTop: '12px' }}>
|
|
384
|
+
<button
|
|
385
|
+
type="button"
|
|
386
|
+
onClick={() => setIsRecoverOpen(true)}
|
|
387
|
+
className="text-sm text-blue-300 hover:text-blue-200 hover:underline"
|
|
388
|
+
>
|
|
389
|
+
{t('auth.recover.entry')}
|
|
390
|
+
</button>
|
|
391
|
+
</div>
|
|
392
|
+
{isAuthCodeVisible && (
|
|
393
|
+
<AuthCode ref={authRef} validImg={validImg} close={close} onReset={onReset} />
|
|
394
|
+
)}
|
|
395
|
+
</form>
|
|
396
|
+
) : (
|
|
397
|
+
<form className="space-y-5" onSubmit={submitRecoverPassword} autoComplete="new-password">
|
|
398
|
+
<div className="flex items-center justify-between">
|
|
399
|
+
<div className="text-white font-semibold">{t('auth.recover.title')}</div>
|
|
400
|
+
<button
|
|
401
|
+
type="button"
|
|
402
|
+
onClick={closeRecover}
|
|
403
|
+
className="text-sm text-gray-300 hover:text-white"
|
|
404
|
+
>
|
|
405
|
+
{t('auth.recover.back_to_login')}
|
|
406
|
+
</button>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
<CxInput
|
|
410
|
+
className="w-full"
|
|
411
|
+
type="email"
|
|
412
|
+
required
|
|
413
|
+
autoComplete="off"
|
|
414
|
+
placeholder={t('auth.recover.email_placeholder')}
|
|
415
|
+
value={recoverEmail}
|
|
416
|
+
onChange={(e) => {
|
|
417
|
+
setRecoverEmail(e.target.value);
|
|
418
|
+
setRecoverEmailCode('');
|
|
419
|
+
}}
|
|
420
|
+
/>
|
|
421
|
+
|
|
422
|
+
<div className="flex items-center gap-2">
|
|
423
|
+
<button
|
|
424
|
+
type="button"
|
|
425
|
+
disabled={recoverSendingCode || recoverCooldownLoading || recoverCooldownSeconds > 0}
|
|
426
|
+
onClick={openRecoverSendCode}
|
|
427
|
+
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"
|
|
428
|
+
>
|
|
429
|
+
{recoverCooldownLoading || recoverSendingCode ? (
|
|
430
|
+
<span className="flex items-center gap-2">
|
|
431
|
+
<Loader2 className="animate-spin h-4 w-4" />
|
|
432
|
+
{t('common.loading')}
|
|
433
|
+
</span>
|
|
434
|
+
) : recoverCooldownSeconds > 0 ? (
|
|
435
|
+
t('auth.recover.send_code_countdown', { count: recoverCooldownSeconds })
|
|
436
|
+
) : (
|
|
437
|
+
t('auth.recover.send_code')
|
|
438
|
+
)}
|
|
439
|
+
</button>
|
|
440
|
+
<CxInput
|
|
441
|
+
className="min-w-0 flex-1"
|
|
442
|
+
autoComplete="off"
|
|
443
|
+
placeholder={t('auth.recover.email_code_placeholder')}
|
|
444
|
+
value={recoverEmailCode}
|
|
445
|
+
onChange={(e) => setRecoverEmailCode(e.target.value)}
|
|
446
|
+
/>
|
|
447
|
+
</div>
|
|
448
|
+
|
|
449
|
+
<CxInput
|
|
450
|
+
className="w-full"
|
|
451
|
+
type="password"
|
|
452
|
+
required
|
|
453
|
+
autoComplete="new-password"
|
|
454
|
+
placeholder={t('auth.recover.new_password_placeholder')}
|
|
455
|
+
value={recoverNewPassword}
|
|
456
|
+
onChange={(e) => setRecoverNewPassword(e.target.value)}
|
|
457
|
+
/>
|
|
458
|
+
<CxInput
|
|
459
|
+
className="w-full"
|
|
460
|
+
type="password"
|
|
461
|
+
required
|
|
462
|
+
autoComplete="new-password"
|
|
463
|
+
placeholder={t('auth.recover.confirm_password_placeholder')}
|
|
464
|
+
value={recoverConfirmPassword}
|
|
465
|
+
onChange={(e) => setRecoverConfirmPassword(e.target.value)}
|
|
466
|
+
/>
|
|
467
|
+
|
|
468
|
+
<button
|
|
469
|
+
type="submit"
|
|
470
|
+
disabled={recoverSubmitting}
|
|
471
|
+
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"
|
|
472
|
+
>
|
|
473
|
+
{recoverSubmitting ? (
|
|
474
|
+
<Loader2 className="animate-spin h-5 w-5" />
|
|
475
|
+
) : (
|
|
476
|
+
<span className="flex items-center gap-2">
|
|
477
|
+
{t('auth.recover.submit')} <ArrowRight size={18} />
|
|
478
|
+
</span>
|
|
479
|
+
)}
|
|
480
|
+
</button>
|
|
481
|
+
|
|
482
|
+
{isRecoverAuthCodeVisible ? (
|
|
483
|
+
<AuthCode
|
|
484
|
+
validImg={handleRecoverSendEmailCode}
|
|
485
|
+
close={() => setIsRecoverAuthCodeVisible(false)}
|
|
486
|
+
onReset={() => {}}
|
|
487
|
+
/>
|
|
488
|
+
) : null}
|
|
489
|
+
</form>
|
|
490
|
+
)}
|
|
491
|
+
</div>
|
|
492
|
+
</div>
|
|
493
|
+
</div>
|
|
494
|
+
</ConfigProvider>
|
|
495
|
+
);
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
export default LoginPage;
|