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,323 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话 / 聊天相关样式(`chat-*` 前缀,避免污染全局)
|
|
3
|
+
* 由 `views/chat/index.tsx`、`index-session.tsx` 引入;后续会话 UI 可继续往本文件加块。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* ----- preparation:流式「正在分析」步骤条 ----- */
|
|
7
|
+
|
|
8
|
+
.chat-prep-panel {
|
|
9
|
+
margin-bottom: 6px;
|
|
10
|
+
border-radius: 8px;
|
|
11
|
+
border: 1px solid rgba(229, 231, 235, 0.9);
|
|
12
|
+
background: rgba(249, 250, 251, 0.8);
|
|
13
|
+
padding: 6px 10px;
|
|
14
|
+
text-align: left;
|
|
15
|
+
width: 600px;
|
|
16
|
+
|
|
17
|
+
html.dark & {
|
|
18
|
+
border-color: rgba(55, 65, 81, 0.9);
|
|
19
|
+
background: rgba(17, 24, 39, 0.5);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.chat-prep-heading {
|
|
24
|
+
margin: 8px 0;
|
|
25
|
+
font-size: 12px;
|
|
26
|
+
font-weight: 500;
|
|
27
|
+
line-height: 1.25;
|
|
28
|
+
color: #6b7280;
|
|
29
|
+
|
|
30
|
+
html.dark & {
|
|
31
|
+
color: #9ca3af;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* 单步副标题 description:限高 + 纵向可滚(脚本粘底);滚动条隐藏,避免占位与「可操作条」观感 */
|
|
36
|
+
.chat-prep-step-desc-scroll {
|
|
37
|
+
max-height: 60px;
|
|
38
|
+
min-height: 0;
|
|
39
|
+
overflow-x: hidden;
|
|
40
|
+
overflow-y: auto;
|
|
41
|
+
margin-right: 0;
|
|
42
|
+
padding-right: 0;
|
|
43
|
+
scrollbar-width: none;
|
|
44
|
+
-ms-overflow-style: none;
|
|
45
|
+
|
|
46
|
+
&::-webkit-scrollbar {
|
|
47
|
+
display: none;
|
|
48
|
+
width: 0;
|
|
49
|
+
height: 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* short_memory / long_memory / knowledge_retrieval:可视约 4 行,裁切顶部;无滚动条、不可滚,内容贴底显示末尾 */
|
|
54
|
+
.chat-prep-step-desc-scroll--memory-tail {
|
|
55
|
+
/* 略加高度,抵消内边距,减轻首行/首段顶边被裁切 */
|
|
56
|
+
max-height: calc(12px * 1.5 * 3 + 10px);
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
margin-right: 0;
|
|
59
|
+
padding-right: 0;
|
|
60
|
+
scrollbar-width: none;
|
|
61
|
+
-ms-overflow-style: none;
|
|
62
|
+
overscroll-behavior: none;
|
|
63
|
+
touch-action: none;
|
|
64
|
+
|
|
65
|
+
&::-webkit-scrollbar {
|
|
66
|
+
display: none;
|
|
67
|
+
width: 0;
|
|
68
|
+
height: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
display: flex;
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
justify-content: flex-end;
|
|
74
|
+
min-height: 0;
|
|
75
|
+
|
|
76
|
+
.chat-prep-step-md {
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
min-height: 0;
|
|
79
|
+
padding-top: 6px;
|
|
80
|
+
padding-bottom: 4px;
|
|
81
|
+
box-sizing: border-box;
|
|
82
|
+
|
|
83
|
+
> p:first-child,
|
|
84
|
+
> :first-child {
|
|
85
|
+
margin-top: 0 !important;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.chat-prep-steps-wrap {
|
|
91
|
+
width: 100%;
|
|
92
|
+
min-width: 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* 勿在 .ant-steps-item-icon 上写死宽高:竖向 rail 与 margin 按 antd 的 icon-size 变量计算 */
|
|
96
|
+
|
|
97
|
+
.chat-prep-steps {
|
|
98
|
+
.ant-steps-item {
|
|
99
|
+
padding-top: 0 !important;
|
|
100
|
+
padding-bottom: 6px !important;
|
|
101
|
+
|
|
102
|
+
&:last-child {
|
|
103
|
+
padding-bottom: 0 !important;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* antd v6 竖向连线:.ant-steps-item-rail(border-inline-start) */
|
|
108
|
+
.ant-steps-item-rail {
|
|
109
|
+
border-inline-start-color: #e2e8f0 !important;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.ant-steps-item-icon {
|
|
113
|
+
display: flex !important;
|
|
114
|
+
flex-shrink: 0;
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: center;
|
|
117
|
+
line-height: 1 !important;
|
|
118
|
+
border-color: #e2e8f0;
|
|
119
|
+
color: #cbd5e1;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.ant-steps-item-process .ant-steps-item-icon {
|
|
123
|
+
border-color: #e2e8f0 !important;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ant-steps-item-finish .ant-steps-item-icon {
|
|
127
|
+
border: 0 !important;
|
|
128
|
+
background: transparent !important;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* 副标题在 rc-steps 里走 .ant-steps-item-content;antd 按 finish/wait 等状态写不同 token,需统一色值 */
|
|
132
|
+
.ant-steps-item-content {
|
|
133
|
+
min-width: 0 !important;
|
|
134
|
+
margin-top: 0 !important;
|
|
135
|
+
max-width: none !important;
|
|
136
|
+
white-space: normal !important;
|
|
137
|
+
word-break: break-word;
|
|
138
|
+
padding-bottom: 0 !important;
|
|
139
|
+
font-size: 12px;
|
|
140
|
+
line-height: 1.375;
|
|
141
|
+
color: #94a3b8 !important;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.ant-steps-item-title {
|
|
145
|
+
margin: 0 !important;
|
|
146
|
+
padding-bottom: 2px;
|
|
147
|
+
line-height: 1.25 !important;
|
|
148
|
+
font-size: 13px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.ant-steps-item-finish .ant-steps-item-title {
|
|
152
|
+
font-weight: 500;
|
|
153
|
+
color: #334155 !important;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.ant-steps-item-process .ant-steps-item-title,
|
|
157
|
+
.ant-steps-item-wait .ant-steps-item-title {
|
|
158
|
+
font-weight: 500;
|
|
159
|
+
color: #1e293b !important;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* 兼容仍带 -description 类名的旧结构 */
|
|
163
|
+
.ant-steps-item-description {
|
|
164
|
+
margin-top: 0 !important;
|
|
165
|
+
max-width: none !important;
|
|
166
|
+
white-space: normal !important;
|
|
167
|
+
word-break: break-word;
|
|
168
|
+
padding-bottom: 0 !important;
|
|
169
|
+
font-size: 12px;
|
|
170
|
+
line-height: 1.375;
|
|
171
|
+
color: #94a3b8 !important;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* loading 点保持主题主色 */
|
|
175
|
+
.chat-prep-step-spin .ant-spin-dot-item {
|
|
176
|
+
background-color: var(--antd-color-primary, #2563eb) !important;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
html.dark & {
|
|
180
|
+
.ant-steps-item-rail {
|
|
181
|
+
border-inline-start-color: #64748b !important;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.ant-steps-item-icon {
|
|
185
|
+
border-color: #64748b;
|
|
186
|
+
color: #94a3b8;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.ant-steps-item-process .ant-steps-item-icon {
|
|
190
|
+
border-color: #64748b !important;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.ant-steps-item-finish .ant-steps-item-title {
|
|
194
|
+
color: #e2e8f0 !important;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.ant-steps-item-process .ant-steps-item-title,
|
|
198
|
+
.ant-steps-item-wait .ant-steps-item-title {
|
|
199
|
+
color: #f1f5f9 !important;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.ant-steps-item-content,
|
|
203
|
+
.ant-steps-item-description {
|
|
204
|
+
color: #cbd5e1 !important;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.chat-prep-step-icon-inner {
|
|
210
|
+
display: inline-flex;
|
|
211
|
+
width: 20px;
|
|
212
|
+
height: 20px;
|
|
213
|
+
align-items: center;
|
|
214
|
+
justify-content: center;
|
|
215
|
+
color: #cbd5e1;
|
|
216
|
+
|
|
217
|
+
html.dark & {
|
|
218
|
+
color: #94a3b8;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
svg {
|
|
222
|
+
flex-shrink: 0;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.chat-prep-step-spin {
|
|
227
|
+
display: inline-flex;
|
|
228
|
+
width: 20px;
|
|
229
|
+
height: 20px;
|
|
230
|
+
align-items: center;
|
|
231
|
+
justify-content: center;
|
|
232
|
+
|
|
233
|
+
.ant-spin-nested-loading {
|
|
234
|
+
padding: 0 !important;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* preparation 副标题内 Markdown(GFM),字号与步骤 content 一致 */
|
|
239
|
+
.chat-prep-step-md {
|
|
240
|
+
font-size: 12px;
|
|
241
|
+
line-height: 1.5;
|
|
242
|
+
word-break: break-word;
|
|
243
|
+
|
|
244
|
+
p {
|
|
245
|
+
margin: 0 0 0.35em;
|
|
246
|
+
|
|
247
|
+
&:last-child {
|
|
248
|
+
margin-bottom: 0;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
ul,
|
|
253
|
+
ol {
|
|
254
|
+
margin: 0.25em 0 0.35em;
|
|
255
|
+
padding-left: 1.25em;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
li {
|
|
259
|
+
margin: 0.15em 0;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
strong {
|
|
263
|
+
font-weight: 600;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
a {
|
|
267
|
+
color: var(--antd-color-primary, #2563eb);
|
|
268
|
+
text-decoration: underline;
|
|
269
|
+
|
|
270
|
+
&:hover {
|
|
271
|
+
opacity: 0.9;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
code {
|
|
276
|
+
padding: 0.1em 0.35em;
|
|
277
|
+
font-size: 0.92em;
|
|
278
|
+
border-radius: 4px;
|
|
279
|
+
background: rgba(0, 0, 0, 0.06);
|
|
280
|
+
|
|
281
|
+
html.dark & {
|
|
282
|
+
background: rgba(255, 255, 255, 0.08);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
pre {
|
|
287
|
+
margin: 0.35em 0;
|
|
288
|
+
padding: 0.5em 0.65em;
|
|
289
|
+
font-size: 11px;
|
|
290
|
+
line-height: 1.4;
|
|
291
|
+
border-radius: 6px;
|
|
292
|
+
overflow-x: auto;
|
|
293
|
+
background: rgba(0, 0, 0, 0.06);
|
|
294
|
+
|
|
295
|
+
html.dark & {
|
|
296
|
+
background: rgba(0, 0, 0, 0.35);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
code {
|
|
300
|
+
padding: 0;
|
|
301
|
+
background: transparent;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
blockquote {
|
|
306
|
+
margin: 0.35em 0;
|
|
307
|
+
padding-left: 0.75em;
|
|
308
|
+
border-left: 3px solid #cbd5e1;
|
|
309
|
+
|
|
310
|
+
html.dark & {
|
|
311
|
+
border-left-color: #64748b;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
h1,
|
|
316
|
+
h2,
|
|
317
|
+
h3,
|
|
318
|
+
h4 {
|
|
319
|
+
font-size: inherit;
|
|
320
|
+
font-weight: 600;
|
|
321
|
+
margin: 0.35em 0 0.2em;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react'
|
|
2
|
+
import { ArrowUp, BarChart2, Globe, Library } from 'lucide-react'
|
|
3
|
+
// import { Atom } from 'lucide-react' // 深度思考入口恢复时一并启用
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
5
|
+
import clsx from 'clsx'
|
|
6
|
+
import { useAuth } from '@/contexts/AuthContext'
|
|
7
|
+
import {
|
|
8
|
+
CHAT_PERM_ENABLE_DATA_ANALYSIS,
|
|
9
|
+
CHAT_PERM_ENABLE_KNOWLEDGE,
|
|
10
|
+
CHAT_PERM_ENABLE_NETWORK,
|
|
11
|
+
clampChatStreamFeatureFlags,
|
|
12
|
+
} from '@/contexts/ChatContext'
|
|
13
|
+
import { useSystemConfig } from '@/config/system'
|
|
14
|
+
import {
|
|
15
|
+
getChatEnableDataAnalysis,
|
|
16
|
+
getChatEnableKnowledgeBase,
|
|
17
|
+
getChatEnableNetwork,
|
|
18
|
+
setChatEnableDataAnalysis,
|
|
19
|
+
setChatEnableKnowledgeBase,
|
|
20
|
+
setChatEnableNetwork,
|
|
21
|
+
} from '@/utils/storage'
|
|
22
|
+
|
|
23
|
+
export interface ChatSendPayload {
|
|
24
|
+
enableNetwork: boolean
|
|
25
|
+
enableKnowledgeBase: boolean
|
|
26
|
+
enableDataAnalysis: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ChatInputProps {
|
|
30
|
+
onSend: (message: string, payload: ChatSendPayload) => void | Promise<void>
|
|
31
|
+
onStop?: () => void
|
|
32
|
+
isLoading: boolean
|
|
33
|
+
disableSend?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const chipBase =
|
|
37
|
+
'inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors'
|
|
38
|
+
|
|
39
|
+
type ChipIcon = typeof Globe
|
|
40
|
+
|
|
41
|
+
function ToggleChip(props: {
|
|
42
|
+
active: boolean
|
|
43
|
+
disabled: boolean
|
|
44
|
+
onClick: () => void
|
|
45
|
+
icon: ChipIcon
|
|
46
|
+
label: string
|
|
47
|
+
}) {
|
|
48
|
+
const { active, disabled, onClick, icon: Icon, label } = props
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
disabled={disabled}
|
|
53
|
+
onClick={onClick}
|
|
54
|
+
className={clsx(
|
|
55
|
+
chipBase,
|
|
56
|
+
active
|
|
57
|
+
? 'border-blue-600 bg-blue-50 text-blue-600 dark:border-blue-500 dark:bg-blue-950/50 dark:text-blue-400'
|
|
58
|
+
: 'border-gray-200 bg-white text-gray-900 dark:border-gray-600 dark:bg-[#131314] dark:text-gray-100',
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
<Icon size={16} strokeWidth={2} />
|
|
62
|
+
{label}
|
|
63
|
+
</button>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ChatInput: React.FC<ChatInputProps> = ({
|
|
68
|
+
onSend,
|
|
69
|
+
onStop,
|
|
70
|
+
isLoading,
|
|
71
|
+
disableSend,
|
|
72
|
+
}) => {
|
|
73
|
+
const [input, setInput] = useState('')
|
|
74
|
+
const { systemName } = useSystemConfig()
|
|
75
|
+
const [enableNetwork, setEnableNetwork] = useState(() =>
|
|
76
|
+
getChatEnableNetwork(),
|
|
77
|
+
)
|
|
78
|
+
const [enableKnowledgeBase, setEnableKnowledgeBase] = useState(() =>
|
|
79
|
+
getChatEnableKnowledgeBase(),
|
|
80
|
+
)
|
|
81
|
+
const [enableDataAnalysis, setEnableDataAnalysis] = useState(() =>
|
|
82
|
+
getChatEnableDataAnalysis(),
|
|
83
|
+
)
|
|
84
|
+
// 深度思考:后续若对接推理/思考链等参数再打开
|
|
85
|
+
// const [deepThinking, setDeepThinking] = useState(false)
|
|
86
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
|
87
|
+
const { t } = useTranslation()
|
|
88
|
+
const { hasPermission } = useAuth()
|
|
89
|
+
|
|
90
|
+
const canUseNetwork = hasPermission(CHAT_PERM_ENABLE_NETWORK)
|
|
91
|
+
const canUseKnowledgeBase = hasPermission(CHAT_PERM_ENABLE_KNOWLEDGE)
|
|
92
|
+
const canUseDataAnalysis = hasPermission(CHAT_PERM_ENABLE_DATA_ANALYSIS)
|
|
93
|
+
|
|
94
|
+
const toggleNetwork = useCallback(() => {
|
|
95
|
+
setEnableNetwork((prev) => {
|
|
96
|
+
const next = !prev
|
|
97
|
+
setChatEnableNetwork(next)
|
|
98
|
+
return next
|
|
99
|
+
})
|
|
100
|
+
}, [])
|
|
101
|
+
|
|
102
|
+
const toggleKnowledgeBase = useCallback(() => {
|
|
103
|
+
setEnableKnowledgeBase((prev) => {
|
|
104
|
+
const next = !prev
|
|
105
|
+
setChatEnableKnowledgeBase(next)
|
|
106
|
+
return next
|
|
107
|
+
})
|
|
108
|
+
}, [])
|
|
109
|
+
|
|
110
|
+
const toggleDataAnalysis = useCallback(() => {
|
|
111
|
+
setEnableDataAnalysis((prev) => {
|
|
112
|
+
const next = !prev
|
|
113
|
+
setChatEnableDataAnalysis(next)
|
|
114
|
+
return next
|
|
115
|
+
})
|
|
116
|
+
}, [])
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!canUseNetwork && enableNetwork) {
|
|
120
|
+
setEnableNetwork(false)
|
|
121
|
+
setChatEnableNetwork(false)
|
|
122
|
+
}
|
|
123
|
+
if (!canUseKnowledgeBase && enableKnowledgeBase) {
|
|
124
|
+
setEnableKnowledgeBase(false)
|
|
125
|
+
setChatEnableKnowledgeBase(false)
|
|
126
|
+
}
|
|
127
|
+
if (!canUseDataAnalysis && enableDataAnalysis) {
|
|
128
|
+
setEnableDataAnalysis(false)
|
|
129
|
+
setChatEnableDataAnalysis(false)
|
|
130
|
+
}
|
|
131
|
+
}, [
|
|
132
|
+
canUseNetwork,
|
|
133
|
+
canUseKnowledgeBase,
|
|
134
|
+
canUseDataAnalysis,
|
|
135
|
+
enableNetwork,
|
|
136
|
+
enableKnowledgeBase,
|
|
137
|
+
enableDataAnalysis,
|
|
138
|
+
])
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (textareaRef.current) {
|
|
142
|
+
textareaRef.current.style.height = 'auto'
|
|
143
|
+
textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px`
|
|
144
|
+
}
|
|
145
|
+
}, [input])
|
|
146
|
+
|
|
147
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
148
|
+
e.preventDefault()
|
|
149
|
+
if (isLoading && onStop) {
|
|
150
|
+
onStop()
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
if (input.trim() && !isLoading) {
|
|
154
|
+
const payload = clampChatStreamFeatureFlags(
|
|
155
|
+
{
|
|
156
|
+
enableNetwork,
|
|
157
|
+
enableKnowledgeBase,
|
|
158
|
+
enableDataAnalysis,
|
|
159
|
+
},
|
|
160
|
+
hasPermission,
|
|
161
|
+
)
|
|
162
|
+
void onSend(input, payload)
|
|
163
|
+
setInput('')
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
168
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
169
|
+
e.preventDefault()
|
|
170
|
+
handleSubmit(e)
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const chipsDisabled = isLoading || disableSend
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<form onSubmit={handleSubmit} className="bg-transparent p-4">
|
|
178
|
+
<div className="relative mx-auto w-full max-w-7xl">
|
|
179
|
+
<div
|
|
180
|
+
className={clsx(
|
|
181
|
+
'rounded-[28px] border border-gray-200 bg-white p-4 shadow-sm transition-shadow',
|
|
182
|
+
'dark:border-gray-700 dark:bg-[#1e1f20]',
|
|
183
|
+
'focus-within:border-gray-300 dark:focus-within:border-gray-600',
|
|
184
|
+
)}
|
|
185
|
+
>
|
|
186
|
+
{isLoading ? (
|
|
187
|
+
<div className="flex min-h-[44px] items-center gap-3 py-1 text-gray-500 dark:text-gray-400">
|
|
188
|
+
<div className="h-5 w-5 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent" />
|
|
189
|
+
<span className="text-sm">{t('chat.processing')}</span>
|
|
190
|
+
</div>
|
|
191
|
+
) : (
|
|
192
|
+
<textarea
|
|
193
|
+
ref={textareaRef}
|
|
194
|
+
value={input}
|
|
195
|
+
onChange={(e) => setInput(e.target.value)}
|
|
196
|
+
onKeyDown={handleKeyDown}
|
|
197
|
+
placeholder={t('chat.placeholder_to_app', { appName: systemName })}
|
|
198
|
+
rows={1}
|
|
199
|
+
className="max-h-48 w-full resize-none border-0 bg-transparent py-1 text-base text-gray-900 outline-none ring-0 placeholder:text-gray-400 dark:text-white dark:placeholder:text-gray-500"
|
|
200
|
+
disabled={isLoading}
|
|
201
|
+
/>
|
|
202
|
+
)}
|
|
203
|
+
|
|
204
|
+
<div className="mt-2 flex flex-wrap items-center justify-between gap-3">
|
|
205
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
206
|
+
{/*
|
|
207
|
+
深度思考(暂隐藏,勿删;恢复时取消注释并启用上方 Atom、deepThinking state)
|
|
208
|
+
<button
|
|
209
|
+
type="button"
|
|
210
|
+
disabled={chipsDisabled}
|
|
211
|
+
onClick={() => setDeepThinking((v) => !v)}
|
|
212
|
+
className={clsx(
|
|
213
|
+
chipBase,
|
|
214
|
+
deepThinking
|
|
215
|
+
? 'border-blue-600 bg-blue-50 text-blue-600 dark:border-blue-500 dark:bg-blue-950/50 dark:text-blue-400'
|
|
216
|
+
: 'border-gray-200 bg-white text-gray-900 dark:border-gray-600 dark:bg-[#131314] dark:text-gray-100',
|
|
217
|
+
)}
|
|
218
|
+
>
|
|
219
|
+
<Atom size={16} strokeWidth={2} />
|
|
220
|
+
{t('chat.deep_thinking')}
|
|
221
|
+
</button>
|
|
222
|
+
*/}
|
|
223
|
+
{canUseNetwork && (
|
|
224
|
+
<ToggleChip
|
|
225
|
+
active={enableNetwork}
|
|
226
|
+
disabled={chipsDisabled}
|
|
227
|
+
onClick={toggleNetwork}
|
|
228
|
+
icon={Globe}
|
|
229
|
+
label={t('chat.web_search')}
|
|
230
|
+
/>
|
|
231
|
+
)}
|
|
232
|
+
{canUseKnowledgeBase && (
|
|
233
|
+
<ToggleChip
|
|
234
|
+
active={enableKnowledgeBase}
|
|
235
|
+
disabled={chipsDisabled}
|
|
236
|
+
onClick={toggleKnowledgeBase}
|
|
237
|
+
icon={Library}
|
|
238
|
+
label={t('chat.knowledge_base')}
|
|
239
|
+
/>
|
|
240
|
+
)}
|
|
241
|
+
{canUseDataAnalysis && (
|
|
242
|
+
<ToggleChip
|
|
243
|
+
active={enableDataAnalysis}
|
|
244
|
+
disabled={chipsDisabled}
|
|
245
|
+
onClick={toggleDataAnalysis}
|
|
246
|
+
icon={BarChart2}
|
|
247
|
+
label={t('chat.data_analysis')}
|
|
248
|
+
/>
|
|
249
|
+
)}
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<div className="ml-auto flex shrink-0 items-center gap-2">
|
|
253
|
+
{/*<button
|
|
254
|
+
type="button"
|
|
255
|
+
disabled={chipsDisabled}
|
|
256
|
+
className="rounded-lg p-2 text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800"
|
|
257
|
+
title={t('chat.attachment')}
|
|
258
|
+
aria-label={t('chat.attachment')}
|
|
259
|
+
>
|
|
260
|
+
<Paperclip size={20} strokeWidth={2} />
|
|
261
|
+
</button>*/}
|
|
262
|
+
<button
|
|
263
|
+
type="submit"
|
|
264
|
+
disabled={(!input.trim() && !isLoading) || disableSend}
|
|
265
|
+
className={clsx(
|
|
266
|
+
'flex h-10 w-10 items-center justify-center rounded-full transition-all',
|
|
267
|
+
isLoading
|
|
268
|
+
? 'bg-gray-200 text-gray-900 hover:bg-gray-300 dark:bg-gray-700 dark:text-white dark:hover:bg-gray-600'
|
|
269
|
+
: input.trim() && !disableSend
|
|
270
|
+
? 'bg-blue-600 text-white shadow-sm hover:bg-blue-700'
|
|
271
|
+
: 'cursor-not-allowed bg-gray-100 text-gray-300 dark:bg-gray-800 dark:text-gray-600',
|
|
272
|
+
)}
|
|
273
|
+
title={
|
|
274
|
+
isLoading
|
|
275
|
+
? t('common.stop') || 'Stop'
|
|
276
|
+
: t('common.send') || 'Send'
|
|
277
|
+
}
|
|
278
|
+
>
|
|
279
|
+
{isLoading ? (
|
|
280
|
+
<span className="block h-2.5 w-2.5 rounded-sm bg-current" />
|
|
281
|
+
) : (
|
|
282
|
+
<ArrowUp size={20} strokeWidth={2.5} />
|
|
283
|
+
)}
|
|
284
|
+
</button>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
<div className="mt-2 text-center">
|
|
289
|
+
<p className="text-xs text-gray-500 dark:text-gray-400">
|
|
290
|
+
{t('chat.disclaimer', { appName: systemName })}
|
|
291
|
+
</p>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
294
|
+
</form>
|
|
295
|
+
)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export default ChatInput
|