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,237 @@
|
|
|
1
|
+
import { getModelMetadataListAPI } from '@api/menus/model-metadata/manage'
|
|
2
|
+
import {
|
|
3
|
+
getModelMetadataRoleDetailAPI,
|
|
4
|
+
updateModelMetadataRoleFullAPI,
|
|
5
|
+
} from '@api/menus/model-metadata/role'
|
|
6
|
+
import { useToast } from '@/contexts/ToastContext'
|
|
7
|
+
import { roleModalShellStyles } from '@/views/page-system/role/modal/role-modal-shell-styles'
|
|
8
|
+
import { CxModal, useCxModal } from '@cx-ui'
|
|
9
|
+
import { forwardRef, useCallback, useImperativeHandle, useState } from 'react'
|
|
10
|
+
import { useTranslation } from 'react-i18next'
|
|
11
|
+
|
|
12
|
+
import RolePermissionAssignPanel, { colKey } from './role-permission-assign-panel'
|
|
13
|
+
|
|
14
|
+
export type RolePermissionModalOpenPayload = {
|
|
15
|
+
record: { id: string | number; name?: string }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 与 role-permission-assign-panel 勾选 key 一致:表/列 id 优先取 id,与列表 schema 对齐 */
|
|
19
|
+
function tableIdFromGrant(tb: any) {
|
|
20
|
+
return String(tb?.id ?? tb?.tableId ?? '').trim()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function columnIdFromGrant(col: any) {
|
|
24
|
+
return String(col?.id ?? col?.columnId ?? '').trim()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function initSelectedFromLibraries(libraries: any[]): Record<string, boolean> {
|
|
28
|
+
const next: Record<string, boolean> = {}
|
|
29
|
+
for (const lib of libraries || []) {
|
|
30
|
+
const mid = String(lib?.metadataId ?? lib?.id ?? '').trim()
|
|
31
|
+
if (!mid) continue
|
|
32
|
+
for (const tb of lib.tables || []) {
|
|
33
|
+
const tid = tableIdFromGrant(tb)
|
|
34
|
+
if (!tid) continue
|
|
35
|
+
for (const col of tb.columns || []) {
|
|
36
|
+
const cid = columnIdFromGrant(col)
|
|
37
|
+
if (!cid) continue
|
|
38
|
+
next[colKey(mid, tid, cid)] = true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return next
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function buildLibrariesFromSelected(selected: Record<string, boolean>) {
|
|
46
|
+
const byMeta = new Map<string, Map<string, string[]>>()
|
|
47
|
+
for (const [k, on] of Object.entries(selected)) {
|
|
48
|
+
if (!on) continue
|
|
49
|
+
const i1 = k.indexOf('::')
|
|
50
|
+
if (i1 < 0) continue
|
|
51
|
+
const i2 = k.indexOf('::', i1 + 2)
|
|
52
|
+
if (i2 < 0) continue
|
|
53
|
+
const metadataId = k.slice(0, i1).trim()
|
|
54
|
+
const tableId = k.slice(i1 + 2, i2).trim()
|
|
55
|
+
const columnId = k.slice(i2 + 2).trim()
|
|
56
|
+
if (!metadataId || !tableId || !columnId) continue
|
|
57
|
+
if (!byMeta.has(metadataId)) byMeta.set(metadataId, new Map())
|
|
58
|
+
const tm = byMeta.get(metadataId)!
|
|
59
|
+
if (!tm.has(tableId)) tm.set(tableId, [])
|
|
60
|
+
tm.get(tableId)!.push(columnId)
|
|
61
|
+
}
|
|
62
|
+
const libraries: { metadataId: string; tables: { tableId: string; columnIds: string[] }[] }[] = []
|
|
63
|
+
for (const [metadataId, tableMap] of byMeta) {
|
|
64
|
+
const tables = Array.from(tableMap.entries())
|
|
65
|
+
.map(([tableId, columnIds]) => ({
|
|
66
|
+
tableId,
|
|
67
|
+
columnIds: [...new Set(columnIds)],
|
|
68
|
+
}))
|
|
69
|
+
.filter((tb) => tb.tableId && tb.columnIds.length > 0)
|
|
70
|
+
if (!tables.length) continue
|
|
71
|
+
libraries.push({ metadataId, tables })
|
|
72
|
+
}
|
|
73
|
+
return libraries
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** 正式 list 接口:data 为数组,每项含 metadataId、tables(含 columns) */
|
|
77
|
+
function buildMetadataIndexFromListResponse(listRes: any) {
|
|
78
|
+
const raw = listRes?.data
|
|
79
|
+
const arr = Array.isArray(raw) ? raw : []
|
|
80
|
+
const byId: Record<string, any> = {}
|
|
81
|
+
const order: string[] = []
|
|
82
|
+
for (const it of arr) {
|
|
83
|
+
const mid = String(it?.metadataId ?? '').trim()
|
|
84
|
+
if (!mid) continue
|
|
85
|
+
byId[mid] = it
|
|
86
|
+
order.push(mid)
|
|
87
|
+
}
|
|
88
|
+
return { metadataById: byId, metadataOrder: order }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const RolePermissionModal = forwardRef<
|
|
92
|
+
{ open: (p: RolePermissionModalOpenPayload) => void; close: () => void },
|
|
93
|
+
{ onSaved?: () => void | Promise<void> }
|
|
94
|
+
>(function RolePermissionModal({ onSaved }, ref) {
|
|
95
|
+
const { t } = useTranslation()
|
|
96
|
+
const { showToast } = useToast()
|
|
97
|
+
const [loading, setLoading] = useState(false)
|
|
98
|
+
const [saving, setSaving] = useState(false)
|
|
99
|
+
const [roleId, setRoleId] = useState<string | number | null>(null)
|
|
100
|
+
const [detail, setDetail] = useState<any>(null)
|
|
101
|
+
const [metadataById, setMetadataById] = useState<Record<string, any>>({})
|
|
102
|
+
const [metadataOrder, setMetadataOrder] = useState<string[]>([])
|
|
103
|
+
const [selected, setSelected] = useState<Record<string, boolean>>({})
|
|
104
|
+
const [assignBootstrapKey, setAssignBootstrapKey] = useState(0)
|
|
105
|
+
/** 列表行传入的名称,接口返回前用于标题,减轻「点了没反应」感 */
|
|
106
|
+
const [titleHintFromList, setTitleHintFromList] = useState<string | undefined>(undefined)
|
|
107
|
+
|
|
108
|
+
const modal = useCxModal({
|
|
109
|
+
onOpen: async (payload) => {
|
|
110
|
+
const id = payload?.data?.record?.id ?? payload?.opeId
|
|
111
|
+
setRoleId(id ?? null)
|
|
112
|
+
setDetail(null)
|
|
113
|
+
setMetadataById({})
|
|
114
|
+
setMetadataOrder([])
|
|
115
|
+
setSelected({})
|
|
116
|
+
setAssignBootstrapKey((k) => k + 1)
|
|
117
|
+
if (id == null || `${id}`.trim() === '') {
|
|
118
|
+
setTitleHintFromList(undefined)
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
const hint = payload?.data?.record?.name
|
|
122
|
+
setTitleHintFromList(typeof hint === 'string' && hint.trim() ? hint.trim() : undefined)
|
|
123
|
+
setLoading(true)
|
|
124
|
+
try {
|
|
125
|
+
const [roleRes, listRes] = await Promise.all([
|
|
126
|
+
getModelMetadataRoleDetailAPI(id),
|
|
127
|
+
getModelMetadataListAPI(),
|
|
128
|
+
])
|
|
129
|
+
const data = (roleRes as any)?.data
|
|
130
|
+
setDetail(data ?? null)
|
|
131
|
+
setSelected(initSelectedFromLibraries(data?.libraries ?? []))
|
|
132
|
+
const idx = buildMetadataIndexFromListResponse(listRes)
|
|
133
|
+
setMetadataById(idx.metadataById)
|
|
134
|
+
setMetadataOrder(idx.metadataOrder)
|
|
135
|
+
} finally {
|
|
136
|
+
setLoading(false)
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
onClose: () => {
|
|
140
|
+
setRoleId(null)
|
|
141
|
+
setDetail(null)
|
|
142
|
+
setMetadataById({})
|
|
143
|
+
setMetadataOrder([])
|
|
144
|
+
setSelected({})
|
|
145
|
+
setTitleHintFromList(undefined)
|
|
146
|
+
},
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
const { isOpen, close } = modal
|
|
150
|
+
|
|
151
|
+
const handleSave = useCallback(async () => {
|
|
152
|
+
if (!roleId || !detail) return
|
|
153
|
+
setSaving(true)
|
|
154
|
+
try {
|
|
155
|
+
const libraries = buildLibrariesFromSelected(selected)
|
|
156
|
+
await updateModelMetadataRoleFullAPI({
|
|
157
|
+
id: String(roleId),
|
|
158
|
+
libraries,
|
|
159
|
+
})
|
|
160
|
+
showToast(t('common.operation_success'), 'success')
|
|
161
|
+
await onSaved?.()
|
|
162
|
+
close()
|
|
163
|
+
} catch {
|
|
164
|
+
// 失败由 axios 拦截器等统一提示
|
|
165
|
+
} finally {
|
|
166
|
+
setSaving(false)
|
|
167
|
+
}
|
|
168
|
+
}, [roleId, detail, selected, showToast, t, onSaved, close])
|
|
169
|
+
|
|
170
|
+
useImperativeHandle(
|
|
171
|
+
ref,
|
|
172
|
+
() => ({
|
|
173
|
+
open: (payload: RolePermissionModalOpenPayload) => {
|
|
174
|
+
modal.open({
|
|
175
|
+
opeType: 'edit',
|
|
176
|
+
opeId: payload.record.id,
|
|
177
|
+
data: { record: payload.record },
|
|
178
|
+
})
|
|
179
|
+
},
|
|
180
|
+
close,
|
|
181
|
+
}),
|
|
182
|
+
[modal.open, close],
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
const titleBase = t('menus.model_metadata.role.role_permission_title')
|
|
186
|
+
const titleName = detail?.name ?? titleHintFromList
|
|
187
|
+
const modalTitle = titleName ? `${titleBase} — ${titleName}` : titleBase
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<CxModal
|
|
191
|
+
isOpen={isOpen}
|
|
192
|
+
title={modalTitle}
|
|
193
|
+
onClose={close}
|
|
194
|
+
opeType="edit"
|
|
195
|
+
onSubmit={() => void handleSave()}
|
|
196
|
+
submitting={saving}
|
|
197
|
+
modalConfig={{
|
|
198
|
+
width: 1104,
|
|
199
|
+
styles: roleModalShellStyles,
|
|
200
|
+
rootClassName: 'cx-modal-role-assign',
|
|
201
|
+
}}
|
|
202
|
+
>
|
|
203
|
+
<div className="flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden">
|
|
204
|
+
{loading ? (
|
|
205
|
+
<RolePermissionAssignPanel
|
|
206
|
+
key={`${String(roleId)}-${assignBootstrapKey}`}
|
|
207
|
+
active={isOpen}
|
|
208
|
+
bootstrapKey={assignBootstrapKey}
|
|
209
|
+
maxHeightClass="h-full min-h-0 w-full flex-1 overflow-hidden"
|
|
210
|
+
metadataById={{}}
|
|
211
|
+
metadataOrder={[]}
|
|
212
|
+
listLoading
|
|
213
|
+
selected={{}}
|
|
214
|
+
onSelectedChange={() => {}}
|
|
215
|
+
/>
|
|
216
|
+
) : !detail ? (
|
|
217
|
+
<div className="py-10 text-center text-sm text-gray-500">{t('common.no_data')}</div>
|
|
218
|
+
) : (
|
|
219
|
+
<RolePermissionAssignPanel
|
|
220
|
+
key={`${String(roleId)}-${assignBootstrapKey}`}
|
|
221
|
+
active={isOpen}
|
|
222
|
+
bootstrapKey={assignBootstrapKey}
|
|
223
|
+
maxHeightClass="h-full min-h-0 w-full flex-1 overflow-hidden"
|
|
224
|
+
metadataById={metadataById}
|
|
225
|
+
metadataOrder={metadataOrder}
|
|
226
|
+
listLoading={false}
|
|
227
|
+
selected={selected}
|
|
228
|
+
onSelectedChange={setSelected}
|
|
229
|
+
/>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
</CxModal>
|
|
233
|
+
)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
RolePermissionModal.displayName = 'RolePermissionModal'
|
|
237
|
+
export default RolePermissionModal
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addModelMetadataRoleAPI,
|
|
3
|
+
getModelMetadataRoleDetailAPI,
|
|
4
|
+
updateModelMetadataRoleBasicAPI,
|
|
5
|
+
} from '@api/menus/model-metadata/role'
|
|
6
|
+
import { useModalSubmit } from '@/hooks/useModalSubmit'
|
|
7
|
+
import { forwardRef, useImperativeHandle, useMemo } from 'react'
|
|
8
|
+
import { useTranslation } from 'react-i18next'
|
|
9
|
+
|
|
10
|
+
import { CxForm, CxFormItem, CxInput, CxModal, useCxModal } from '@cx-ui'
|
|
11
|
+
|
|
12
|
+
type OpenPayload = {
|
|
13
|
+
opeType?: string
|
|
14
|
+
opeId?: string | number
|
|
15
|
+
data?: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Props = {
|
|
19
|
+
onCancel?: () => void
|
|
20
|
+
onOk?: (values: any) => void | Promise<void>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const MODAL_WIDTH = 520
|
|
24
|
+
|
|
25
|
+
const SubmitModal = forwardRef<
|
|
26
|
+
{ close: () => void; open: (payload?: OpenPayload) => void },
|
|
27
|
+
Props
|
|
28
|
+
>(function SubmitModal(props, ref) {
|
|
29
|
+
const { onCancel, onOk } = props
|
|
30
|
+
const { t } = useTranslation()
|
|
31
|
+
|
|
32
|
+
const modal = useCxModal({
|
|
33
|
+
onOpen: async (payload) => {
|
|
34
|
+
form.resetFields()
|
|
35
|
+
const type = payload?.opeType ?? 'add'
|
|
36
|
+
if (type === 'edit' && payload?.opeId != null && `${payload.opeId}`.trim() !== '') {
|
|
37
|
+
try {
|
|
38
|
+
const res = await getModelMetadataRoleDetailAPI(payload.opeId)
|
|
39
|
+
const data = (res as any)?.data
|
|
40
|
+
if (data) {
|
|
41
|
+
form.setFieldsValue({
|
|
42
|
+
name: data.name ?? '',
|
|
43
|
+
code: data.code ?? '',
|
|
44
|
+
description: data.description ?? '',
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.error(e)
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
form.setFieldsValue({
|
|
52
|
+
name: '',
|
|
53
|
+
code: '',
|
|
54
|
+
description: '',
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
onClose: () => {
|
|
59
|
+
onCancel?.()
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const { isOpen, close, form, opeType, opeId } = modal
|
|
64
|
+
const { submitting, handleSubmit } = useModalSubmit()
|
|
65
|
+
|
|
66
|
+
const title = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
opeType === 'edit'
|
|
69
|
+
? t('menus.model_metadata.role.edit')
|
|
70
|
+
: t('menus.model_metadata.role.add'),
|
|
71
|
+
[opeType, t],
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const handleModalSubmit = async () => {
|
|
75
|
+
const result = await handleSubmit({
|
|
76
|
+
opeType,
|
|
77
|
+
validate: () => form.validateFields(),
|
|
78
|
+
addAPI: addModelMetadataRoleAPI,
|
|
79
|
+
editAPI: (payload: any) =>
|
|
80
|
+
updateModelMetadataRoleBasicAPI({ ...payload, id: opeId }),
|
|
81
|
+
transform: (values: any) => ({
|
|
82
|
+
name: values.name,
|
|
83
|
+
code: values.code ?? '',
|
|
84
|
+
description: values.description ?? '',
|
|
85
|
+
}),
|
|
86
|
+
successMessage: {
|
|
87
|
+
add: t('common.add_success'),
|
|
88
|
+
edit: t('common.edit_success'),
|
|
89
|
+
},
|
|
90
|
+
onSuccess: async ({ payload }) => {
|
|
91
|
+
await onOk?.(payload)
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
if (result) close()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
useImperativeHandle(
|
|
98
|
+
ref,
|
|
99
|
+
() => ({
|
|
100
|
+
open: modal.open,
|
|
101
|
+
close,
|
|
102
|
+
}),
|
|
103
|
+
[modal.open, close],
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<CxModal
|
|
108
|
+
title={title}
|
|
109
|
+
isOpen={isOpen}
|
|
110
|
+
onClose={close}
|
|
111
|
+
opeType={opeType === 'edit' ? 'edit' : 'add'}
|
|
112
|
+
onSubmit={() => void handleModalSubmit()}
|
|
113
|
+
submitting={submitting}
|
|
114
|
+
modalConfig={{ width: MODAL_WIDTH }}
|
|
115
|
+
>
|
|
116
|
+
<CxForm form={form} layout="vertical" className="pt-1">
|
|
117
|
+
<CxFormItem
|
|
118
|
+
name="name"
|
|
119
|
+
label={t('menus.model_metadata.role.fields.name')}
|
|
120
|
+
rules={[{ required: true, message: t('common.required') }]}
|
|
121
|
+
>
|
|
122
|
+
<CxInput maxLength={128} />
|
|
123
|
+
</CxFormItem>
|
|
124
|
+
<CxFormItem name="code" label={t('menus.model_metadata.role.fields.code')}>
|
|
125
|
+
<CxInput maxLength={64} />
|
|
126
|
+
</CxFormItem>
|
|
127
|
+
<CxFormItem name="description" label={t('menus.model_metadata.role.fields.description')}>
|
|
128
|
+
<CxInput.Textarea rows={3} maxLength={500} />
|
|
129
|
+
</CxFormItem>
|
|
130
|
+
</CxForm>
|
|
131
|
+
</CxModal>
|
|
132
|
+
)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
export default SubmitModal
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { CxModalRef } from '@cx-ui/modal/useCxModal'
|
|
2
|
+
import { CxButton } from '@cx-ui'
|
|
3
|
+
import { useMemo, useRef } from 'react'
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
5
|
+
import UpdateDetailModal from '../../modal/update-detail-modal'
|
|
6
|
+
import SummaryList from './summary-list'
|
|
7
|
+
import { flattenOneCategory, parseTrainingRowContent, type TrainingDetailItem } from './types'
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
row: TrainingDetailItem
|
|
11
|
+
summaryPreviewLimit?: number
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function RecordNodeCard({ row, summaryPreviewLimit }: Props) {
|
|
15
|
+
const { t } = useTranslation()
|
|
16
|
+
const updateDetailModalRef = useRef<CxModalRef>(null)
|
|
17
|
+
const c = useMemo(() => parseTrainingRowContent(row), [row])
|
|
18
|
+
const meta = useMemo(
|
|
19
|
+
() => ({
|
|
20
|
+
schemaVersion: row.schemaVersion,
|
|
21
|
+
updateTime: row.updateTime,
|
|
22
|
+
updateBy: row.updateBy,
|
|
23
|
+
detailId: row.id,
|
|
24
|
+
}),
|
|
25
|
+
[row],
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const tableRows = useMemo(() => flattenOneCategory(c, 'tables', meta), [c, meta])
|
|
29
|
+
const documentRows = useMemo(() => flattenOneCategory(c, 'documents', meta), [c, meta])
|
|
30
|
+
const exampleSqlRows = useMemo(() => flattenOneCategory(c, 'exampleSql', meta), [c, meta])
|
|
31
|
+
|
|
32
|
+
const merged = useMemo(() => [...tableRows, ...documentRows, ...exampleSqlRows], [tableRows, documentRows, exampleSqlRows])
|
|
33
|
+
|
|
34
|
+
const hasLimit = summaryPreviewLimit != null && summaryPreviewLimit >= 0
|
|
35
|
+
const previewRows = useMemo(
|
|
36
|
+
() => (hasLimit ? merged.slice(0, summaryPreviewLimit!) : merged),
|
|
37
|
+
[hasLimit, merged, summaryPreviewLimit],
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const showMore = hasLimit ? merged.length > summaryPreviewLimit! : merged.length > 0
|
|
41
|
+
|
|
42
|
+
const empty = (
|
|
43
|
+
<div className="rounded border border-dashed border-gray-200 py-4 text-center text-xs text-gray-400 dark:border-gray-600">
|
|
44
|
+
{t('menus.model_metadata.training.detail_empty_section')}
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
const listKey = String(row.id ?? `${row.schemaVersion ?? ''}-${row.updateTime ?? ''}`)
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className="flex w-full min-w-0 max-w-full flex-col">
|
|
52
|
+
<div key={listKey} className="w-full min-w-0">
|
|
53
|
+
{merged.length ? (
|
|
54
|
+
<>
|
|
55
|
+
<SummaryList rows={previewRows} showScope />
|
|
56
|
+
{showMore ? (
|
|
57
|
+
<div className="mt-2 flex justify-start">
|
|
58
|
+
<CxButton type="link" className="h-auto p-0" onClick={() => updateDetailModalRef.current?.open({ data: { row } })}>
|
|
59
|
+
{t('menus.model_metadata.training.detail_view_full')}
|
|
60
|
+
</CxButton>
|
|
61
|
+
</div>
|
|
62
|
+
) : null}
|
|
63
|
+
</>
|
|
64
|
+
) : (
|
|
65
|
+
empty
|
|
66
|
+
)}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<UpdateDetailModal ref={updateDetailModalRef} />
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
package/src/views/page-menus/model-metadata/training/components/detail-records/summary-lines.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import type { TrainingChangeCategory, TrainingChangeOp } from './types'
|
|
2
|
+
|
|
3
|
+
/** 变更前值(摘要内强调块) */
|
|
4
|
+
export type SummaryChangeBeforeSeg = { role: 'changeBefore'; text: string }
|
|
5
|
+
/** 变更后值(摘要内强调块) */
|
|
6
|
+
export type SummaryChangeAfterSeg = { role: 'changeAfter'; text: string }
|
|
7
|
+
/** 单段 SQL 展示(用 code-view) */
|
|
8
|
+
export type SummarySqlSnippetSeg = { role: 'sqlSnippet'; text: string }
|
|
9
|
+
/** SQL 字段变更:上下对比(变更前 / 变更后) */
|
|
10
|
+
export type SummarySqlPairSeg = { role: 'changeSqlPair'; fieldLabel: string; before: string; after: string }
|
|
11
|
+
|
|
12
|
+
export type SummarySeg =
|
|
13
|
+
| string
|
|
14
|
+
| SummaryChangeBeforeSeg
|
|
15
|
+
| SummaryChangeAfterSeg
|
|
16
|
+
| SummarySqlSnippetSeg
|
|
17
|
+
| SummarySqlPairSeg
|
|
18
|
+
|
|
19
|
+
/** 一行摘要:多段横向或纵向拼接 */
|
|
20
|
+
export type SummaryLine = SummarySeg[]
|
|
21
|
+
|
|
22
|
+
function skipChangedKey(k: string) {
|
|
23
|
+
return /Sha256$/i.test(k) || /Len$/i.test(k)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function manageFieldLabel(t: (k: string) => string, fieldKey: string): string {
|
|
27
|
+
const alias: Record<string, string> = {
|
|
28
|
+
exampleSqlPreview: 'menus.model_metadata.manage.fields.exampleSql',
|
|
29
|
+
name: 'menus.model_metadata.manage.fields.docName',
|
|
30
|
+
code: 'menus.model_metadata.manage.fields.docCode',
|
|
31
|
+
}
|
|
32
|
+
const ik = alias[fieldKey] ?? `menus.model_metadata.manage.fields.${fieldKey}`
|
|
33
|
+
const v = t(ik)
|
|
34
|
+
return v === ik ? fieldKey : v
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function pushDiffLine(lines: SummaryLine[], fieldLabel: string, before: string, after: string) {
|
|
38
|
+
lines.push([
|
|
39
|
+
`${fieldLabel}:`,
|
|
40
|
+
{ role: 'changeBefore', text: before },
|
|
41
|
+
' 变更为 ',
|
|
42
|
+
{ role: 'changeAfter', text: after },
|
|
43
|
+
])
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function pushSqlPairLine(lines: SummaryLine[], fieldLabel: string, before: string, after: string) {
|
|
47
|
+
lines.push([{ role: 'changeSqlPair', fieldLabel, before, after }])
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function collectChangedLines(
|
|
51
|
+
changed: any,
|
|
52
|
+
t: (k: string) => string,
|
|
53
|
+
resolveLabelKey: (rawKey: string) => string = (k) => k,
|
|
54
|
+
sqlDiffKeys?: readonly string[],
|
|
55
|
+
): SummaryLine[] {
|
|
56
|
+
const out: SummaryLine[] = []
|
|
57
|
+
if (changed == null || typeof changed !== 'object') return out
|
|
58
|
+
for (const [k, v] of Object.entries(changed)) {
|
|
59
|
+
if (skipChangedKey(k) || k === 'columns') continue
|
|
60
|
+
if (v != null && typeof v === 'object') {
|
|
61
|
+
const o = v as any
|
|
62
|
+
if ('before' in o || 'after' in o || 'beforePreview' in o || 'afterPreview' in o) {
|
|
63
|
+
const b = o.before ?? o.beforePreview ?? '—'
|
|
64
|
+
const a = o.after ?? o.afterPreview ?? '—'
|
|
65
|
+
const label = manageFieldLabel(t, resolveLabelKey(k))
|
|
66
|
+
if (sqlDiffKeys && sqlDiffKeys.includes(k)) {
|
|
67
|
+
pushSqlPairLine(out, label, String(b), String(a))
|
|
68
|
+
} else {
|
|
69
|
+
pushDiffLine(out, label, String(b), String(a))
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return out
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function tablePath(it: any) {
|
|
78
|
+
return [it.tableSchema, it.tableName].filter(Boolean).join('.') || '—'
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function appendColumnGroupLines(
|
|
82
|
+
lines: SummaryLine[],
|
|
83
|
+
cols: any,
|
|
84
|
+
op: 'added' | 'modified' | 'removed',
|
|
85
|
+
t: (k: string) => string,
|
|
86
|
+
) {
|
|
87
|
+
const list = cols?.[op]
|
|
88
|
+
if (!Array.isArray(list)) return
|
|
89
|
+
const opLabel =
|
|
90
|
+
op === 'added'
|
|
91
|
+
? t('menus.model_metadata.training.change_col_group_added')
|
|
92
|
+
: op === 'modified'
|
|
93
|
+
? t('menus.model_metadata.training.change_col_group_modified')
|
|
94
|
+
: t('menus.model_metadata.training.change_col_group_removed')
|
|
95
|
+
for (const col of list) {
|
|
96
|
+
const name = col.columnName ?? col.name ?? '—'
|
|
97
|
+
if (op === 'added') {
|
|
98
|
+
const dt = col.dataType ?? col.dataTypeName ?? ''
|
|
99
|
+
const cmt = col.commentText ?? col.columnComment ?? ''
|
|
100
|
+
lines.push([
|
|
101
|
+
`${opLabel}:${name}${dt ? `(${dt})` : ''}${cmt ? ` ${t('menus.model_metadata.manage.fields.commentText')}:${cmt}` : ''}`,
|
|
102
|
+
])
|
|
103
|
+
} else if (op === 'removed') {
|
|
104
|
+
lines.push([`${opLabel}:${name}`])
|
|
105
|
+
} else {
|
|
106
|
+
const colDiffs = collectChangedLines(col.changed, t)
|
|
107
|
+
const row: SummarySeg[] = [`${opLabel}「${name}」`]
|
|
108
|
+
for (let i = 0; i < colDiffs.length; i++) {
|
|
109
|
+
if (i === 0) row.push(':')
|
|
110
|
+
else row.push(';')
|
|
111
|
+
for (const seg of colDiffs[i]) row.push(seg)
|
|
112
|
+
}
|
|
113
|
+
lines.push(row)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const EXAMPLE_SQL_DIFF_KEYS = ['exampleSql', 'exampleSqlPreview'] as const
|
|
119
|
+
|
|
120
|
+
/** 摘要按行返回,每行内可含变更前/后、SQL 片段或 SQL 上下对比 */
|
|
121
|
+
export function buildOperationDetailLines(
|
|
122
|
+
t: (k: string) => string,
|
|
123
|
+
category: TrainingChangeCategory,
|
|
124
|
+
op: TrainingChangeOp,
|
|
125
|
+
item: any,
|
|
126
|
+
): SummaryLine[] {
|
|
127
|
+
const lines: SummaryLine[] = []
|
|
128
|
+
if (category === 'tables') {
|
|
129
|
+
if (op === 'added') {
|
|
130
|
+
lines.push([`${t('menus.model_metadata.training.change_line_table')}:${tablePath(item)}`])
|
|
131
|
+
if (item.tableComment) lines.push([`${manageFieldLabel(t, 'tableComment')}:${item.tableComment}`])
|
|
132
|
+
if (item.tableType) lines.push([`${manageFieldLabel(t, 'tableType')}:${item.tableType}`])
|
|
133
|
+
if (item.columnCount != null) lines.push([`${manageFieldLabel(t, 'columnCount')}:${item.columnCount}`])
|
|
134
|
+
} else if (op === 'removed') {
|
|
135
|
+
lines.push([`${t('menus.model_metadata.training.change_line_table')}:${tablePath(item)}`])
|
|
136
|
+
if (item.tableComment) lines.push([`${manageFieldLabel(t, 'tableComment')}:${item.tableComment}`])
|
|
137
|
+
} else {
|
|
138
|
+
lines.push([`${t('menus.model_metadata.training.change_line_table')}:${tablePath(item)}`])
|
|
139
|
+
lines.push(...collectChangedLines(item.changed, t))
|
|
140
|
+
let cols = item.changed?.columns
|
|
141
|
+
if (
|
|
142
|
+
(!cols || typeof cols !== 'object') &&
|
|
143
|
+
(item.columnsModified != null || item.columnsAdded != null || item.columnsRemoved != null)
|
|
144
|
+
) {
|
|
145
|
+
const removed = Array.isArray(item.columnsRemoved) ? item.columnsRemoved : []
|
|
146
|
+
cols = {
|
|
147
|
+
added: Array.isArray(item.columnsAdded) ? item.columnsAdded : [],
|
|
148
|
+
modified: Array.isArray(item.columnsModified) ? item.columnsModified : [],
|
|
149
|
+
removed: removed.map((x: any) => (typeof x === 'string' ? { columnName: x } : x)),
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (cols && typeof cols === 'object') {
|
|
153
|
+
appendColumnGroupLines(lines, cols, 'added', t)
|
|
154
|
+
appendColumnGroupLines(lines, cols, 'modified', t)
|
|
155
|
+
appendColumnGroupLines(lines, cols, 'removed', t)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return lines
|
|
159
|
+
}
|
|
160
|
+
if (category === 'documents') {
|
|
161
|
+
if (op === 'added') {
|
|
162
|
+
if (item.name) lines.push([`${manageFieldLabel(t, 'docName')}:${item.name}`])
|
|
163
|
+
if (item.code) lines.push([`${manageFieldLabel(t, 'docCode')}:${item.code}`])
|
|
164
|
+
if (item.description) lines.push([`${manageFieldLabel(t, 'docDescription')}:${item.description}`])
|
|
165
|
+
} else if (op === 'removed') {
|
|
166
|
+
if (item.name) lines.push([`${manageFieldLabel(t, 'docName')}:${item.name}`])
|
|
167
|
+
if (item.code) lines.push([`${manageFieldLabel(t, 'docCode')}:${item.code}`])
|
|
168
|
+
} else {
|
|
169
|
+
lines.push(...collectChangedLines(item.changed, t, (k) => (k === 'description' ? 'docDescription' : k)))
|
|
170
|
+
}
|
|
171
|
+
return lines
|
|
172
|
+
}
|
|
173
|
+
if (op === 'added') {
|
|
174
|
+
const sql = item.exampleSqlPreview ?? item.exampleSql
|
|
175
|
+
if (sql) {
|
|
176
|
+
lines.push([`${manageFieldLabel(t, 'exampleSql')}:`, { role: 'sqlSnippet', text: String(sql) }])
|
|
177
|
+
}
|
|
178
|
+
if (item.description) lines.push([`${manageFieldLabel(t, 'exampleSqlDescription')}:${item.description}`])
|
|
179
|
+
} else if (op === 'removed') {
|
|
180
|
+
const sql = item.exampleSqlPreview ?? item.exampleSql
|
|
181
|
+
if (sql) {
|
|
182
|
+
lines.push([`${manageFieldLabel(t, 'exampleSql')}:`, { role: 'sqlSnippet', text: String(sql) }])
|
|
183
|
+
}
|
|
184
|
+
if (item.description) lines.push([`${manageFieldLabel(t, 'exampleSqlDescription')}:${item.description}`])
|
|
185
|
+
} else {
|
|
186
|
+
lines.push(
|
|
187
|
+
...collectChangedLines(
|
|
188
|
+
item.changed,
|
|
189
|
+
t,
|
|
190
|
+
(k) => (k === 'description' ? 'exampleSqlDescription' : k),
|
|
191
|
+
EXAMPLE_SQL_DIFF_KEYS,
|
|
192
|
+
),
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
return lines
|
|
196
|
+
}
|