@gientech/modual 2.0.7 → 2.0.9
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/.editorconfig +38 -0
- package/.prettierignore +16 -0
- package/.prettierrc +17 -0
- package/INSTALL_TROUBLESHOOTING.md +316 -0
- package/USAGE.md +247 -0
- package/bash.exe.stackdump +40 -0
- package/components.json +21 -0
- package/dist/README.md +761 -0
- package/{assets/GientechStreamReader-Dx72IaEx.js → dist/assets/GientechStreamReader-CNj6Rcm7.js} +1 -1
- package/{assets/index-D4pXe94o.js → dist/assets/index-BJv0t0eJ.js} +36 -36
- package/{assets/index-BbNz3Zrz.js → dist/assets/index-CU45mVZ4.js} +1 -1
- package/{chat.js → dist/chat.js} +1 -1
- package/{databaseId.js → dist/databaseId.js} +1 -1
- package/{index.js → dist/index.js} +1 -1
- package/dist/package.json +68 -0
- package/{streamFilesReader.js → dist/streamFilesReader.js} +1 -1
- package/doc_assets/2.png +0 -0
- package/doc_assets/demo.md +27 -0
- package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +2 -0
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +23699 -0
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +1 -0
- package/doc_assets/demos/dist-app/index.html +14 -0
- package/doc_assets/demos/dist-app/vite.svg +1 -0
- package/doc_assets/images/1.png +0 -0
- package/doc_assets/images/3.png +0 -0
- package/doc_assets/images/component-screenshot.png +1 -0
- package/doc_assets/install.md +5 -0
- package/doc_assets/v2.0.7/345/217/230/346/233/264/346/200/273/347/273/223.md +115 -0
- package/doc_assets//346/226/271/346/241/210//344/274/230/345/214/226/346/226/271/346/241/210-/345/244/232/344/274/232/350/257/235SSE/350/277/236/346/216/245/347/256/241/347/220/206.md +504 -0
- package/eslint.config.js +92 -0
- package/index.html +13 -0
- package/package.json +103 -41
- package/package.json.demo-backup +109 -0
- package/postcss.config.cjs +19 -0
- package/public/icons/answerAwartar.png +0 -0
- package/public/icons/docx-file.png +0 -0
- package/public/icons/folder.png +0 -0
- package/public/icons/html.png +0 -0
- package/public/icons/image.png +0 -0
- package/public/icons/jpg-file.png +0 -0
- package/public/icons/json.png +0 -0
- package/public/icons/md.png +0 -0
- package/public/icons/pdf.png +0 -0
- package/public/icons/pptx.png +0 -0
- package/public/icons/questionAwartar.png +0 -0
- package/public/icons/sheets.png +0 -0
- package/public/icons/txt.png +0 -0
- package/public/icons/xlsx.png +0 -0
- package/public/vite.svg +1 -0
- package/public/worker/pdf.worker.min.js +22 -0
- package/scripts/README.md +133 -0
- package/scripts/build-demo.js +88 -0
- package/scripts/decrypt-api-key.js +95 -0
- package/scripts/demo-selector.js +216 -0
- package/scripts/dev-demo.js +76 -0
- package/scripts/preview-demo.js +130 -0
- package/scripts/run-demo.bat +34 -0
- package/src/assets/img/close.png +0 -0
- package/src/assets/img/database.png +0 -0
- package/src/assets/img/downArrow.png +0 -0
- package/src/assets/img/downLoad.png +0 -0
- package/src/assets/img/excel.png +0 -0
- package/src/assets/img/graphIcon.png +0 -0
- package/src/assets/img/img.png +0 -0
- package/src/assets/img/pdf.png +0 -0
- package/src/assets/img/ppt.png +0 -0
- package/src/assets/img/singleQa.png +0 -0
- package/src/assets/img/txt.png +0 -0
- package/src/assets/img/webSearch.png +0 -0
- package/src/assets/img/word.png +0 -0
- package/src/assets/login/homeBg.png +0 -0
- package/src/assets/login/left.jpg +0 -0
- package/src/assets/login/logoImg.png +0 -0
- package/src/examples/ConversationAssistantPage/index.tsx +41 -0
- package/src/examples/Demo/index.tsx +12 -0
- package/src/examples/LoginPage/index.tsx +18 -0
- package/src/examples/chat/components/DrawerGraphPreview.tsx +78 -0
- package/src/examples/chat/index.tsx +166 -0
- package/src/examples/chat/logo03.png +0 -0
- package/src/examples/gientechStreamFilesReader/index.tsx +951 -0
- package/src/examples/headlessChat/assets/mind.svg +6 -0
- package/src/examples/headlessChat/assets/net.svg +7 -0
- package/src/examples/headlessChat/index.tsx +285 -0
- package/src/examples/ragDatabaseDataPage/index.tsx +40 -0
- package/src/examples/ragDatabaseIdPage/index.tsx +47 -0
- package/src/examples/ragDatabasePage/index.tsx +36 -0
- package/src/examples/ragModelManagePage/index.tsx +38 -0
- package/src/examples/ragSearchPage/index.tsx +0 -0
- package/src/examples/ragSensitiveWordsPage/index.tsx +32 -0
- package/src/examples/streamFiles/index.tsx +417 -0
- package/src/lib_enter.ts +43 -0
- package/src/main.tsx +5 -0
- package/src/main.tsx.backup +5 -0
- package/src/modules/CHAT_UNIFICATION_PLAN.md +324 -0
- package/src/modules/assistantConfig/assets/databse.svg +6 -0
- package/src/modules/assistantConfig/assets/empty.png +0 -0
- package/src/modules/assistantConfig/assets/graph.svg +4 -0
- package/src/modules/assistantConfig/assets/knowledge.svg +4 -0
- package/src/modules/assistantConfig/assets/sensitive.svg +5 -0
- package/src/modules/assistantConfig/components/Database.tsx +171 -0
- package/src/modules/assistantConfig/components/Graph.tsx +177 -0
- package/src/modules/assistantConfig/components/Knowledge.tsx +276 -0
- package/src/modules/assistantConfig/components/NotFoundContent.tsx +21 -0
- package/src/modules/assistantConfig/components/Paragraph.tsx +51 -0
- package/src/modules/assistantConfig/components/ParamsItem.tsx +39 -0
- package/src/modules/assistantConfig/components/ResourceBinderItem.tsx +133 -0
- package/src/modules/assistantConfig/components/SearchableSelector.tsx +500 -0
- package/src/modules/assistantConfig/components/Sensitive.tsx +221 -0
- package/src/modules/assistantConfig/components/SliderInput.tsx +65 -0
- package/src/modules/assistantConfig/constants.tsx +75 -0
- package/src/modules/assistantConfig/index.tsx +710 -0
- package/src/modules/assistantConfig/server.ts +262 -0
- package/src/modules/chat/Conversations/Item.tsx +167 -0
- package/src/modules/chat/Conversations/List.tsx +210 -0
- package/src/modules/chat/Conversations/groupByTime.ts +39 -0
- package/src/modules/chat/Conversations/index.tsx +252 -0
- package/src/modules/chat/ReferenceBar.tsx +622 -0
- package/src/modules/chat/constants.tsx +57 -0
- package/src/modules/chat/index.tsx +2449 -0
- package/src/modules/chat/referenceCom/DeleteModal.tsx +75 -0
- package/src/modules/chat/referenceCom/DrawerContent.tsx +136 -0
- package/src/modules/chat/referenceCom/DrawerDatabase.tsx +102 -0
- package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +86 -0
- package/src/modules/chat/referenceCom/DrawerPreview.tsx +73 -0
- package/src/modules/chat/referenceCom/DrawerTitle.tsx +26 -0
- package/src/modules/chat/referenceCom/RenameModal.tsx +86 -0
- package/src/modules/chat/referenceCom/TagCom.tsx +30 -0
- package/src/modules/chat/style.less +3 -0
- package/src/modules/chat/types.ts +17 -0
- package/src/modules/chat/utils/index.ts +348 -0
- package/src/modules/database/CreateModal.tsx +403 -0
- package/src/modules/database/assets/Doris.png +0 -0
- package/src/modules/database/assets/PostgreSQL.png +0 -0
- package/src/modules/database/assets/SQLServer.png +0 -0
- package/src/modules/database/assets/database.svg +11 -0
- package/src/modules/database/assets/database_add.svg +53 -0
- package/src/modules/database/assets/database_connect.svg +66 -0
- package/src/modules/database/assets/database_upload.svg +29 -0
- package/src/modules/database/assets/empty.png +0 -0
- package/src/modules/database/assets/mysql.svg +14 -0
- package/src/modules/database/index.tsx +477 -0
- package/src/modules/database/server.ts +196 -0
- package/src/modules/databaseId/CustomCom.tsx +156 -0
- package/src/modules/databaseId/EditConfig.tsx +280 -0
- package/src/modules/databaseId/UploadDrawer.tsx +535 -0
- package/src/modules/databaseId/assets/aiOptimize.svg +10 -0
- package/src/modules/databaseId/assets/empty.png +0 -0
- package/src/modules/databaseId/assets/template.svg +6 -0
- package/src/modules/databaseId/assets/upload.svg +9 -0
- package/src/modules/databaseId/assets/useTemp.svg +6 -0
- package/src/modules/databaseId/index.tsx +769 -0
- package/src/modules/databaseId/server.ts +286 -0
- package/src/modules/databaseId/style.css +5 -0
- package/src/modules/databaseTable/EditRowDrawer.tsx +124 -0
- package/src/modules/databaseTable/index.tsx +359 -0
- package/src/modules/databaseTable/server.ts +180 -0
- package/src/modules/headlessChat/ReferenceBar.tsx +783 -0
- package/src/modules/headlessChat/constants.tsx +54 -0
- package/src/modules/headlessChat/index.tsx +1782 -0
- package/src/modules/headlessChat/referenceCom/DeleteModal.tsx +75 -0
- package/src/modules/headlessChat/referenceCom/DrawerContent.tsx +136 -0
- package/src/modules/headlessChat/referenceCom/DrawerDatabase.tsx +102 -0
- package/src/modules/headlessChat/referenceCom/DrawerGraphPreview.tsx +86 -0
- package/src/modules/headlessChat/referenceCom/DrawerPreview.tsx +73 -0
- package/src/modules/headlessChat/referenceCom/DrawerTitle.tsx +26 -0
- package/src/modules/headlessChat/referenceCom/RenameModal.tsx +86 -0
- package/src/modules/headlessChat/referenceCom/TagCom.tsx +30 -0
- package/src/modules/headlessChat/style.less +3 -0
- package/src/modules/headlessChat/types.ts +23 -0
- package/src/modules/headlessChat/utils/index.ts +348 -0
- package/src/modules/login/components/Login/LoginBox/index.tsx +102 -0
- package/src/modules/login/components/Login/RegisterBox/index.tsx +180 -0
- package/src/modules/login/components/Login/index.tsx +100 -0
- package/src/modules/login/index.tsx +106 -0
- package/src/modules/login/style.css +3 -0
- package/src/modules/login/useServices.ts +53 -0
- package/src/modules/login/utils.ts +42 -0
- package/src/modules/modelManage/ConfigDrawer.tsx +249 -0
- package/src/modules/modelManage/ReplaceModal.tsx +124 -0
- package/src/modules/modelManage/assets/empty.png +0 -0
- package/src/modules/modelManage/const.ts +51 -0
- package/src/modules/modelManage/index.tsx +606 -0
- package/src/modules/modelManage/server.ts +223 -0
- package/src/modules/nodegraph/index.tsx +1 -0
- package/src/modules/search/assets/Icon-history.svg +8 -0
- package/src/modules/search/assets/answerAwartar.png +0 -0
- package/src/modules/search/assets/doc.png +0 -0
- package/src/modules/search/assets/genera.gif +0 -0
- package/src/modules/search/assets/icon-robot.svg +9 -0
- package/src/modules/search/assets/icon-search-bar.svg +14 -0
- package/src/modules/search/assets/icon-sub-title.svg +3 -0
- package/src/modules/search/assets/icon-title.svg +9 -0
- package/src/modules/search/assets/icon-zoomOut.svg +9 -0
- package/src/modules/search/assets/iconAi.svg +9 -0
- package/src/modules/search/assets/pdf.png +0 -0
- package/src/modules/search/assets/ppt.png +0 -0
- package/src/modules/search/assets/search.svg +3 -0
- package/src/modules/search/assets/selected.svg +4 -0
- package/src/modules/search/assets/txt.png +0 -0
- package/src/modules/search/assets/xls.png +0 -0
- package/src/modules/search/components/AssisSelect.tsx +137 -0
- package/src/modules/search/components/Editor/ChatViewEditor.tsx +261 -0
- package/src/modules/search/components/Editor/aichat.css +1 -0
- package/src/modules/search/components/Editor/constant.ts +13 -0
- package/src/modules/search/components/Editor/index.tsx +113 -0
- package/src/modules/search/components/Editor/plugins/autofomatRules.ts +332 -0
- package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +20 -0
- package/src/modules/search/components/Editor/plugins/createIndexes.tsx +38 -0
- package/src/modules/search/components/Editor/plugins/displayer.ts +298 -0
- package/src/modules/search/components/Editor/plugins/imageClick.tsx +32 -0
- package/src/modules/search/components/Editor/plugins/myplugin.tsx +98 -0
- package/src/modules/search/components/Editor/ui/avatar.tsx +19 -0
- package/src/modules/search/components/Editor/ui/blockquote-element.tsx +21 -0
- package/src/modules/search/components/Editor/ui/button.tsx +58 -0
- package/src/modules/search/components/Editor/ui/calendar.tsx +68 -0
- package/src/modules/search/components/Editor/ui/caption.tsx +46 -0
- package/src/modules/search/components/Editor/ui/checkbox.tsx +27 -0
- package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +188 -0
- package/src/modules/search/components/Editor/ui/code-block-element.css +434 -0
- package/src/modules/search/components/Editor/ui/code-block-element.tsx +39 -0
- package/src/modules/search/components/Editor/ui/code-leaf.tsx +24 -0
- package/src/modules/search/components/Editor/ui/code-line-element.tsx +10 -0
- package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +21 -0
- package/src/modules/search/components/Editor/ui/column-element.tsx +30 -0
- package/src/modules/search/components/Editor/ui/column-group-element.tsx +94 -0
- package/src/modules/search/components/Editor/ui/command.tsx +75 -0
- package/src/modules/search/components/Editor/ui/comment-avatar.tsx +22 -0
- package/src/modules/search/components/Editor/ui/comment-create-form.tsx +37 -0
- package/src/modules/search/components/Editor/ui/comment-item.tsx +74 -0
- package/src/modules/search/components/Editor/ui/comment-leaf.tsx +49 -0
- package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +42 -0
- package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +22 -0
- package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +32 -0
- package/src/modules/search/components/Editor/ui/comment-value.tsx +34 -0
- package/src/modules/search/components/Editor/ui/comments-popover.tsx +63 -0
- package/src/modules/search/components/Editor/ui/date-element.tsx +83 -0
- package/src/modules/search/components/Editor/ui/dialog.tsx +63 -0
- package/src/modules/search/components/Editor/ui/draggable.tsx +177 -0
- package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +180 -0
- package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +85 -0
- package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +28 -0
- package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +76 -0
- package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +8 -0
- package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +51 -0
- package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +77 -0
- package/src/modules/search/components/Editor/ui/heading-element.tsx +48 -0
- package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +17 -0
- package/src/modules/search/components/Editor/ui/hr-element.tsx +30 -0
- package/src/modules/search/components/Editor/ui/icons.tsx +267 -0
- package/src/modules/search/components/Editor/ui/image-element.tsx +74 -0
- package/src/modules/search/components/Editor/ui/inline-combobox.tsx +368 -0
- package/src/modules/search/components/Editor/ui/input.tsx +25 -0
- package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +218 -0
- package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +20 -0
- package/src/modules/search/components/Editor/ui/link-element.tsx +29 -0
- package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +161 -0
- package/src/modules/search/components/Editor/ui/list-element.tsx +30 -0
- package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +24 -0
- package/src/modules/search/components/Editor/ui/media-embed-element.tsx +133 -0
- package/src/modules/search/components/Editor/ui/media-popover.tsx +97 -0
- package/src/modules/search/components/Editor/ui/mention-element.tsx +43 -0
- package/src/modules/search/components/Editor/ui/mention-input-element.tsx +141 -0
- package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +93 -0
- package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +67 -0
- package/src/modules/search/components/Editor/ui/paragraph-element.tsx +4 -0
- package/src/modules/search/components/Editor/ui/placeholder.tsx +52 -0
- package/src/modules/search/components/Editor/ui/popover.tsx +32 -0
- package/src/modules/search/components/Editor/ui/resizable.tsx +66 -0
- package/src/modules/search/components/Editor/ui/separator.tsx +25 -0
- package/src/modules/search/components/Editor/ui/style.less +12 -0
- package/src/modules/search/components/Editor/ui/table-cell-element.tsx +143 -0
- package/src/modules/search/components/Editor/ui/table-element.tsx +243 -0
- package/src/modules/search/components/Editor/ui/table-row-element.tsx +22 -0
- package/src/modules/search/components/Editor/ui/tableValue.tsx +135 -0
- package/src/modules/search/components/Editor/ui/todo-list-element.tsx +43 -0
- package/src/modules/search/components/Editor/ui/toggle-element.tsx +31 -0
- package/src/modules/search/components/Editor/ui/toolbar.tsx +157 -0
- package/src/modules/search/components/Editor/ui/tooltip.tsx +65 -0
- package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +160 -0
- package/src/modules/search/components/Editor/ui/with-draggables.tsx +175 -0
- package/src/modules/search/components/FileList.tsx +287 -0
- package/src/modules/search/components/ImageGroupView/index.tsx +85 -0
- package/src/modules/search/components/ResultContent.tsx +232 -0
- package/src/modules/search/components/SearchInput.tsx +232 -0
- package/src/modules/search/components/SearchLanding.tsx +74 -0
- package/src/modules/search/components/SearchView.tsx +563 -0
- package/src/modules/search/components/SimpleEditor.tsx +158 -0
- package/src/modules/search/components/SimpleFileList.tsx +215 -0
- package/src/modules/search/index.tsx +10 -0
- package/src/modules/search/reademe.md +1 -0
- package/src/modules/search/servers/apis.tsx +19 -0
- package/src/modules/search/servers/index.ts +184 -0
- package/src/modules/search/style.less +503 -0
- package/src/modules/search/type.ts +22 -0
- package/src/modules/search/utils.ts +34 -0
- package/src/modules/sensitive/index.tsx +313 -0
- package/src/modules/sensitive/server.ts +122 -0
- package/src/modules/streamFilesReader/GientechStreamReader.tsx +1625 -0
- package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
- package/src/modules/streamFilesReader/components/Header/index.tsx +297 -0
- package/src/modules/streamFilesReader/index.tsx +3 -0
- package/src/style.css +6 -0
- package/src/type.d.ts +0 -0
- package/src/utils/commonFn.tsx +111 -0
- package/src/utils/decryptApiKey.ts +40 -0
- package/src/utils/gientechCommon/components/AppError.tsx +32 -0
- package/src/utils/gientechCommon/components/AppLoading.tsx +75 -0
- package/src/utils/gientechCommon/components/DeleteModal.tsx +75 -0
- package/src/utils/gientechCommon/components/DisplayError.tsx +33 -0
- package/src/utils/gientechCommon/components/DisplayLoading.tsx +38 -0
- package/src/utils/gientechCommon/components/FeedBackModal.tsx +319 -0
- package/src/utils/gientechCommon/components/FileCardCommon.tsx +82 -0
- package/src/utils/gientechCommon/components/FileManager/index.tsx +418 -0
- package/src/utils/gientechCommon/components/FileManager/style.css +5 -0
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +581 -0
- package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +359 -0
- package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +245 -0
- package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +209 -0
- package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
- package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +148 -0
- package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +14 -0
- package/src/utils/gientechCommon/components/RenameModal.tsx +86 -0
- package/src/utils/gientechCommon/components/style.less +11 -0
- package/src/utils/gientechCommon/configs/commonConfig.ts +2 -0
- package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
- package/src/utils/gientechCommon/configs/stylesConfig.ts +142 -0
- package/src/utils/gientechCommon/hooks/AichatUseController.tsx +417 -0
- package/src/utils/gientechCommon/hooks/useFileDisplayTools.tsx +251 -0
- package/src/utils/gientechCommon/hooks/useFileManager.ts +208 -0
- package/src/utils/gientechCommon/slate/converters/deserializers.ts +763 -0
- package/src/utils/gientechCommon/slate/converters/mockData.ts +232 -0
- package/src/utils/gientechCommon/slate/converters/slateConverters.ts +258 -0
- package/src/utils/gientechCommon/slate/richElements/index.tsx +499 -0
- package/src/utils/gientechCommon/utils/fileUtils.ts +86 -0
- package/src/utils/gientechCommon/utils/request.ts +37 -0
- package/src/utils/gientechCommon/utils/serverFn.ts +172 -0
- package/src/utils/index.tsx +142 -0
- package/src/utils/testconfigs/demologin/index.tsx +32 -0
- package/src/utils/testconfigs/index.ts +59 -0
- package/src/vite-env.d.ts +42 -0
- package/stats.html +4949 -0
- package/tailwind.config.js +170 -0
- package/tsconfig.app.json +30 -0
- package/tsconfig.app.tsbuildinfo +11 -0
- package/tsconfig.json +13 -0
- package/tsconfig.node.json +22 -0
- package/tsconfig.node.tsbuildinfo +1 -0
- package/vite.config.app.ts +93 -0
- package/vite.config.ts +232 -0
- package/workflows/release.yml +60 -0
- package//346/215/242/350/241/214/346/240/274/345/274/217/344/277/235/346/214/201/344/274/230/345/214/226/346/226/271/346/241/210.md +359 -0
- /package/{assets → dist/assets}/Doris.png +0 -0
- /package/{assets → dist/assets}/PostgreSQL.png +0 -0
- /package/{assets → dist/assets}/SQLServer.png +0 -0
- /package/{assets → dist/assets}/database.svg +0 -0
- /package/{assets → dist/assets}/database_add.svg +0 -0
- /package/{assets → dist/assets}/database_connect.svg +0 -0
- /package/{assets → dist/assets}/database_upload.svg +0 -0
- /package/{assets → dist/assets}/databse.svg +0 -0
- /package/{assets → dist/assets}/defaultWeLogo.svg +0 -0
- /package/{assets → dist/assets}/empty.png +0 -0
- /package/{assets → dist/assets}/graph.svg +0 -0
- /package/{assets → dist/assets}/homeBg.png +0 -0
- /package/{assets → dist/assets}/index-B2yNvzjy.js +0 -0
- /package/{assets → dist/assets}/index-BKe5FgcC.js +0 -0
- /package/{assets → dist/assets}/index-CpW6Dhpp.js +0 -0
- /package/{assets → dist/assets}/index-D72cKELw.js +0 -0
- /package/{assets → dist/assets}/index-DdVFXD_y.js +0 -0
- /package/{assets → dist/assets}/index-DrkSoKz6.js +0 -0
- /package/{assets → dist/assets}/index-ZopkeZtI.js +0 -0
- /package/{assets → dist/assets}/index-g-SUxfJH.js +0 -0
- /package/{assets → dist/assets}/index-j0kQJd0a.js +0 -0
- /package/{assets → dist/assets}/knowledge.svg +0 -0
- /package/{assets → dist/assets}/left.jpg +0 -0
- /package/{assets → dist/assets}/logoImg.png +0 -0
- /package/{assets → dist/assets}/mysql.svg +0 -0
- /package/{assets → dist/assets}/plus-V9zUoSq6.js +0 -0
- /package/{assets → dist/assets}/sensitive.svg +0 -0
- /package/{assets → dist/assets}/style-CGmZ5osp.js +0 -0
- /package/{assets → dist/assets}/style.css +0 -0
- /package/{assets → dist/assets}/style2.css +0 -0
- /package/{assets → dist/assets}/style3.css +0 -0
- /package/{assets → dist/assets}/style4.css +0 -0
- /package/{assets → dist/assets}/worker-BbpylX7l.js +0 -0
- /package/{assets → dist/assets}/x-CnaaLGJF.js +0 -0
- /package/{assistantConfig.d.ts → dist/assistantConfig.d.ts} +0 -0
- /package/{assistantConfig.js → dist/assistantConfig.js} +0 -0
- /package/{chat.d.ts → dist/chat.d.ts} +0 -0
- /package/{database.d.ts → dist/database.d.ts} +0 -0
- /package/{database.js → dist/database.js} +0 -0
- /package/{databaseId.d.ts → dist/databaseId.d.ts} +0 -0
- /package/{databaseTable.d.ts → dist/databaseTable.d.ts} +0 -0
- /package/{databaseTable.js → dist/databaseTable.js} +0 -0
- /package/{icons → dist/icons}/answerAwartar.png +0 -0
- /package/{icons → dist/icons}/docx-file.png +0 -0
- /package/{icons → dist/icons}/folder.png +0 -0
- /package/{icons → dist/icons}/html.png +0 -0
- /package/{icons → dist/icons}/image.png +0 -0
- /package/{icons → dist/icons}/jpg-file.png +0 -0
- /package/{icons → dist/icons}/json.png +0 -0
- /package/{icons → dist/icons}/md.png +0 -0
- /package/{icons → dist/icons}/pdf.png +0 -0
- /package/{icons → dist/icons}/pptx.png +0 -0
- /package/{icons → dist/icons}/questionAwartar.png +0 -0
- /package/{icons → dist/icons}/sheets.png +0 -0
- /package/{icons → dist/icons}/txt.png +0 -0
- /package/{icons → dist/icons}/xlsx.png +0 -0
- /package/{index.d.ts → dist/index.d.ts} +0 -0
- /package/{modelManage.d.ts → dist/modelManage.d.ts} +0 -0
- /package/{modelManage.js → dist/modelManage.js} +0 -0
- /package/{sensitive.d.ts → dist/sensitive.d.ts} +0 -0
- /package/{sensitive.js → dist/sensitive.js} +0 -0
- /package/{streamFilesReader.d.ts → dist/streamFilesReader.d.ts} +0 -0
- /package/{vite.svg → dist/vite.svg} +0 -0
- /package/{worker → dist/worker}/pdf.worker.min.js +0 -0
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import { useEffect, useMemo, useState, useRef } from 'react';
|
|
2
|
+
import { Popover, Input } from 'antd';
|
|
3
|
+
import { Search, X, ChevronLeft, ChevronRight } from 'lucide-react';
|
|
4
|
+
import { type Styles, defaultTheme } from '@mxmweb/zui';
|
|
5
|
+
import { uid } from 'uid';
|
|
6
|
+
import defaultWeLogo from './defaultWeLogo.svg';
|
|
7
|
+
import defaultBot from './defaultBot.png';
|
|
8
|
+
|
|
9
|
+
const createWelcomeStyles = (colors: any, classId: string) => {
|
|
10
|
+
const c = { ...defaultTheme.colors, ...colors };
|
|
11
|
+
return `
|
|
12
|
+
.g-welcome-${classId} .g-welcome-title {
|
|
13
|
+
background-image: linear-gradient(90deg, #3262FA 0%, #6C18FF 100%);
|
|
14
|
+
-webkit-background-clip: text;
|
|
15
|
+
background-clip: text;
|
|
16
|
+
color: transparent;
|
|
17
|
+
-webkit-text-fill-color: transparent;
|
|
18
|
+
}
|
|
19
|
+
.g-welcome-${classId} .g-welcome-subtitle {
|
|
20
|
+
color: ${c.disabled};
|
|
21
|
+
}
|
|
22
|
+
.g-welcome-${classId} .g-welcome-btn {
|
|
23
|
+
background-color: #ffffff;
|
|
24
|
+
border-color: ${c.border};
|
|
25
|
+
color: ${c.text};
|
|
26
|
+
height: 36px;
|
|
27
|
+
border-width: 1px;
|
|
28
|
+
box-shadow: 0 1px 2px rgba(31,35,41,0.04);
|
|
29
|
+
}
|
|
30
|
+
.g-welcome-${classId} .g-welcome-btn:hover {
|
|
31
|
+
border-color: ${c.primary};
|
|
32
|
+
color: ${c.primary};
|
|
33
|
+
background-color: #ffffff;
|
|
34
|
+
box-shadow: 0 2px 6px rgba(31,35,41,0.08);
|
|
35
|
+
}
|
|
36
|
+
.g-welcome-${classId} .g-welcome-btn.active {
|
|
37
|
+
background-image: linear-gradient(90deg, #F1F8FF 0%, #F9F4FF 100%);
|
|
38
|
+
border-color: ${c.primary};
|
|
39
|
+
box-shadow: 0 4px 10px rgba(24, 144, 255, 0.25);
|
|
40
|
+
}
|
|
41
|
+
.g-welcome-${classId} .g-welcome-btn .icon-badge {
|
|
42
|
+
width: 24px;
|
|
43
|
+
height: 24px;
|
|
44
|
+
border-radius: 9999px;
|
|
45
|
+
display: inline-flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
background: radial-gradient(100% 100% at 50% 0%, #F2F3F5 0%, #FFFFFF 100%);
|
|
49
|
+
box-shadow: inset 0 0 0 1px ${c.border};
|
|
50
|
+
}
|
|
51
|
+
.g-welcome-${classId} .g-welcome-pagination-btn {
|
|
52
|
+
background: transparent;
|
|
53
|
+
border: none;
|
|
54
|
+
color: ${c.disabled};
|
|
55
|
+
padding: 6px 10px;
|
|
56
|
+
border-radius: 9999px;
|
|
57
|
+
transition: all 0.2s;
|
|
58
|
+
font-size: 14px;
|
|
59
|
+
line-height: 1;
|
|
60
|
+
min-width: 32px;
|
|
61
|
+
height: 32px;
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
}
|
|
66
|
+
.g-welcome-${classId} .g-welcome-pagination-btn:hover:not(:disabled) {
|
|
67
|
+
color: ${c.text};
|
|
68
|
+
background-color: ${c.border}33;
|
|
69
|
+
}
|
|
70
|
+
.g-welcome-${classId} .g-welcome-pagination-btn.active {
|
|
71
|
+
color: ${c.primary};
|
|
72
|
+
background: radial-gradient(100% 100% at 50% 50%, ${c.primary}10 0%, ${c.primary}08 100%);
|
|
73
|
+
box-shadow: 0 2px 10px ${c.primary}12, inset 0 0 0 1px ${c.primary}1A;
|
|
74
|
+
}
|
|
75
|
+
.g-welcome-${classId} .g-welcome-pagination-btn:disabled {
|
|
76
|
+
color: ${c.disabled};
|
|
77
|
+
cursor: not-allowed;
|
|
78
|
+
background: transparent;
|
|
79
|
+
}
|
|
80
|
+
.g-welcome-${classId} .g-welcome-pagination-text {
|
|
81
|
+
color: ${c.disabled};
|
|
82
|
+
font-size: 14px;
|
|
83
|
+
padding: 0 8px;
|
|
84
|
+
}
|
|
85
|
+
.g-welcome-${classId} .g-welcome-pagination-dot {
|
|
86
|
+
width: 6px;
|
|
87
|
+
height: 6px;
|
|
88
|
+
border-radius: 50%;
|
|
89
|
+
background-color: ${c.border};
|
|
90
|
+
transition: all 0.2s;
|
|
91
|
+
}
|
|
92
|
+
.g-welcome-${classId} .g-welcome-pagination-dot.active {
|
|
93
|
+
background-color: ${c.primary};
|
|
94
|
+
width: 20px;
|
|
95
|
+
border-radius: 3px;
|
|
96
|
+
}
|
|
97
|
+
.g-welcome-${classId} .g-welcome-search-btn {
|
|
98
|
+
background-color: #ffffff;
|
|
99
|
+
border: 1px solid ${c.border};
|
|
100
|
+
color: ${c.text};
|
|
101
|
+
padding: 8px 8px;
|
|
102
|
+
border-radius: 100%;
|
|
103
|
+
cursor: pointer;
|
|
104
|
+
transition: all 0.2s;
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
gap: 6px;
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
box-shadow: 0 1px 2px rgba(31,35,41,0.04);
|
|
110
|
+
}
|
|
111
|
+
.g-welcome-${classId} .g-welcome-search-btn:hover {
|
|
112
|
+
border-color: ${c.primary};
|
|
113
|
+
color: ${c.primary};
|
|
114
|
+
box-shadow: 0 2px 6px rgba(31,35,41,0.08);
|
|
115
|
+
}
|
|
116
|
+
.g-welcome-${classId} .g-welcome-search-input {
|
|
117
|
+
border: 1px solid ${c.border};
|
|
118
|
+
border-radius: 9999px;
|
|
119
|
+
transition: all 0.2s;
|
|
120
|
+
height: 40px;
|
|
121
|
+
padding: 0 14px;
|
|
122
|
+
}
|
|
123
|
+
.g-welcome-${classId} .g-welcome-search-input:focus,
|
|
124
|
+
.g-welcome-${classId} .g-welcome-search-input:hover {
|
|
125
|
+
border-color: ${c.primary};
|
|
126
|
+
box-shadow: 0 0 0 2px ${c.primary}1A;
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function AssistantConfigCard({ config, styles }: { config: any, styles?: Styles }) {
|
|
132
|
+
if (!config) return null;
|
|
133
|
+
const parseConfig = JSON.parse(config.configJson);
|
|
134
|
+
//console.log('parseConfig',parseConfig);
|
|
135
|
+
|
|
136
|
+
const colors = useMemo(() => ({
|
|
137
|
+
...defaultTheme.colors,
|
|
138
|
+
...styles?.theme?.colors
|
|
139
|
+
}), [styles]);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div className="w-[340px] rounded-xl p-4 animate-fade-in bg-white">
|
|
143
|
+
{/* 标题区 */}
|
|
144
|
+
<div className="flex items-center mb-2">
|
|
145
|
+
<span className="text-md font-bold truncate mr-2" style={{ color: colors.primary }}>{parseConfig.config_name || '助手配置'}</span>
|
|
146
|
+
<span
|
|
147
|
+
className="text-xs truncate rounded px-2 py-0.5"
|
|
148
|
+
style={{
|
|
149
|
+
backgroundColor: `${colors.primary}1A`,
|
|
150
|
+
color: colors.disabled
|
|
151
|
+
}}
|
|
152
|
+
>{parseConfig.model_name}</span>
|
|
153
|
+
</div>
|
|
154
|
+
{/* 默认回复 */}
|
|
155
|
+
{/* <div className="text-xs text-gray-500 mb-2 break-all whitespace-pre-line">{parseConfig.defaultAnswer}</div> */}
|
|
156
|
+
<div className="border-b my-2" style={{ borderColor: colors.border }} />
|
|
157
|
+
{/* 基础参数 */}
|
|
158
|
+
<div className="flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-700 mb-2" style={{ color: colors.text }}>
|
|
159
|
+
<div>上下文最大轮数:<span className="font-semibold">{parseConfig.max_round}</span></div>
|
|
160
|
+
<div>最大令牌数:<span className="font-semibold">{parseConfig.max_tokens}</span></div>
|
|
161
|
+
<div>温度:<span className="font-semibold">{parseConfig.temperature}</span></div>
|
|
162
|
+
<div>召回数:<span className="font-semibold">{parseConfig.top_k}</span></div>
|
|
163
|
+
<div>多样性:<span className="font-semibold">{parseConfig.top_p}</span></div>
|
|
164
|
+
<div>相似度阈值:<span className="font-semibold">{parseConfig.score_threshold}</span></div>
|
|
165
|
+
</div>
|
|
166
|
+
{/* 知识库 */}
|
|
167
|
+
<div className="mb-2">
|
|
168
|
+
<div className="text-xs text-gray-400 mb-1" style={{ color: colors.disabled }}>关联知识库:</div>
|
|
169
|
+
<div className="flex flex-wrap gap-1">
|
|
170
|
+
{parseConfig.knowledge_base_name ? parseConfig.knowledge_base_name.split(';').map((kb: any,index:number) => (
|
|
171
|
+
<span
|
|
172
|
+
key={index}
|
|
173
|
+
className="px-2 py-0.5 rounded-full text-xs"
|
|
174
|
+
style={{
|
|
175
|
+
backgroundColor: `${colors.primary}1A`,
|
|
176
|
+
color: colors.primary
|
|
177
|
+
}}
|
|
178
|
+
>{kb}</span>
|
|
179
|
+
)) : <span className="text-gray-300" style={{ color: colors.disabled }}>无</span>}
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
{/* 其他开关 */}
|
|
183
|
+
<div className='mb-2'>
|
|
184
|
+
<div className="text-xs text-gray-400 mb-1" style={{ color: colors.disabled }}>开启功能:</div>
|
|
185
|
+
<div className="flex flex-wrap gap-2 text-xs mt-2">
|
|
186
|
+
{!!parseConfig.enabled_faq && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>FAQ</span>}
|
|
187
|
+
{!!parseConfig.enabled_graph && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>图谱</span>}
|
|
188
|
+
{!!parseConfig.dependOnKb && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>强知识依赖</span>}
|
|
189
|
+
{!!parseConfig.enabled_table_select && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>表格筛选</span>}
|
|
190
|
+
{!!parseConfig.enabled_rerank && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>精排模式</span>}
|
|
191
|
+
{!!parseConfig.need_trace_source && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>溯源</span>}
|
|
192
|
+
{!!parseConfig.is_download && <span className="px-2 py-0.5 rounded" style={{ backgroundColor: `${colors.success}1A`, color: colors.success }}>下载溯源</span>}
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function useTypewriter(text: string, deps: any[] = [], speed = 60) {
|
|
200
|
+
const [displayed, setDisplayed] = useState('');
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
setDisplayed('');
|
|
203
|
+
if (!text) return;
|
|
204
|
+
let i = 0;
|
|
205
|
+
const timer = setInterval(() => {
|
|
206
|
+
setDisplayed(prev => {
|
|
207
|
+
if (i >= text.length) {
|
|
208
|
+
clearInterval(timer);
|
|
209
|
+
return prev;
|
|
210
|
+
}
|
|
211
|
+
i++;
|
|
212
|
+
return text.slice(0, i);
|
|
213
|
+
});
|
|
214
|
+
}, speed);
|
|
215
|
+
return () => clearInterval(timer);
|
|
216
|
+
}, [text, ...deps]);
|
|
217
|
+
return displayed;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// 添加类型定义,支持 selectedId 和 onSelectAssistant
|
|
221
|
+
interface GientechNewChatWelcomeProps {
|
|
222
|
+
assistantList: any[];
|
|
223
|
+
eventsEmit?: (type: string, data?: any) => void;
|
|
224
|
+
styles?: Styles;
|
|
225
|
+
selectedId?: string;
|
|
226
|
+
onSelectAssistant?: (id: string) => void;
|
|
227
|
+
productLogo?: string; // 外部传入的产品logo
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function GientechNewChatWelcome(props: GientechNewChatWelcomeProps) {
|
|
231
|
+
const { assistantList, eventsEmit, styles, selectedId, onSelectAssistant, productLogo } = props;
|
|
232
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
233
|
+
const [searchVisible, setSearchVisible] = useState(false);
|
|
234
|
+
const [searchKeyword, setSearchKeyword] = useState('');
|
|
235
|
+
// 搜索框打开时每页显示6个,否则显示12个
|
|
236
|
+
const pageSize = (searchVisible || searchKeyword.trim()) ? 6 : 12;
|
|
237
|
+
|
|
238
|
+
// 只在 selectedId 变化时触发事件,且去重
|
|
239
|
+
const prevSelectedId = useRef<string | undefined>();
|
|
240
|
+
// 标记是否是选择助手导致的搜索关键词清空
|
|
241
|
+
const isClearingSearchForSelection = useRef(false);
|
|
242
|
+
// 记录选择助手时的目标页面,用于防止被重置
|
|
243
|
+
const targetPageForSelection = useRef<number | null>(null);
|
|
244
|
+
// 记录是否已经为当前 selectedId 设置了目标页面,避免重复设置
|
|
245
|
+
const hasSetPageForSelectedId = useRef<string | null>(null);
|
|
246
|
+
// 记录上一次的搜索关键词,用于判断是否真正变化
|
|
247
|
+
const prevSearchKeyword = useRef<string>('');
|
|
248
|
+
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
if (selectedId && prevSelectedId.current !== selectedId) {
|
|
251
|
+
eventsEmit?.('conversation:new_assistant_change', { assistantId: selectedId });
|
|
252
|
+
prevSelectedId.current = selectedId;
|
|
253
|
+
}
|
|
254
|
+
}, [selectedId, eventsEmit]);
|
|
255
|
+
|
|
256
|
+
const classId = useMemo(() => uid(), []);
|
|
257
|
+
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
if (styles?.theme?.colors) {
|
|
260
|
+
const styleTag = document.createElement('style');
|
|
261
|
+
styleTag.innerHTML = createWelcomeStyles(styles.theme.colors, classId);
|
|
262
|
+
styleTag.id = `g-welcome-styles-${classId}`;
|
|
263
|
+
document.head.appendChild(styleTag);
|
|
264
|
+
|
|
265
|
+
return () => {
|
|
266
|
+
const el = document.getElementById(styleTag.id);
|
|
267
|
+
if (el) {
|
|
268
|
+
el.remove();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}, [styles, classId]);
|
|
273
|
+
|
|
274
|
+
const selectAssistant = useMemo(() => {
|
|
275
|
+
return assistantList.find(assistant => assistant.id === selectedId);
|
|
276
|
+
}, [assistantList, selectedId]);
|
|
277
|
+
|
|
278
|
+
const selectAssistantConfig = useMemo(() => {
|
|
279
|
+
return JSON.parse(selectAssistant?.configJson || '{}');
|
|
280
|
+
}, [selectAssistant]);
|
|
281
|
+
|
|
282
|
+
// 搜索过滤逻辑
|
|
283
|
+
const filteredAssistants = useMemo(() => {
|
|
284
|
+
if (!searchKeyword.trim()) {
|
|
285
|
+
return assistantList || [];
|
|
286
|
+
}
|
|
287
|
+
const keyword = searchKeyword.toLowerCase().trim();
|
|
288
|
+
return (assistantList || []).filter(assistant => {
|
|
289
|
+
const name = assistant.name?.toLowerCase() || '';
|
|
290
|
+
// 也可以搜索配置中的信息
|
|
291
|
+
try {
|
|
292
|
+
const cfg = JSON.parse(assistant.configJson || '{}');
|
|
293
|
+
const configName = cfg.config_name?.toLowerCase() || '';
|
|
294
|
+
return name.includes(keyword) || configName.includes(keyword);
|
|
295
|
+
} catch {
|
|
296
|
+
return name.includes(keyword);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}, [assistantList, searchKeyword]);
|
|
300
|
+
|
|
301
|
+
// 分页逻辑
|
|
302
|
+
const totalPages = Math.ceil((filteredAssistants?.length || 0) / pageSize);
|
|
303
|
+
const currentAssistants = filteredAssistants?.slice((currentPage - 1) * pageSize, currentPage * pageSize) || [];
|
|
304
|
+
|
|
305
|
+
// 当选中助手时,自动跳转到对应页面(只在 selectedId 变化时执行)
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
if (selectedId && selectedId !== hasSetPageForSelectedId.current) {
|
|
308
|
+
// 如果正在清空搜索(选择助手导致的),已经有目标页面了,不重复计算
|
|
309
|
+
if (isClearingSearchForSelection.current && targetPageForSelection.current !== null) {
|
|
310
|
+
hasSetPageForSelectedId.current = selectedId;
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
// 如果有搜索关键词,基于过滤后的列表跳转;否则基于完整列表跳转
|
|
314
|
+
const targetList = searchKeyword.trim() ? filteredAssistants : assistantList;
|
|
315
|
+
if (targetList && targetList.length > 0) {
|
|
316
|
+
const selectedIndex = targetList.findIndex(a => a.id === selectedId);
|
|
317
|
+
if (selectedIndex !== -1) {
|
|
318
|
+
const targetPage = Math.floor(selectedIndex / pageSize) + 1;
|
|
319
|
+
setCurrentPage(targetPage);
|
|
320
|
+
hasSetPageForSelectedId.current = selectedId;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}, [selectedId, assistantList, filteredAssistants, pageSize, searchKeyword]);
|
|
325
|
+
|
|
326
|
+
// 当搜索关键词变化时,重置到第一页(但选择助手导致的清空除外)
|
|
327
|
+
useEffect(() => {
|
|
328
|
+
// 如果搜索关键词没有真正变化,不执行任何操作
|
|
329
|
+
if (searchKeyword === prevSearchKeyword.current) {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// 如果是选择助手导致的搜索关键词清空,跳转到目标页面并清除标记
|
|
334
|
+
if (isClearingSearchForSelection.current && targetPageForSelection.current !== null) {
|
|
335
|
+
setCurrentPage(targetPageForSelection.current);
|
|
336
|
+
isClearingSearchForSelection.current = false;
|
|
337
|
+
targetPageForSelection.current = null;
|
|
338
|
+
prevSearchKeyword.current = searchKeyword;
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// 如果已经为 selectedId 设置了页面(说明是选择助手导致的),不重置页面
|
|
343
|
+
if (hasSetPageForSelectedId.current === selectedId) {
|
|
344
|
+
prevSearchKeyword.current = searchKeyword;
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// 用户主动输入搜索关键词时,重置到第一页,并清除已设置的页面标记
|
|
349
|
+
if (!isClearingSearchForSelection.current) {
|
|
350
|
+
// 如果用户主动输入搜索关键词,清除已设置的页面标记,允许重新计算
|
|
351
|
+
if (searchKeyword.trim()) {
|
|
352
|
+
hasSetPageForSelectedId.current = null;
|
|
353
|
+
}
|
|
354
|
+
setCurrentPage(1);
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
prevSearchKeyword.current = searchKeyword;
|
|
358
|
+
}, [searchKeyword, selectedId]);
|
|
359
|
+
|
|
360
|
+
// 当过滤结果变化时,如果当前页超出总页数,自动调整到最后一页
|
|
361
|
+
useEffect(() => {
|
|
362
|
+
if (totalPages > 0 && currentPage > totalPages) {
|
|
363
|
+
setCurrentPage(totalPages);
|
|
364
|
+
}
|
|
365
|
+
}, [totalPages, currentPage]);
|
|
366
|
+
|
|
367
|
+
const prologue = selectAssistantConfig.prologue || '您好,欢迎使用小鲸智能问答';
|
|
368
|
+
const prologueTypewriter = useTypewriter(prologue, [selectedId], 30);
|
|
369
|
+
|
|
370
|
+
return (
|
|
371
|
+
<div className={`flex flex-col relative items-center justify-center h-full w-full g-welcome-${classId}`}>
|
|
372
|
+
{/* 产品Logo */}
|
|
373
|
+
<img
|
|
374
|
+
src={productLogo || (defaultWeLogo as unknown as string)}
|
|
375
|
+
alt="logo"
|
|
376
|
+
className="mb-4"
|
|
377
|
+
style={{ width: 68, height: 68 }}
|
|
378
|
+
/>
|
|
379
|
+
<div className="text-3xl font-bold mb-2 g-welcome-title">{prologueTypewriter}</div>
|
|
380
|
+
{!selectedId && <div className="flex mb-2 g-welcome-subtitle">请选择一个智能助手</div>}
|
|
381
|
+
|
|
382
|
+
<div
|
|
383
|
+
style={{
|
|
384
|
+
maxWidth: '1200px',
|
|
385
|
+
}}
|
|
386
|
+
className="flex mt-8 flex-wrap gap-3
|
|
387
|
+
max-w-[1200px] px-8 w-full mx-auto justify-center mb-4">
|
|
388
|
+
{/* 搜索按钮/输入框 - 永远渲染为第一个元素 */}
|
|
389
|
+
{!searchVisible ? (
|
|
390
|
+
<button type="button" className="g-welcome-search-btn" onClick={() => setSearchVisible(true)}>
|
|
391
|
+
<Search size={16} />
|
|
392
|
+
</button>
|
|
393
|
+
) : (
|
|
394
|
+
<div className="flex items-center gap-2 px-5 w-full" style={{ flexBasis: '100%' }}>
|
|
395
|
+
<Input
|
|
396
|
+
className="g-welcome-search-input w-full"
|
|
397
|
+
placeholder="搜索助手名称"
|
|
398
|
+
prefix={<Search size={16} />}
|
|
399
|
+
suffix={
|
|
400
|
+
<button
|
|
401
|
+
type="button"
|
|
402
|
+
onClick={() => {
|
|
403
|
+
setSearchVisible(false);
|
|
404
|
+
setSearchKeyword('');
|
|
405
|
+
}}
|
|
406
|
+
style={{ background: 'transparent', border: 'none', cursor: 'pointer' }}
|
|
407
|
+
>
|
|
408
|
+
<X size={14} />
|
|
409
|
+
</button>
|
|
410
|
+
}
|
|
411
|
+
value={searchKeyword}
|
|
412
|
+
onChange={(e) => setSearchKeyword(e.target.value)}
|
|
413
|
+
autoFocus
|
|
414
|
+
/>
|
|
415
|
+
</div>
|
|
416
|
+
)}
|
|
417
|
+
|
|
418
|
+
{/* 助手列表或空状态 */}
|
|
419
|
+
{currentAssistants && currentAssistants.length > 0 ? (
|
|
420
|
+
<>
|
|
421
|
+
{currentAssistants.map(assistant => {
|
|
422
|
+
const isActive = selectedId === assistant.id;
|
|
423
|
+
// 图标解析:优先 assistant.icon,其次配置中的 icon/avatar/logo,最后使用默认
|
|
424
|
+
let iconSrc: string | undefined = assistant.icon;
|
|
425
|
+
try {
|
|
426
|
+
const cfg = JSON.parse(assistant.configJson || '{}');
|
|
427
|
+
iconSrc = iconSrc || cfg.icon || cfg.avatar || cfg.logo;
|
|
428
|
+
} catch (e) {
|
|
429
|
+
// ignore json parse error
|
|
430
|
+
}
|
|
431
|
+
iconSrc = iconSrc || (defaultBot as unknown as string);
|
|
432
|
+
return (
|
|
433
|
+
<Popover
|
|
434
|
+
key={assistant.id}
|
|
435
|
+
content={() => <AssistantConfigCard config={assistantList.find(item => item.id === assistant.id)} styles={styles} />}
|
|
436
|
+
trigger="hover"
|
|
437
|
+
placement="bottom"
|
|
438
|
+
>
|
|
439
|
+
<button
|
|
440
|
+
type="button"
|
|
441
|
+
className={`g-welcome-btn px-3 cursor-pointer rounded-full border font-medium min-w-[160px] text-sm transition-all flex items-center gap-2 ${isActive ? 'active' : ''}`}
|
|
442
|
+
onClick={() => {
|
|
443
|
+
onSelectAssistant?.(assistant.id);
|
|
444
|
+
|
|
445
|
+
// 计算目标页面:如果在搜索中,基于完整列表(因为搜索会被清空);否则基于当前列表
|
|
446
|
+
const isInSearch = searchVisible || searchKeyword.trim();
|
|
447
|
+
const targetList = isInSearch ? assistantList : (searchKeyword.trim() ? filteredAssistants : assistantList);
|
|
448
|
+
const selectedIndex = targetList.findIndex(a => a.id === assistant.id);
|
|
449
|
+
|
|
450
|
+
if (selectedIndex !== -1) {
|
|
451
|
+
// 如果在搜索中,清空后 pageSize 会变成 12;否则使用当前的 pageSize
|
|
452
|
+
const targetPageSize = isInSearch ? 12 : pageSize;
|
|
453
|
+
const targetPage = Math.floor(selectedIndex / targetPageSize) + 1;
|
|
454
|
+
|
|
455
|
+
// 立即跳转到目标页面
|
|
456
|
+
setCurrentPage(targetPage);
|
|
457
|
+
// 标记已经为当前 selectedId 设置了页面
|
|
458
|
+
hasSetPageForSelectedId.current = assistant.id;
|
|
459
|
+
|
|
460
|
+
// 若在搜索视图中选择了助手,需要清空搜索
|
|
461
|
+
if (isInSearch) {
|
|
462
|
+
// 保存目标页面,用于在搜索关键词清空时跳转
|
|
463
|
+
targetPageForSelection.current = targetPage;
|
|
464
|
+
// 设置标记,表示这是选择助手导致的清空
|
|
465
|
+
isClearingSearchForSelection.current = true;
|
|
466
|
+
// 延迟清空搜索,确保跳转逻辑先执行
|
|
467
|
+
setTimeout(() => {
|
|
468
|
+
setSearchKeyword('');
|
|
469
|
+
setSearchVisible(false);
|
|
470
|
+
}, 100);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}}
|
|
474
|
+
title={assistant.name}
|
|
475
|
+
>
|
|
476
|
+
<span className="icon-badge">
|
|
477
|
+
<img src={iconSrc} alt="icon" style={{ width: 16, height: 16, borderRadius: 4 }} />
|
|
478
|
+
</span>
|
|
479
|
+
<span className="truncate max-w-[180px]">{assistant.name}</span>
|
|
480
|
+
</button>
|
|
481
|
+
</Popover>
|
|
482
|
+
);
|
|
483
|
+
})}
|
|
484
|
+
</>
|
|
485
|
+
) : (
|
|
486
|
+
<div className="g-welcome-subtitle">暂无可用助手</div>
|
|
487
|
+
)}
|
|
488
|
+
</div>
|
|
489
|
+
{/* 分页控制 */}
|
|
490
|
+
{totalPages > 1 && (
|
|
491
|
+
<div className="flex items-center gap-2">
|
|
492
|
+
<button
|
|
493
|
+
type="button"
|
|
494
|
+
className="g-welcome-pagination-btn"
|
|
495
|
+
onClick={() => setCurrentPage(p => Math.max(1, p - 1))}
|
|
496
|
+
disabled={currentPage === 1}
|
|
497
|
+
>
|
|
498
|
+
<ChevronLeft size={16} />
|
|
499
|
+
</button>
|
|
500
|
+
|
|
501
|
+
{/* 页码显示 */}
|
|
502
|
+
<div className="flex items-center gap-1">
|
|
503
|
+
{(() => {
|
|
504
|
+
const pages: (number | string)[] = [];
|
|
505
|
+
const maxVisible = 7; // 最多显示7个页码
|
|
506
|
+
|
|
507
|
+
if (totalPages <= maxVisible) {
|
|
508
|
+
// 如果总页数少于等于7,显示所有页码
|
|
509
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
510
|
+
pages.push(i);
|
|
511
|
+
}
|
|
512
|
+
} else {
|
|
513
|
+
// 总是显示第一页
|
|
514
|
+
pages.push(1);
|
|
515
|
+
|
|
516
|
+
if (currentPage <= 4) {
|
|
517
|
+
// 当前页在前4页,显示 1 2 3 4 5 ... totalPages
|
|
518
|
+
for (let i = 2; i <= 5; i++) {
|
|
519
|
+
pages.push(i);
|
|
520
|
+
}
|
|
521
|
+
pages.push('...');
|
|
522
|
+
pages.push(totalPages);
|
|
523
|
+
} else if (currentPage >= totalPages - 3) {
|
|
524
|
+
// 当前页在后4页,显示 1 ... totalPages-4 totalPages-3 totalPages-2 totalPages-1 totalPages
|
|
525
|
+
pages.push('...');
|
|
526
|
+
for (let i = totalPages - 4; i <= totalPages; i++) {
|
|
527
|
+
pages.push(i);
|
|
528
|
+
}
|
|
529
|
+
} else {
|
|
530
|
+
// 当前页在中间,显示 1 ... currentPage-1 currentPage currentPage+1 ... totalPages
|
|
531
|
+
pages.push('...');
|
|
532
|
+
for (let i = currentPage - 1; i <= currentPage + 1; i++) {
|
|
533
|
+
pages.push(i);
|
|
534
|
+
}
|
|
535
|
+
pages.push('...');
|
|
536
|
+
pages.push(totalPages);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return pages.map((page, index) => {
|
|
541
|
+
if (page === '...') {
|
|
542
|
+
return (
|
|
543
|
+
<span key={`ellipsis-${index}`} className="g-welcome-pagination-text px-1">
|
|
544
|
+
...
|
|
545
|
+
</span>
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const pageNum = page as number;
|
|
550
|
+
const isActive = currentPage === pageNum;
|
|
551
|
+
|
|
552
|
+
return (
|
|
553
|
+
<button
|
|
554
|
+
type="button"
|
|
555
|
+
key={pageNum}
|
|
556
|
+
className={`g-welcome-pagination-btn ${isActive ? 'active' : ''}`}
|
|
557
|
+
onClick={() => setCurrentPage(pageNum)}
|
|
558
|
+
>
|
|
559
|
+
{pageNum}
|
|
560
|
+
</button>
|
|
561
|
+
);
|
|
562
|
+
});
|
|
563
|
+
})()}
|
|
564
|
+
</div>
|
|
565
|
+
|
|
566
|
+
<button
|
|
567
|
+
type="button"
|
|
568
|
+
className="g-welcome-pagination-btn"
|
|
569
|
+
onClick={() => setCurrentPage(p => Math.min(totalPages, p + 1))}
|
|
570
|
+
disabled={currentPage === totalPages}
|
|
571
|
+
>
|
|
572
|
+
<ChevronRight size={16} />
|
|
573
|
+
</button>
|
|
574
|
+
</div>
|
|
575
|
+
)}
|
|
576
|
+
</div>
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// 只在assistantList、defaultSelect、styles变化时才重渲染
|
|
581
|
+
export default GientechNewChatWelcome;
|