@gientech/modual 2.0.5 → 2.0.7
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/README.md +118 -0
- package/{dist/assets/GientechStreamReader-DUCq-O5X.js → assets/GientechStreamReader-Dx72IaEx.js} +1 -1
- package/{dist/assets/index-QI9biQrR.js → assets/index-BbNz3Zrz.js} +1 -1
- package/{dist/assets/index-KCfkkJKb.js → assets/index-D4pXe94o.js} +117 -117
- package/assets/style.css +1 -0
- package/assets/style4.css +1 -0
- package/chat.js +844 -0
- package/{dist/databaseId.js → databaseId.js} +1 -1
- package/{dist/index.js → index.js} +1 -1
- package/package.json +41 -103
- package/{dist/streamFilesReader.js → streamFilesReader.js} +1 -1
- package/.editorconfig +0 -38
- package/.prettierignore +0 -16
- package/.prettierrc +0 -17
- package/USAGE.md +0 -247
- package/bash.exe.stackdump +0 -40
- package/components.json +0 -21
- package/dist/README.md +0 -643
- package/dist/assets/style.css +0 -1
- package/dist/assets/style4.css +0 -1
- package/dist/chat.js +0 -824
- package/dist/package.json +0 -68
- package/doc_assets/2.png +0 -0
- package/doc_assets/demo.md +0 -27
- package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +0 -2
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +0 -23699
- package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +0 -1
- package/doc_assets/demos/dist-app/index.html +0 -14
- package/doc_assets/demos/dist-app/vite.svg +0 -1
- package/doc_assets/images/1.png +0 -0
- package/doc_assets/images/3.png +0 -0
- package/doc_assets/images/component-screenshot.png +0 -1
- package/doc_assets/install.md +0 -5
- 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 +0 -504
- package/eslint.config.js +0 -92
- package/index.html +0 -13
- package/package.json.demo-backup +0 -109
- package/postcss.config.cjs +0 -19
- 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 +0 -1
- package/public/worker/pdf.worker.min.js +0 -22
- package/scripts/README.md +0 -133
- package/scripts/build-demo.js +0 -88
- package/scripts/decrypt-api-key.js +0 -95
- package/scripts/demo-selector.js +0 -216
- package/scripts/dev-demo.js +0 -76
- package/scripts/preview-demo.js +0 -130
- package/scripts/run-demo.bat +0 -34
- 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 +0 -41
- package/src/examples/Demo/index.tsx +0 -12
- package/src/examples/LoginPage/index.tsx +0 -18
- package/src/examples/chat/components/DrawerGraphPreview.tsx +0 -78
- package/src/examples/chat/index.tsx +0 -154
- package/src/examples/chat/logo03.png +0 -0
- package/src/examples/gientechStreamFilesReader/index.tsx +0 -951
- package/src/examples/headlessChat/index.tsx +0 -234
- package/src/examples/ragDatabaseDataPage/index.tsx +0 -40
- package/src/examples/ragDatabaseIdPage/index.tsx +0 -47
- package/src/examples/ragDatabasePage/index.tsx +0 -36
- package/src/examples/ragModelManagePage/index.tsx +0 -38
- package/src/examples/ragSearchPage/index.tsx +0 -0
- package/src/examples/ragSensitiveWordsPage/index.tsx +0 -32
- package/src/examples/streamFiles/index.tsx +0 -417
- package/src/lib_enter.ts +0 -43
- package/src/main.tsx +0 -5
- package/src/main.tsx.backup +0 -5
- package/src/modules/CHAT_UNIFICATION_PLAN.md +0 -324
- package/src/modules/assistantConfig/assets/databse.svg +0 -6
- package/src/modules/assistantConfig/assets/empty.png +0 -0
- package/src/modules/assistantConfig/assets/graph.svg +0 -4
- package/src/modules/assistantConfig/assets/knowledge.svg +0 -4
- package/src/modules/assistantConfig/assets/sensitive.svg +0 -5
- package/src/modules/assistantConfig/components/Database.tsx +0 -171
- package/src/modules/assistantConfig/components/Graph.tsx +0 -177
- package/src/modules/assistantConfig/components/Knowledge.tsx +0 -276
- package/src/modules/assistantConfig/components/NotFoundContent.tsx +0 -21
- package/src/modules/assistantConfig/components/Paragraph.tsx +0 -51
- package/src/modules/assistantConfig/components/ParamsItem.tsx +0 -39
- package/src/modules/assistantConfig/components/ResourceBinderItem.tsx +0 -133
- package/src/modules/assistantConfig/components/SearchableSelector.tsx +0 -500
- package/src/modules/assistantConfig/components/Sensitive.tsx +0 -221
- package/src/modules/assistantConfig/components/SliderInput.tsx +0 -65
- package/src/modules/assistantConfig/constants.tsx +0 -75
- package/src/modules/assistantConfig/index.tsx +0 -710
- package/src/modules/assistantConfig/server.ts +0 -262
- package/src/modules/chat/Conversations/Item.tsx +0 -167
- package/src/modules/chat/Conversations/List.tsx +0 -210
- package/src/modules/chat/Conversations/groupByTime.ts +0 -39
- package/src/modules/chat/Conversations/index.tsx +0 -252
- package/src/modules/chat/ReferenceBar.tsx +0 -622
- package/src/modules/chat/constants.tsx +0 -52
- package/src/modules/chat/data.txt +0 -82
- package/src/modules/chat/index.tsx +0 -2054
- package/src/modules/chat/referenceCom/DeleteModal.tsx +0 -75
- package/src/modules/chat/referenceCom/DrawerContent.tsx +0 -136
- package/src/modules/chat/referenceCom/DrawerDatabase.tsx +0 -102
- package/src/modules/chat/referenceCom/DrawerGraphPreview.tsx +0 -86
- package/src/modules/chat/referenceCom/DrawerPreview.tsx +0 -73
- package/src/modules/chat/referenceCom/DrawerTitle.tsx +0 -26
- package/src/modules/chat/referenceCom/RenameModal.tsx +0 -86
- package/src/modules/chat/referenceCom/TagCom.tsx +0 -30
- package/src/modules/chat/style.less +0 -3
- package/src/modules/chat/types.ts +0 -17
- package/src/modules/chat/utils/index.ts +0 -348
- package/src/modules/database/CreateModal.tsx +0 -403
- 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 +0 -11
- package/src/modules/database/assets/database_add.svg +0 -53
- package/src/modules/database/assets/database_connect.svg +0 -66
- package/src/modules/database/assets/database_upload.svg +0 -29
- package/src/modules/database/assets/empty.png +0 -0
- package/src/modules/database/assets/mysql.svg +0 -14
- package/src/modules/database/index.tsx +0 -477
- package/src/modules/database/server.ts +0 -196
- package/src/modules/databaseId/CustomCom.tsx +0 -156
- package/src/modules/databaseId/EditConfig.tsx +0 -280
- package/src/modules/databaseId/UploadDrawer.tsx +0 -535
- package/src/modules/databaseId/assets/aiOptimize.svg +0 -10
- package/src/modules/databaseId/assets/empty.png +0 -0
- package/src/modules/databaseId/assets/template.svg +0 -6
- package/src/modules/databaseId/assets/upload.svg +0 -9
- package/src/modules/databaseId/assets/useTemp.svg +0 -6
- package/src/modules/databaseId/index.tsx +0 -769
- package/src/modules/databaseId/server.ts +0 -286
- package/src/modules/databaseId/style.css +0 -5
- package/src/modules/databaseTable/EditRowDrawer.tsx +0 -124
- package/src/modules/databaseTable/index.tsx +0 -359
- package/src/modules/databaseTable/server.ts +0 -180
- package/src/modules/headlessChat/ReferenceBar.tsx +0 -783
- package/src/modules/headlessChat/constants.tsx +0 -54
- package/src/modules/headlessChat/index.tsx +0 -1706
- package/src/modules/headlessChat/referenceCom/DeleteModal.tsx +0 -75
- package/src/modules/headlessChat/referenceCom/DrawerContent.tsx +0 -136
- package/src/modules/headlessChat/referenceCom/DrawerDatabase.tsx +0 -102
- package/src/modules/headlessChat/referenceCom/DrawerGraphPreview.tsx +0 -86
- package/src/modules/headlessChat/referenceCom/DrawerPreview.tsx +0 -73
- package/src/modules/headlessChat/referenceCom/DrawerTitle.tsx +0 -26
- package/src/modules/headlessChat/referenceCom/RenameModal.tsx +0 -86
- package/src/modules/headlessChat/referenceCom/TagCom.tsx +0 -30
- package/src/modules/headlessChat/style.less +0 -3
- package/src/modules/headlessChat/types.ts +0 -23
- package/src/modules/headlessChat/utils/index.ts +0 -348
- package/src/modules/login/components/Login/LoginBox/index.tsx +0 -102
- package/src/modules/login/components/Login/RegisterBox/index.tsx +0 -180
- package/src/modules/login/components/Login/index.tsx +0 -100
- package/src/modules/login/index.tsx +0 -106
- package/src/modules/login/style.css +0 -3
- package/src/modules/login/useServices.ts +0 -53
- package/src/modules/login/utils.ts +0 -42
- package/src/modules/modelManage/ConfigDrawer.tsx +0 -249
- package/src/modules/modelManage/ReplaceModal.tsx +0 -124
- package/src/modules/modelManage/assets/empty.png +0 -0
- package/src/modules/modelManage/const.ts +0 -51
- package/src/modules/modelManage/index.tsx +0 -606
- package/src/modules/modelManage/server.ts +0 -223
- package/src/modules/nodegraph/index.tsx +0 -1
- package/src/modules/search/assets/Icon-history.svg +0 -8
- 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 +0 -9
- package/src/modules/search/assets/icon-search-bar.svg +0 -14
- package/src/modules/search/assets/icon-sub-title.svg +0 -3
- package/src/modules/search/assets/icon-title.svg +0 -9
- package/src/modules/search/assets/icon-zoomOut.svg +0 -9
- package/src/modules/search/assets/iconAi.svg +0 -9
- 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 +0 -3
- package/src/modules/search/assets/selected.svg +0 -4
- 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 +0 -137
- package/src/modules/search/components/Editor/ChatViewEditor.tsx +0 -261
- package/src/modules/search/components/Editor/aichat.css +0 -1
- package/src/modules/search/components/Editor/constant.ts +0 -13
- package/src/modules/search/components/Editor/index.tsx +0 -113
- package/src/modules/search/components/Editor/plugins/autofomatRules.ts +0 -332
- package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +0 -20
- package/src/modules/search/components/Editor/plugins/createIndexes.tsx +0 -38
- package/src/modules/search/components/Editor/plugins/displayer.ts +0 -298
- package/src/modules/search/components/Editor/plugins/imageClick.tsx +0 -32
- package/src/modules/search/components/Editor/plugins/myplugin.tsx +0 -98
- package/src/modules/search/components/Editor/ui/avatar.tsx +0 -19
- package/src/modules/search/components/Editor/ui/blockquote-element.tsx +0 -21
- package/src/modules/search/components/Editor/ui/button.tsx +0 -58
- package/src/modules/search/components/Editor/ui/calendar.tsx +0 -68
- package/src/modules/search/components/Editor/ui/caption.tsx +0 -46
- package/src/modules/search/components/Editor/ui/checkbox.tsx +0 -27
- package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +0 -188
- package/src/modules/search/components/Editor/ui/code-block-element.css +0 -434
- package/src/modules/search/components/Editor/ui/code-block-element.tsx +0 -39
- package/src/modules/search/components/Editor/ui/code-leaf.tsx +0 -24
- package/src/modules/search/components/Editor/ui/code-line-element.tsx +0 -10
- package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +0 -21
- package/src/modules/search/components/Editor/ui/column-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/column-group-element.tsx +0 -94
- package/src/modules/search/components/Editor/ui/command.tsx +0 -75
- package/src/modules/search/components/Editor/ui/comment-avatar.tsx +0 -22
- package/src/modules/search/components/Editor/ui/comment-create-form.tsx +0 -37
- package/src/modules/search/components/Editor/ui/comment-item.tsx +0 -74
- package/src/modules/search/components/Editor/ui/comment-leaf.tsx +0 -49
- package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +0 -42
- package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +0 -22
- package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +0 -32
- package/src/modules/search/components/Editor/ui/comment-value.tsx +0 -34
- package/src/modules/search/components/Editor/ui/comments-popover.tsx +0 -63
- package/src/modules/search/components/Editor/ui/date-element.tsx +0 -83
- package/src/modules/search/components/Editor/ui/dialog.tsx +0 -63
- package/src/modules/search/components/Editor/ui/draggable.tsx +0 -177
- package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +0 -180
- package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +0 -85
- package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +0 -28
- package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +0 -76
- package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +0 -8
- package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +0 -51
- package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +0 -77
- package/src/modules/search/components/Editor/ui/heading-element.tsx +0 -48
- package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +0 -17
- package/src/modules/search/components/Editor/ui/hr-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/icons.tsx +0 -267
- package/src/modules/search/components/Editor/ui/image-element.tsx +0 -74
- package/src/modules/search/components/Editor/ui/inline-combobox.tsx +0 -368
- package/src/modules/search/components/Editor/ui/input.tsx +0 -25
- package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +0 -218
- package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +0 -20
- package/src/modules/search/components/Editor/ui/link-element.tsx +0 -29
- package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +0 -161
- package/src/modules/search/components/Editor/ui/list-element.tsx +0 -30
- package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +0 -24
- package/src/modules/search/components/Editor/ui/media-embed-element.tsx +0 -133
- package/src/modules/search/components/Editor/ui/media-popover.tsx +0 -97
- package/src/modules/search/components/Editor/ui/mention-element.tsx +0 -43
- package/src/modules/search/components/Editor/ui/mention-input-element.tsx +0 -141
- package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +0 -93
- package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +0 -67
- package/src/modules/search/components/Editor/ui/paragraph-element.tsx +0 -4
- package/src/modules/search/components/Editor/ui/placeholder.tsx +0 -52
- package/src/modules/search/components/Editor/ui/popover.tsx +0 -32
- package/src/modules/search/components/Editor/ui/resizable.tsx +0 -66
- package/src/modules/search/components/Editor/ui/separator.tsx +0 -25
- package/src/modules/search/components/Editor/ui/style.less +0 -12
- package/src/modules/search/components/Editor/ui/table-cell-element.tsx +0 -143
- package/src/modules/search/components/Editor/ui/table-element.tsx +0 -243
- package/src/modules/search/components/Editor/ui/table-row-element.tsx +0 -22
- package/src/modules/search/components/Editor/ui/tableValue.tsx +0 -135
- package/src/modules/search/components/Editor/ui/todo-list-element.tsx +0 -43
- package/src/modules/search/components/Editor/ui/toggle-element.tsx +0 -31
- package/src/modules/search/components/Editor/ui/toolbar.tsx +0 -157
- package/src/modules/search/components/Editor/ui/tooltip.tsx +0 -65
- package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +0 -160
- package/src/modules/search/components/Editor/ui/with-draggables.tsx +0 -175
- package/src/modules/search/components/FileList.tsx +0 -287
- package/src/modules/search/components/ImageGroupView/index.tsx +0 -85
- package/src/modules/search/components/ResultContent.tsx +0 -232
- package/src/modules/search/components/SearchInput.tsx +0 -232
- package/src/modules/search/components/SearchLanding.tsx +0 -74
- package/src/modules/search/components/SearchView.tsx +0 -563
- package/src/modules/search/components/SimpleEditor.tsx +0 -158
- package/src/modules/search/components/SimpleFileList.tsx +0 -215
- package/src/modules/search/index.tsx +0 -10
- package/src/modules/search/reademe.md +0 -1
- package/src/modules/search/servers/apis.tsx +0 -19
- package/src/modules/search/servers/index.ts +0 -184
- package/src/modules/search/style.less +0 -503
- package/src/modules/search/type.ts +0 -22
- package/src/modules/search/utils.ts +0 -34
- package/src/modules/sensitive/index.tsx +0 -313
- package/src/modules/sensitive/server.ts +0 -122
- package/src/modules/streamFilesReader/GientechStreamReader.tsx +0 -1625
- package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
- package/src/modules/streamFilesReader/components/Header/index.tsx +0 -297
- package/src/modules/streamFilesReader/index.tsx +0 -3
- package/src/style.css +0 -6
- package/src/type.d.ts +0 -0
- package/src/utils/commonFn.tsx +0 -111
- package/src/utils/decryptApiKey.ts +0 -40
- package/src/utils/gientechCommon/components/AppError.tsx +0 -32
- package/src/utils/gientechCommon/components/AppLoading.tsx +0 -75
- package/src/utils/gientechCommon/components/DeleteModal.tsx +0 -75
- package/src/utils/gientechCommon/components/DisplayError.tsx +0 -33
- package/src/utils/gientechCommon/components/DisplayLoading.tsx +0 -38
- package/src/utils/gientechCommon/components/FeedBackModal.tsx +0 -319
- package/src/utils/gientechCommon/components/FileCardCommon.tsx +0 -82
- package/src/utils/gientechCommon/components/FileManager/index.tsx +0 -400
- package/src/utils/gientechCommon/components/FileManager/style.css +0 -5
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +0 -581
- package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +0 -359
- package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +0 -245
- package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +0 -209
- package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
- package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +0 -148
- package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +0 -14
- package/src/utils/gientechCommon/components/RenameModal.tsx +0 -86
- package/src/utils/gientechCommon/components/style.less +0 -11
- package/src/utils/gientechCommon/configs/commonConfig.ts +0 -2
- package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
- package/src/utils/gientechCommon/configs/stylesConfig.ts +0 -142
- package/src/utils/gientechCommon/hooks/AichatUseController.tsx +0 -417
- package/src/utils/gientechCommon/hooks/useFileDisplayTools.tsx +0 -204
- package/src/utils/gientechCommon/hooks/useFileManager.ts +0 -193
- package/src/utils/gientechCommon/slate/converters/deserializers.ts +0 -763
- package/src/utils/gientechCommon/slate/converters/mockData.ts +0 -232
- package/src/utils/gientechCommon/slate/converters/slateConverters.ts +0 -258
- package/src/utils/gientechCommon/slate/richElements/index.tsx +0 -499
- package/src/utils/gientechCommon/utils/fileUtils.ts +0 -86
- package/src/utils/gientechCommon/utils/request.ts +0 -37
- package/src/utils/gientechCommon/utils/serverFn.ts +0 -172
- package/src/utils/index.tsx +0 -142
- package/src/utils/testconfigs/demologin/index.tsx +0 -32
- package/src/utils/testconfigs/index.ts +0 -59
- package/src/vite-env.d.ts +0 -42
- package/stats.html +0 -4949
- package/tailwind.config.js +0 -170
- package/tsconfig.app.json +0 -30
- package/tsconfig.app.tsbuildinfo +0 -11
- package/tsconfig.json +0 -13
- package/tsconfig.node.json +0 -22
- package/tsconfig.node.tsbuildinfo +0 -1
- package/vite.config.app.ts +0 -93
- package/vite.config.ts +0 -232
- package/workflows/release.yml +0 -60
- 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 +0 -359
- /package/{dist/assets → assets}/Doris.png +0 -0
- /package/{dist/assets → assets}/PostgreSQL.png +0 -0
- /package/{dist/assets → assets}/SQLServer.png +0 -0
- /package/{dist/assets → assets}/database.svg +0 -0
- /package/{dist/assets → assets}/database_add.svg +0 -0
- /package/{dist/assets → assets}/database_connect.svg +0 -0
- /package/{dist/assets → assets}/database_upload.svg +0 -0
- /package/{dist/assets → assets}/databse.svg +0 -0
- /package/{dist/assets → assets}/defaultWeLogo.svg +0 -0
- /package/{dist/assets → assets}/empty.png +0 -0
- /package/{dist/assets → assets}/graph.svg +0 -0
- /package/{dist/assets → assets}/homeBg.png +0 -0
- /package/{dist/assets → assets}/index-B2yNvzjy.js +0 -0
- /package/{dist/assets → assets}/index-BKe5FgcC.js +0 -0
- /package/{dist/assets → assets}/index-CpW6Dhpp.js +0 -0
- /package/{dist/assets → assets}/index-D72cKELw.js +0 -0
- /package/{dist/assets → assets}/index-DdVFXD_y.js +0 -0
- /package/{dist/assets → assets}/index-DrkSoKz6.js +0 -0
- /package/{dist/assets → assets}/index-ZopkeZtI.js +0 -0
- /package/{dist/assets → assets}/index-g-SUxfJH.js +0 -0
- /package/{dist/assets → assets}/index-j0kQJd0a.js +0 -0
- /package/{dist/assets → assets}/knowledge.svg +0 -0
- /package/{dist/assets → assets}/left.jpg +0 -0
- /package/{dist/assets → assets}/logoImg.png +0 -0
- /package/{dist/assets → assets}/mysql.svg +0 -0
- /package/{dist/assets → assets}/plus-V9zUoSq6.js +0 -0
- /package/{dist/assets → assets}/sensitive.svg +0 -0
- /package/{dist/assets → assets}/style-CGmZ5osp.js +0 -0
- /package/{dist/assets → assets}/style2.css +0 -0
- /package/{dist/assets → assets}/style3.css +0 -0
- /package/{dist/assets → assets}/worker-BbpylX7l.js +0 -0
- /package/{dist/assets → assets}/x-CnaaLGJF.js +0 -0
- /package/{dist/assistantConfig.d.ts → assistantConfig.d.ts} +0 -0
- /package/{dist/assistantConfig.js → assistantConfig.js} +0 -0
- /package/{dist/chat.d.ts → chat.d.ts} +0 -0
- /package/{dist/database.d.ts → database.d.ts} +0 -0
- /package/{dist/database.js → database.js} +0 -0
- /package/{dist/databaseId.d.ts → databaseId.d.ts} +0 -0
- /package/{dist/databaseTable.d.ts → databaseTable.d.ts} +0 -0
- /package/{dist/databaseTable.js → databaseTable.js} +0 -0
- /package/{dist/icons → icons}/answerAwartar.png +0 -0
- /package/{dist/icons → icons}/docx-file.png +0 -0
- /package/{dist/icons → icons}/folder.png +0 -0
- /package/{dist/icons → icons}/html.png +0 -0
- /package/{dist/icons → icons}/image.png +0 -0
- /package/{dist/icons → icons}/jpg-file.png +0 -0
- /package/{dist/icons → icons}/json.png +0 -0
- /package/{dist/icons → icons}/md.png +0 -0
- /package/{dist/icons → icons}/pdf.png +0 -0
- /package/{dist/icons → icons}/pptx.png +0 -0
- /package/{dist/icons → icons}/questionAwartar.png +0 -0
- /package/{dist/icons → icons}/sheets.png +0 -0
- /package/{dist/icons → icons}/txt.png +0 -0
- /package/{dist/icons → icons}/xlsx.png +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/modelManage.d.ts → modelManage.d.ts} +0 -0
- /package/{dist/modelManage.js → modelManage.js} +0 -0
- /package/{dist/sensitive.d.ts → sensitive.d.ts} +0 -0
- /package/{dist/sensitive.js → sensitive.js} +0 -0
- /package/{dist/streamFilesReader.d.ts → streamFilesReader.d.ts} +0 -0
- /package/{dist/vite.svg → vite.svg} +0 -0
- /package/{dist/worker → worker}/pdf.worker.min.js +0 -0
|
@@ -1,581 +0,0 @@
|
|
|
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;
|