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,26 @@
|
|
|
1
|
+
import type { ToastType } from '@/contexts/ToastContext'
|
|
2
|
+
|
|
3
|
+
type ToastHandler = (
|
|
4
|
+
message: string,
|
|
5
|
+
type: ToastType,
|
|
6
|
+
duration?: number,
|
|
7
|
+
) => void
|
|
8
|
+
|
|
9
|
+
let toastHandler: ToastHandler | null = null
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 由 ToastProvider 挂载时注册,供 axios 等非 React 上下文使用(不可用 useToast)
|
|
13
|
+
*/
|
|
14
|
+
export function bindGlobalToast(handler: ToastHandler | null) {
|
|
15
|
+
toastHandler = handler
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function showGlobalToast(
|
|
19
|
+
message: string,
|
|
20
|
+
type: ToastType = 'error',
|
|
21
|
+
duration?: number,
|
|
22
|
+
) {
|
|
23
|
+
const text = (message ?? '').trim()
|
|
24
|
+
if (!text) return
|
|
25
|
+
toastHandler?.(text, type, duration)
|
|
26
|
+
}
|
package/src/utils/url.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an avatar URL path to a full URL if it's relative.
|
|
3
|
+
* 将头像 URL 路径解析为完整 URL(如果是相对路径)。
|
|
4
|
+
*
|
|
5
|
+
* @param path The avatar path from the database / 数据库中的头像路径
|
|
6
|
+
* @returns The resolved URL / 解析后的 URL
|
|
7
|
+
*/
|
|
8
|
+
export const resolveAvatarUrl = (path: string | null | undefined): string | undefined => {
|
|
9
|
+
if (!path) return undefined;
|
|
10
|
+
|
|
11
|
+
// If it's already an absolute URL, return as is (but handle localhost cleanup)
|
|
12
|
+
if (path.startsWith('http')) {
|
|
13
|
+
// Compatibility: If it's a legacy 'localhost' URL but we are accessing via IP,
|
|
14
|
+
// we might want to "force" it to be relative so it gets resolved correctly.
|
|
15
|
+
if (path.includes('://localhost:8000/static/avatars/')) {
|
|
16
|
+
const filename = path.split('/').pop();
|
|
17
|
+
return `/static/avatars/${filename}`; // Will be handled by the next check
|
|
18
|
+
}
|
|
19
|
+
return path;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// If it's a relative path starting with /static
|
|
23
|
+
if (path.startsWith('/static')) {
|
|
24
|
+
// In development/LAN, the backend is usually on port 8000
|
|
25
|
+
// We can derive the backend location.
|
|
26
|
+
// If we are on the same host but different port (e.g. 5173 vs 8000),
|
|
27
|
+
// or on a different device in LAN.
|
|
28
|
+
|
|
29
|
+
// Use the current window location to find the host IP/domain
|
|
30
|
+
const host = window.location.hostname;
|
|
31
|
+
|
|
32
|
+
// Rule: If we are in dev (vite) or local network, assume backend is on port 8000
|
|
33
|
+
// unless overridden.
|
|
34
|
+
return `${window.location.protocol}//${host}:8000${path}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return path;
|
|
38
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const validatePhoneNumber = (countryCode: string, phoneNumber: string): boolean => {
|
|
2
|
+
// Remove any whitespace
|
|
3
|
+
const cleanNumber = phoneNumber.replace(/\s/g, '');
|
|
4
|
+
|
|
5
|
+
if (countryCode === '+86') {
|
|
6
|
+
// China: 11 digits, starts with 1, second digit 3-9
|
|
7
|
+
return /^1[3-9]\d{9}$/.test(cleanNumber);
|
|
8
|
+
} else {
|
|
9
|
+
// Others: 5-15 digits (E.164 recommendation is max 15, min usually around 5-7)
|
|
10
|
+
return /^\d{5,15}$/.test(cleanNumber);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const validateEmail = (email: string): boolean => {
|
|
15
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
16
|
+
};
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
.slider-mask-bg {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 100%;
|
|
7
|
+
background-color: rgba(0, 0, 0, 50%);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.slider-mask {
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
left: 0;
|
|
14
|
+
height: 40px;
|
|
15
|
+
background: #d1e9fe;
|
|
16
|
+
border: 0 solid #1991fa;
|
|
17
|
+
border-radius: 2px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.inner-mv-img,
|
|
21
|
+
.inner-bg-img,
|
|
22
|
+
.slider-title {
|
|
23
|
+
user-select: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.mask {
|
|
27
|
+
z-index: 998;
|
|
28
|
+
display: block;
|
|
29
|
+
width: 310px;
|
|
30
|
+
height: 280px;
|
|
31
|
+
margin: 0 auto;
|
|
32
|
+
background: rgba(0, 0, 0, 0%);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.container {
|
|
36
|
+
position: absolute;
|
|
37
|
+
top: -300px;
|
|
38
|
+
z-index: 999;
|
|
39
|
+
width: 310px;
|
|
40
|
+
height: 280px;
|
|
41
|
+
padding: 17px 15px;
|
|
42
|
+
margin: auto;
|
|
43
|
+
background: rgba(255, 255, 255, 100%);
|
|
44
|
+
border-radius: 6px;
|
|
45
|
+
box-shadow: 0 0 11px 0 rgba(153, 153, 153, 100%);
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.slider-title {
|
|
50
|
+
display: flex;
|
|
51
|
+
font-size: 14px;
|
|
52
|
+
color: #333;
|
|
53
|
+
justify-content: space-between;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// .button-group {
|
|
57
|
+
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
// img {
|
|
61
|
+
// width: 25px;
|
|
62
|
+
// height: 25px;
|
|
63
|
+
// cursor: pointer;
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
.slide {
|
|
67
|
+
position: relative;
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 40px;
|
|
70
|
+
background-color: #f7f9fa;
|
|
71
|
+
border: 1px solid #e4e7eb;
|
|
72
|
+
box-sizing: border-box;
|
|
73
|
+
|
|
74
|
+
&::before {
|
|
75
|
+
position: absolute;
|
|
76
|
+
display: flex;
|
|
77
|
+
width: 100%;
|
|
78
|
+
height: 100%;
|
|
79
|
+
font-size: 12px;
|
|
80
|
+
color: #999;
|
|
81
|
+
text-indent: 50px;
|
|
82
|
+
content: '按住左边按钮移动完成上方拼图';
|
|
83
|
+
justify-content: center;
|
|
84
|
+
align-items: center;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.codeimg {
|
|
89
|
+
position: relative;
|
|
90
|
+
width: 280px;
|
|
91
|
+
height: 180px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
img {
|
|
95
|
+
width: 100%;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.backgroup-img {
|
|
99
|
+
position: absolute;
|
|
100
|
+
top: 0;
|
|
101
|
+
left: 0;
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.move-img {
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 0;
|
|
108
|
+
left: 0;
|
|
109
|
+
width: 52.2px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.block {
|
|
113
|
+
position: absolute;
|
|
114
|
+
top: 0;
|
|
115
|
+
left: 0;
|
|
116
|
+
display: flex;
|
|
117
|
+
width: 40px;
|
|
118
|
+
height: 38px;
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
background-color: #fff;
|
|
121
|
+
box-shadow: 0 0 3px rgba(0, 0, 0, 30%);
|
|
122
|
+
justify-content: center;
|
|
123
|
+
align-items: center;
|
|
124
|
+
background-size: 30px;
|
|
125
|
+
background-repeat: no-repeat;
|
|
126
|
+
background-position: center;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.block:hover {
|
|
130
|
+
color: #fff;
|
|
131
|
+
background-color: #1991fa;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.loading {
|
|
135
|
+
position: absolute;
|
|
136
|
+
top: 0;
|
|
137
|
+
left: 0;
|
|
138
|
+
z-index: 100;
|
|
139
|
+
display: flex;
|
|
140
|
+
width: 100%;
|
|
141
|
+
height: 100%;
|
|
142
|
+
color: #fff;
|
|
143
|
+
background: rgba(0, 0, 0, 20%);
|
|
144
|
+
border-radius: 6px;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
align-items: center;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.hint-success {
|
|
150
|
+
position: absolute;
|
|
151
|
+
z-index: 30;
|
|
152
|
+
width: 100%;
|
|
153
|
+
height: 30px;
|
|
154
|
+
line-height: 30px;
|
|
155
|
+
color: #67c23a;
|
|
156
|
+
text-align: center;
|
|
157
|
+
background-color: #f0f9eb;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.hint-error {
|
|
161
|
+
position: absolute;
|
|
162
|
+
z-index: 30;
|
|
163
|
+
width: 100%;
|
|
164
|
+
height: 30px;
|
|
165
|
+
line-height: 30px;
|
|
166
|
+
color: #f56c6c;
|
|
167
|
+
text-align: center;
|
|
168
|
+
background-color: #fef0f0;
|
|
169
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
.auth-code-overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
z-index: 2000;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.slider-mask-bg {
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background-color: rgba(0, 0, 0, 50%);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.slider {
|
|
17
|
+
position: fixed;
|
|
18
|
+
inset: 0;
|
|
19
|
+
display: flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
z-index: 2001;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.slider-mask {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
height: 40px;
|
|
30
|
+
background: #d1e9fe;
|
|
31
|
+
border: 0 solid #1991fa;
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.inner-mv-img,
|
|
36
|
+
.inner-bg-img,
|
|
37
|
+
.slider-title {
|
|
38
|
+
user-select: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.mask {
|
|
42
|
+
z-index: 998;
|
|
43
|
+
display: block;
|
|
44
|
+
width: 310px;
|
|
45
|
+
height: 280px;
|
|
46
|
+
margin: 0 auto;
|
|
47
|
+
background: rgba(0, 0, 0, 0%);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.container {
|
|
51
|
+
position: relative;
|
|
52
|
+
top: 0;
|
|
53
|
+
z-index: 999;
|
|
54
|
+
width: 310px;
|
|
55
|
+
height: 280px;
|
|
56
|
+
padding: 17px 15px;
|
|
57
|
+
margin: auto;
|
|
58
|
+
background: rgba(255, 255, 255, 100%);
|
|
59
|
+
border-radius: 6px;
|
|
60
|
+
box-shadow: 0 0 11px 0 rgba(153, 153, 153, 100%);
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.slider-title {
|
|
65
|
+
display: flex;
|
|
66
|
+
font-size: 14px;
|
|
67
|
+
color: #333;
|
|
68
|
+
justify-content: space-between;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.slide {
|
|
72
|
+
position: relative;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 40px;
|
|
75
|
+
background-color: #f7f9fa;
|
|
76
|
+
border: 1px solid #e4e7eb;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
|
|
79
|
+
&::before {
|
|
80
|
+
position: absolute;
|
|
81
|
+
display: flex;
|
|
82
|
+
width: 100%;
|
|
83
|
+
height: 100%;
|
|
84
|
+
font-size: 12px;
|
|
85
|
+
color: #999;
|
|
86
|
+
text-indent: 50px;
|
|
87
|
+
content: '按住左边按钮移动完成上方拼图';
|
|
88
|
+
justify-content: center;
|
|
89
|
+
align-items: center;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.codeimg {
|
|
94
|
+
position: relative;
|
|
95
|
+
width: 280px;
|
|
96
|
+
height: 180px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
img {
|
|
100
|
+
width: 100%;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.backgroup-img {
|
|
104
|
+
position: absolute;
|
|
105
|
+
top: 0;
|
|
106
|
+
left: 0;
|
|
107
|
+
width: 100%;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.move-img {
|
|
111
|
+
position: absolute;
|
|
112
|
+
top: 0;
|
|
113
|
+
left: 0;
|
|
114
|
+
width: 52.2px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.block {
|
|
118
|
+
position: absolute;
|
|
119
|
+
top: 0;
|
|
120
|
+
left: 0;
|
|
121
|
+
display: flex;
|
|
122
|
+
width: 40px;
|
|
123
|
+
height: 38px;
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
background-color: #fff;
|
|
126
|
+
box-shadow: 0 0 3px rgba(0, 0, 0, 30%);
|
|
127
|
+
justify-content: center;
|
|
128
|
+
align-items: center;
|
|
129
|
+
background-size: 30px;
|
|
130
|
+
background-repeat: no-repeat;
|
|
131
|
+
background-position: center;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.block:hover {
|
|
135
|
+
color: #fff;
|
|
136
|
+
background-color: #1991fa;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.loading {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 0;
|
|
142
|
+
left: 0;
|
|
143
|
+
z-index: 100;
|
|
144
|
+
display: flex;
|
|
145
|
+
width: 100%;
|
|
146
|
+
height: 100%;
|
|
147
|
+
color: #fff;
|
|
148
|
+
background: rgba(0, 0, 0, 20%);
|
|
149
|
+
border-radius: 6px;
|
|
150
|
+
justify-content: center;
|
|
151
|
+
align-items: center;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.hint-success {
|
|
155
|
+
position: absolute;
|
|
156
|
+
z-index: 30;
|
|
157
|
+
width: 100%;
|
|
158
|
+
height: 30px;
|
|
159
|
+
line-height: 30px;
|
|
160
|
+
color: #67c23a;
|
|
161
|
+
text-align: center;
|
|
162
|
+
background-color: #f0f9eb;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.hint-error {
|
|
166
|
+
position: absolute;
|
|
167
|
+
z-index: 30;
|
|
168
|
+
width: 100%;
|
|
169
|
+
height: 30px;
|
|
170
|
+
line-height: 30px;
|
|
171
|
+
color: #f56c6c;
|
|
172
|
+
text-align: center;
|
|
173
|
+
background-color: #fef0f0;
|
|
174
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RightOutlined,
|
|
3
|
+
RedoOutlined,
|
|
4
|
+
CloseOutlined
|
|
5
|
+
} from '@ant-design/icons';
|
|
6
|
+
import React, { useEffect , useState , useRef} from 'react'
|
|
7
|
+
|
|
8
|
+
import { notification } from 'antd'
|
|
9
|
+
|
|
10
|
+
import { getImgSwipeAPI } from '@api/common/auth';
|
|
11
|
+
import styles from './index.module.less'
|
|
12
|
+
|
|
13
|
+
// 避免 React StrictMode 开发态双挂载导致重复请求验证码图片
|
|
14
|
+
let captchaInitInFlight: Promise<any> | null = null
|
|
15
|
+
|
|
16
|
+
interface AuthCodeProps {
|
|
17
|
+
validImg: (data: any, callback?: () => void) => void | Promise<void>;
|
|
18
|
+
close: () => void;
|
|
19
|
+
onReset:() => void;
|
|
20
|
+
ref?: any;
|
|
21
|
+
}
|
|
22
|
+
interface TrackData {
|
|
23
|
+
bgImageWidth: any;
|
|
24
|
+
bgImageHeight: any;
|
|
25
|
+
sliderImageWidth: any;
|
|
26
|
+
sliderImageHeight: any;
|
|
27
|
+
startSlidingTime: any;
|
|
28
|
+
entSlidingTime: any;
|
|
29
|
+
trackList: any[];
|
|
30
|
+
}
|
|
31
|
+
const AuthCode: React.FC<AuthCodeProps> = (props:any) => {
|
|
32
|
+
const block: any = useRef(false)
|
|
33
|
+
/** 滑块背景图片 */
|
|
34
|
+
const [ backgroupImg, setBackgroupImg ] = useState('')
|
|
35
|
+
/** 滑块图片 */
|
|
36
|
+
const [ moveImg, setMoveImg] = useState('')
|
|
37
|
+
/** 是否已经移动滑块 */
|
|
38
|
+
// const [ startMove, setStartMove ] = useState(false)
|
|
39
|
+
const startMove = useRef(false)
|
|
40
|
+
|
|
41
|
+
/** 滑块移动距离 */
|
|
42
|
+
const [ blcokLeft, setBlcokLeft ] = useState(0)
|
|
43
|
+
|
|
44
|
+
/** 开始滑动的x轴 */
|
|
45
|
+
// const [ startX, setStartX ] = useState(0)
|
|
46
|
+
const startX= useRef(0)
|
|
47
|
+
// const [ startY, setStartY ] = useState(0)
|
|
48
|
+
const startY= useRef(0)
|
|
49
|
+
|
|
50
|
+
/** 划过的百分比 */
|
|
51
|
+
const [ movePercent, setMovePercent ] = useState(0)
|
|
52
|
+
/** 验证码唯一ID */
|
|
53
|
+
const [ uuid, setUuid ] = useState('')
|
|
54
|
+
/** 滑块移动的x轴 */
|
|
55
|
+
const [ moveX, setMoveX ] = useState(0)
|
|
56
|
+
const orderNumber = useRef(0)
|
|
57
|
+
/** 加载遮罩标识 */
|
|
58
|
+
const [ loading, setLoading ] = useState(true)
|
|
59
|
+
const trackData = useRef<TrackData>({
|
|
60
|
+
bgImageWidth: 0,
|
|
61
|
+
bgImageHeight: 0,
|
|
62
|
+
sliderImageWidth: 0,
|
|
63
|
+
sliderImageHeight: 0,
|
|
64
|
+
startSlidingTime: null,
|
|
65
|
+
entSlidingTime: null,
|
|
66
|
+
trackList: []
|
|
67
|
+
})
|
|
68
|
+
const [ verificationResult ,setVerificationResult] = useState<any>(null)
|
|
69
|
+
const [ showAuthCode ,setShowAuthCode] = useState(false)
|
|
70
|
+
// 重置
|
|
71
|
+
const reset=() =>{
|
|
72
|
+
setVerificationResult(null)
|
|
73
|
+
setMoveX(0)
|
|
74
|
+
setMovePercent(0)
|
|
75
|
+
startX.current = 0
|
|
76
|
+
startY.current = 0
|
|
77
|
+
// setStartY(0)
|
|
78
|
+
setBlcokLeft(0)
|
|
79
|
+
trackData.current = {
|
|
80
|
+
bgImageWidth: 0,
|
|
81
|
+
bgImageHeight: 0,
|
|
82
|
+
sliderImageWidth: 0,
|
|
83
|
+
sliderImageHeight: 0,
|
|
84
|
+
startSlidingTime: null,
|
|
85
|
+
entSlidingTime: null,
|
|
86
|
+
trackList: []
|
|
87
|
+
}
|
|
88
|
+
getImg()
|
|
89
|
+
}
|
|
90
|
+
// const add = () => {
|
|
91
|
+
// setOrderNumber(orderNumber+1)
|
|
92
|
+
// }
|
|
93
|
+
const setShowChild = ()=>{
|
|
94
|
+
setShowAuthCode(true)
|
|
95
|
+
}
|
|
96
|
+
const validImg = () => {
|
|
97
|
+
orderNumber.current++
|
|
98
|
+
props.validImg({trackData:trackData.current, uuid:uuid, orderNumber:orderNumber},()=>{
|
|
99
|
+
reset()
|
|
100
|
+
if (orderNumber.current >= 3) {
|
|
101
|
+
notification.open({
|
|
102
|
+
message: '警告',
|
|
103
|
+
type: 'warning',
|
|
104
|
+
description: '验证次数过多,请重新输入账号密码验证',
|
|
105
|
+
});
|
|
106
|
+
close();
|
|
107
|
+
props.onReset()
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
// 按下鼠标
|
|
112
|
+
const move = (e:any) => {
|
|
113
|
+
// console.log('点下拖动改变的值',startMove);
|
|
114
|
+
if (!startMove.current) return;
|
|
115
|
+
const moveX = (e.pageX * 2.12 - startX.current) / 2.12;
|
|
116
|
+
const pageX = e.pageX * 2.12;
|
|
117
|
+
const pageY = e.pageY * 2.12;
|
|
118
|
+
trackData.current.trackList.push({
|
|
119
|
+
x: pageX - startX.current,
|
|
120
|
+
y: pageY - startY.current,
|
|
121
|
+
t: (new Date().getTime() - new Date(trackData.current.startSlidingTime).getTime())})
|
|
122
|
+
const movePercent = moveX / 280;
|
|
123
|
+
if (moveX <= 0) {
|
|
124
|
+
setBlcokLeft(0);
|
|
125
|
+
setMoveX(0);
|
|
126
|
+
setMovePercent(0);
|
|
127
|
+
} else if (moveX >= 0 && moveX <= 235) {
|
|
128
|
+
setBlcokLeft(moveX);
|
|
129
|
+
setMoveX(moveX);
|
|
130
|
+
setMovePercent(movePercent);
|
|
131
|
+
} else if (moveX >= 235) {
|
|
132
|
+
setBlcokLeft(235);
|
|
133
|
+
setMoveX(235);
|
|
134
|
+
setMovePercent(movePercent);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// 弹起鼠标
|
|
138
|
+
const up = (e:any) => {
|
|
139
|
+
// setTrackData((prevState) => ({
|
|
140
|
+
// ...prevState,
|
|
141
|
+
// entSlidingTime: new Date().getTime()
|
|
142
|
+
// }));
|
|
143
|
+
trackData.current.entSlidingTime = new Date().getTime()
|
|
144
|
+
window.removeEventListener('mousemove', move);
|
|
145
|
+
window.removeEventListener('mouseup', up);
|
|
146
|
+
|
|
147
|
+
if (!startMove.current) return;
|
|
148
|
+
startMove.current = false
|
|
149
|
+
if (trackData.current.trackList.length > 0) {
|
|
150
|
+
trackData.current.trackList[0].x = 0
|
|
151
|
+
trackData.current.trackList[0].y = 0
|
|
152
|
+
}
|
|
153
|
+
validImg();
|
|
154
|
+
}
|
|
155
|
+
// 关闭
|
|
156
|
+
const close = () => {
|
|
157
|
+
props.close()
|
|
158
|
+
setLoading(false)
|
|
159
|
+
}
|
|
160
|
+
const start = async (e:any) => {
|
|
161
|
+
startMove.current = true
|
|
162
|
+
trackData.current.startSlidingTime = new Date().getTime()
|
|
163
|
+
startX.current = e.pageX * 2.12
|
|
164
|
+
startY.current = e.pageY * 2.12
|
|
165
|
+
window.addEventListener('mousemove', move);
|
|
166
|
+
window.addEventListener('mouseup', up);
|
|
167
|
+
}
|
|
168
|
+
const getImg = async () => {
|
|
169
|
+
if (!captchaInitInFlight) {
|
|
170
|
+
captchaInitInFlight = getImgSwipeAPI().finally(() => {
|
|
171
|
+
captchaInitInFlight = null
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
const res: any = await captchaInitInFlight
|
|
175
|
+
if (res && res.data && res.data.imageCaptchaInfo) {
|
|
176
|
+
setBackgroupImg(res.data.imageCaptchaInfo.backgroundImage)
|
|
177
|
+
setMoveImg(res.data.imageCaptchaInfo.templateImage)
|
|
178
|
+
setUuid(res.data.captchaId)
|
|
179
|
+
trackData.current = {...trackData.current, ...res.data.imageCaptchaInfo}
|
|
180
|
+
trackData.current.bgImageWidth = res.data.imageCaptchaInfo.backgroundImageWidth
|
|
181
|
+
trackData.current.bgImageHeight = res.data.imageCaptchaInfo.backgroundImageHeight
|
|
182
|
+
trackData.current.sliderImageWidth = res.data.imageCaptchaInfo.templateImageHeight
|
|
183
|
+
trackData.current.sliderImageHeight = res.data.imageCaptchaInfo.templateImageWidth
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
getImg()
|
|
188
|
+
}, [])
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
// style={{'display':showAuthCode?'black':'none'}}
|
|
192
|
+
<div className={styles['auth-code-overlay']}>
|
|
193
|
+
<div className={styles['slider-mask-bg']} onClick={close} />
|
|
194
|
+
<div className={styles["slider"]}>
|
|
195
|
+
<div className={styles["mask"]}>
|
|
196
|
+
<div className={styles["container"]}>
|
|
197
|
+
<div className={styles["slider-title"]}>
|
|
198
|
+
<div className={styles["text"]}>
|
|
199
|
+
<span>请完成下列验证后继续</span>
|
|
200
|
+
</div>
|
|
201
|
+
<div className={styles['button-group']}>
|
|
202
|
+
<RedoOutlined style={{'fontSize': '24px','cursor': 'pointer'}} onClick={reset}/>
|
|
203
|
+
<CloseOutlined style={{'fontSize': '24px','marginLeft': '8px','cursor': 'pointer'}} onClick={close}/>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
<div className={styles['codeimg']}>
|
|
207
|
+
<div style={{'display':verificationResult&&verificationResult!==null?'block':'none'}} className={styles['hint-success']}>验证成功 !</div>
|
|
208
|
+
<div style={{'display':verificationResult !== null && !verificationResult?'block':'none'}} className= {styles["hint-error"]}>验证失败 !</div>
|
|
209
|
+
<div className={styles['backgroup-img']}>
|
|
210
|
+
<img className="inner-bg-img" src={backgroupImg} />
|
|
211
|
+
</div>
|
|
212
|
+
<div className={styles["move-img"]} style={{'left': `${moveX}px`}}>
|
|
213
|
+
<img className={styles["inner-mv-img"]} src={moveImg} />
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
<div className={styles["slide"]}>
|
|
217
|
+
<div className={styles["slider-mask"]} style={{width: `${blcokLeft}px`}}>
|
|
218
|
+
<div ref={block} className={styles["block"]} style={{'left': `${blcokLeft}px`}} onMouseDown={start}>
|
|
219
|
+
<RightOutlined style={{'fontSize': '24px','cursor': 'pointer','color':'#ccc'}}/>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
<div style={{'display':loading?'none':'block'}} className={styles["loading"]}>
|
|
224
|
+
<span>获取验证图片...</span>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export default AuthCode
|