@gientech/modual 2.2.3-fix.5 → 2.2.3-fix.6
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/CHANGELOG.md +162 -0
- package/Dockerfile +15 -0
- package/README.md +761 -761
- package/USAGE.md +247 -0
- package/bash.exe.stackdump +40 -0
- package/components.json +21 -0
- package/default.conf +19 -0
- package/dist/README.md +761 -0
- package/{assets/GientechStreamReader-r5ZTSZk2.js → dist/assets/GientechStreamReader-Bae2-4f7.js} +1 -1
- package/{assets/LeftOutlined-DZMeGbKk.js → dist/assets/LeftOutlined-COk0w5nY.js} +1 -1
- package/{assets/circle-plus-B73z_SUN.js → dist/assets/circle-plus-DOKqXUMk.js} +1 -1
- package/{assets → dist/assets}/database.svg +11 -11
- package/{assets → dist/assets}/database_add.svg +53 -53
- package/{assets → dist/assets}/database_connect.svg +66 -66
- package/{assets → dist/assets}/database_upload.svg +29 -29
- package/{assets → dist/assets}/databse.svg +6 -6
- package/{assets → dist/assets}/defaultWeLogo.svg +14 -14
- package/{assets → dist/assets}/graph.svg +4 -4
- package/{assets → dist/assets}/iconAi.svg +9 -9
- package/dist/assets/index-1PwCuRjv.js +1061 -0
- package/dist/assets/index-7QvYA6eT.js +1 -0
- package/{assets/index-97Oe7YBe.js → dist/assets/index-BKbpfN9S.js} +1 -1
- package/{assets/index-B4k3tK0f.js → dist/assets/index-BXdyn2W3.js} +1 -1
- package/dist/assets/index-BhUNGJOe.js +27 -0
- package/{assets/index-BDc2zBbG.js → dist/assets/index-Bin0NZwF.js} +3 -7
- package/{assets/index-DHK_n74G.js → dist/assets/index-CpSzj-Sx.js} +73 -58
- package/{assets/index-usBlUHOb.js → dist/assets/index-Ct_k24Ar.js} +1 -1
- package/dist/assets/index-DT3qkjJ3.js +750 -0
- package/dist/assets/index-lFBFf_0k.js +1890 -0
- package/{assets/index-iOuQJ8vu.js → dist/assets/index-vfI1_Qg0.js} +1 -1
- package/{assets → dist/assets}/knowledge.svg +4 -4
- package/{assets → dist/assets}/mysql.svg +14 -14
- package/{assets → dist/assets}/sensitive.svg +5 -5
- package/{assets/style-6bvhg-jh.js → dist/assets/style-CfNUqKAA.js} +7 -7
- package/dist/assets/style2.css +1 -0
- package/dist/assets/style5.css +1 -0
- package/{assets/triangle-alert-C4Z1AkGW.js → dist/assets/triangle-alert-CaJaaCaZ.js} +1 -1
- package/{assets/x-DWGzNb9c.js → dist/assets/x-B65AntWN.js} +1 -1
- package/{assistantConfig.js → dist/assistantConfig.js} +9 -14
- package/dist/chat.js +1 -0
- package/dist/chatCompare.js +1 -0
- package/dist/database.js +20 -0
- package/{databaseId.js → dist/databaseId.js} +1 -1
- package/{databaseTable.js → dist/databaseTable.js} +1 -1
- package/dist/index.js +1 -0
- package/dist/modelManage.js +1 -0
- package/dist/package.json +73 -0
- package/{sensitive.js → dist/sensitive.js} +6 -6
- package/dist/streamFilesReader.js +1 -0
- package/{worker → dist/worker}/pdf.worker.min.js +21 -21
- 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//346/226/271/346/241/210/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/doc_assets//346/226/271/346/241/210//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/eslint.config.js +92 -0
- package/index.html +13 -0
- package/package.json +125 -44
- 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/rag/assets/index.Bd0tNzw0.js +2797 -0
- package/rag/assets/index.D6t67hlu.css +1 -0
- package/rag/assets/left.KBHV5h7q.jpg +0 -0
- package/rag/assets/worker-BbpylX7l.DptbXke_.js +13 -0
- package/release-it.json +21 -0
- package/scripts/README.md +133 -0
- package/scripts/build-demo.js +88 -0
- package/scripts/check-changelog.cjs +124 -0
- package/scripts/check-version.cjs +49 -0
- package/scripts/decrypt-api-key.js +95 -0
- package/scripts/demo-selector.js +216 -0
- package/scripts/dev-demo.js +85 -0
- package/scripts/open-file.cjs +61 -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/iconAi.svg +9 -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/search.svg +3 -0
- package/src/assets/img/selected.svg +4 -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 +42 -0
- package/src/examples/LoginPage/index.tsx +20 -0
- package/src/examples/chat/components/DrawerGraphPreview.tsx +78 -0
- package/src/examples/chat/index.tsx +171 -0
- package/src/examples/chat/logo03.png +0 -0
- package/src/examples/chatCompare/icons/rag_think.svg +8 -0
- package/src/examples/chatCompare/icons/wenda_lianwangsousuo.svg +9 -0
- package/src/examples/chatCompare/index.tsx +154 -0
- package/src/examples/gientechStreamFilesReader/index.tsx +979 -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 +298 -0
- package/src/examples/knowledgebaseDetails/index.tsx +119 -0
- package/src/examples/ragDatabaseDataPage/index.tsx +40 -0
- package/src/examples/ragDatabaseIdPage/index.tsx +126 -0
- package/src/examples/ragDatabasePage/index.tsx +36 -0
- package/src/examples/ragModelManagePage/index.tsx +107 -0
- package/src/examples/ragModelManagePage/style.css +7 -0
- package/src/examples/ragSearchPage/index.tsx +0 -0
- package/src/examples/ragSensitiveWordsPage/index.tsx +117 -0
- package/src/examples/ragSensitiveWordsPage/style.css +16 -0
- package/src/examples/sensitiveId/index.tsx +41 -0
- package/src/examples/streamFiles/index.tsx +417 -0
- package/src/examples/utils/demo_setting_pannel.ts +0 -0
- package/src/lib_enter.ts +44 -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 +40 -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 +66 -0
- package/src/modules/assistantConfig/constants.tsx +75 -0
- package/src/modules/assistantConfig/index.tsx +785 -0
- package/src/modules/assistantConfig/server.ts +262 -0
- package/src/modules/chat/AllFiles.tsx +158 -0
- package/src/modules/chat/Conversations/Item.tsx +169 -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 +255 -0
- package/src/modules/chat/ReferenceBar.tsx +659 -0
- package/src/modules/chat/constants.tsx +66 -0
- package/src/modules/chat/i18n.ts +151 -0
- package/src/modules/chat/i18n.tsx +151 -0
- package/src/modules/chat/icons/rag_think.svg +8 -0
- package/src/modules/chat/icons/wenda_lianwangsousuo.svg +9 -0
- package/src/modules/chat/index.tsx +2400 -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.css +6 -0
- package/src/modules/chat/style.less +7 -0
- package/src/modules/chat/types.ts +17 -0
- package/src/modules/chat/utils/index.ts +348 -0
- package/src/modules/chatCompare/UseChatCompareHooks.ts +103 -0
- package/src/modules/chatCompare/components/AichatCompareUseController.tsx +754 -0
- package/src/modules/chatCompare/components/AssistantSelector.tsx +127 -0
- package/src/modules/chatCompare/components/ChatInputer.tsx +67 -0
- package/src/modules/chatCompare/components/ChatInstance.tsx +426 -0
- package/src/modules/chatCompare/components/ChatItem.tsx +556 -0
- package/src/modules/chatCompare/components/Sender/FileCardCommon.tsx +97 -0
- package/src/modules/chatCompare/components/Sender/FileUpload.tsx +89 -0
- package/src/modules/chatCompare/components/Sender/FilesDisplay.tsx +309 -0
- package/src/modules/chatCompare/components/Sender/VoiceInput.tsx +80 -0
- package/src/modules/chatCompare/components/Sender/contexts/BadgeContext.tsx +36 -0
- package/src/modules/chatCompare/components/Sender/fileIcon.tsx +100 -0
- package/src/modules/chatCompare/components/Sender/index.tsx +850 -0
- package/src/modules/chatCompare/components/UseChatInstanceHooks.ts +406 -0
- package/src/modules/chatCompare/components/UseScrollHooks.ts +36 -0
- package/src/modules/chatCompare/components/components/AllFiles.tsx +156 -0
- package/src/modules/chatCompare/components/components/DeleteModal.tsx +75 -0
- package/src/modules/chatCompare/components/components/DrawerContent.tsx +138 -0
- package/src/modules/chatCompare/components/components/DrawerDatabase.tsx +110 -0
- package/src/modules/chatCompare/components/components/DrawerGraphPreview.tsx +95 -0
- package/src/modules/chatCompare/components/components/DrawerPreview.tsx +75 -0
- package/src/modules/chatCompare/components/components/DrawerTitle.tsx +26 -0
- package/src/modules/chatCompare/components/components/DrawerVideo.tsx +85 -0
- package/src/modules/chatCompare/components/components/ReferenceBar.tsx +659 -0
- package/src/modules/chatCompare/components/components/RenameModal.tsx +86 -0
- package/src/modules/chatCompare/components/components/TagCom.tsx +30 -0
- package/src/modules/chatCompare/components/defaultStyleSet.tsx +148 -0
- package/src/modules/chatCompare/components/server.ts +208 -0
- package/src/modules/chatCompare/components/serverFn.ts +172 -0
- package/src/modules/chatCompare/components/style.less +97 -0
- package/src/modules/chatCompare/components/useFileManager.ts +173 -0
- package/src/modules/chatCompare/components/utils.ts +31 -0
- package/src/modules/chatCompare/data.ts +842 -0
- package/src/modules/chatCompare/index.tsx +537 -0
- package/src/modules/chatCompare/utils/AiChat.types.tsx +110 -0
- package/src/modules/chatCompare/utils/constants.tsx +70 -0
- package/src/modules/chatCompare/utils/fileUploadValidator.ts +183 -0
- package/src/modules/chatCompare/utils/icons/rag_think.svg +8 -0
- package/src/modules/chatCompare/utils/icons/wenda_lianwangsousuo.svg +9 -0
- package/src/modules/chatCompare/utils/index.ts +46 -0
- package/src/modules/database/CreateModal.tsx +402 -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/i18n.ts +360 -0
- package/src/modules/databaseId/index.tsx +855 -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 +1903 -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/knowledgeBase/index.tsx +58 -0
- package/src/modules/knowledgeBase/server.ts +196 -0
- package/src/modules/knowledgebaseDetails/KnowledgeBaseDetails.tsx +169 -0
- package/src/modules/knowledgebaseDetails/components/KnowledgeBaseSummaryCard.tsx +193 -0
- package/src/modules/knowledgebaseDetails/components/fileManagementParts.tsx +534 -0
- package/src/modules/knowledgebaseDetails/components/index.ts +3 -0
- package/src/modules/knowledgebaseDetails/index.ts +3 -0
- package/src/modules/knowledgebaseDetails/modules/ConfigModule.tsx +49 -0
- package/src/modules/knowledgebaseDetails/modules/FaqModule.tsx +47 -0
- package/src/modules/knowledgebaseDetails/modules/KnowledgeParseModule.tsx +771 -0
- package/src/modules/knowledgebaseDetails/modules/RetrievalTestModule.tsx +49 -0
- package/src/modules/knowledgebaseDetails/modules/UploadManagementModule.tsx +49 -0
- package/src/modules/knowledgebaseDetails/modules/types.ts +44 -0
- package/src/modules/knowledgebaseDetails/modules-shim.d.ts +14 -0
- package/src/modules/knowledgebaseDetails/servers/analysis.ts +5 -0
- package/src/modules/knowledgebaseDetails/servers/index.ts +318 -0
- package/src/modules/login/components/Login/LoginBox/index.tsx +105 -0
- package/src/modules/login/components/Login/RegisterBox/index.tsx +181 -0
- package/src/modules/login/components/Login/index.tsx +100 -0
- package/src/modules/login/i18n.ts +217 -0
- package/src/modules/login/index.tsx +113 -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 +267 -0
- package/src/modules/modelManage/ReplaceModal.tsx +113 -0
- package/src/modules/modelManage/assets/empty.png +0 -0
- package/src/modules/modelManage/const.ts +51 -0
- package/src/modules/modelManage/i18n.ts +407 -0
- package/src/modules/modelManage/index.tsx +668 -0
- package/src/modules/modelManage/server.ts +231 -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/i18n.ts +391 -0
- package/src/modules/sensitive/index.tsx +604 -0
- package/src/modules/sensitive/sensitiveEditor.tsx +543 -0
- package/src/modules/sensitive/server.ts +197 -0
- package/src/modules/sensitiveId/AutoTag.tsx +311 -0
- package/src/modules/sensitiveId/UploadModal.tsx +181 -0
- package/src/modules/sensitiveId/VirtualWrap.tsx +125 -0
- package/src/modules/sensitiveId/index.tsx +253 -0
- package/src/modules/sensitiveId/server.ts +142 -0
- package/src/modules/streamFilesReader/GientechStreamReader.tsx +1658 -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 +153 -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 +583 -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 +761 -0
- package/src/utils/gientechCommon/hooks/style.less +8 -0
- package/src/utils/gientechCommon/hooks/useFileDisplayTools.tsx +352 -0
- package/src/utils/gientechCommon/hooks/useFileManager.ts +169 -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/index.ts +386 -0
- package/src/utils/gientechCommon/utils/request.ts +37 -0
- package/src/utils/gientechCommon/utils/serverFn.ts +172 -0
- package/src/utils/index.tsx +186 -0
- package/src/utils/testconfigs/demologin/index.tsx +32 -0
- package/src/utils/testconfigs/index.ts +66 -0
- package/src/vite-env.d.ts +49 -0
- package/stats.html +4949 -0
- package/tailwind.config.js +170 -0
- package/tsconfig.app.json +31 -0
- package/tsconfig.app.tsbuildinfo +11 -0
- package/tsconfig.json +17 -0
- package/tsconfig.node.json +23 -0
- package/tsconfig.node.tsbuildinfo +1 -0
- package/vite.config.app.ts +91 -0
- package/vite.config.ts +238 -0
- package/assets/index-BIEKgWu0.js +0 -27
- package/assets/index-C1tyXsqQ.js +0 -943
- package/assets/index-CzZQWA2P.js +0 -1
- package/assets/index-DPA1HCWQ.js +0 -1372
- package/assets/index-DPyRygOA.js +0 -745
- package/assets/plus-BICgMvz9.js +0 -6
- package/assets/search-CD5YKija.js +0 -6
- package/assets/style2.css +0 -1
- package/assets/style5.css +0 -1
- package/chat.js +0 -1
- package/chatCompare.js +0 -1
- package/database.js +0 -20
- package/index.js +0 -1
- package/modelManage.js +0 -1
- package/streamFilesReader.js +0 -1
- /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}/empty.png +0 -0
- /package/{assets → dist/assets}/homeBg.png +0 -0
- /package/{assets → dist/assets}/index-CpW6Dhpp.js +0 -0
- /package/{assets → dist/assets}/left.jpg +0 -0
- /package/{assets → dist/assets}/logoImg.png +0 -0
- /package/{assets → dist/assets}/style.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/{assistantConfig.d.ts → dist/assistantConfig.d.ts} +0 -0
- /package/{chat.d.ts → dist/chat.d.ts} +0 -0
- /package/{chatCompare.d.ts → dist/chatCompare.d.ts} +0 -0
- /package/{database.d.ts → dist/database.d.ts} +0 -0
- /package/{databaseId.d.ts → dist/databaseId.d.ts} +0 -0
- /package/{databaseTable.d.ts → dist/databaseTable.d.ts} +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/{sensitive.d.ts → dist/sensitive.d.ts} +0 -0
- /package/{streamFilesReader.d.ts → dist/streamFilesReader.d.ts} +0 -0
- /package/{vite.svg → dist/vite.svg} +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { message } from 'antd';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
const specialErrorCodes = ['10014'];
|
|
4
|
+
|
|
5
|
+
type IDataSourceType = 'DataTable' | 'DirectDB';
|
|
6
|
+
|
|
7
|
+
export interface SensitiveApiProps {
|
|
8
|
+
url?: string;
|
|
9
|
+
token?: string;
|
|
10
|
+
role?: string;
|
|
11
|
+
/** 由调用方传入,用于 i18n 错误提示兜底 */
|
|
12
|
+
getMessage?: (key: string) => string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** 敏感词模块业务 Server 约定接口(推荐由外部注入以便复用、mock) */
|
|
16
|
+
export interface SensitiveServer {
|
|
17
|
+
getLibraryList: (params: any) => Promise<any>;
|
|
18
|
+
createLibrary: (params: any) => Promise<any>;
|
|
19
|
+
deleteLibrary: (id: any) => Promise<any>;
|
|
20
|
+
/** 更新敏感词库(如 name、words) */
|
|
21
|
+
updateLibrary: (id: string, params: { name?: string; words?: string[] }) => Promise<any>;
|
|
22
|
+
/** 下载导入模板(GET,带 token),返回 Blob 用于前端触发下载 */
|
|
23
|
+
downloadTemplate: (fileType: 'csv' | 'txt') => Promise<Blob | false>;
|
|
24
|
+
/** 导入敏感词文件:PUT FormData(file),路径 /sensitive/word/:id/import */
|
|
25
|
+
importWords: (libraryId: string, file: File) => Promise<any>;
|
|
26
|
+
getWords : (id: any) => Promise<any>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const AxiosInstance = ({ url, token, role, getMessage }: SensitiveApiProps): SensitiveServer => {
|
|
30
|
+
const fallback = (key: string, def: string) => (getMessage ? getMessage(key) : def);
|
|
31
|
+
const axios$ = axios.create({
|
|
32
|
+
baseURL: url,
|
|
33
|
+
// 配置请求超时时间
|
|
34
|
+
timeout: 1000000,
|
|
35
|
+
});
|
|
36
|
+
// 请求拦截
|
|
37
|
+
axios$.interceptors.request.use((config: any) => {
|
|
38
|
+
let target_cookie = token;
|
|
39
|
+
|
|
40
|
+
const noA = ['user/login', 'user/kaptcha', 'user/regist'];
|
|
41
|
+
// dangerous behaviour
|
|
42
|
+
if (!target_cookie && !noA.some((item: string) => config.url.includes(item))) {
|
|
43
|
+
window.location.pathname = '/login';
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
config.headers.Authorization = target_cookie || '';
|
|
48
|
+
// 这里传中文会报错
|
|
49
|
+
config.headers.userName = role === '未登录用户' ? '' : role;
|
|
50
|
+
// config.headers.userId = roleId;
|
|
51
|
+
return config;
|
|
52
|
+
});
|
|
53
|
+
// 返回拦截
|
|
54
|
+
axios$.interceptors.response.use(
|
|
55
|
+
response => {
|
|
56
|
+
// 获取接口返回结果
|
|
57
|
+
const noA = ['user/kaptcha'];
|
|
58
|
+
const res = response.data;
|
|
59
|
+
if (noA.some((item: string) => response.config.url && response.config.url.includes(item))) {
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
if (res.size && res.type) {
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
const { success, errorMsg, errorCode } = res;
|
|
66
|
+
// 处理特殊错误码的情况,页面自己处理错误,例如上传文件重复
|
|
67
|
+
if (specialErrorCodes.includes(errorCode)) {
|
|
68
|
+
return res;
|
|
69
|
+
}
|
|
70
|
+
if (success) return res;
|
|
71
|
+
message.error(errorMsg || fallback('server.requestError', '请求出错,请稍后再试'));
|
|
72
|
+
return false;
|
|
73
|
+
},
|
|
74
|
+
error => {
|
|
75
|
+
// 主动取消请求,不给报错信息
|
|
76
|
+
if (error.message === 'canceled') {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (
|
|
80
|
+
error?.response?.data?.errorCode === '30013' ||
|
|
81
|
+
error?.response?.data?.errorCode === '30023'
|
|
82
|
+
) {
|
|
83
|
+
message.error((error?.response?.data || {}).errorMsg || fallback('server.requestError', '请求出错,请稍后再试'));
|
|
84
|
+
// location.pathname = '/login';
|
|
85
|
+
}
|
|
86
|
+
if (error?.response?.status === 401) {
|
|
87
|
+
console.log('Error url:', error?.request?.responseURL);
|
|
88
|
+
message.error((error?.response?.data || {}).errorMsg || fallback('server.noPermission', '没有足够权限'));
|
|
89
|
+
//window.location.pathname = "/login";
|
|
90
|
+
}
|
|
91
|
+
console.log('Error occurs', error);
|
|
92
|
+
if ('未设置默认配置!' != (error?.response?.data || {}).errorMsg) {
|
|
93
|
+
message.error((error?.response?.data || {}).errorMsg || fallback('server.requestError', '请求出错,请稍后再试'));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
const getLibraryList = async (params: any) => {
|
|
98
|
+
try {
|
|
99
|
+
const res: any = await axios$.get(`/sensitive/library?${new URLSearchParams(params).toString()}`);
|
|
100
|
+
const { success, data } = res;
|
|
101
|
+
if (success) return data;
|
|
102
|
+
return false;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
console.log('e', e);
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const createLibrary = async (params: any) => {
|
|
110
|
+
try {
|
|
111
|
+
const res: any = await axios$.post(`/sensitive/library`, params);
|
|
112
|
+
const { success, data } = res;
|
|
113
|
+
if (success) return data;
|
|
114
|
+
return false;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
console.log('e', e);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const deleteLibrary = async (id: any) => {
|
|
122
|
+
try {
|
|
123
|
+
const res: any = await axios$.delete(`/sensitive/library/${id}`);
|
|
124
|
+
const { success, data } = res;
|
|
125
|
+
if (success) return data;
|
|
126
|
+
return false;
|
|
127
|
+
} catch (e) {
|
|
128
|
+
console.log('e', e);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const updateLibrary = async (id: string, params: { name?: string; words?: string[] }) => {
|
|
134
|
+
try {
|
|
135
|
+
const res: any = await axios$.put(`/sensitive/library/${id}`, params);
|
|
136
|
+
const { success, data } = res;
|
|
137
|
+
if (success) return data;
|
|
138
|
+
return false;
|
|
139
|
+
} catch (e) {
|
|
140
|
+
console.log('e', e);
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/** 下载导入模板:GET 请求,走当前 axios 实例(baseURL 已含用户传入的 proxy),路径仅 /sensitive/word/downloadTemplate */
|
|
146
|
+
const downloadTemplate = async (fileType: 'csv' | 'txt'): Promise<Blob | false> => {
|
|
147
|
+
try {
|
|
148
|
+
const res: any = await axios$.get('/sensitive/word/downloadTemplate', {
|
|
149
|
+
params: { fileType },
|
|
150
|
+
responseType: 'blob',
|
|
151
|
+
});
|
|
152
|
+
if (res && typeof res.size === 'number') return res as Blob;
|
|
153
|
+
return false;
|
|
154
|
+
} catch (e) {
|
|
155
|
+
console.log('e', e);
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/** 导入敏感词文件:PUT /sensitive/word/:libraryId/import,FormData 字段 file(binary),不设 Content-Type 由 axios 自动带 boundary */
|
|
161
|
+
const importWords = async (libraryId: string, file: File): Promise<any> => {
|
|
162
|
+
try {
|
|
163
|
+
const formData = new FormData();
|
|
164
|
+
formData.append('file', file);
|
|
165
|
+
const res: any = await axios$.put(`/sensitive/word/${libraryId}/import`, formData);
|
|
166
|
+
if (res && res.success !== false) return res;
|
|
167
|
+
return false;
|
|
168
|
+
} catch (e) {
|
|
169
|
+
console.log('e', e);
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const getWords = async (id: string) => {
|
|
175
|
+
try {
|
|
176
|
+
const res: any = await axios$.get(`/sensitive/library/${id}`);
|
|
177
|
+
const { success, data } = res;
|
|
178
|
+
if (success) return data;
|
|
179
|
+
return false;
|
|
180
|
+
} catch (e) {
|
|
181
|
+
console.log('e', e);
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
getLibraryList,
|
|
188
|
+
createLibrary,
|
|
189
|
+
deleteLibrary,
|
|
190
|
+
updateLibrary,
|
|
191
|
+
downloadTemplate,
|
|
192
|
+
importWords,
|
|
193
|
+
getWords
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export default AxiosInstance;
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { X, Plus } from 'lucide-react';
|
|
3
|
+
import type { InputRef } from "antd";
|
|
4
|
+
import { Input, message, Tag, theme } from "antd";
|
|
5
|
+
import VirtualWrap from "./VirtualWrap";
|
|
6
|
+
import { debounce } from "../../utils/commonFn"
|
|
7
|
+
|
|
8
|
+
const FONT_SIZE = 12;
|
|
9
|
+
const INPUT_WIDTH = 64;
|
|
10
|
+
const ADD_TAG_TYPE = "add_tab_20250208";
|
|
11
|
+
|
|
12
|
+
const canvas = document.createElement("canvas");
|
|
13
|
+
interface AutoTagInterface {
|
|
14
|
+
wrapRef?: any;
|
|
15
|
+
tags: string[];
|
|
16
|
+
setTags: (arg: string[]) => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
fuzzyNameOrId?: string;
|
|
19
|
+
addLabel?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const AutoTag = ({
|
|
23
|
+
tags,
|
|
24
|
+
setTags,
|
|
25
|
+
disabled,
|
|
26
|
+
fuzzyNameOrId,
|
|
27
|
+
addLabel,
|
|
28
|
+
wrapRef = null
|
|
29
|
+
}: AutoTagInterface) => {
|
|
30
|
+
const { token } = theme.useToken();
|
|
31
|
+
const [inputVisible, setInputVisible] = useState(false);
|
|
32
|
+
const [editInputIndex, setEditInputIndex] = useState(-1);
|
|
33
|
+
const [editInitVal, setEditInitVal] = useState<string>("");
|
|
34
|
+
const inputRef = useRef<InputRef>(null);
|
|
35
|
+
const editInputRef = useRef<InputRef>(null);
|
|
36
|
+
const tagInputStyle: React.CSSProperties = {
|
|
37
|
+
width: INPUT_WIDTH,
|
|
38
|
+
height: 32,
|
|
39
|
+
marginInlineEnd: 8,
|
|
40
|
+
verticalAlign: "top",
|
|
41
|
+
fontSize: FONT_SIZE,
|
|
42
|
+
lineHeight: 30,
|
|
43
|
+
minWidth: INPUT_WIDTH
|
|
44
|
+
};
|
|
45
|
+
const [containerHeight, setContainerHeight] = useState<number>(0);
|
|
46
|
+
const [containerWidth, setContainerWidth] = useState<number>(0);
|
|
47
|
+
const [canvasContext, setCanvasContext] = useState<any>(
|
|
48
|
+
canvas.getContext("2d")
|
|
49
|
+
);
|
|
50
|
+
const [virtualList, setVirtualList] = useState<Array<any>>([]);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
setContainerRect();
|
|
54
|
+
}, [wrapRef]);
|
|
55
|
+
|
|
56
|
+
const handleClose = (removedTag: string) => () => {
|
|
57
|
+
const newTags = tags.filter((tag) => tag.trim() !== removedTag);
|
|
58
|
+
setTags(newTags);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const showInput = () => {
|
|
62
|
+
setInputVisible(true);
|
|
63
|
+
setTimeout(() => inputRef.current?.focus(), 0);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const getStrLenght = (str: string) => {
|
|
67
|
+
let totalLength = 0;
|
|
68
|
+
|
|
69
|
+
for (let i = 0; i < str.length; i++) {
|
|
70
|
+
// 判断当前字符是字母还是数字
|
|
71
|
+
if (/[a-zA-Z0-9]/.test(str[i])) {
|
|
72
|
+
totalLength += 1.2; // 字母和数字长度为1
|
|
73
|
+
} else {
|
|
74
|
+
// 其他字符(比如汉字、emoji等)长度为2
|
|
75
|
+
totalLength += 2;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (FONT_SIZE / 2) * totalLength + 30;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleInputConfirm = (e: any) => {
|
|
83
|
+
const _value = e.target.value.trim();
|
|
84
|
+
if (_value && !tags.includes(_value)) {
|
|
85
|
+
setTags([...tags, _value.slice(0, 16)]);
|
|
86
|
+
}
|
|
87
|
+
setInputVisible(false);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const handleEditInputConfirm = (e: any) => {
|
|
91
|
+
const _value = e.target.value.trim();
|
|
92
|
+
if (_value) {
|
|
93
|
+
const newTags = [...tags];
|
|
94
|
+
newTags[editInputIndex] = _value.slice(0, 16);
|
|
95
|
+
setTags(newTags);
|
|
96
|
+
setEditInputIndex(-1);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const tagPlusStyle: React.CSSProperties = {
|
|
101
|
+
height: 32,
|
|
102
|
+
background: token.colorBgContainer,
|
|
103
|
+
borderStyle: "dashed",
|
|
104
|
+
borderColor: "#D9D9D9",
|
|
105
|
+
padding: "0 15px",
|
|
106
|
+
lineHeight: "32px",
|
|
107
|
+
fontSize: FONT_SIZE,
|
|
108
|
+
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const handleIptChange = debounce((e: React.ChangeEvent<HTMLInputElement>) => {
|
|
112
|
+
const _value = e.target.value.trim();
|
|
113
|
+
const editIpt = editInputRef.current;
|
|
114
|
+
if (_value.length >= 16 && editIpt && editIpt.input) {
|
|
115
|
+
message.warning("敏感词最多可输入16个字符!");
|
|
116
|
+
}
|
|
117
|
+
}, 300);
|
|
118
|
+
|
|
119
|
+
const getTextWidth = (
|
|
120
|
+
text: string,
|
|
121
|
+
fontSize = 12,
|
|
122
|
+
fontFamily = "PingFangSC,微软雅黑,Helvetic"
|
|
123
|
+
) => {
|
|
124
|
+
canvasContext.font = `${fontSize}px ${fontFamily}`;
|
|
125
|
+
return canvasContext.measureText(text).width;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const RenderRow = (props: any) => {
|
|
129
|
+
const { item } = props;
|
|
130
|
+
const { list } = item;
|
|
131
|
+
return (
|
|
132
|
+
<div className="mb-4">
|
|
133
|
+
{list && list.length
|
|
134
|
+
? list.map((i: any, index: number) => (
|
|
135
|
+
<span key={`tag_wrap_${index}`}>{renderTag(i)}</span>
|
|
136
|
+
))
|
|
137
|
+
: null}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const editTag = (label: string, idx: number) => (e: any) => {
|
|
143
|
+
if (disabled) return;
|
|
144
|
+
setEditInputIndex(idx);
|
|
145
|
+
setEditInitVal(label);
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const setEditIptWidth = () => {
|
|
150
|
+
const editIpt = editInputRef.current;
|
|
151
|
+
if (editIpt && editIpt.input) {
|
|
152
|
+
editIpt.input.style.width = `${getStrLenght(editIpt.input.value.slice(0, 16))}px`;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const setAddIptWidth = () => {
|
|
156
|
+
const addIpt = inputRef.current;
|
|
157
|
+
if (addIpt && addIpt.input) {
|
|
158
|
+
addIpt.input.style.width = `${getStrLenght(addIpt.input.value.slice(0, 16))}px`;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const editIptOnInput = debounce(setEditIptWidth, 200);
|
|
163
|
+
|
|
164
|
+
const addIptOnInput = debounce(setAddIptWidth, 200);
|
|
165
|
+
|
|
166
|
+
const renderTag = (tagData: any) => {
|
|
167
|
+
const { idx, label } = tagData;
|
|
168
|
+
return editInputIndex === idx ? (
|
|
169
|
+
<Input
|
|
170
|
+
ref={editInputRef}
|
|
171
|
+
key={`edit-ipt-${idx}`}
|
|
172
|
+
maxLength={16}
|
|
173
|
+
size="small"
|
|
174
|
+
style={tagInputStyle}
|
|
175
|
+
defaultValue={editInitVal}
|
|
176
|
+
onInput={editIptOnInput}
|
|
177
|
+
onBlur={handleEditInputConfirm}
|
|
178
|
+
onPressEnter={handleEditInputConfirm}
|
|
179
|
+
onChange={handleIptChange}
|
|
180
|
+
/>
|
|
181
|
+
) : label === ADD_TAG_TYPE ? (
|
|
182
|
+
inputVisible ? (
|
|
183
|
+
<Input
|
|
184
|
+
ref={inputRef}
|
|
185
|
+
type="text"
|
|
186
|
+
size="small"
|
|
187
|
+
maxLength={16}
|
|
188
|
+
style={tagInputStyle}
|
|
189
|
+
onInput={addIptOnInput}
|
|
190
|
+
onBlur={handleInputConfirm}
|
|
191
|
+
onPressEnter={handleInputConfirm}
|
|
192
|
+
onChange={handleIptChange}
|
|
193
|
+
/>
|
|
194
|
+
) : (
|
|
195
|
+
<Tag
|
|
196
|
+
icon={<Plus size={14} className="inline mr-[6px] mt-[-4px]" />}
|
|
197
|
+
color="processing"
|
|
198
|
+
style={tagPlusStyle}
|
|
199
|
+
onClick={showInput}
|
|
200
|
+
>
|
|
201
|
+
{addLabel || "添加"}
|
|
202
|
+
</Tag>
|
|
203
|
+
)
|
|
204
|
+
) : (
|
|
205
|
+
<Tag
|
|
206
|
+
key={`tag_${idx}`}
|
|
207
|
+
style={{
|
|
208
|
+
userSelect: "none",
|
|
209
|
+
height: "32px",
|
|
210
|
+
lineHeight: "30px",
|
|
211
|
+
padding: "0 15px",
|
|
212
|
+
fontSize: `${FONT_SIZE}px`,
|
|
213
|
+
background: "white",
|
|
214
|
+
borderColor: "#EBEBEB"
|
|
215
|
+
}}
|
|
216
|
+
closable={!disabled}
|
|
217
|
+
onClose={handleClose(label)}
|
|
218
|
+
// closeIcon={<X />}
|
|
219
|
+
>
|
|
220
|
+
<span onDoubleClick={editTag(label, idx)}>{label}</span>
|
|
221
|
+
</Tag>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const setContainerRect = () => {
|
|
226
|
+
if (wrapRef && wrapRef.current) {
|
|
227
|
+
const { height, width } = wrapRef.current.getBoundingClientRect();
|
|
228
|
+
setContainerHeight(height);
|
|
229
|
+
setContainerWidth(width);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
const filterTags = useMemo(() => {
|
|
234
|
+
return (tags || []).concat(ADD_TAG_TYPE).filter((tag) => {
|
|
235
|
+
return fuzzyNameOrId ? tag.indexOf(fuzzyNameOrId) > -1 : true;
|
|
236
|
+
});
|
|
237
|
+
}, [tags, fuzzyNameOrId]);
|
|
238
|
+
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
if (containerWidth && containerHeight && filterTags && filterTags.length) {
|
|
241
|
+
fixRenderData();
|
|
242
|
+
}
|
|
243
|
+
}, [filterTags, containerHeight, containerWidth]);
|
|
244
|
+
|
|
245
|
+
const resizeFn = debounce(() => {
|
|
246
|
+
setContainerRect();
|
|
247
|
+
}, 500);
|
|
248
|
+
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
window.addEventListener("resize", resizeFn);
|
|
251
|
+
return () => {
|
|
252
|
+
window.removeEventListener("resize", resizeFn);
|
|
253
|
+
};
|
|
254
|
+
}, []);
|
|
255
|
+
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
if (editInputIndex >= 0) {
|
|
258
|
+
setEditIptWidth();
|
|
259
|
+
setTimeout(() => {
|
|
260
|
+
editInputRef.current?.focus();
|
|
261
|
+
}, 100);
|
|
262
|
+
}
|
|
263
|
+
}, [editInputIndex]);
|
|
264
|
+
|
|
265
|
+
const fixRenderData = () => {
|
|
266
|
+
const _list: Array<any> = [];
|
|
267
|
+
let _row: Array<any> = [];
|
|
268
|
+
let len: number = 0;
|
|
269
|
+
const tagMargin = 18;
|
|
270
|
+
const fixWidth = 49 + tagMargin;
|
|
271
|
+
// console.log("fixRenderData", containerWidth)
|
|
272
|
+
filterTags.forEach((str: string, idx: number) => {
|
|
273
|
+
const _str = str.trim();
|
|
274
|
+
const strWidth = getTextWidth(_str);
|
|
275
|
+
const tagWidth = strWidth + fixWidth;
|
|
276
|
+
const obj = {
|
|
277
|
+
idx,
|
|
278
|
+
label: _str
|
|
279
|
+
};
|
|
280
|
+
if (len + tagWidth > containerWidth) {
|
|
281
|
+
_list.push({ idx, list: [..._row] });
|
|
282
|
+
_row = [{ ...obj }];
|
|
283
|
+
len = tagWidth;
|
|
284
|
+
} else {
|
|
285
|
+
len = len + tagWidth;
|
|
286
|
+
_row.push({ ...obj });
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
_list.push({ idx: _list.length + 1, list: [..._row] });
|
|
290
|
+
setVirtualList([..._list]);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const res = useMemo(() => {
|
|
294
|
+
return virtualList.length ? (
|
|
295
|
+
<VirtualWrap
|
|
296
|
+
list={virtualList}
|
|
297
|
+
itemHeight={22}
|
|
298
|
+
paddingY={12}
|
|
299
|
+
wrapPadding={32}
|
|
300
|
+
wrapperRef={wrapRef}
|
|
301
|
+
itemKey="idx"
|
|
302
|
+
>
|
|
303
|
+
<RenderRow />
|
|
304
|
+
</VirtualWrap>
|
|
305
|
+
) : null;
|
|
306
|
+
}, [virtualList, editInputIndex, inputVisible]);
|
|
307
|
+
|
|
308
|
+
return <>{res}</>;
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
export default AutoTag;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Modal,
|
|
3
|
+
Form,
|
|
4
|
+
UploadProps,
|
|
5
|
+
UploadFile,
|
|
6
|
+
ConfigProvider,
|
|
7
|
+
message, Upload
|
|
8
|
+
} from "antd";
|
|
9
|
+
import { ReactNode, useEffect, useState } from "react";
|
|
10
|
+
import { Button, defaultTheme, type Styles } from '@mxmweb/zui';
|
|
11
|
+
const { Dragger } = Upload;
|
|
12
|
+
import warningLinear from "../../assets/img/warningLinear.png";
|
|
13
|
+
import upload from "../../assets/img/upload.png";
|
|
14
|
+
import File from "../../assets/img/file.png";
|
|
15
|
+
|
|
16
|
+
interface IEmpty {
|
|
17
|
+
isShowCreateModal: boolean;
|
|
18
|
+
closeModal: (isRefresh: boolean) => void;
|
|
19
|
+
uploadType?: string;
|
|
20
|
+
uploadEvents: (action: string, payload?: any) => void;
|
|
21
|
+
accept?: string;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
footerChildren?: ReactNode;
|
|
24
|
+
title?: string | ReactNode;
|
|
25
|
+
// UploadFile: (id: string, formData: FormData) => void
|
|
26
|
+
multiple?: boolean;
|
|
27
|
+
subTitle?: string;
|
|
28
|
+
fileName?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const UploadModal = (props: IEmpty) => {
|
|
32
|
+
const {
|
|
33
|
+
isShowCreateModal,
|
|
34
|
+
closeModal,
|
|
35
|
+
uploadEvents,
|
|
36
|
+
children,
|
|
37
|
+
accept = ".csv,.txt",
|
|
38
|
+
title,
|
|
39
|
+
// UploadFile,
|
|
40
|
+
multiple = true,
|
|
41
|
+
subTitle = "支持单次上传,支持 csv、txt格式。",
|
|
42
|
+
fileName = "file"
|
|
43
|
+
} = props;
|
|
44
|
+
const [createForm] = Form.useForm();
|
|
45
|
+
const [loading, setLoading] = useState(false);
|
|
46
|
+
|
|
47
|
+
const [fileList, setFileList]: any = useState<UploadFile[]>([]);
|
|
48
|
+
const modalStyles = {
|
|
49
|
+
header: {
|
|
50
|
+
padding: "20px 24px",
|
|
51
|
+
borderBottom: "1px solid #F0F0F0",
|
|
52
|
+
margin: 0
|
|
53
|
+
},
|
|
54
|
+
body: { padding: "16px 24px 20px 24px", borderBottom: "1px solid #F0F0F0" },
|
|
55
|
+
mask: {},
|
|
56
|
+
footer: { padding: "16px 24px", margin: 0 },
|
|
57
|
+
content: { padding: 0, borderRadius: "4px" }
|
|
58
|
+
};
|
|
59
|
+
const successFn = () => {
|
|
60
|
+
closeModal(false);
|
|
61
|
+
setLoading(false);
|
|
62
|
+
createForm.resetFields();
|
|
63
|
+
uploadEvents("uploaded");
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const handlerCancle = () => {
|
|
67
|
+
createForm.resetFields();
|
|
68
|
+
closeModal(false);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handleOk = async () => {
|
|
72
|
+
const formData = new FormData();
|
|
73
|
+
fileList.forEach((file: any) => {
|
|
74
|
+
formData.append(fileName, file);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
setLoading(true);
|
|
78
|
+
uploadEvents("uploaded", formData);
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
};
|
|
82
|
+
const upLoadProps: UploadProps = {
|
|
83
|
+
multiple,
|
|
84
|
+
fileList,
|
|
85
|
+
onRemove: (file) => {
|
|
86
|
+
setFileList((fileList: any) => {
|
|
87
|
+
const fileListIds = fileList.map((item: any) => item.uid);
|
|
88
|
+
const index = fileListIds.indexOf(file.uid);
|
|
89
|
+
const newFileList = fileList.slice();
|
|
90
|
+
newFileList.splice(index, 1);
|
|
91
|
+
return [...newFileList];
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
beforeUpload(file) {
|
|
95
|
+
if (fileList.length) {
|
|
96
|
+
message.warning("只能上传一个文件");
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
setFileList((fileList: any) => {
|
|
100
|
+
return [...fileList, file];
|
|
101
|
+
});
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const renderFooter = () => {
|
|
107
|
+
return (
|
|
108
|
+
<div className="flex justify-end gap-3">
|
|
109
|
+
<Button
|
|
110
|
+
label="取消"
|
|
111
|
+
onClick={handlerCancle}
|
|
112
|
+
/>
|
|
113
|
+
<Button
|
|
114
|
+
mode="primary"
|
|
115
|
+
label="确认"
|
|
116
|
+
loading={loading}
|
|
117
|
+
onClick={handleOk}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!isShowCreateModal) {
|
|
125
|
+
setFileList([]);
|
|
126
|
+
}
|
|
127
|
+
}, [isShowCreateModal]);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<ConfigProvider
|
|
131
|
+
modal={{
|
|
132
|
+
styles: modalStyles
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<Modal
|
|
136
|
+
title={title || "上传文件"}
|
|
137
|
+
open={isShowCreateModal}
|
|
138
|
+
footer={renderFooter}
|
|
139
|
+
onCancel={handlerCancle}
|
|
140
|
+
width={650}
|
|
141
|
+
>
|
|
142
|
+
<div className="">
|
|
143
|
+
<div className="h-[44px] bg-[#E6F4FF] flex items-center px-[12px] mb-[10px] rounded-[4px] justify-between">
|
|
144
|
+
<div className="flex items-center">
|
|
145
|
+
<img
|
|
146
|
+
src={warningLinear}
|
|
147
|
+
width={24}
|
|
148
|
+
height={24}
|
|
149
|
+
className="mr-[8px]"
|
|
150
|
+
/>
|
|
151
|
+
<div className="text-text-color1">先下载模板后上传</div>
|
|
152
|
+
</div>
|
|
153
|
+
{children}
|
|
154
|
+
</div>
|
|
155
|
+
<Dragger
|
|
156
|
+
{...upLoadProps}
|
|
157
|
+
accept={accept}
|
|
158
|
+
iconRender={() => {
|
|
159
|
+
return <img src={File} width={12} height={12} />;
|
|
160
|
+
}}
|
|
161
|
+
style={{ backgroundColor: "#F9FAFC", borderColor: "#D9D9D9" }}
|
|
162
|
+
>
|
|
163
|
+
<div className="flex flex-col items-center">
|
|
164
|
+
<img src={upload} width={48} height={48} />
|
|
165
|
+
<p className="mt-[12px] text-[14px] text-text-color1 mb-[4px]">
|
|
166
|
+
点击或将文件拖拽到此处上传
|
|
167
|
+
</p>
|
|
168
|
+
<span style={{ color: "#999", fontSize: "12px", fontWeight: 400 }}>
|
|
169
|
+
{subTitle}
|
|
170
|
+
</span>
|
|
171
|
+
</div>
|
|
172
|
+
|
|
173
|
+
</Dragger>
|
|
174
|
+
</div>
|
|
175
|
+
<div className="btn-group"></div>
|
|
176
|
+
</Modal>
|
|
177
|
+
</ConfigProvider>
|
|
178
|
+
);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export default UploadModal;
|