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,287 @@
|
|
|
1
|
+
import { addUser, editUser, getUserDetailAPI } from '@/api/system/user'
|
|
2
|
+
import { useModalSubmit } from '@/hooks/useModalSubmit'
|
|
3
|
+
import {
|
|
4
|
+
CxForm,
|
|
5
|
+
CxFormItem,
|
|
6
|
+
CxInput,
|
|
7
|
+
CxModal,
|
|
8
|
+
CxSelect,
|
|
9
|
+
UploadImg,
|
|
10
|
+
useCxModal,
|
|
11
|
+
} from '@cx-ui'
|
|
12
|
+
import { Form, Input, Select, Space } from 'antd'
|
|
13
|
+
import {
|
|
14
|
+
forwardRef,
|
|
15
|
+
useImperativeHandle,
|
|
16
|
+
useMemo
|
|
17
|
+
} from 'react'
|
|
18
|
+
import { useTranslation } from 'react-i18next'
|
|
19
|
+
import { buildUserFormRules, emptyUserFormValues } from '../userFormShared'
|
|
20
|
+
import './modal-style/submit-modal.less'
|
|
21
|
+
|
|
22
|
+
interface UserModalProps {
|
|
23
|
+
onOk?: (values: any) => void | Promise<void>
|
|
24
|
+
onCancel?: () => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type ModalMode = 'add' | 'edit'
|
|
28
|
+
type OpenPayload = {
|
|
29
|
+
opeType?: ModalMode
|
|
30
|
+
opeId?: number | string
|
|
31
|
+
record?: any
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const ProductModal = forwardRef<any, UserModalProps>(function ProductModal(_props, ref) {
|
|
35
|
+
const { onOk, onCancel } = _props as UserModalProps
|
|
36
|
+
const { t } = useTranslation()
|
|
37
|
+
const { submitting, handleSubmit } = useModalSubmit<any, any>()
|
|
38
|
+
|
|
39
|
+
const modal = useCxModal({
|
|
40
|
+
onOpen: async (payload) => {
|
|
41
|
+
const nextType = payload.opeType ?? 'add'
|
|
42
|
+
const record = payload.data
|
|
43
|
+
const { form, setOpeId } = modal
|
|
44
|
+
|
|
45
|
+
setOpeId(nextType === 'edit' ? payload.opeId : undefined)
|
|
46
|
+
if (nextType === 'edit' && payload.opeId) {
|
|
47
|
+
try {
|
|
48
|
+
const detailRes = await getUserDetailAPI(payload.opeId)
|
|
49
|
+
fillFormByDetail(normalizeUserDetail(detailRes))
|
|
50
|
+
} catch (error) {
|
|
51
|
+
// 详情接口失败时回退到列表 record,确保弹框仍可编辑
|
|
52
|
+
fillFormByDetail(record || {})
|
|
53
|
+
}
|
|
54
|
+
} else if (nextType === 'edit' && record) {
|
|
55
|
+
fillFormByDetail(record)
|
|
56
|
+
} else {
|
|
57
|
+
form.resetFields()
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
onClose: () => {
|
|
61
|
+
onCancel?.()
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const { isOpen, close, form, opeType, opeId } = modal
|
|
66
|
+
const avatarValue = Form.useWatch('avatar', form)
|
|
67
|
+
const userRules = useMemo(() => buildUserFormRules(t, opeType === 'detail' ? 'edit' : opeType), [t, opeType])
|
|
68
|
+
// 弹框名称
|
|
69
|
+
const title = useMemo(
|
|
70
|
+
() => (opeType === 'edit' ? t('system.user.modal_user.edit_title') : t('system.user.modal_user.add_title')),
|
|
71
|
+
[opeType, t],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const normalizeUserDetail = (raw: any) => {
|
|
75
|
+
if (raw?.data?.data) return raw.data.data
|
|
76
|
+
if (raw?.data) return raw.data
|
|
77
|
+
return raw || {}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** 将详情里的 phone 拆成区号与手机号(兼容历史存储为 “+86 138xxxx” 的格式)。 */
|
|
81
|
+
const parsePhoneForForm = (raw: unknown): { areaCode: string; phone: string } => {
|
|
82
|
+
const str = raw != null && raw !== '' ? String(raw).trim() : ''
|
|
83
|
+
if (!str) return { areaCode: '+86', phone: '' }
|
|
84
|
+
const parts = str.split(/\s+/).filter(Boolean)
|
|
85
|
+
if (parts.length > 1 && String(parts[0]).startsWith('+')) {
|
|
86
|
+
return { areaCode: String(parts[0]), phone: parts.slice(1).join(' ') }
|
|
87
|
+
}
|
|
88
|
+
return { areaCode: '+86', phone: str }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const fillFormByDetail = (detail: any) => {
|
|
92
|
+
const { areaCode, phone } = parsePhoneForForm(detail?.phone)
|
|
93
|
+
const avatarRaw = detail?.avatar
|
|
94
|
+
const avatarList =
|
|
95
|
+
Array.isArray(avatarRaw)
|
|
96
|
+
? avatarRaw.filter(Boolean).map((x) => String(x))
|
|
97
|
+
: avatarRaw
|
|
98
|
+
? [String(avatarRaw)]
|
|
99
|
+
: []
|
|
100
|
+
form.setFieldsValue({
|
|
101
|
+
name: detail?.email ?? '',
|
|
102
|
+
code: detail?.name ?? '',
|
|
103
|
+
password: '',
|
|
104
|
+
areaCode,
|
|
105
|
+
phone,
|
|
106
|
+
avatar: avatarList,
|
|
107
|
+
remark: detail?.remark ?? '',
|
|
108
|
+
sex: Number(detail?.sex ?? 1),
|
|
109
|
+
is_active: Number(detail?.status) === 1 || Boolean(detail?.is_active),
|
|
110
|
+
})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** 头像上传成功后,将组件回传的地址写入表单 avatar 字段(地址数组)。 */
|
|
114
|
+
const handleAvatarUploaded = (fileList: any[]) => {
|
|
115
|
+
const addresses = (Array.isArray(fileList) ? fileList : [])
|
|
116
|
+
.map((f) => f?.response?.data?.address ?? f?.url ?? '')
|
|
117
|
+
.filter(Boolean)
|
|
118
|
+
.map((x) => String(x))
|
|
119
|
+
form.setFieldValue('avatar', addresses)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const onOkClick = async () => {
|
|
123
|
+
if (opeType === 'detail') return
|
|
124
|
+
const result = await handleSubmit({
|
|
125
|
+
opeType,
|
|
126
|
+
validate: () => form.validateFields(),
|
|
127
|
+
addAPI: addUser,
|
|
128
|
+
editAPI: (payload) => editUser(payload),
|
|
129
|
+
transform: (values) => ({
|
|
130
|
+
email: values.name,
|
|
131
|
+
name: values.code,
|
|
132
|
+
password: values.password,
|
|
133
|
+
areaCode: values.areaCode,
|
|
134
|
+
phone: values.phone,
|
|
135
|
+
avatar: values.avatar[0],
|
|
136
|
+
remark: values.remark,
|
|
137
|
+
sex: Number(values.sex ?? 1),
|
|
138
|
+
is_active: values.is_active,
|
|
139
|
+
...(opeType === 'edit' ? { id: opeId } : {}),
|
|
140
|
+
}),
|
|
141
|
+
// successMessage: {
|
|
142
|
+
// add: t('system.user.toast.create_success'),
|
|
143
|
+
// edit: t('system.user.toast.update_success'),
|
|
144
|
+
// },
|
|
145
|
+
onSuccess: async (ctx) => {
|
|
146
|
+
await onOk?.({
|
|
147
|
+
...ctx.values,
|
|
148
|
+
id: opeId,
|
|
149
|
+
})
|
|
150
|
+
},
|
|
151
|
+
})
|
|
152
|
+
if (result) {
|
|
153
|
+
close()
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
useImperativeHandle(ref, () => ({
|
|
158
|
+
open: modal.open,
|
|
159
|
+
close,
|
|
160
|
+
}), [modal.open, close])
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<CxModal
|
|
164
|
+
title={title}
|
|
165
|
+
isOpen={isOpen}
|
|
166
|
+
onClose={close}
|
|
167
|
+
modalConfig={{ width: 600 }}
|
|
168
|
+
opeType={opeType}
|
|
169
|
+
submitting={submitting}
|
|
170
|
+
onSubmit={onOkClick}
|
|
171
|
+
>
|
|
172
|
+
<CxForm
|
|
173
|
+
form={form}
|
|
174
|
+
rules={userRules}
|
|
175
|
+
layout="vertical"
|
|
176
|
+
initialValues={emptyUserFormValues()}>
|
|
177
|
+
<CxFormItem
|
|
178
|
+
label={t('system.user.modal_user.email_label')}
|
|
179
|
+
name="name">
|
|
180
|
+
<CxInput.Large placeholder={t('system.user.modal_user.email_placeholder')} />
|
|
181
|
+
</CxFormItem>
|
|
182
|
+
|
|
183
|
+
<CxFormItem
|
|
184
|
+
label={t('system.user.modal_user.nickname_label')}
|
|
185
|
+
name="code">
|
|
186
|
+
<CxInput.Large placeholder={t('system.user.modal_user.nickname_placeholder')} />
|
|
187
|
+
</CxFormItem>
|
|
188
|
+
{opeType !== 'edit' && (
|
|
189
|
+
<CxFormItem
|
|
190
|
+
label={t('system.user.modal_user.password_label')}
|
|
191
|
+
name="password">
|
|
192
|
+
<CxInput.Large
|
|
193
|
+
type="password"
|
|
194
|
+
placeholder={t('system.user.modal_user.password_placeholder')}
|
|
195
|
+
/>
|
|
196
|
+
</CxFormItem>
|
|
197
|
+
)}
|
|
198
|
+
<CxFormItem label={t('system.user.modal_user.phone_label')}>
|
|
199
|
+
<Space.Compact className="customizeStyle" style={{ width: '100%' }}>
|
|
200
|
+
<Form.Item name="areaCode" noStyle>
|
|
201
|
+
<Select
|
|
202
|
+
style={{ width: 110 }}
|
|
203
|
+
options={[
|
|
204
|
+
{
|
|
205
|
+
label: t('system.user.modal_user.phone_area_code'),
|
|
206
|
+
value: '+86',
|
|
207
|
+
},
|
|
208
|
+
]}
|
|
209
|
+
/>
|
|
210
|
+
</Form.Item>
|
|
211
|
+
<CxFormItem name="phone" noStyle>
|
|
212
|
+
<Input placeholder={t('system.user.modal_user.phone_placeholder')} />
|
|
213
|
+
</CxFormItem>
|
|
214
|
+
</Space.Compact>
|
|
215
|
+
</CxFormItem>
|
|
216
|
+
<CxFormItem label={t('system.user.modal_user.avatar_label')} name="avatar">
|
|
217
|
+
<UploadImg
|
|
218
|
+
value={avatarValue}
|
|
219
|
+
maxCount={1}
|
|
220
|
+
onUploaded={handleAvatarUploaded}
|
|
221
|
+
/>
|
|
222
|
+
</CxFormItem>
|
|
223
|
+
<CxFormItem label={t('system.user.modal_user.sex_label')} name="sex">
|
|
224
|
+
<CxSelect.Large
|
|
225
|
+
options={[
|
|
226
|
+
{ label: t('system.user.modal_user.sex_male'), value: 1 },
|
|
227
|
+
{ label: t('system.user.modal_user.sex_female'), value: 0 },
|
|
228
|
+
]}
|
|
229
|
+
/>
|
|
230
|
+
</CxFormItem>
|
|
231
|
+
<CxFormItem label={t('system.user.modal_user.remark_label')} name="remark">
|
|
232
|
+
<CxInput.Textarea
|
|
233
|
+
placeholder={t('system.user.modal_user.remark_placeholder')}
|
|
234
|
+
/>
|
|
235
|
+
</CxFormItem>
|
|
236
|
+
|
|
237
|
+
{/* <CxFormItem
|
|
238
|
+
label=''
|
|
239
|
+
name="is_active"
|
|
240
|
+
valuePropName="checked">
|
|
241
|
+
<Switch /> {t('common.enabled')}
|
|
242
|
+
</CxFormItem> */}
|
|
243
|
+
{/* <Form.Item
|
|
244
|
+
label="状态"
|
|
245
|
+
name="status"
|
|
246
|
+
rules={[{ required: true, message: '请选择状态' }]}>
|
|
247
|
+
<CxSelect
|
|
248
|
+
options={[
|
|
249
|
+
{ name: '启用', value: 'enabled' },
|
|
250
|
+
{ name: '禁用', value: 'disabled' },
|
|
251
|
+
]}
|
|
252
|
+
fieldNames={{ label: 'name', value: 'value' }}
|
|
253
|
+
/>
|
|
254
|
+
</Form.Item>
|
|
255
|
+
<Form.Item
|
|
256
|
+
label="角色"
|
|
257
|
+
name="roles"
|
|
258
|
+
initialValue={[]}
|
|
259
|
+
rules={[{ required: true, message: '请选择角色' }]}>
|
|
260
|
+
<CxMultiSelect options={[
|
|
261
|
+
{ label: '启用', value: 'enabled' },
|
|
262
|
+
{ label: '禁用', value: 'disabled' },
|
|
263
|
+
]} placeholder="请选择角色" />
|
|
264
|
+
</Form.Item>
|
|
265
|
+
<Form.Item
|
|
266
|
+
label="日期选择"
|
|
267
|
+
name="time"
|
|
268
|
+
rules={[{ required: true, message: '请选择时间' }]}>
|
|
269
|
+
<CxDatePicker />
|
|
270
|
+
</Form.Item>
|
|
271
|
+
<Form.Item
|
|
272
|
+
label="日期区间选择"
|
|
273
|
+
name="times"
|
|
274
|
+
rules={[{ required: true, message: '请选择时间区间' }]}>
|
|
275
|
+
<CxRangePicker />
|
|
276
|
+
</Form.Item>
|
|
277
|
+
{type === 'edit' && (
|
|
278
|
+
<div style={{ color: '#999' }}>
|
|
279
|
+
当前编辑 id: {String(opeId ?? '')}
|
|
280
|
+
</div>
|
|
281
|
+
)} */}
|
|
282
|
+
</CxForm>
|
|
283
|
+
</CxModal>
|
|
284
|
+
)
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
export default ProductModal
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Rule } from 'antd/es/form'
|
|
2
|
+
import type { TFunction } from 'i18next'
|
|
3
|
+
|
|
4
|
+
export type UserFormValues = {
|
|
5
|
+
name: string
|
|
6
|
+
code: string
|
|
7
|
+
password: string
|
|
8
|
+
/** 手机区号(如 +86) */
|
|
9
|
+
areaCode: string
|
|
10
|
+
/** 手机号(不含区号) */
|
|
11
|
+
phone: string
|
|
12
|
+
avatar: string
|
|
13
|
+
remark: string
|
|
14
|
+
sex: number
|
|
15
|
+
is_active: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function emptyUserFormValues(): UserFormValues {
|
|
19
|
+
return {
|
|
20
|
+
name: '',
|
|
21
|
+
code: '',
|
|
22
|
+
password: '',
|
|
23
|
+
areaCode: '+86',
|
|
24
|
+
phone: '',
|
|
25
|
+
avatar: '',
|
|
26
|
+
remark: '',
|
|
27
|
+
sex: 1,
|
|
28
|
+
is_active: true,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function buildUserFormRules(
|
|
33
|
+
t: TFunction,
|
|
34
|
+
mode: string = 'add',
|
|
35
|
+
): {
|
|
36
|
+
name: Rule[]
|
|
37
|
+
code: Rule[]
|
|
38
|
+
password?: Rule[]
|
|
39
|
+
phone: Rule[]
|
|
40
|
+
sex: Rule[]
|
|
41
|
+
} {
|
|
42
|
+
return {
|
|
43
|
+
name: [{ required: true, message: t('system.user.modal_user.rules.email.required') }],
|
|
44
|
+
code: [{ required: true, message: t('system.user.modal_user.rules.nickname.required') }],
|
|
45
|
+
...(mode === 'add'
|
|
46
|
+
? { password: [{ required: true, message: t('system.user.modal_user.rules.password.required') }] }
|
|
47
|
+
: {}),
|
|
48
|
+
phone: [{ required: true, message: t('system.user.modal_user.rules.phone.required') }],
|
|
49
|
+
sex: [{ required: true, message: t('system.user.modal_user.rules.sex.required') }],
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import typography from '@tailwindcss/typography';
|
|
2
|
+
|
|
3
|
+
/** @type {import('tailwindcss').Config} */
|
|
4
|
+
export default {
|
|
5
|
+
content: [
|
|
6
|
+
"./index.html",
|
|
7
|
+
"./src/**/*.{js,ts,jsx,tsx}",
|
|
8
|
+
],
|
|
9
|
+
darkMode: 'class', // Enable class-based dark mode
|
|
10
|
+
theme: {
|
|
11
|
+
extend: {},
|
|
12
|
+
},
|
|
13
|
+
plugins: [
|
|
14
|
+
typography,
|
|
15
|
+
],
|
|
16
|
+
}
|
|
17
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
+
"target": "ES2022",
|
|
5
|
+
"useDefineForClassFields": true,
|
|
6
|
+
"lib": [
|
|
7
|
+
"ES2022",
|
|
8
|
+
"DOM",
|
|
9
|
+
"DOM.Iterable"
|
|
10
|
+
],
|
|
11
|
+
"module": "ESNext",
|
|
12
|
+
"types": ["vite/client"],
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
|
|
15
|
+
/* Bundler mode */
|
|
16
|
+
"moduleResolution": "bundler",
|
|
17
|
+
"allowImportingTsExtensions": true,
|
|
18
|
+
"verbatimModuleSyntax": false,
|
|
19
|
+
"moduleDetection": "force",
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"jsx": "react-jsx",
|
|
22
|
+
|
|
23
|
+
/* 让 src 下的 .js 也进入工程,编辑器才能解析 @utils 等 paths(Vite 运行时已支持) */
|
|
24
|
+
"allowJs": true,
|
|
25
|
+
"checkJs": false,
|
|
26
|
+
|
|
27
|
+
/* Path aliases */
|
|
28
|
+
"baseUrl": ".",
|
|
29
|
+
"paths": {
|
|
30
|
+
"@/*": ["./src/*"],
|
|
31
|
+
"@cx-ui": ["./src/components/cx-ui/index.ts"],
|
|
32
|
+
"@cx-ui/*": ["./src/components/cx-ui/*"],
|
|
33
|
+
"@components/*": ["./src/components/*"],
|
|
34
|
+
"@utils/*": ["./src/utils/*"],
|
|
35
|
+
"@api/*": ["./src/api/*"],
|
|
36
|
+
"@http/*": ["./src/http/*"]
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/* Linting */
|
|
40
|
+
"strict": false,
|
|
41
|
+
"noUnusedLocals": false,
|
|
42
|
+
"noUnusedParameters": false,
|
|
43
|
+
"erasableSyntaxOnly": true,
|
|
44
|
+
"noFallthroughCasesInSwitch": false,
|
|
45
|
+
"noUncheckedSideEffectImports": false
|
|
46
|
+
},
|
|
47
|
+
"include": ["src"]
|
|
48
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "ES2023",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
|
|
10
|
+
/* Bundler mode */
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"verbatimModuleSyntax": true,
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"erasableSyntaxOnly": true,
|
|
22
|
+
"noFallthroughCasesInSwitch": true,
|
|
23
|
+
"noUncheckedSideEffectImports": true
|
|
24
|
+
},
|
|
25
|
+
"include": ["vite.config.ts"]
|
|
26
|
+
}
|