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,120 @@
|
|
|
1
|
+
import type { SwitchProps } from 'antd'
|
|
2
|
+
import { Switch } from 'antd'
|
|
3
|
+
import type { ReactNode } from 'react'
|
|
4
|
+
import './index.less'
|
|
5
|
+
|
|
6
|
+
export type CxSwitchVariant = 'default' | 'text' | 'dual'
|
|
7
|
+
|
|
8
|
+
export type CxSwitchProps = SwitchProps & {
|
|
9
|
+
variant?: CxSwitchVariant
|
|
10
|
+
/** variant=text:选中态轨道内文案 */
|
|
11
|
+
checkedText?: ReactNode
|
|
12
|
+
/** variant=text:未选中态轨道内文案 */
|
|
13
|
+
uncheckedText?: ReactNode
|
|
14
|
+
/** variant=dual:左侧文案(对应 dualUncheckedValue) */
|
|
15
|
+
leftLabel?: ReactNode
|
|
16
|
+
/** variant=dual:右侧文案(对应 dualCheckedValue) */
|
|
17
|
+
rightLabel?: ReactNode
|
|
18
|
+
/** variant=dual:左侧对应取值 */
|
|
19
|
+
dualUncheckedValue?: string | number
|
|
20
|
+
/** variant=dual:右侧对应取值 */
|
|
21
|
+
dualCheckedValue?: string | number
|
|
22
|
+
/** variant=dual 时由 Form 注入 */
|
|
23
|
+
value?: string | number | boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 表单用开关;支持轨道内文案(text)、左右文案 + 双值(dual)。
|
|
28
|
+
*/
|
|
29
|
+
const CxSwitch = ({
|
|
30
|
+
className,
|
|
31
|
+
variant = 'default',
|
|
32
|
+
checkedText,
|
|
33
|
+
uncheckedText,
|
|
34
|
+
leftLabel,
|
|
35
|
+
rightLabel,
|
|
36
|
+
dualUncheckedValue = 1,
|
|
37
|
+
dualCheckedValue = 2,
|
|
38
|
+
value,
|
|
39
|
+
checked,
|
|
40
|
+
onChange,
|
|
41
|
+
disabled,
|
|
42
|
+
...rest
|
|
43
|
+
}: CxSwitchProps) => {
|
|
44
|
+
const baseClass = ['cx-switch', className].filter(Boolean).join(' ')
|
|
45
|
+
|
|
46
|
+
if (variant === 'dual') {
|
|
47
|
+
const raw =
|
|
48
|
+
value !== undefined && value !== null
|
|
49
|
+
? Number(value)
|
|
50
|
+
: Number(dualUncheckedValue)
|
|
51
|
+
const isRight = raw === Number(dualCheckedValue)
|
|
52
|
+
|
|
53
|
+
const emit = (next: string | number) => {
|
|
54
|
+
if (disabled) return
|
|
55
|
+
if (typeof onChange !== 'function') return
|
|
56
|
+
// Form 注入的 onChange 多为单参;antd Switch 为 (checked, e)。dual 只向外抛业务值。
|
|
57
|
+
;(onChange as unknown as (v: string | number) => void)(next)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
className={['cx-switch-dual', disabled && 'cx-switch-dual--disabled']
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join(' ')}>
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
className={`cx-switch-dual__side${!isRight ? ' cx-switch-dual__side--active' : ''}`}
|
|
69
|
+
onClick={() => emit(dualUncheckedValue)}>
|
|
70
|
+
{leftLabel}
|
|
71
|
+
</button>
|
|
72
|
+
<Switch
|
|
73
|
+
{...rest}
|
|
74
|
+
disabled={disabled}
|
|
75
|
+
className={`${baseClass} cx-switch--dual-track`}
|
|
76
|
+
checked={isRight}
|
|
77
|
+
onChange={(c) => emit(c ? dualCheckedValue : dualUncheckedValue)}
|
|
78
|
+
/>
|
|
79
|
+
<button
|
|
80
|
+
type="button"
|
|
81
|
+
disabled={disabled}
|
|
82
|
+
className={`cx-switch-dual__side${isRight ? ' cx-switch-dual__side--active' : ''}`}
|
|
83
|
+
onClick={() => emit(dualCheckedValue)}>
|
|
84
|
+
{rightLabel}
|
|
85
|
+
</button>
|
|
86
|
+
</div>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (variant === 'text') {
|
|
91
|
+
const {
|
|
92
|
+
checkedChildren: rcCheckedChildren,
|
|
93
|
+
unCheckedChildren: rcUnCheckedChildren,
|
|
94
|
+
...textRest
|
|
95
|
+
} = rest
|
|
96
|
+
return (
|
|
97
|
+
<Switch
|
|
98
|
+
{...textRest}
|
|
99
|
+
disabled={disabled}
|
|
100
|
+
checked={checked}
|
|
101
|
+
onChange={onChange}
|
|
102
|
+
checkedChildren={checkedText ?? rcCheckedChildren}
|
|
103
|
+
unCheckedChildren={uncheckedText ?? rcUnCheckedChildren}
|
|
104
|
+
className={[baseClass, 'cx-switch--text'].filter(Boolean).join(' ')}
|
|
105
|
+
/>
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Switch
|
|
111
|
+
{...rest}
|
|
112
|
+
disabled={disabled}
|
|
113
|
+
checked={checked}
|
|
114
|
+
onChange={onChange}
|
|
115
|
+
className={baseClass}
|
|
116
|
+
/>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default CxSwitch
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
.cx-table {
|
|
2
|
+
height: 100%;
|
|
3
|
+
|
|
4
|
+
// 字体统一(与页面主 UI 字体一致)
|
|
5
|
+
// 字号对齐 LiteTable(table: text-sm)
|
|
6
|
+
font-size: 14px;
|
|
7
|
+
line-height: 20px;
|
|
8
|
+
.ant-table,
|
|
9
|
+
.ant-table * {
|
|
10
|
+
font-family: inherit;
|
|
11
|
+
font-size: inherit;
|
|
12
|
+
line-height: inherit;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 表头样式对齐 `LiteTable`(原生 table):
|
|
16
|
+
// - bg-gray-50 / dark:bg-gray-700/50
|
|
17
|
+
// - text-gray-500 / dark:text-gray-400
|
|
18
|
+
// - th: px-3 py-4 font-medium
|
|
19
|
+
.ant-table-thead > tr > th {
|
|
20
|
+
background: #f9fafb; // gray-50
|
|
21
|
+
color: #6b7280; // gray-500
|
|
22
|
+
padding: 16px 12px; // py-4 px-3
|
|
23
|
+
border-bottom: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// antd 默认表头字重是 600,这里在 cx-table 范围内覆盖为正常字重
|
|
27
|
+
.ant-table-wrapper .ant-table-thead > tr > th,
|
|
28
|
+
.ant-table-wrapper .ant-table-thead > tr > td {
|
|
29
|
+
font-weight: 400 !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 内容单元格 padding 对齐 LiteTable(td: px-3 py-4)
|
|
33
|
+
.ant-table-tbody > tr > td {
|
|
34
|
+
padding: 16px 12px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 选择列(checkbox/radio)对齐:去掉 th/td padding 并居中
|
|
38
|
+
.ant-table-thead > tr > th.cx-table__select-col,
|
|
39
|
+
.ant-table-tbody > tr > td.cx-table__select-col {
|
|
40
|
+
padding: 0 !important;
|
|
41
|
+
text-align: center;
|
|
42
|
+
line-height: 0;
|
|
43
|
+
vertical-align: middle;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.cx-table--small {
|
|
47
|
+
.ant-table-thead > tr > th {
|
|
48
|
+
padding: 12px 12px;
|
|
49
|
+
}
|
|
50
|
+
.ant-table-tbody > tr > td {
|
|
51
|
+
padding: 12px 12px;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 预留更紧凑的表格尺寸(用于选择弹框等空间有限场景) */
|
|
56
|
+
&.cx-table--mini {
|
|
57
|
+
font-size: 13px;
|
|
58
|
+
line-height: 18px;
|
|
59
|
+
.ant-table-thead > tr > th {
|
|
60
|
+
padding: 6px 6px;
|
|
61
|
+
}
|
|
62
|
+
.ant-table-tbody > tr > td {
|
|
63
|
+
padding: 6px 6px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// antd 默认会在 th 之间加分隔线与 hover 背景,这里对齐 LiteTable 的干净表头
|
|
69
|
+
.ant-table-thead > tr > th::before {
|
|
70
|
+
display: none;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 深色模式:跟随项目的 dark class(Tailwind 方案)
|
|
74
|
+
.dark & {
|
|
75
|
+
.ant-table-thead > tr > th {
|
|
76
|
+
background: rgba(55, 65, 81, 0.5); // gray-700/50
|
|
77
|
+
color: #9ca3af; // gray-400
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.ant-table {
|
|
82
|
+
height: 100%;
|
|
83
|
+
.ant-table-container {
|
|
84
|
+
height: 100%;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// antd Table 根节点:高度继承自外层容器
|
|
88
|
+
.ant-table-wrapper {
|
|
89
|
+
height: inherit;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Table 在有 loading 时会多一层 Spin 包裹,这些都要继承高度,否则内部撑不起来
|
|
93
|
+
.ant-spin-nested-loading,
|
|
94
|
+
.ant-spin,
|
|
95
|
+
.ant-spin-container {
|
|
96
|
+
height: inherit;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 只允许 body 容器纵向滚动,避免出现“嵌套滚动/双滚动条”
|
|
100
|
+
.ant-table-container,
|
|
101
|
+
.ant-table-content {
|
|
102
|
+
overflow-y: hidden !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// body:数据少不显示滚动条(auto),数据多才滚动;顺便把滚动条调淡一点
|
|
106
|
+
.ant-table-body {
|
|
107
|
+
overflow-y: auto !important;
|
|
108
|
+
scrollbar-width: thin; // Firefox
|
|
109
|
+
scrollbar-color: rgba(0, 0, 0, 0.24) transparent;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 未启用 scroll.x 时,彻底隐藏横向滚动条(避免 1px 溢出导致出现横条)
|
|
113
|
+
&.cx-table--no-scroll-x {
|
|
114
|
+
.ant-table-body {
|
|
115
|
+
overflow-x: hidden !important;
|
|
116
|
+
}
|
|
117
|
+
.ant-table-content {
|
|
118
|
+
overflow-x: hidden !important;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.ant-table-body::-webkit-scrollbar,
|
|
123
|
+
.ant-table-body *::-webkit-scrollbar {
|
|
124
|
+
width: 8px;
|
|
125
|
+
height: 8px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.ant-table-body::-webkit-scrollbar-track,
|
|
129
|
+
.ant-table-body *::-webkit-scrollbar-track {
|
|
130
|
+
background: transparent;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.ant-table-body::-webkit-scrollbar-thumb,
|
|
134
|
+
.ant-table-body *::-webkit-scrollbar-thumb {
|
|
135
|
+
background: rgba(0, 0, 0, 0.24);
|
|
136
|
+
border-radius: 999px;
|
|
137
|
+
border: 2px solid transparent;
|
|
138
|
+
background-clip: content-box;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.ant-table-body:hover::-webkit-scrollbar-thumb,
|
|
142
|
+
.ant-table-body:hover *::-webkit-scrollbar-thumb {
|
|
143
|
+
background: rgba(0, 0, 0, 0.38);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.dark & {
|
|
147
|
+
.ant-table-body {
|
|
148
|
+
scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
|
|
149
|
+
}
|
|
150
|
+
.ant-table-body::-webkit-scrollbar-thumb,
|
|
151
|
+
.ant-table-body *::-webkit-scrollbar-thumb {
|
|
152
|
+
background: rgba(255, 255, 255, 0.24);
|
|
153
|
+
}
|
|
154
|
+
.ant-table-body:hover::-webkit-scrollbar-thumb,
|
|
155
|
+
.ant-table-body:hover *::-webkit-scrollbar-thumb {
|
|
156
|
+
background: rgba(255, 255, 255, 0.38);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { TableProps } from 'antd'
|
|
2
|
+
import { Table } from 'antd'
|
|
3
|
+
import clsx from 'clsx'
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
import { CxEmptyState } from '../empty-state'
|
|
7
|
+
import './index.less'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 基于 antd Table 的封装:
|
|
11
|
+
* - 强制挂载 `cx-table` class,便于在 `.cx-table { ... }` 里做定向样式覆盖
|
|
12
|
+
* - 不修改 antd 全局样式
|
|
13
|
+
*/
|
|
14
|
+
export type CxTableOwnProps<RecordType extends object = any> = Omit<TableProps<RecordType>, 'size'> & {
|
|
15
|
+
/**
|
|
16
|
+
* 表头固定 + 内容区内部滚动:
|
|
17
|
+
* 开启后会自动计算 scroll.y(基于父容器高度),并把结果合并进 `props.scroll`。
|
|
18
|
+
*/
|
|
19
|
+
autoScrollY?: boolean
|
|
20
|
+
/** 自动计算 scroll.y 的最小高度(px),默认 120 */
|
|
21
|
+
minScrollY?: number
|
|
22
|
+
/** 表格尺寸:影响行高/间距(默认 default);须 Omit antd Table `size`,否则与 large|middle|small 求交只剩 small */
|
|
23
|
+
size?: 'default' | 'small' | 'mini'
|
|
24
|
+
/** 自定义空状态文案,不传则使用 `common.no_data` */
|
|
25
|
+
emptyText?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function CxTable<RecordType extends object = any>(props: CxTableOwnProps<RecordType>) {
|
|
29
|
+
const { t } = useTranslation()
|
|
30
|
+
const {
|
|
31
|
+
className,
|
|
32
|
+
autoScrollY,
|
|
33
|
+
minScrollY = 120,
|
|
34
|
+
size = 'default',
|
|
35
|
+
scroll,
|
|
36
|
+
pagination,
|
|
37
|
+
tableLayout,
|
|
38
|
+
columns,
|
|
39
|
+
emptyText,
|
|
40
|
+
...rest
|
|
41
|
+
} = props
|
|
42
|
+
const wrapRef = useRef<HTMLDivElement | null>(null)
|
|
43
|
+
const [autoY, setAutoY] = useState<number | undefined>(undefined)
|
|
44
|
+
const [wrapW, setWrapW] = useState<number | undefined>(undefined)
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!autoScrollY) {
|
|
48
|
+
setAutoY(undefined)
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
const wrap = wrapRef.current
|
|
52
|
+
if (!wrap) return
|
|
53
|
+
|
|
54
|
+
const calc = () => {
|
|
55
|
+
const h = wrap.getBoundingClientRect().height
|
|
56
|
+
if (!Number.isFinite(h) || h <= 0) return
|
|
57
|
+
const headerEl = wrap.querySelector(
|
|
58
|
+
'.ant-table-header',
|
|
59
|
+
) as HTMLElement | null
|
|
60
|
+
const headerH = headerEl ? headerEl.getBoundingClientRect().height : 0
|
|
61
|
+
setAutoY(Math.max(minScrollY, Math.floor(h - headerH)))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
calc()
|
|
65
|
+
const ro = new ResizeObserver(() => calc())
|
|
66
|
+
ro.observe(wrap)
|
|
67
|
+
return () => ro.disconnect()
|
|
68
|
+
}, [autoScrollY, minScrollY])
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const wrap = wrapRef.current
|
|
72
|
+
if (!wrap) return
|
|
73
|
+
const calc = () => {
|
|
74
|
+
const w = wrap.getBoundingClientRect().width
|
|
75
|
+
if (!Number.isFinite(w) || w <= 0) return
|
|
76
|
+
setWrapW(Math.floor(w))
|
|
77
|
+
}
|
|
78
|
+
calc()
|
|
79
|
+
const ro = new ResizeObserver(() => calc())
|
|
80
|
+
ro.observe(wrap)
|
|
81
|
+
return () => ro.disconnect()
|
|
82
|
+
}, [])
|
|
83
|
+
|
|
84
|
+
const mergedScroll = useMemo(() => {
|
|
85
|
+
if (!autoScrollY || autoY == null) return scroll
|
|
86
|
+
return { ...(scroll as any), y: autoY } as any
|
|
87
|
+
}, [autoScrollY, autoY, scroll])
|
|
88
|
+
|
|
89
|
+
const mergedColumns = useMemo(() => {
|
|
90
|
+
if (!Array.isArray(columns)) return columns
|
|
91
|
+
const base = columns.map((c: any) => ({
|
|
92
|
+
...c,
|
|
93
|
+
dataIndex: c?.dataIndex ?? c?.key,
|
|
94
|
+
}))
|
|
95
|
+
|
|
96
|
+
// 关闭横向滚动时(scroll.x 未设置)在 fixed 布局下把“未设置 width 的列”平分剩余宽度
|
|
97
|
+
const noScrollX = scroll == null || (scroll as any).x == null
|
|
98
|
+
const isFixed = tableLayout === 'fixed'
|
|
99
|
+
if (!noScrollX || !isFixed || wrapW == null) return base
|
|
100
|
+
|
|
101
|
+
let fixedW = 0
|
|
102
|
+
const flexCols: any[] = []
|
|
103
|
+
for (const c of base as any[]) {
|
|
104
|
+
const w = c?.width
|
|
105
|
+
if (typeof w === 'number' && Number.isFinite(w)) {
|
|
106
|
+
fixedW += w
|
|
107
|
+
} else if (w == null) {
|
|
108
|
+
flexCols.push(c)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (flexCols.length === 0) return base
|
|
112
|
+
|
|
113
|
+
const remain = wrapW - fixedW
|
|
114
|
+
const each = Math.floor(remain / flexCols.length)
|
|
115
|
+
return (base as any[]).map((c) => {
|
|
116
|
+
if (c?.width != null) return c
|
|
117
|
+
const mw = typeof c?.minWidth === 'number' ? c.minWidth : undefined
|
|
118
|
+
const nextW = mw != null ? Math.max(mw, each) : each
|
|
119
|
+
return { ...c, width: nextW }
|
|
120
|
+
})
|
|
121
|
+
}, [columns, scroll, tableLayout, wrapW])
|
|
122
|
+
|
|
123
|
+
const mergedPagination = pagination === undefined ? false : pagination
|
|
124
|
+
const mergedTableLayout = tableLayout ?? 'fixed'
|
|
125
|
+
const noScrollX = scroll == null || (scroll as any).x == null
|
|
126
|
+
|
|
127
|
+
const emptyTextValue = emptyText ?? t('common.no_data')
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
ref={wrapRef}
|
|
132
|
+
className={clsx(
|
|
133
|
+
'cx-table',
|
|
134
|
+
`cx-table--${size}`,
|
|
135
|
+
noScrollX && 'cx-table--no-scroll-x',
|
|
136
|
+
className,
|
|
137
|
+
)}
|
|
138
|
+
>
|
|
139
|
+
<Table<RecordType>
|
|
140
|
+
{...rest}
|
|
141
|
+
columns={mergedColumns as any}
|
|
142
|
+
pagination={mergedPagination}
|
|
143
|
+
tableLayout={mergedTableLayout}
|
|
144
|
+
scroll={mergedScroll}
|
|
145
|
+
locale={{ emptyText: <CxEmptyState message={emptyTextValue} /> }}
|
|
146
|
+
/>
|
|
147
|
+
</div>
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export type { CxTableOwnProps as CxTableProps }
|
|
152
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.cx-tabs {
|
|
2
|
+
& > .ant-tabs-content-holder {
|
|
3
|
+
flex: 1;
|
|
4
|
+
min-height: 0;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
& > .ant-tabs-content-holder > .ant-tabs-content {
|
|
9
|
+
height: 100%;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
& > .ant-tabs-content-holder > .ant-tabs-content > .ant-tabs-tabpane {
|
|
13
|
+
height: 100%;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { TabsProps } from 'antd'
|
|
2
|
+
import { Tabs } from 'antd'
|
|
3
|
+
import clsx from 'clsx'
|
|
4
|
+
import type { Ref } from 'react'
|
|
5
|
+
import { forwardRef } from 'react'
|
|
6
|
+
import './index.less'
|
|
7
|
+
|
|
8
|
+
export type CxTabsProps = TabsProps & {
|
|
9
|
+
/** 自定义类名 */
|
|
10
|
+
className?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const CxTabsInner = forwardRef<any, CxTabsProps>(
|
|
14
|
+
({ className, ...rest }, ref) => {
|
|
15
|
+
return (
|
|
16
|
+
<Tabs
|
|
17
|
+
ref={ref as Ref<any>}
|
|
18
|
+
{...rest}
|
|
19
|
+
className={clsx('cx-tabs', className)}
|
|
20
|
+
style={{
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexDirection: 'column',
|
|
23
|
+
flex: 1,
|
|
24
|
+
minHeight: 0,
|
|
25
|
+
...rest.style,
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
CxTabsInner.displayName = 'CxTabs'
|
|
33
|
+
|
|
34
|
+
export const CxTabs = CxTabsInner
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* CxTag:仅作用于同时带 .cx-tag 的 antd Tag */
|
|
2
|
+
|
|
3
|
+
span.cx-tag.ant-tag {
|
|
4
|
+
margin-inline-end: 0;
|
|
5
|
+
/* 与 antd 主题圆角对齐(无 CSS 变量时退回 6px) */
|
|
6
|
+
border-radius: var(--ant-border-radius-sm, 6px);
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
line-height: 1.25;
|
|
9
|
+
font-weight: 500;
|
|
10
|
+
|
|
11
|
+
/* CxTag 内部所有内容字号统一 12px */
|
|
12
|
+
* {
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* 胶囊:与用户管理状态列(rounded-full + text-xs + px-2.5 py-1)一致 */
|
|
18
|
+
span.cx-tag.ant-tag.cx-tag--pill {
|
|
19
|
+
border-radius: 9999px;
|
|
20
|
+
padding-block: 4px;
|
|
21
|
+
padding-inline: 10px;
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
font-weight: 500;
|
|
24
|
+
line-height: 1.25;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* filled + 状态色:覆盖 antd 默认 success/error,与用户管理启用/禁用对齐 */
|
|
28
|
+
span.cx-tag.ant-tag.ant-tag-filled.ant-tag-success {
|
|
29
|
+
background: #dcfce7;
|
|
30
|
+
color: #166534;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
span.cx-tag.ant-tag.ant-tag-filled.ant-tag-error {
|
|
34
|
+
background: #fee2e2;
|
|
35
|
+
color: #991b1b;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dark span.cx-tag.ant-tag.ant-tag-filled.ant-tag-success {
|
|
39
|
+
background: rgba(22, 101, 52, 0.35);
|
|
40
|
+
color: #bbf7d0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dark span.cx-tag.ant-tag.ant-tag-filled.ant-tag-error {
|
|
44
|
+
background: rgba(153, 27, 27, 0.35);
|
|
45
|
+
color: #fecaca;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
span.cx-tag.ant-tag .ant-tag-close-icon {
|
|
49
|
+
margin-inline-start: 4px;
|
|
50
|
+
font-size: 12px;
|
|
51
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { ENUM_DATA, getEnumLabelKey } from '@/meta'
|
|
2
|
+
import { getIconComponent } from '@/utils/routeConfig'
|
|
3
|
+
import type { TagProps } from 'antd'
|
|
4
|
+
import { Tag } from 'antd'
|
|
5
|
+
import clsx from 'clsx'
|
|
6
|
+
import { forwardRef, memo } from 'react'
|
|
7
|
+
import { useTranslation } from 'react-i18next'
|
|
8
|
+
|
|
9
|
+
export type CxTagProps = TagProps & {
|
|
10
|
+
/**
|
|
11
|
+
* 胶囊全圆角 + 与用户管理状态列一致的字号/字重/内边距。
|
|
12
|
+
* 不设时圆角跟随 antd 主题(`--ant-border-radius-sm` 等)。
|
|
13
|
+
*/
|
|
14
|
+
pill?: boolean
|
|
15
|
+
/** 固定宽度(不传则按内容自适应) */
|
|
16
|
+
width?: number | string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** YesNo Tag:显示「是/否」,基于 commonYesNo 枚举 */
|
|
20
|
+
export type CxTagYesNoProps = Omit<CxTagProps, 'children'> & {
|
|
21
|
+
value: unknown
|
|
22
|
+
/** 枚举 key,预留扩展,默认 'commonYesNo' */
|
|
23
|
+
enumKey?: string
|
|
24
|
+
/** 是否反转:true 时 0=是,1=否;适用于「需要认证」等反向语义 */
|
|
25
|
+
reverse?: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Enabled Tag:显示「启用/禁用」,基于 commonStatus 枚举 */
|
|
29
|
+
export type CxTagEnabledProps = Omit<CxTagProps, 'children'> & {
|
|
30
|
+
value: unknown
|
|
31
|
+
/** 枚举 key,预留扩展,默认 'commonStatus' */
|
|
32
|
+
enumKey?: string
|
|
33
|
+
/** 是否反转:true 时 0/1 与文案、颜色对调(与 YesNo 一致) */
|
|
34
|
+
reverse?: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Enum Tag:通用枚举 Tag,根据 enumKey 和 value 自动获取 label */
|
|
38
|
+
export type CxTagEnumProps = Omit<CxTagProps, 'children'> & {
|
|
39
|
+
value: unknown
|
|
40
|
+
/** 枚举 key,如 'commonStatus'、'commonYesNo'、'permissionApiType' 等 */
|
|
41
|
+
enumKey: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const CxTagInner = forwardRef<HTMLSpanElement, CxTagProps>(
|
|
45
|
+
(
|
|
46
|
+
{ className, pill = true, width, style, variant = 'filled', children, ...rest },
|
|
47
|
+
ref,
|
|
48
|
+
) => {
|
|
49
|
+
return (
|
|
50
|
+
<Tag
|
|
51
|
+
ref={ref}
|
|
52
|
+
{...rest}
|
|
53
|
+
variant={variant}
|
|
54
|
+
style={width == null ? style : { ...style, width }}
|
|
55
|
+
className={clsx('cx-tag', pill && 'cx-tag--pill', className)}
|
|
56
|
+
>
|
|
57
|
+
{children}
|
|
58
|
+
</Tag>
|
|
59
|
+
)
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
CxTagInner.displayName = 'CxTag'
|
|
64
|
+
|
|
65
|
+
/** YesNo Tag 组件 */
|
|
66
|
+
function CxTagYesNoInner({ value, enumKey = 'commonYesNo', reverse = false, ...rest }: CxTagYesNoProps) {
|
|
67
|
+
const { t } = useTranslation()
|
|
68
|
+
// 如果反转,则交换 0 和 1 的映射
|
|
69
|
+
const normalizedValue = reverse ? (Number(value) === 0 ? 1 : Number(value) === 1 ? 0 : value) : value
|
|
70
|
+
const labelKey = getEnumLabelKey(enumKey, normalizedValue)
|
|
71
|
+
|
|
72
|
+
// 如果没有自定义 color,根据标准化后的值自动设置颜色
|
|
73
|
+
if (!rest.color) {
|
|
74
|
+
rest.color = Number(normalizedValue) === 1 ? 'success' : 'default'
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return <CxTagInner {...rest}>{labelKey ? t(labelKey) : undefined}</CxTagInner>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Enabled Tag 组件 */
|
|
81
|
+
function CxTagEnabledInner({
|
|
82
|
+
value,
|
|
83
|
+
enumKey = 'commonStatus',
|
|
84
|
+
reverse = false,
|
|
85
|
+
...rest
|
|
86
|
+
}: CxTagEnabledProps) {
|
|
87
|
+
const { t } = useTranslation()
|
|
88
|
+
const normalizedValue = reverse
|
|
89
|
+
? Number(value) === 0
|
|
90
|
+
? 1
|
|
91
|
+
: Number(value) === 1
|
|
92
|
+
? 0
|
|
93
|
+
: value
|
|
94
|
+
: value
|
|
95
|
+
const labelKey = getEnumLabelKey(enumKey, normalizedValue)
|
|
96
|
+
const n = Number(normalizedValue)
|
|
97
|
+
// 如果没有自定义 color,则根据状态自动设置颜色
|
|
98
|
+
if (!rest.color) {
|
|
99
|
+
rest.color = n === 1 ? 'success' : 'error'
|
|
100
|
+
}
|
|
101
|
+
return <CxTagInner {...rest}>{labelKey ? t(labelKey) : undefined}</CxTagInner>
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Enum Tag 组件 */
|
|
105
|
+
function CxTagEnumInner({ value, enumKey, ...rest }: CxTagEnumProps) {
|
|
106
|
+
const { t } = useTranslation()
|
|
107
|
+
const labelKey = getEnumLabelKey(enumKey, value)
|
|
108
|
+
const item = ENUM_DATA[enumKey]?.dataMap?.[`${value}`]
|
|
109
|
+
const iconName = typeof item?.icon === 'string' ? item.icon : undefined
|
|
110
|
+
const Icon = getIconComponent(iconName)
|
|
111
|
+
// 如果没有自定义 color,则从枚举配置中读取颜色
|
|
112
|
+
if (!rest.color) {
|
|
113
|
+
const colorMap = ENUM_DATA[enumKey]?.tagColorMap
|
|
114
|
+
if (colorMap) {
|
|
115
|
+
const colorValue = colorMap[`${value}`]
|
|
116
|
+
if (colorValue) {
|
|
117
|
+
rest.color = colorValue
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return (
|
|
122
|
+
<CxTagInner {...rest}>
|
|
123
|
+
<span className="inline-flex items-center gap-1">
|
|
124
|
+
{Icon ? <Icon size={14} /> : null}
|
|
125
|
+
{labelKey ? t(labelKey) : undefined}
|
|
126
|
+
</span>
|
|
127
|
+
</CxTagInner>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
CxTagYesNoInner.displayName = 'CxTag.YesNo'
|
|
132
|
+
CxTagEnabledInner.displayName = 'CxTag.Enabled'
|
|
133
|
+
CxTagEnumInner.displayName = 'CxTag.Enum'
|
|
134
|
+
|
|
135
|
+
/** 基于 antd Tag;`color` 与官方一致(如 success / error 或 `#xxx`);列表纯展示可受益于 `memo`。 */
|
|
136
|
+
export const CxTag = Object.assign(memo(CxTagInner), {
|
|
137
|
+
YesNo: memo(CxTagYesNoInner),
|
|
138
|
+
Enabled: memo(CxTagEnabledInner),
|
|
139
|
+
Enum: memo(CxTagEnumInner),
|
|
140
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TimelineProps } from 'antd'
|
|
2
|
+
import { Timeline } from 'antd'
|
|
3
|
+
import type { CSSProperties } from 'react'
|
|
4
|
+
|
|
5
|
+
export type CxTimelineProps = Omit<TimelineProps, 'className' | 'style'> & {
|
|
6
|
+
className?: string
|
|
7
|
+
style?: CSSProperties
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function CxTimeline(props: CxTimelineProps) {
|
|
11
|
+
const { className, style, ...restProps } = props
|
|
12
|
+
|
|
13
|
+
return <Timeline className={className} style={style} {...restProps} />
|
|
14
|
+
}
|