@gientech/modual 1.3.2 → 1.3.3

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.
Files changed (309) hide show
  1. package/.editorconfig +38 -0
  2. package/.prettierignore +16 -0
  3. package/.prettierrc +17 -0
  4. package/README.md +129 -129
  5. package/USAGE.md +191 -0
  6. package/bash.exe.stackdump +40 -0
  7. package/components.json +21 -0
  8. package/dist/README.md +129 -0
  9. package/{assets → dist/assets}/database.svg +11 -11
  10. package/{assets → dist/assets}/database_add.svg +53 -53
  11. package/{assets → dist/assets}/database_connect.svg +66 -66
  12. package/{assets → dist/assets}/database_upload.svg +29 -29
  13. package/{assets → dist/assets}/defaultWeLogo.svg +14 -14
  14. package/{assets/index-ldqIbm0x.js → dist/assets/index-XvC_4jDB.js} +106 -101
  15. package/{assets/index-D-dGaGjW.js → dist/assets/index-mPgEc8KC.js} +288 -102
  16. package/{assets/MySQL.svg → dist/assets/mysql.svg} +14 -14
  17. package/dist/assets/style.css +1 -0
  18. package/dist/assets/style3.css +1 -0
  19. package/{chat.js → dist/chat.js} +78 -78
  20. package/dist/database.js +20 -0
  21. package/{databaseId.js → dist/databaseId.js} +1 -1
  22. package/{databaseTable.js → dist/databaseTable.js} +1 -1
  23. package/{modelManage.js → dist/modelManage.js} +1 -1
  24. package/dist/package.json +56 -0
  25. package/{sensitive.js → dist/sensitive.js} +1 -1
  26. package/{streamFilesReader.js → dist/streamFilesReader.js} +11 -11
  27. package/{worker → dist/worker}/pdf.worker.min.js +21 -21
  28. package/doc_assets/2.png +0 -0
  29. package/doc_assets/demo.md +27 -0
  30. package/doc_assets/demos/dist-app/assets/index.Dh-ZAS9Z.css +2 -0
  31. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js +23699 -0
  32. package/doc_assets/demos/dist-app/assets/index.Dv8KVW18.js.map +1 -0
  33. package/doc_assets/demos/dist-app/index.html +14 -0
  34. package/doc_assets/demos/dist-app/vite.svg +1 -0
  35. package/doc_assets/images/1.png +0 -0
  36. package/doc_assets/images/3.png +0 -0
  37. package/doc_assets/images/component-screenshot.png +1 -0
  38. package/doc_assets/install.md +5 -0
  39. package/eslint.config.js +92 -0
  40. package/index.html +13 -0
  41. package/package.json +83 -39
  42. package/postcss.config.cjs +19 -0
  43. package/public/vite.svg +1 -0
  44. package/public/worker/pdf.worker.min.js +22 -0
  45. package/scripts/README.md +133 -0
  46. package/scripts/build-demo.js +88 -0
  47. package/scripts/demo-selector.js +216 -0
  48. package/scripts/dev-demo.js +76 -0
  49. package/scripts/preview-demo.js +130 -0
  50. package/scripts/run-demo.bat +34 -0
  51. package/src/assets/img/downArrow.png +0 -0
  52. package/src/assets/img/excel.png +0 -0
  53. package/src/assets/img/img.png +0 -0
  54. package/src/assets/img/pdf.png +0 -0
  55. package/src/assets/img/ppt.png +0 -0
  56. package/src/assets/img/txt.png +0 -0
  57. package/src/assets/img/word.png +0 -0
  58. package/src/assets/login/homeBg.png +0 -0
  59. package/src/assets/login/left.jpg +0 -0
  60. package/src/assets/login/logoImg.png +0 -0
  61. package/src/examples/LoginPage/index.tsx +18 -0
  62. package/src/examples/aaa/index.tsx +3758 -0
  63. package/src/examples/chat/components/DrawerGraphPreview.tsx +78 -0
  64. package/src/examples/chat/index.tsx +190 -0
  65. package/src/examples/gientechStreamFilesReader/index.tsx +1016 -0
  66. package/src/examples/ragDatabaseDataPage/index.tsx +36 -0
  67. package/src/examples/ragDatabaseIdPage/index.tsx +44 -0
  68. package/src/examples/ragDatabasePage/index.tsx +36 -0
  69. package/src/examples/ragModelManagePage/index.tsx +37 -0
  70. package/src/examples/ragSearchPage/index.tsx +0 -0
  71. package/src/examples/ragSensitiveWordsPage/index.tsx +32 -0
  72. package/src/examples/streamFiles/index.tsx +384 -0
  73. package/src/lib_enter.ts +38 -0
  74. package/src/main.tsx +5 -0
  75. package/src/main.tsx.backup +5 -0
  76. package/src/modules/chat/Conversations/Item.tsx +167 -0
  77. package/src/modules/chat/Conversations/List.tsx +143 -0
  78. package/src/modules/chat/Conversations/groupByTime.ts +39 -0
  79. package/src/modules/chat/Conversations/index.tsx +212 -0
  80. package/src/modules/chat/constants.tsx +33 -0
  81. package/src/modules/chat/data.txt +82 -0
  82. package/src/modules/chat/index.tsx +1908 -0
  83. package/src/modules/chat/types.ts +17 -0
  84. package/src/modules/database/CreateModal.tsx +398 -0
  85. package/src/modules/database/assets/Doris.png +0 -0
  86. package/src/modules/database/assets/PostgreSQL.png +0 -0
  87. package/src/modules/database/assets/SQLServer.png +0 -0
  88. package/src/modules/database/assets/database.svg +11 -0
  89. package/src/modules/database/assets/database_add.svg +53 -0
  90. package/src/modules/database/assets/database_connect.svg +66 -0
  91. package/src/modules/database/assets/database_upload.svg +29 -0
  92. package/src/modules/database/assets/empty.png +0 -0
  93. package/src/modules/database/assets/mysql.svg +14 -0
  94. package/src/modules/database/index.tsx +466 -0
  95. package/src/modules/database/server.ts +196 -0
  96. package/src/modules/databaseId/CustomCom.tsx +156 -0
  97. package/src/modules/databaseId/EditConfig.tsx +268 -0
  98. package/src/modules/databaseId/UploadDrawer.tsx +520 -0
  99. package/src/modules/databaseId/assets/aiOptimize.svg +10 -0
  100. package/src/modules/databaseId/assets/empty.png +0 -0
  101. package/src/modules/databaseId/assets/template.svg +6 -0
  102. package/src/modules/databaseId/assets/upload.svg +9 -0
  103. package/src/modules/databaseId/assets/useTemp.svg +6 -0
  104. package/src/modules/databaseId/index.tsx +734 -0
  105. package/src/modules/databaseId/server.ts +286 -0
  106. package/src/modules/databaseId/style.css +5 -0
  107. package/src/modules/databaseTable/EditRowDrawer.tsx +119 -0
  108. package/src/modules/databaseTable/index.tsx +357 -0
  109. package/src/modules/databaseTable/server.ts +180 -0
  110. package/src/modules/headlessChat/constants.tsx +32 -0
  111. package/src/modules/headlessChat/index.tsx +1065 -0
  112. package/src/modules/headlessChat/types.ts +23 -0
  113. package/src/modules/login/components/Login/LoginBox/index.tsx +102 -0
  114. package/src/modules/login/components/Login/RegisterBox/index.tsx +180 -0
  115. package/src/modules/login/components/Login/index.tsx +100 -0
  116. package/src/modules/login/index.tsx +106 -0
  117. package/src/modules/login/style.css +3 -0
  118. package/src/modules/login/useServices.ts +53 -0
  119. package/src/modules/login/utils.ts +42 -0
  120. package/src/modules/modelManage/ConfigDrawer.tsx +249 -0
  121. package/src/modules/modelManage/assets/empty.png +0 -0
  122. package/src/modules/modelManage/const.ts +50 -0
  123. package/src/modules/modelManage/index.tsx +439 -0
  124. package/src/modules/modelManage/server.ts +185 -0
  125. package/src/modules/nodegraph/index.tsx +1 -0
  126. package/src/modules/search/assets/Icon-history.svg +8 -0
  127. package/src/modules/search/assets/answerAwartar.png +0 -0
  128. package/src/modules/search/assets/doc.png +0 -0
  129. package/src/modules/search/assets/genera.gif +0 -0
  130. package/src/modules/search/assets/icon-robot.svg +9 -0
  131. package/src/modules/search/assets/icon-search-bar.svg +14 -0
  132. package/src/modules/search/assets/icon-sub-title.svg +3 -0
  133. package/src/modules/search/assets/icon-title.svg +9 -0
  134. package/src/modules/search/assets/icon-zoomOut.svg +9 -0
  135. package/src/modules/search/assets/iconAi.svg +9 -0
  136. package/src/modules/search/assets/pdf.png +0 -0
  137. package/src/modules/search/assets/ppt.png +0 -0
  138. package/src/modules/search/assets/search.svg +3 -0
  139. package/src/modules/search/assets/selected.svg +4 -0
  140. package/src/modules/search/assets/txt.png +0 -0
  141. package/src/modules/search/assets/xls.png +0 -0
  142. package/src/modules/search/components/AssisSelect.tsx +137 -0
  143. package/src/modules/search/components/Editor/ChatViewEditor.tsx +261 -0
  144. package/src/modules/search/components/Editor/aichat.css +1 -0
  145. package/src/modules/search/components/Editor/constant.ts +13 -0
  146. package/src/modules/search/components/Editor/index.tsx +113 -0
  147. package/src/modules/search/components/Editor/plugins/autofomatRules.ts +332 -0
  148. package/src/modules/search/components/Editor/plugins/convertImgPlugins.tsx +20 -0
  149. package/src/modules/search/components/Editor/plugins/createIndexes.tsx +38 -0
  150. package/src/modules/search/components/Editor/plugins/displayer.ts +298 -0
  151. package/src/modules/search/components/Editor/plugins/imageClick.tsx +32 -0
  152. package/src/modules/search/components/Editor/plugins/myplugin.tsx +98 -0
  153. package/src/modules/search/components/Editor/ui/avatar.tsx +19 -0
  154. package/src/modules/search/components/Editor/ui/blockquote-element.tsx +21 -0
  155. package/src/modules/search/components/Editor/ui/button.tsx +58 -0
  156. package/src/modules/search/components/Editor/ui/calendar.tsx +68 -0
  157. package/src/modules/search/components/Editor/ui/caption.tsx +46 -0
  158. package/src/modules/search/components/Editor/ui/checkbox.tsx +27 -0
  159. package/src/modules/search/components/Editor/ui/code-block-combobox.tsx +188 -0
  160. package/src/modules/search/components/Editor/ui/code-block-element.css +434 -0
  161. package/src/modules/search/components/Editor/ui/code-block-element.tsx +39 -0
  162. package/src/modules/search/components/Editor/ui/code-leaf.tsx +24 -0
  163. package/src/modules/search/components/Editor/ui/code-line-element.tsx +10 -0
  164. package/src/modules/search/components/Editor/ui/code-syntax-leaf.tsx +21 -0
  165. package/src/modules/search/components/Editor/ui/column-element.tsx +30 -0
  166. package/src/modules/search/components/Editor/ui/column-group-element.tsx +94 -0
  167. package/src/modules/search/components/Editor/ui/command.tsx +75 -0
  168. package/src/modules/search/components/Editor/ui/comment-avatar.tsx +22 -0
  169. package/src/modules/search/components/Editor/ui/comment-create-form.tsx +37 -0
  170. package/src/modules/search/components/Editor/ui/comment-item.tsx +74 -0
  171. package/src/modules/search/components/Editor/ui/comment-leaf.tsx +49 -0
  172. package/src/modules/search/components/Editor/ui/comment-more-dropdown.tsx +42 -0
  173. package/src/modules/search/components/Editor/ui/comment-reply-items.tsx +22 -0
  174. package/src/modules/search/components/Editor/ui/comment-resolve-button.tsx +32 -0
  175. package/src/modules/search/components/Editor/ui/comment-value.tsx +34 -0
  176. package/src/modules/search/components/Editor/ui/comments-popover.tsx +63 -0
  177. package/src/modules/search/components/Editor/ui/date-element.tsx +83 -0
  178. package/src/modules/search/components/Editor/ui/dialog.tsx +63 -0
  179. package/src/modules/search/components/Editor/ui/draggable.tsx +177 -0
  180. package/src/modules/search/components/Editor/ui/dropdown-menu.tsx +180 -0
  181. package/src/modules/search/components/Editor/ui/emoji-input-element.tsx +85 -0
  182. package/src/modules/search/components/Editor/ui/excalidraw-element.tsx +28 -0
  183. package/src/modules/search/components/Editor/ui/fixed-toolbar-buttons.tsx +76 -0
  184. package/src/modules/search/components/Editor/ui/fixed-toolbar.tsx +8 -0
  185. package/src/modules/search/components/Editor/ui/floating-toolbar-buttons.tsx +51 -0
  186. package/src/modules/search/components/Editor/ui/floating-toolbar.tsx +77 -0
  187. package/src/modules/search/components/Editor/ui/heading-element.tsx +48 -0
  188. package/src/modules/search/components/Editor/ui/highlight-leaf.tsx +17 -0
  189. package/src/modules/search/components/Editor/ui/hr-element.tsx +30 -0
  190. package/src/modules/search/components/Editor/ui/icons.tsx +267 -0
  191. package/src/modules/search/components/Editor/ui/image-element.tsx +74 -0
  192. package/src/modules/search/components/Editor/ui/inline-combobox.tsx +368 -0
  193. package/src/modules/search/components/Editor/ui/input.tsx +25 -0
  194. package/src/modules/search/components/Editor/ui/insert-dropdown-menu.tsx +218 -0
  195. package/src/modules/search/components/Editor/ui/kbd-leaf.tsx +20 -0
  196. package/src/modules/search/components/Editor/ui/link-element.tsx +29 -0
  197. package/src/modules/search/components/Editor/ui/link-floating-toolbar.tsx +161 -0
  198. package/src/modules/search/components/Editor/ui/list-element.tsx +30 -0
  199. package/src/modules/search/components/Editor/ui/mark-toolbar-button.tsx +24 -0
  200. package/src/modules/search/components/Editor/ui/media-embed-element.tsx +133 -0
  201. package/src/modules/search/components/Editor/ui/media-popover.tsx +97 -0
  202. package/src/modules/search/components/Editor/ui/mention-element.tsx +43 -0
  203. package/src/modules/search/components/Editor/ui/mention-input-element.tsx +141 -0
  204. package/src/modules/search/components/Editor/ui/mode-dropdown-menu.tsx +93 -0
  205. package/src/modules/search/components/Editor/ui/more-dropdown-menu.tsx +67 -0
  206. package/src/modules/search/components/Editor/ui/paragraph-element.tsx +4 -0
  207. package/src/modules/search/components/Editor/ui/placeholder.tsx +52 -0
  208. package/src/modules/search/components/Editor/ui/popover.tsx +32 -0
  209. package/src/modules/search/components/Editor/ui/resizable.tsx +66 -0
  210. package/src/modules/search/components/Editor/ui/separator.tsx +25 -0
  211. package/src/modules/search/components/Editor/ui/style.less +12 -0
  212. package/src/modules/search/components/Editor/ui/table-cell-element.tsx +143 -0
  213. package/src/modules/search/components/Editor/ui/table-element.tsx +243 -0
  214. package/src/modules/search/components/Editor/ui/table-row-element.tsx +22 -0
  215. package/src/modules/search/components/Editor/ui/tableValue.tsx +135 -0
  216. package/src/modules/search/components/Editor/ui/todo-list-element.tsx +43 -0
  217. package/src/modules/search/components/Editor/ui/toggle-element.tsx +31 -0
  218. package/src/modules/search/components/Editor/ui/toolbar.tsx +157 -0
  219. package/src/modules/search/components/Editor/ui/tooltip.tsx +65 -0
  220. package/src/modules/search/components/Editor/ui/turn-into-dropdown-menu.tsx +160 -0
  221. package/src/modules/search/components/Editor/ui/with-draggables.tsx +175 -0
  222. package/src/modules/search/components/FileList.tsx +287 -0
  223. package/src/modules/search/components/ImageGroupView/index.tsx +85 -0
  224. package/src/modules/search/components/ResultContent.tsx +232 -0
  225. package/src/modules/search/components/SearchInput.tsx +232 -0
  226. package/src/modules/search/components/SearchLanding.tsx +74 -0
  227. package/src/modules/search/components/SearchView.tsx +563 -0
  228. package/src/modules/search/components/SimpleEditor.tsx +158 -0
  229. package/src/modules/search/components/SimpleFileList.tsx +215 -0
  230. package/src/modules/search/index.tsx +10 -0
  231. package/src/modules/search/reademe.md +1 -0
  232. package/src/modules/search/servers/apis.tsx +19 -0
  233. package/src/modules/search/servers/index.ts +184 -0
  234. package/src/modules/search/style.less +503 -0
  235. package/src/modules/search/type.ts +22 -0
  236. package/src/modules/search/utils.ts +34 -0
  237. package/src/modules/sensitive/index.tsx +313 -0
  238. package/src/modules/sensitive/server.ts +122 -0
  239. package/src/modules/streamFilesReader/GientechStreamReader.tsx +1555 -0
  240. package/src/modules/streamFilesReader/components/Header/Toolbar.tsx +0 -0
  241. package/src/modules/streamFilesReader/components/Header/index.tsx +297 -0
  242. package/src/modules/streamFilesReader/index.tsx +3 -0
  243. package/src/style.css +6 -0
  244. package/src/type.d.ts +0 -0
  245. package/src/utils/commonFn.tsx +111 -0
  246. package/src/utils/gientechCommon/components/AppError.tsx +32 -0
  247. package/src/utils/gientechCommon/components/AppLoading.tsx +75 -0
  248. package/src/utils/gientechCommon/components/DeleteModal.tsx +75 -0
  249. package/src/utils/gientechCommon/components/DisplayError.tsx +33 -0
  250. package/src/utils/gientechCommon/components/DisplayLoading.tsx +38 -0
  251. package/src/utils/gientechCommon/components/FeedBackModal.tsx +310 -0
  252. package/src/utils/gientechCommon/components/FileCardCommon.tsx +82 -0
  253. package/src/utils/gientechCommon/components/FileManager/index.tsx +390 -0
  254. package/src/utils/gientechCommon/components/FileManager/style.css +5 -0
  255. package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +296 -0
  256. package/src/utils/gientechCommon/components/Messages/ReferenceCard.tsx +339 -0
  257. package/src/utils/gientechCommon/components/Messages/RetriveItem.tsx +245 -0
  258. package/src/utils/gientechCommon/components/Messages/WebRetriveItem.tsx +209 -0
  259. package/src/utils/gientechCommon/components/Messages/defaultBot.png +0 -0
  260. package/src/utils/gientechCommon/components/Messages/defaultStyleSet.tsx +148 -0
  261. package/src/utils/gientechCommon/components/Messages/defaultWeLogo.svg +14 -0
  262. package/src/utils/gientechCommon/components/RenameModal.tsx +86 -0
  263. package/src/utils/gientechCommon/components/style.less +11 -0
  264. package/src/utils/gientechCommon/configs/commonConfig.ts +2 -0
  265. package/src/utils/gientechCommon/configs/senderConfig.ts +0 -0
  266. package/src/utils/gientechCommon/configs/stylesConfig.ts +142 -0
  267. package/src/utils/gientechCommon/hooks/AichatUseController.tsx +345 -0
  268. package/src/utils/gientechCommon/slate/converters/deserializers.ts +763 -0
  269. package/src/utils/gientechCommon/slate/converters/mockData.ts +232 -0
  270. package/src/utils/gientechCommon/slate/converters/slateConverters.ts +258 -0
  271. package/src/utils/gientechCommon/slate/richElements/index.tsx +499 -0
  272. package/src/utils/gientechCommon/utils/request.ts +37 -0
  273. package/src/utils/gientechCommon/utils/serverFn.ts +172 -0
  274. package/src/utils/index.tsx +126 -0
  275. package/src/utils/testconfigs/demologin/index.tsx +32 -0
  276. package/src/utils/testconfigs/index.ts +53 -0
  277. package/src/vite-env.d.ts +11 -0
  278. package/stats.html +4949 -0
  279. package/tailwind.config.js +170 -0
  280. package/tsconfig.app.json +30 -0
  281. package/tsconfig.app.tsbuildinfo +11 -0
  282. package/tsconfig.json +13 -0
  283. package/tsconfig.node.json +22 -0
  284. package/tsconfig.node.tsbuildinfo +1 -0
  285. package/vite.config.ts +177 -0
  286. package/workflows/release.yml +60 -0
  287. package/assets/style.css +0 -1
  288. package/assets/style3.css +0 -1
  289. package/database.js +0 -20
  290. /package/{assets → dist/assets}/Doris.png +0 -0
  291. /package/{assets → dist/assets}/PostgreSQL.png +0 -0
  292. /package/{assets → dist/assets}/SQLServer.png +0 -0
  293. /package/{assets → dist/assets}/_commonjsHelpers-gnU0ypJ3.js +0 -0
  294. /package/{assets → dist/assets}/circle-alert-g2Y6zAjt.js +0 -0
  295. /package/{assets → dist/assets}/empty.png +0 -0
  296. /package/{assets → dist/assets}/index-CEK88UzR.js +0 -0
  297. /package/{assets → dist/assets}/index-CpW6Dhpp.js +0 -0
  298. /package/{assets → dist/assets}/plus-omCUN0e3.js +0 -0
  299. /package/{assets → dist/assets}/style2.css +0 -0
  300. /package/{assets → dist/assets}/styled-components.browser.esm-DPkS13KC.js +0 -0
  301. /package/{assets → dist/assets}/x-vPcWt3fC.js +0 -0
  302. /package/{chat.d.ts → dist/chat.d.ts} +0 -0
  303. /package/{database.d.ts → dist/database.d.ts} +0 -0
  304. /package/{databaseId.d.ts → dist/databaseId.d.ts} +0 -0
  305. /package/{databaseTable.d.ts → dist/databaseTable.d.ts} +0 -0
  306. /package/{modelManage.d.ts → dist/modelManage.d.ts} +0 -0
  307. /package/{sensitive.d.ts → dist/sensitive.d.ts} +0 -0
  308. /package/{streamFilesReader.d.ts → dist/streamFilesReader.d.ts} +0 -0
  309. /package/{vite.svg → dist/vite.svg} +0 -0
@@ -0,0 +1,439 @@
1
+ import React, { useMemo, useState, useEffect, useRef } from 'react';
2
+ import { message, Modal, Badge, Tooltip } from 'antd';
3
+ import { Plus } from 'lucide-react';
4
+ import { DashboardContainer, Styles, Button } from '@mxmweb/zui';
5
+ import { Xviwer, CustomComponents } from '@mxmweb/xviewer';
6
+
7
+ import EmptyImg from './assets/empty.png';
8
+ import AxiosInstance from './server';
9
+ import ConfigDrawer from './ConfigDrawer';
10
+ import { getStatusColor, statusArr, OPT_BTN } from './const';
11
+
12
+ import '@mxmweb/zui/style.css';
13
+
14
+ const { confirm } = Modal;
15
+
16
+ const initPage = {
17
+ pageNum: 1,
18
+ pageSize: 1000,
19
+ };
20
+ interface ModelManageViewProps {
21
+ url?: string;
22
+ token?: string;
23
+ role?: string;
24
+ styles?: Styles;
25
+ CustomComponents?: CustomComponents;
26
+ eventsEmit?: (name: string, data: any) => void;
27
+ getBtnDisabled?: (type: OPT_BTN, permission: number) => boolean;
28
+ }
29
+
30
+ const StatusComponent = (props: any) => {
31
+ const { value, cell } = props;
32
+ const color = getStatusColor(props.cell.statusType);
33
+ if (value == '不可用') {
34
+ return (
35
+ <Tooltip title={cell.errorMsg}>
36
+ <div className="flex items-center gap-2">
37
+ <Badge color={color} text={value} />
38
+ </div>
39
+ </Tooltip>
40
+ );
41
+ } else {
42
+ return <Badge color={color} text={value} />;
43
+ }
44
+ };
45
+
46
+ export default function ModelManageView(props: ModelManageViewProps) {
47
+ const { url, token, role, CustomComponents, eventsEmit, getBtnDisabled } = props;
48
+
49
+ const [status, setStatus] = useState<any>({
50
+ container: 'ready',
51
+ content: 'ready',
52
+ });
53
+
54
+ // 创建ref来访问核心组件实例
55
+ const coreRef = useRef<any>(null);
56
+ const [data, setData] = useState<
57
+ {
58
+ id: string;
59
+ data?: any[];
60
+ }[]
61
+ >();
62
+
63
+ // 抽屉状态管理
64
+ const [drawerVisible, setDrawerVisible] = useState(false);
65
+ const [drawerTitle, setDrawerTitle] = useState('');
66
+ const [modelInfo, setModelInfo] = useState<any>();
67
+
68
+ // 使用类型options
69
+ const [modelUseTypeOpt, setModelUseTypeOpt] = useState<{ label: string; value: string }[]>([]);
70
+ const [modelProtocolsOpt, setModelProtocolsOpt] = useState<{ label: string; value: string }[]>(
71
+ []
72
+ );
73
+ const {
74
+ getModelList,
75
+ delModelById,
76
+ createModel,
77
+ updateModelById,
78
+ getUseTypeList,
79
+ getModelProtocolsList,
80
+ } = AxiosInstance({
81
+ url,
82
+ token,
83
+ role,
84
+ eventsEmit: eventsEmit,
85
+ });
86
+
87
+ // 模拟应用初始化过程
88
+ useEffect(() => {
89
+ setStatus((prev: any) => ({ ...prev, content: 'loading' }));
90
+ handleFetchList();
91
+ }, []);
92
+
93
+ const handleData = (data: any[]) => {
94
+ return (data || []).map((_t, i) => {
95
+ let status = statusArr.find((s: any) => s.status == _t.status);
96
+ return {
97
+ id: _t.id,
98
+ data: [
99
+ { columnId: 'modelName', value: _t.modelName },
100
+ {
101
+ columnId: 'modelProtocol',
102
+ value: _t.modelProtocol,
103
+ type: 'customized',
104
+ },
105
+ { columnId: 'type', value: _t.type, type: 'customized' },
106
+ { columnId: 'dec', value: _t.dec },
107
+ {
108
+ columnId: 'status',
109
+ ...status,
110
+ type: 'customized',
111
+ errorMsg: _t.errorMsg,
112
+ },
113
+ {
114
+ columnId: 'actions',
115
+ value: 'edit',
116
+ label: '编辑',
117
+ type: 'action',
118
+ disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.EDIT, _t.permission),
119
+ },
120
+ {
121
+ columnId: 'actions',
122
+ value: 'auth',
123
+ label: '授权',
124
+ type: 'action',
125
+ disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.AUTHORIZE, _t.permission),
126
+ },
127
+ {
128
+ columnId: 'actions',
129
+ value: 'delete',
130
+ label: '删除',
131
+ type: 'action',
132
+ disabled: getBtnDisabled && getBtnDisabled(OPT_BTN.AUTHORIZE, _t.permission),
133
+ },
134
+ { columnId: 'url', value: _t.url },
135
+ { columnId: 'apiKey', value: _t.apiKey },
136
+ { columnId: 'modelIde', value: _t.modelIde },
137
+ { columnId: 'thinking', value: _t.thinking },
138
+ ],
139
+ };
140
+ });
141
+ };
142
+
143
+ const handleFetchList = async () => {
144
+ try {
145
+ const [listRes, useTypeRes, modelProtocolsRes] = await Promise.allSettled([
146
+ getModelList(initPage),
147
+ getUseTypeList(),
148
+ getModelProtocolsList(),
149
+ ]);
150
+
151
+ if (listRes.status === 'fulfilled' && listRes.value) {
152
+ const _data = handleData(listRes.value.records);
153
+ setData(_data || []);
154
+ setStatus((prev: any) => ({ ...prev, content: 'ready' }));
155
+ }
156
+
157
+ if (useTypeRes.status === 'fulfilled' && useTypeRes.value) {
158
+ setModelUseTypeOpt(
159
+ (useTypeRes.value || []).map((o: any) => ({ ...o, value: Number(o.value) }))
160
+ );
161
+ }
162
+
163
+ if (modelProtocolsRes.status === 'fulfilled' && modelProtocolsRes.value) {
164
+ setModelProtocolsOpt(
165
+ (modelProtocolsRes.value || []).map((o: any) => ({ ...o, value: Number(o.value) }))
166
+ );
167
+ }
168
+ } catch (e) {
169
+ console.error('[TableApiError] getTableList:', e);
170
+ }
171
+ };
172
+
173
+ const viewConfig = useMemo(
174
+ () => ({
175
+ label: '数据库表格',
176
+ defaultActiveId: 'model-table',
177
+ model: null,
178
+ views: [
179
+ {
180
+ label: '模型',
181
+ id: 'model-table',
182
+ type: 'table' as const,
183
+ viewBehavior: 'pagination' as const, //or pagination
184
+ allowMultiSelect: false,
185
+ viewPageSize: 10,
186
+ columns: [
187
+ { id: 'modelName', title: '模型名称', type: 'label' },
188
+ {
189
+ id: 'modelProtocol',
190
+ title: '模型传输协议',
191
+ type: 'customized',
192
+ component: (props: any) => {
193
+ const { value } = props;
194
+ const modelProtocol = modelProtocolsOpt.find((o: any) => o.value == value)?.label;
195
+ return <span>{modelProtocol}</span>;
196
+ },
197
+ },
198
+ {
199
+ id: 'type',
200
+ title: '使用类型',
201
+ type: 'customized',
202
+ component: (props: any) => {
203
+ const { value } = props;
204
+ const type = modelUseTypeOpt.find((o: any) => o.value == value)?.label;
205
+ return <span>{type}</span>;
206
+ },
207
+ },
208
+ { id: 'dec', title: '说明', type: 'paragraph' },
209
+ {
210
+ id: 'status',
211
+ title: '状态',
212
+ type: 'customized',
213
+ component: <StatusComponent />,
214
+ helpText:
215
+ '当前模型状态为初次新增校验状态,若模型下线,此状态不会主动更新,需手动执行模型删除',
216
+ },
217
+ {
218
+ id: 'actions',
219
+ title: '操作',
220
+ type: 'customized',
221
+ component: (props: any) => {
222
+ const { value, cell, row } = props;
223
+ const { disabled, label } = cell;
224
+ if (disabled) {
225
+ return (
226
+ <Tooltip title="角色无权限操作">
227
+ <Button mode="text" label={label} disabled={disabled} />
228
+ </Tooltip>
229
+ );
230
+ } else {
231
+ return (
232
+ <Button
233
+ mode="text"
234
+ label={label}
235
+ onClick={() => handleEventsEmit(`table_action_${value}`, row, undefined)}
236
+ />
237
+ );
238
+ }
239
+ },
240
+ },
241
+ ],
242
+ toolbar: [
243
+ {
244
+ type: 'button' as const,
245
+ btnType: 'primary' as const,
246
+ key: 'add',
247
+ label: '新建',
248
+ icon: <Plus />,
249
+ },
250
+ ],
251
+ },
252
+ ],
253
+ }),
254
+ [data, modelUseTypeOpt, modelProtocolsOpt]
255
+ );
256
+
257
+ // 自定义空数据组件
258
+ const EmptyData: React.FC = () => (
259
+ <div className="flex flex-col items-center justify-center h-full">
260
+ <div className="text-xl font-semibold mb-3" style={{ color: '#374151' }}>
261
+ <img src={EmptyImg} width={120} />
262
+ </div>
263
+ <div className="text-base mb-6" style={{ color: '#6b7280' }}>
264
+ 暂无数据,请先新建模型
265
+ </div>
266
+ <div className="flex gap-3">
267
+ <Button
268
+ mode="primary"
269
+ label="新建模型"
270
+ onClick={() => {
271
+ setDrawerTitle('新建');
272
+ setDrawerVisible(true);
273
+ }}
274
+ />
275
+ </div>
276
+ </div>
277
+ );
278
+
279
+ // 事件分流函数,先处理核心层UI/动画,再决定是否向上透传
280
+ async function handleEventsEmit(name: string, data: any, appFn: any) {
281
+ console.log('[adopter] mergedEventsEmit', name, data, appFn);
282
+ // 1. 先处理核心层UI/动画/数据
283
+ switch (name) {
284
+ case 'toolbar_add': {
285
+ setDrawerTitle('新建');
286
+ setDrawerVisible(true);
287
+ break;
288
+ }
289
+ case 'table_action_delete': {
290
+ try {
291
+ const name = data.data.find((d: any) => d.columnId == 'modelName').value;
292
+ confirm({
293
+ title: '确认删除?',
294
+ content: `确定要删除模型 “${name}” 吗?此操作不可恢复。`,
295
+ okText: '删除',
296
+ cancelText: '取消',
297
+ async onOk() {
298
+ const res = await delModelById(data.id);
299
+ if (res && coreRef?.current) {
300
+ coreRef?.current.appFn.removeItem(data.id);
301
+ message.success(`删除成功`);
302
+ }
303
+ },
304
+ });
305
+ } catch (e) {
306
+ console.error('删除表数据失败', e);
307
+ }
308
+ break;
309
+ }
310
+ case 'table_action_edit': {
311
+ setDrawerTitle('编辑');
312
+ setDrawerVisible(true);
313
+ setModelInfo(data);
314
+ break;
315
+ }
316
+ //新增模型
317
+ case 'form_submitted_add': {
318
+ try {
319
+ const _data = data.fields.reduce((acc: any, item: any) => {
320
+ acc[item.name] = item.value;
321
+ return acc;
322
+ }, {});
323
+ const res = await createModel({
324
+ ..._data,
325
+ });
326
+ if (res) {
327
+ let status = statusArr.find((s: any) => s.status == res.status);
328
+ const newModel = {
329
+ id: res.id,
330
+ data: [
331
+ ...(Object.keys(res) || []).map((key: any) => {
332
+ return {
333
+ columnId: key,
334
+ value: (res as any)[key],
335
+ ...((key == 'modelProtocol' || key == 'type') && {
336
+ type: 'customized',
337
+ }),
338
+ ...(key == 'status' && {
339
+ ...status,
340
+ type: 'customized',
341
+ errorMsg: (res as any).errorMsg,
342
+ }),
343
+ };
344
+ }),
345
+ { columnId: 'actions', value: 'edit', label: '编辑', type: 'action' },
346
+ { columnId: 'actions', value: 'auth', label: '授权', type: 'action' },
347
+ { columnId: 'actions', value: 'delete', label: '删除', type: 'action' },
348
+ ],
349
+ };
350
+ coreRef?.current?.appFn?.addItem(newModel, { animate: true, position: 'start' });
351
+ message.success('模型新增成功!');
352
+ }
353
+ } catch (e) {
354
+ console.error('保存失败!', e);
355
+ } finally {
356
+ handleDrawerClose();
357
+ }
358
+ break;
359
+ }
360
+
361
+ //修改模型配置
362
+ case 'form_submitted_edit': {
363
+ try {
364
+ const _data = data.fields.reduce((acc: any, item: any) => {
365
+ acc[item.name] = item.value;
366
+ return acc;
367
+ }, {});
368
+
369
+ const res = await updateModelById({
370
+ ..._data,
371
+ id: modelInfo.id,
372
+ });
373
+ if (res) {
374
+ let status = statusArr.find((s: any) => s.status == res.status);
375
+ const patch = {
376
+ ...modelInfo,
377
+ data: modelInfo.data.map((m: any) => {
378
+ if (res[m.columnId] !== null && res[m.columnId] !== undefined) {
379
+ if (m.columnId == 'status') {
380
+ return {
381
+ ...m,
382
+ ...status,
383
+ };
384
+ } else {
385
+ m.value = res[m.columnId];
386
+ }
387
+ }
388
+ return m;
389
+ }),
390
+ };
391
+ coreRef?.current?.appFn?.updateItem(patch, modelInfo?.id);
392
+ message.success('模型编辑成功!');
393
+ }
394
+ } catch (e) {
395
+ console.error('保存失败!', e);
396
+ } finally {
397
+ handleDrawerClose();
398
+ }
399
+ break;
400
+ }
401
+
402
+ default:
403
+ // 2. 透传到业务层(如有需要)
404
+ if (typeof props.eventsEmit === 'function') {
405
+ props.eventsEmit(name, data);
406
+ }
407
+ break;
408
+ }
409
+ }
410
+ const handleDrawerClose = () => {
411
+ setDrawerVisible(false);
412
+ setModelInfo(undefined);
413
+ };
414
+ return (
415
+ <DashboardContainer title="模型管理">
416
+ <Xviwer
417
+ dataSource={data}
418
+ ref={coreRef}
419
+ eventsEmit={handleEventsEmit}
420
+ status={status}
421
+ CustomComponents={{
422
+ EmptyData,
423
+ ...CustomComponents,
424
+ }}
425
+ {...viewConfig}
426
+ />
427
+ {/* 右侧抽屉 - 添加编辑模型 */}
428
+ <ConfigDrawer
429
+ drawerTitle={drawerTitle}
430
+ drawerVisible={drawerVisible}
431
+ handleDrawerClose={handleDrawerClose}
432
+ modelInfo={modelInfo}
433
+ modelUseTypeOpt={modelUseTypeOpt}
434
+ modelProtocolsOpt={modelProtocolsOpt}
435
+ eventsEmit={handleEventsEmit}
436
+ />
437
+ </DashboardContainer>
438
+ );
439
+ }
@@ -0,0 +1,185 @@
1
+ import axios from 'axios';
2
+
3
+ type IDataSourceType = 'DataTable' | 'DirectDB';
4
+
5
+ interface DatabaseApiProps {
6
+ url?: string;
7
+ token?: string;
8
+ role?: string;
9
+ eventsEmit?: (name: string, data: any) => void;
10
+ }
11
+
12
+ const AxiosInstance = ({ url, token, role, eventsEmit }: DatabaseApiProps) => {
13
+ const axios$ = axios.create({
14
+ baseURL: url,
15
+ // 配置请求超时时间
16
+ timeout: 1000000,
17
+ });
18
+ // 请求拦截
19
+ axios$.interceptors.request.use((config: any) => {
20
+ let target_cookie = token;
21
+
22
+ const noA = ['user/login', 'user/kaptcha', 'user/regist'];
23
+ // dangerous behaviour
24
+ if (!target_cookie && !noA.some((item: string) => config.url.includes(item))) {
25
+ // 通过eventsEmit抛出认证错误事件,让调用层处理
26
+ if (eventsEmit) {
27
+ eventsEmit('request:error_auth', {
28
+ errorMsg: '未登录或token已过期',
29
+ redirect: '/login',
30
+ });
31
+ }
32
+ return Promise.reject(new Error('未登录或token已过期'));
33
+ }
34
+
35
+ config.headers.Authorization = target_cookie || '';
36
+ // 这里传中文会报错
37
+ config.headers.userName = role === '未登录用户' ? '' : role;
38
+ return config;
39
+ });
40
+
41
+ // 返回拦截
42
+ axios$.interceptors.response.use(
43
+ response => {
44
+ // 获取接口返回结果
45
+ const noA = ['user/kaptcha'];
46
+ const res = response.data;
47
+ if (noA.some((item: string) => response.config.url && response.config.url.includes(item))) {
48
+ return res;
49
+ }
50
+ if (res.size && res.type) {
51
+ return res;
52
+ }
53
+ const { success, errorMsg, errorCode } = res;
54
+
55
+ if (success) {
56
+ return res;
57
+ } else {
58
+ // 通过eventsEmit抛出业务错误事件,让调用层处理
59
+ if (eventsEmit) {
60
+ eventsEmit('request:error_business', {
61
+ errorCode,
62
+ errorMsg: errorMsg || '请求出错,请稍后再试',
63
+ response: res,
64
+ });
65
+ }
66
+ }
67
+ return false;
68
+ },
69
+ error => {
70
+ // 主动取消请求,不给报错信息
71
+ if (error.message === 'canceled') {
72
+ return Promise.reject(error);
73
+ }
74
+
75
+ // 通过eventsEmit抛出网络错误事件,让调用层处理
76
+ if (eventsEmit) {
77
+ let errorType = 'request:error_network';
78
+ let errorData: any = {
79
+ errorMsg: '网络请求失败',
80
+ error: error,
81
+ };
82
+
83
+ if (error?.response?.status === 401) {
84
+ errorType = 'request:error_auth';
85
+ errorData = {
86
+ errorMsg: '没有足够权限',
87
+ error: error,
88
+ redirect: '/login',
89
+ };
90
+ } else if (
91
+ error?.response?.data?.errorCode === '30013' ||
92
+ error?.response?.data?.errorCode === '30023'
93
+ ) {
94
+ errorType = 'request:error_business';
95
+ errorData = {
96
+ errorCode: error?.response?.data?.errorCode,
97
+ errorMsg: error?.response?.data?.message || '请求出错,请稍后再试',
98
+ error: error,
99
+ };
100
+ }
101
+
102
+ eventsEmit(errorType, errorData);
103
+ }
104
+ return Promise.reject(error);
105
+ }
106
+ );
107
+ // 获取表数据
108
+ const getModelList = async (params: any) => {
109
+ try {
110
+ const res: any = await axios$.get(`/allPage?${new URLSearchParams(params).toString()}`);
111
+ const { success, data } = res;
112
+ if (success) return data;
113
+ } catch (e) {
114
+ console.log('getModelList error:', e);
115
+ return false;
116
+ }
117
+ };
118
+
119
+ //删除模型
120
+ const delModelById = async (id: string | number) => {
121
+ try {
122
+ const res: any = await axios$.delete(`/delete?id=${id}`);
123
+ const { success, data } = res;
124
+ if (success) return data;
125
+ } catch (e) {
126
+ console.log('delModelById error:', e);
127
+ }
128
+ };
129
+
130
+ // 创建模型
131
+ const createModel = async (params: any) => {
132
+ try {
133
+ const res: any = await axios$.post(`/create`, params);
134
+
135
+ const { success, data } = res;
136
+ if (success) return data;
137
+ } catch (e) {
138
+ console.log('createModel error:', e);
139
+ }
140
+ };
141
+ // 编辑模型
142
+ const updateModelById = async (params: any) => {
143
+ try {
144
+ const res: any = await axios$.put(`/update`, params);
145
+
146
+ const { success, data } = res;
147
+ if (success) return data;
148
+ } catch (e) {
149
+ console.log('updateModelById error:', e);
150
+ }
151
+ };
152
+ //使用类型list
153
+ const getUseTypeList = async () => {
154
+ try {
155
+ const res: any = await axios$.get(`/getModelTypes`);
156
+ const { success, data } = res;
157
+ if (success) return data;
158
+ } catch (e) {
159
+ console.log('getUseTypeList error:', e);
160
+ return false;
161
+ }
162
+ };
163
+
164
+ //传输协议list
165
+ const getModelProtocolsList = async () => {
166
+ try {
167
+ const res: any = await axios$.get(`/getModelProtocols`);
168
+ const { success, data } = res;
169
+ if (success) return data;
170
+ } catch (e) {
171
+ console.log('getModelProtocolsList error:', e);
172
+ return false;
173
+ }
174
+ };
175
+ return {
176
+ getModelList,
177
+ delModelById,
178
+ createModel,
179
+ updateModelById,
180
+ getUseTypeList,
181
+ getModelProtocolsList,
182
+ };
183
+ };
184
+
185
+ export default AxiosInstance;
@@ -0,0 +1 @@
1
+ import { AiChat, type AppStatusManager } from '@mxmweb/aichat';
@@ -0,0 +1,8 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Icon">
3
+ <g id="Vector">
4
+ <path d="M8 1C4.13438 1 1 4.13438 1 8C1 11.8656 4.13438 15 8 15C11.8656 15 15 11.8656 15 8C15 4.13438 11.8656 1 8 1ZM8 13.8125C4.79063 13.8125 2.1875 11.2094 2.1875 8C2.1875 4.79063 4.79063 2.1875 8 2.1875C11.2094 2.1875 13.8125 4.79063 13.8125 8C13.8125 11.2094 11.2094 13.8125 8 13.8125Z" fill="#888888"/>
5
+ <path d="M10.7297 9.97811L8.50156 8.36718V4.5C8.50156 4.43125 8.44531 4.375 8.37656 4.375H7.625C7.55625 4.375 7.5 4.43125 7.5 4.5V8.80311C7.5 8.84374 7.51875 8.88124 7.55156 8.90467L10.1359 10.789C10.1922 10.8297 10.2703 10.8172 10.3109 10.7625L10.7578 10.1531C10.7984 10.0953 10.7859 10.0172 10.7297 9.97811Z" fill="#888888"/>
6
+ </g>
7
+ </g>
8
+ </svg>