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,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 动态菜单生成的路由元数据(由 {@link generateAdminRoutes} 写入)。
|
|
3
|
+
* 用于:从详情/提交页回到真实列表路径、按菜单 code 跳转(避免写死 path)。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type AdminMenuRouteEntry = {
|
|
7
|
+
/** 与 generateAdminRoutes 中 `basePath` 一致,无首尾 /,如 `page-menus/knowledge` */
|
|
8
|
+
basePath: string
|
|
9
|
+
/** 列表页 pathname,与路由注册一致,如 `/page-menus/knowledge/index` 或 `/knowledge` */
|
|
10
|
+
listPath: string
|
|
11
|
+
/** 后台菜单 code,可空 */
|
|
12
|
+
menuCode?: string
|
|
13
|
+
hasDetail: boolean
|
|
14
|
+
hasSubmit: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let entries: AdminMenuRouteEntry[] = []
|
|
18
|
+
|
|
19
|
+
const codeToListPath = new Map<string, string>()
|
|
20
|
+
|
|
21
|
+
function normalizePathname(p: string): string {
|
|
22
|
+
if (!p || p === '/') return '/'
|
|
23
|
+
return p.startsWith('/') ? p : `/${p}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function resetMenuRouteRegistry(): void {
|
|
27
|
+
entries = []
|
|
28
|
+
codeToListPath.clear()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 在生成主布局业务路由时调用,与 router 里对 `route.path` / `basePath` 的计算保持一致。
|
|
33
|
+
*/
|
|
34
|
+
export function registerAdminMenuRoute(entry: AdminMenuRouteEntry): void {
|
|
35
|
+
entries.push(entry)
|
|
36
|
+
if (entry.menuCode != null && String(entry.menuCode).trim() !== '') {
|
|
37
|
+
codeToListPath.set(String(entry.menuCode).trim(), entry.listPath)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 当前 pathname 是否落在某菜单的详情/提交子路由下;是则返回该菜单的列表页 pathname。
|
|
43
|
+
* 按 basePath 长度降序匹配,避免父子路径串台。
|
|
44
|
+
*/
|
|
45
|
+
export function getListPathFromSubRoutePathname(pathname: string): string | null {
|
|
46
|
+
const p = normalizePathname(pathname)
|
|
47
|
+
const sorted = [...entries].sort((a, b) => b.basePath.length - a.basePath.length)
|
|
48
|
+
|
|
49
|
+
for (const e of sorted) {
|
|
50
|
+
const bp = e.basePath.replace(/^\/+|\/+$/g, '')
|
|
51
|
+
if (!bp) continue
|
|
52
|
+
|
|
53
|
+
if (e.hasDetail) {
|
|
54
|
+
const detailPrefix = `/${bp}/detail`
|
|
55
|
+
if (p === detailPrefix || p.startsWith(`${detailPrefix}/`)) {
|
|
56
|
+
return e.listPath
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (e.hasSubmit) {
|
|
60
|
+
const submitPrefix = `/${bp}/submit`
|
|
61
|
+
if (p === submitPrefix || p.startsWith(`${submitPrefix}/`)) {
|
|
62
|
+
return e.listPath
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** 按菜单 code 取列表页 pathname(需在菜单里配置过 code 且已注册) */
|
|
70
|
+
export function getListPathByMenuCode(menuCode: string): string | undefined {
|
|
71
|
+
if (!menuCode || String(menuCode).trim() === '') return undefined
|
|
72
|
+
return codeToListPath.get(String(menuCode).trim())
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** 供调试或侧栏高亮 */
|
|
76
|
+
export function getRegisteredMenuRouteEntries(): readonly AdminMenuRouteEntry[] {
|
|
77
|
+
return entries
|
|
78
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 权限操作语义:列表「复制为×」用前四种;名称/后缀推断含 导出、启用、禁用。
|
|
3
|
+
*/
|
|
4
|
+
export type PermissionCrud =
|
|
5
|
+
| 'add'
|
|
6
|
+
| 'edit'
|
|
7
|
+
| 'delete'
|
|
8
|
+
| 'detail'
|
|
9
|
+
| 'export'
|
|
10
|
+
| 'enable'
|
|
11
|
+
| 'disable'
|
|
12
|
+
|
|
13
|
+
/** 兼容旧命名(列表复制菜单仍为 add/edit/delete/view) */
|
|
14
|
+
export type PermissionCrudCopyVariant = PermissionCrud
|
|
15
|
+
|
|
16
|
+
const TITLE_WORD: Record<PermissionCrud, string> = {
|
|
17
|
+
add: '新增',
|
|
18
|
+
edit: '修改',
|
|
19
|
+
delete: '删除',
|
|
20
|
+
detail: '详情',
|
|
21
|
+
export: '导出',
|
|
22
|
+
enable: '启用',
|
|
23
|
+
disable: '禁用',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const TITLE_KEYWORDS = [
|
|
27
|
+
'新增',
|
|
28
|
+
'修改',
|
|
29
|
+
'删除',
|
|
30
|
+
'详情',
|
|
31
|
+
'导出',
|
|
32
|
+
'启用',
|
|
33
|
+
'禁用',
|
|
34
|
+
] as const
|
|
35
|
+
|
|
36
|
+
const HTTP_METHOD: Record<PermissionCrud, string> = {
|
|
37
|
+
add: 'POST',
|
|
38
|
+
edit: 'PUT',
|
|
39
|
+
delete: 'DELETE',
|
|
40
|
+
detail: 'GET',
|
|
41
|
+
export: 'GET',
|
|
42
|
+
enable: 'PUT',
|
|
43
|
+
disable: 'PUT',
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const EN_VERB: Record<PermissionCrud, string> = {
|
|
47
|
+
add: 'add',
|
|
48
|
+
edit: 'edit',
|
|
49
|
+
delete: 'delete',
|
|
50
|
+
detail: 'detail',
|
|
51
|
+
export: 'export',
|
|
52
|
+
enable: 'enable',
|
|
53
|
+
disable: 'disable',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** 长词、易混词优先;edit 前须非小写字母,避免命中 credit 等 */
|
|
57
|
+
const VERBS: { kw: string; crud: PermissionCrud }[] = [
|
|
58
|
+
{ kw: 'edit', crud: 'edit' },
|
|
59
|
+
{ kw: 'disable', crud: 'disable' },
|
|
60
|
+
{ kw: 'delete', crud: 'delete' },
|
|
61
|
+
{ kw: 'export', crud: 'export' },
|
|
62
|
+
{ kw: 'enable', crud: 'enable' },
|
|
63
|
+
{ kw: 'detail', crud: 'detail' },
|
|
64
|
+
{ kw: 'edit', crud: 'edit' },
|
|
65
|
+
{ kw: 'add', crud: 'add' },
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
function hitVerb(lower: string): { i: number; len: number; crud: PermissionCrud } | null {
|
|
69
|
+
let best: { i: number; len: number; crud: PermissionCrud } | null = null
|
|
70
|
+
for (const { kw, crud } of VERBS) {
|
|
71
|
+
let from = 0
|
|
72
|
+
while (from <= lower.length - kw.length) {
|
|
73
|
+
const i = lower.indexOf(kw, from)
|
|
74
|
+
if (i < 0) break
|
|
75
|
+
const ok = i === 0 || /[^a-z]/.test(lower[i - 1])
|
|
76
|
+
if (ok && (!best || i < best.i)) {
|
|
77
|
+
best = { i, len: kw.length, crud }
|
|
78
|
+
}
|
|
79
|
+
from = i + 1
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return best
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function patchTitle(title: string, op: PermissionCrud): string {
|
|
86
|
+
const w = TITLE_WORD[op]
|
|
87
|
+
const s = String(title ?? '')
|
|
88
|
+
let bi = -1
|
|
89
|
+
let bl = 0
|
|
90
|
+
for (const kw of TITLE_KEYWORDS) {
|
|
91
|
+
const i = s.indexOf(kw)
|
|
92
|
+
if (i >= 0 && (bi < 0 || i < bi)) {
|
|
93
|
+
bi = i
|
|
94
|
+
bl = kw.length
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (bi >= 0) return s.slice(0, bi) + w + s.slice(bi + bl)
|
|
98
|
+
return w + s
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function patchSuffix(suffix: string, op: PermissionCrud): string {
|
|
102
|
+
const s = String(suffix ?? '')
|
|
103
|
+
const lower = s.toLowerCase()
|
|
104
|
+
const h = hitVerb(lower)
|
|
105
|
+
// 无法识别动词时,直接使用目标操作的后缀
|
|
106
|
+
if (!h) return EN_VERB[op]
|
|
107
|
+
const en = EN_VERB[op]
|
|
108
|
+
return s.slice(0, h.i) + en + s.slice(h.i + h.len)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** 旧数据 + 目标操作 → 名称、请求方法、编码后缀(与列表「复制为×」同一套规则) */
|
|
112
|
+
export type PermissionCrudSlice = {
|
|
113
|
+
title: string
|
|
114
|
+
httpMethod: string
|
|
115
|
+
/** 权限编码里菜单冒号后的整段后缀 */
|
|
116
|
+
codeSuffix: string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function toPermissionCrudSlice(
|
|
120
|
+
prev: PermissionCrudSlice,
|
|
121
|
+
op: PermissionCrud,
|
|
122
|
+
): PermissionCrudSlice {
|
|
123
|
+
return {
|
|
124
|
+
title: patchTitle(prev.title, op),
|
|
125
|
+
httpMethod: HTTP_METHOD[op],
|
|
126
|
+
codeSuffix: patchSuffix(prev.codeSuffix, op),
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** 从后缀推断操作;无识别动词则 null */
|
|
131
|
+
export function inferCrudFromSuffix(suffix: string | null | undefined): PermissionCrud | null {
|
|
132
|
+
const h = hitVerb(String(suffix ?? '').toLowerCase())
|
|
133
|
+
return h ? h.crud : null
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** 表单:自定义优先于字典选中项,得到有效后缀 */
|
|
137
|
+
export function getEffectiveCodeSuffix(
|
|
138
|
+
codeCustom: unknown,
|
|
139
|
+
codePreset: unknown,
|
|
140
|
+
): string {
|
|
141
|
+
const c = String(codeCustom ?? '').trim()
|
|
142
|
+
const p =
|
|
143
|
+
codePreset != null && String(codePreset).trim() !== ''
|
|
144
|
+
? String(codePreset).trim()
|
|
145
|
+
: ''
|
|
146
|
+
return c !== '' ? c : p
|
|
147
|
+
}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import * as Icons from 'lucide-react';
|
|
2
|
+
import type { MenuTreeItem } from '../types/menu';
|
|
3
|
+
|
|
4
|
+
// 图标映射表 - 将字符串映射到实际的图标组件
|
|
5
|
+
export const iconMap: Record<string, any> = {
|
|
6
|
+
MessageSquare: Icons.MessageSquare,
|
|
7
|
+
MessageSquareQuote: Icons.MessageSquareQuote,
|
|
8
|
+
Settings: Icons.Settings,
|
|
9
|
+
Cog: Icons.Cog,
|
|
10
|
+
Wrench: Icons.Wrench,
|
|
11
|
+
SlidersHorizontal: Icons.SlidersHorizontal,
|
|
12
|
+
LogOut: Icons.LogOut,
|
|
13
|
+
LogIn: Icons.LogIn,
|
|
14
|
+
Menu: Icons.Menu,
|
|
15
|
+
Plus: Icons.Plus,
|
|
16
|
+
Minus: Icons.Minus,
|
|
17
|
+
CirclePlus: Icons.CirclePlus,
|
|
18
|
+
SquarePlus: Icons.SquarePlus,
|
|
19
|
+
Trash2: Icons.Trash2,
|
|
20
|
+
Check: Icons.Check,
|
|
21
|
+
CheckCircle2: Icons.CheckCircle2,
|
|
22
|
+
X: Icons.X,
|
|
23
|
+
CircleX: Icons.CircleX,
|
|
24
|
+
Search: Icons.Search,
|
|
25
|
+
Filter: Icons.Filter,
|
|
26
|
+
Funnel: Icons.Funnel,
|
|
27
|
+
ChevronDown: Icons.ChevronDown,
|
|
28
|
+
ChevronRight: Icons.ChevronRight,
|
|
29
|
+
ChevronLeft: Icons.ChevronLeft,
|
|
30
|
+
ChevronUp: Icons.ChevronUp,
|
|
31
|
+
Loader2: Icons.Loader2,
|
|
32
|
+
Shield: Icons.Shield,
|
|
33
|
+
ShieldUser: Icons.ShieldUser,
|
|
34
|
+
ShieldCheck: Icons.ShieldCheck,
|
|
35
|
+
Users: Icons.Users,
|
|
36
|
+
User: Icons.User,
|
|
37
|
+
UserCog: Icons.UserCog,
|
|
38
|
+
UserRound: Icons.UserRound,
|
|
39
|
+
Lock: Icons.Lock,
|
|
40
|
+
Unlock: Icons.Unlock,
|
|
41
|
+
KeyRound: Icons.KeyRound,
|
|
42
|
+
MoreVertical: Icons.MoreVertical,
|
|
43
|
+
MoreHorizontal: Icons.MoreHorizontal,
|
|
44
|
+
Pin: Icons.Pin,
|
|
45
|
+
PinOff: Icons.PinOff,
|
|
46
|
+
Edit2: Icons.Edit2,
|
|
47
|
+
Pencil: Icons.Pencil,
|
|
48
|
+
PenSquare: Icons.PenSquare,
|
|
49
|
+
LibraryBig: Icons.LibraryBig,
|
|
50
|
+
BookOpen: Icons.BookOpen,
|
|
51
|
+
FileText: Icons.FileText,
|
|
52
|
+
File: Icons.File,
|
|
53
|
+
Files: Icons.Files,
|
|
54
|
+
FileCode2: Icons.FileCode2,
|
|
55
|
+
FileStack: Icons.FileStack,
|
|
56
|
+
HousePlus: Icons.HousePlus,
|
|
57
|
+
Home: Icons.Home,
|
|
58
|
+
House: Icons.House,
|
|
59
|
+
Building2: Icons.Building2,
|
|
60
|
+
Landmark: Icons.Landmark,
|
|
61
|
+
Briefcase: Icons.Briefcase,
|
|
62
|
+
Folder: Icons.Folder,
|
|
63
|
+
FolderOpen: Icons.FolderOpen,
|
|
64
|
+
Database: Icons.Database,
|
|
65
|
+
Server: Icons.Server,
|
|
66
|
+
Cloud: Icons.Cloud,
|
|
67
|
+
Globe: Icons.Globe,
|
|
68
|
+
Network: Icons.Network,
|
|
69
|
+
Terminal: Icons.Terminal,
|
|
70
|
+
Code2: Icons.Code2,
|
|
71
|
+
Bug: Icons.Bug,
|
|
72
|
+
Bell: Icons.Bell,
|
|
73
|
+
Mail: Icons.Mail,
|
|
74
|
+
Phone: Icons.Phone,
|
|
75
|
+
Calendar: Icons.Calendar,
|
|
76
|
+
Clock3: Icons.Clock3,
|
|
77
|
+
History: Icons.History,
|
|
78
|
+
RefreshCw: Icons.RefreshCw,
|
|
79
|
+
RotateCcw: Icons.RotateCcw,
|
|
80
|
+
Download: Icons.Download,
|
|
81
|
+
Upload: Icons.Upload,
|
|
82
|
+
Eye: Icons.Eye,
|
|
83
|
+
EyeOff: Icons.EyeOff,
|
|
84
|
+
Copy: Icons.Copy,
|
|
85
|
+
Clipboard: Icons.Clipboard,
|
|
86
|
+
BadgeCheck: Icons.BadgeCheck,
|
|
87
|
+
Award: Icons.Award,
|
|
88
|
+
Star: Icons.Star,
|
|
89
|
+
Heart: Icons.Heart,
|
|
90
|
+
Flag: Icons.Flag,
|
|
91
|
+
Tags: Icons.Tags,
|
|
92
|
+
Tag: Icons.Tag,
|
|
93
|
+
Map: Icons.Map,
|
|
94
|
+
MapPin: Icons.MapPin,
|
|
95
|
+
Wallet: Icons.Wallet,
|
|
96
|
+
CreditCard: Icons.CreditCard,
|
|
97
|
+
Receipt: Icons.Receipt,
|
|
98
|
+
ShoppingCart: Icons.ShoppingCart,
|
|
99
|
+
Package: Icons.Package,
|
|
100
|
+
Truck: Icons.Truck,
|
|
101
|
+
PieChart: Icons.PieChart,
|
|
102
|
+
BarChart3: Icons.BarChart3,
|
|
103
|
+
LineChart: Icons.LineChart,
|
|
104
|
+
|
|
105
|
+
// 菜单 / 导航
|
|
106
|
+
MenuSquare: Icons.MenuSquare,
|
|
107
|
+
ListTree: Icons.ListTree,
|
|
108
|
+
PanelLeft: Icons.PanelLeft,
|
|
109
|
+
PanelRight: Icons.PanelRight,
|
|
110
|
+
|
|
111
|
+
// 业务规则 / 工作流
|
|
112
|
+
GitCompare: Icons.GitCompare,
|
|
113
|
+
Route: Icons.Route,
|
|
114
|
+
WorkflowIcon: Icons.Workflow,
|
|
115
|
+
GitMerge: Icons.GitMerge,
|
|
116
|
+
SplitSquareHorizontal: Icons.SplitSquareHorizontal,
|
|
117
|
+
|
|
118
|
+
// 反馈 / 审查
|
|
119
|
+
MessageCircleWarning: Icons.MessageCircleWarning,
|
|
120
|
+
AlertTriangle: Icons.AlertTriangle,
|
|
121
|
+
AlertCircle: Icons.AlertCircle,
|
|
122
|
+
ClipboardCheck: Icons.ClipboardCheck,
|
|
123
|
+
|
|
124
|
+
// 系统日志 / 监控
|
|
125
|
+
ScrollText: Icons.ScrollText,
|
|
126
|
+
FileSearch: Icons.FileSearch,
|
|
127
|
+
ActivitySquare: Icons.ActivitySquare,
|
|
128
|
+
ChartSpline: Icons.ChartSpline,
|
|
129
|
+
|
|
130
|
+
// 用户管理
|
|
131
|
+
UserPlus: Icons.UserPlus,
|
|
132
|
+
UserMinus: Icons.UserMinus,
|
|
133
|
+
UsersRound: Icons.UsersRound,
|
|
134
|
+
ContactRound: Icons.ContactRound,
|
|
135
|
+
IdCard: Icons.IdCard,
|
|
136
|
+
|
|
137
|
+
// 部门管理
|
|
138
|
+
Building: Icons.Building,
|
|
139
|
+
Trees: Icons.Trees,
|
|
140
|
+
NetworkIcon: Icons.Network,
|
|
141
|
+
GitFork: Icons.GitFork,
|
|
142
|
+
|
|
143
|
+
// 角色管理
|
|
144
|
+
Badge: Icons.Badge,
|
|
145
|
+
ShieldAlert: Icons.ShieldAlert,
|
|
146
|
+
ShieldQuestion: Icons.ShieldQuestion,
|
|
147
|
+
UserCog2: Icons.UserCog2,
|
|
148
|
+
|
|
149
|
+
// 权限管理
|
|
150
|
+
Key: Icons.Key,
|
|
151
|
+
LockKeyhole: Icons.LockKeyhole,
|
|
152
|
+
Fingerprint: Icons.Fingerprint,
|
|
153
|
+
ShieldHalf: Icons.ShieldHalf,
|
|
154
|
+
|
|
155
|
+
// 知识库管理
|
|
156
|
+
BookMarked: Icons.BookMarked,
|
|
157
|
+
BookDashed: Icons.BookDashed,
|
|
158
|
+
Library: Icons.Library,
|
|
159
|
+
Bookmark: Icons.Bookmark,
|
|
160
|
+
BookOpenCheck: Icons.BookOpenCheck,
|
|
161
|
+
GraduationCap: Icons.GraduationCap,
|
|
162
|
+
|
|
163
|
+
// 技能管理
|
|
164
|
+
Sparkles: Icons.Sparkles,
|
|
165
|
+
Wand2: Icons.Wand2,
|
|
166
|
+
Lightbulb: Icons.Lightbulb,
|
|
167
|
+
ZapOff: Icons.ZapOff,
|
|
168
|
+
Stars: Icons.Stars,
|
|
169
|
+
WrenchIcon: Icons.Wrench,
|
|
170
|
+
|
|
171
|
+
// 智能体配置
|
|
172
|
+
Bot: Icons.Bot,
|
|
173
|
+
BotMessageSquare: Icons.BotMessageSquare,
|
|
174
|
+
BrainCircuit: Icons.BrainCircuit,
|
|
175
|
+
BrainCog: Icons.BrainCog,
|
|
176
|
+
CpuIcon: Icons.Cpu,
|
|
177
|
+
Settings2: Icons.Settings2,
|
|
178
|
+
|
|
179
|
+
// 系统设置
|
|
180
|
+
Sliders: Icons.Sliders,
|
|
181
|
+
ToggleLeft: Icons.ToggleLeft,
|
|
182
|
+
ToggleRight: Icons.ToggleRight,
|
|
183
|
+
SwitchCamera: Icons.SwitchCamera,
|
|
184
|
+
Component: Icons.Component,
|
|
185
|
+
|
|
186
|
+
// 数据字典
|
|
187
|
+
BookType: Icons.BookType,
|
|
188
|
+
Type: Icons.Type,
|
|
189
|
+
Hash: Icons.Hash,
|
|
190
|
+
TableProperties: Icons.TableProperties,
|
|
191
|
+
|
|
192
|
+
// 模型元数据
|
|
193
|
+
DatabaseZap: Icons.DatabaseZap,
|
|
194
|
+
TableIcon: Icons.Table2,
|
|
195
|
+
Columns4: Icons.Columns4,
|
|
196
|
+
SquareCode: Icons.SquareCode,
|
|
197
|
+
Brackets: Icons.Brackets,
|
|
198
|
+
Variable: Icons.Variable,
|
|
199
|
+
|
|
200
|
+
// Web / 后台系统常用
|
|
201
|
+
Activity: Icons.Activity,
|
|
202
|
+
Antenna: Icons.Antenna,
|
|
203
|
+
Binary: Icons.Binary,
|
|
204
|
+
Box: Icons.Box,
|
|
205
|
+
Boxes: Icons.Boxes,
|
|
206
|
+
Braces: Icons.Braces,
|
|
207
|
+
ClipboardList: Icons.ClipboardList,
|
|
208
|
+
ExternalLink: Icons.ExternalLink,
|
|
209
|
+
GitBranch: Icons.GitBranch,
|
|
210
|
+
Kanban: Icons.Kanban,
|
|
211
|
+
Laptop: Icons.Laptop,
|
|
212
|
+
LayoutDashboard: Icons.LayoutDashboard,
|
|
213
|
+
LayoutGrid: Icons.LayoutGrid,
|
|
214
|
+
Layers: Icons.Layers,
|
|
215
|
+
Layers2: Icons.Layers2,
|
|
216
|
+
Link2: Icons.Link2,
|
|
217
|
+
Merge: Icons.Merge,
|
|
218
|
+
Monitor: Icons.Monitor,
|
|
219
|
+
MonitorCog: Icons.MonitorCog,
|
|
220
|
+
QrCode: Icons.QrCode,
|
|
221
|
+
Router: Icons.Router,
|
|
222
|
+
Rss: Icons.Rss,
|
|
223
|
+
ScanLine: Icons.ScanLine,
|
|
224
|
+
Share2: Icons.Share2,
|
|
225
|
+
Smartphone: Icons.Smartphone,
|
|
226
|
+
Split: Icons.Split,
|
|
227
|
+
Table2: Icons.Table2,
|
|
228
|
+
Tablet: Icons.Tablet,
|
|
229
|
+
Webhook: Icons.Webhook,
|
|
230
|
+
Wifi: Icons.Wifi,
|
|
231
|
+
WifiCog: Icons.WifiCog,
|
|
232
|
+
Workflow: Icons.Workflow,
|
|
233
|
+
|
|
234
|
+
// 工业 / 设备 / 能源
|
|
235
|
+
Anvil: Icons.Anvil,
|
|
236
|
+
Bolt: Icons.Bolt,
|
|
237
|
+
Cable: Icons.Cable,
|
|
238
|
+
CircleGauge: Icons.CircleGauge,
|
|
239
|
+
Cpu: Icons.Cpu,
|
|
240
|
+
Cylinder: Icons.Cylinder,
|
|
241
|
+
DatabaseBackup: Icons.DatabaseBackup,
|
|
242
|
+
Drill: Icons.Drill,
|
|
243
|
+
Droplets: Icons.Droplets,
|
|
244
|
+
Factory: Icons.Factory,
|
|
245
|
+
Fan: Icons.Fan,
|
|
246
|
+
Flame: Icons.Flame,
|
|
247
|
+
Gauge: Icons.Gauge,
|
|
248
|
+
HardDrive: Icons.HardDrive,
|
|
249
|
+
HardDriveDownload: Icons.HardDriveDownload,
|
|
250
|
+
HardDriveUpload: Icons.HardDriveUpload,
|
|
251
|
+
Heater: Icons.Heater,
|
|
252
|
+
Microscope: Icons.Microscope,
|
|
253
|
+
Nut: Icons.Nut,
|
|
254
|
+
Orbit: Icons.Orbit,
|
|
255
|
+
Plug: Icons.Plug,
|
|
256
|
+
Plug2: Icons.Plug2,
|
|
257
|
+
PlugZap: Icons.PlugZap,
|
|
258
|
+
Radar: Icons.Radar,
|
|
259
|
+
Radio: Icons.Radio,
|
|
260
|
+
RadioTower: Icons.RadioTower,
|
|
261
|
+
Satellite: Icons.Satellite,
|
|
262
|
+
SatelliteDish: Icons.SatelliteDish,
|
|
263
|
+
ServerCog: Icons.ServerCog,
|
|
264
|
+
TowerControl: Icons.TowerControl,
|
|
265
|
+
Warehouse: Icons.Warehouse,
|
|
266
|
+
Wind: Icons.Wind,
|
|
267
|
+
Zap: Icons.Zap,
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 根据图标名称获取图标组件
|
|
272
|
+
*/
|
|
273
|
+
export const getIconComponent = (iconName?: string) => {
|
|
274
|
+
if (!iconName) return null;
|
|
275
|
+
return iconMap[iconName] || null;
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 过滤菜单树(仅做展示层结构调整):
|
|
280
|
+
* - 后端已经按权限筛过,这里不再做权限判断
|
|
281
|
+
* - 跳过 hidden
|
|
282
|
+
* - 如果 only-child 且 alwaysShow=false,则提升子菜单到当前层级(不显示父级)
|
|
283
|
+
* - 多子菜单且 alwaysShow=false,只展示子菜单(不显示父级)
|
|
284
|
+
* - 其他情况保持父子结构
|
|
285
|
+
*/
|
|
286
|
+
export const filterMenuTree = (
|
|
287
|
+
menus: MenuTreeItem[],
|
|
288
|
+
_hasPermission: (permission: string) => boolean,
|
|
289
|
+
): MenuTreeItem[] => {
|
|
290
|
+
const walk = (nodes: MenuTreeItem[] | undefined): MenuTreeItem[] => {
|
|
291
|
+
if (!nodes?.length) return []
|
|
292
|
+
|
|
293
|
+
const result: MenuTreeItem[] = []
|
|
294
|
+
|
|
295
|
+
for (const menu of nodes) {
|
|
296
|
+
if (menu.hidden) continue
|
|
297
|
+
|
|
298
|
+
const children = walk(menu.children)
|
|
299
|
+
|
|
300
|
+
if (!children.length) {
|
|
301
|
+
// 叶子节点:直接保留
|
|
302
|
+
result.push({ ...menu, children: [] })
|
|
303
|
+
continue
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (menu.alwaysShow) {
|
|
307
|
+
// 显示父级 + 子级
|
|
308
|
+
result.push({ ...menu, children })
|
|
309
|
+
} else {
|
|
310
|
+
const shouldFullDisplay =
|
|
311
|
+
Boolean((menu as any).alwaysShow) || Number((menu as any).fullDisplay) === 1
|
|
312
|
+
if (children.length === 1) {
|
|
313
|
+
// 只有一个子菜单时,只展示子菜单
|
|
314
|
+
if (shouldFullDisplay) {
|
|
315
|
+
result.push({ ...menu, children })
|
|
316
|
+
} else {
|
|
317
|
+
result.push(children[0])
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
// 多个子菜单,只展示子菜单列表
|
|
321
|
+
if (shouldFullDisplay) {
|
|
322
|
+
result.push({ ...menu, children })
|
|
323
|
+
} else {
|
|
324
|
+
result.push(...children)
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return result
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return walk(menus)
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 展平菜单树为列表(用于生成路由)
|
|
338
|
+
*/
|
|
339
|
+
export const flattenMenuTree = (menus: MenuTreeItem[]): MenuTreeItem[] => {
|
|
340
|
+
const result: MenuTreeItem[] = [];
|
|
341
|
+
|
|
342
|
+
for (const menu of menus) {
|
|
343
|
+
result.push(menu);
|
|
344
|
+
if (menu.children && menu.children.length > 0) {
|
|
345
|
+
result.push(...flattenMenuTree(menu.children));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return result;
|
|
350
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import Cookies from 'js-cookie'
|
|
2
|
+
import aesUtil from '@utils/aesUtil'
|
|
3
|
+
|
|
4
|
+
export const STORAGE_PREFIX = 'apps-agent-'
|
|
5
|
+
|
|
6
|
+
function getReturnData(value: string | null): string {
|
|
7
|
+
if (!value) {
|
|
8
|
+
return ''
|
|
9
|
+
}
|
|
10
|
+
const result = aesUtil.decrypt(value)
|
|
11
|
+
if (typeof result === 'object' && result !== null) {
|
|
12
|
+
return JSON.stringify(result)
|
|
13
|
+
}
|
|
14
|
+
return typeof result === 'string' ? result : String(result)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 存储 localStorage(值会经 aesUtil 加密)
|
|
19
|
+
*/
|
|
20
|
+
export const setStore = (name: string, content: unknown): void => {
|
|
21
|
+
if (!name) return
|
|
22
|
+
const str =
|
|
23
|
+
typeof content === 'string' ? content : JSON.stringify(content)
|
|
24
|
+
window.localStorage.setItem(STORAGE_PREFIX + name, aesUtil.encrypt(str))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 获取 localStorage
|
|
29
|
+
*/
|
|
30
|
+
export const getStore = (name: string): string | undefined => {
|
|
31
|
+
if (!name) return undefined
|
|
32
|
+
const v = window.localStorage.getItem(STORAGE_PREFIX + name)
|
|
33
|
+
return getReturnData(v)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** 会话流式请求:是否开启联网搜索(与 ChatInput 一致) */
|
|
37
|
+
export const CHAT_ENABLE_NETWORK_STORE = 'chat-enable-network'
|
|
38
|
+
|
|
39
|
+
export function getChatEnableNetwork(): boolean {
|
|
40
|
+
const raw = getStore(CHAT_ENABLE_NETWORK_STORE)
|
|
41
|
+
if (raw === undefined || raw === '') return false
|
|
42
|
+
try {
|
|
43
|
+
return JSON.parse(raw) === true
|
|
44
|
+
} catch {
|
|
45
|
+
return raw === 'true'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function setChatEnableNetwork(enabled: boolean): void {
|
|
50
|
+
setStore(CHAT_ENABLE_NETWORK_STORE, enabled)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** 会话流式请求:是否启用知识库检索 */
|
|
54
|
+
export const CHAT_ENABLE_KNOWLEDGE_BASE_STORE = 'chat-enable-knowledge-base'
|
|
55
|
+
|
|
56
|
+
export function getChatEnableKnowledgeBase(): boolean {
|
|
57
|
+
const raw = getStore(CHAT_ENABLE_KNOWLEDGE_BASE_STORE)
|
|
58
|
+
if (raw === undefined || raw === '') return false
|
|
59
|
+
try {
|
|
60
|
+
return JSON.parse(raw) === true
|
|
61
|
+
} catch {
|
|
62
|
+
return raw === 'true'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function setChatEnableKnowledgeBase(enabled: boolean): void {
|
|
67
|
+
setStore(CHAT_ENABLE_KNOWLEDGE_BASE_STORE, enabled)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** 会话流式请求:是否启用数据分析 */
|
|
71
|
+
export const CHAT_ENABLE_DATA_ANALYSIS_STORE = 'chat-enable-data-analysis'
|
|
72
|
+
|
|
73
|
+
export function getChatEnableDataAnalysis(): boolean {
|
|
74
|
+
const raw = getStore(CHAT_ENABLE_DATA_ANALYSIS_STORE)
|
|
75
|
+
if (raw === undefined || raw === '') return false
|
|
76
|
+
try {
|
|
77
|
+
return JSON.parse(raw) === true
|
|
78
|
+
} catch {
|
|
79
|
+
return raw === 'true'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function setChatEnableDataAnalysis(enabled: boolean): void {
|
|
84
|
+
setStore(CHAT_ENABLE_DATA_ANALYSIS_STORE, enabled)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 删除 localStorage
|
|
89
|
+
*/
|
|
90
|
+
export const removeStore = (name: string): void => {
|
|
91
|
+
if (!name) return
|
|
92
|
+
window.localStorage.removeItem(STORAGE_PREFIX + name)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 删除本应用前缀下的 localStorage
|
|
97
|
+
*/
|
|
98
|
+
export const clearStore = (): void => {
|
|
99
|
+
Object.keys(window.localStorage).forEach((key) => {
|
|
100
|
+
if (key.startsWith(STORAGE_PREFIX)) {
|
|
101
|
+
window.localStorage.removeItem(key)
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export const setSessionStore = (name: string, content: unknown): void => {
|
|
107
|
+
if (!name) return
|
|
108
|
+
const str =
|
|
109
|
+
typeof content === 'string' ? content : JSON.stringify(content)
|
|
110
|
+
window.sessionStorage.setItem(STORAGE_PREFIX + name, aesUtil.encrypt(str))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const getSessionStore = (name: string): string | undefined => {
|
|
114
|
+
if (!name) return undefined
|
|
115
|
+
const v = window.sessionStorage.getItem(STORAGE_PREFIX + name)
|
|
116
|
+
return getReturnData(v)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const removeSessionStore = (name: string): void => {
|
|
120
|
+
if (!name) return
|
|
121
|
+
window.sessionStorage.removeItem(STORAGE_PREFIX + name)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function getCookie(key: string): string {
|
|
125
|
+
const v = Cookies.get(STORAGE_PREFIX + key)
|
|
126
|
+
return getReturnData(v ?? null)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function setCookie(key: string, value: string): string | undefined {
|
|
130
|
+
return Cookies.set(STORAGE_PREFIX + key, aesUtil.encrypt(value))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function removeCookie(key: string): void {
|
|
134
|
+
Cookies.remove(STORAGE_PREFIX + key)
|
|
135
|
+
}
|