@gientech/modual 1.4.7 → 1.5.2
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/dist/assets/GientechStreamReader-KtCNi1G3.js +447 -0
- package/dist/assets/Input-CNqIA41v.js +236 -0
- package/dist/assets/index-Bof0D4vl.js +1088 -0
- package/dist/assets/{index-BVENTW1Q.js → index-C5RhLYRh.js} +1 -1
- package/dist/assets/index-COcmK9my.js +1 -0
- package/dist/assets/index-CysDmrpo.js +1798 -0
- package/dist/assets/{index-7rZAt9P3.js → index-DP8Ki8qW.js} +1 -1
- package/dist/assets/index-pybYlMAT.js +11 -0
- package/dist/assets/{plus-CrtEUXaQ.js → plus-CzbYbK8K.js} +1 -1
- package/dist/assets/style3.css +1 -1
- package/dist/assets/worker-BbpylX7l.js +13 -0
- package/dist/assets/{x-Dr3EBTzJ.js → x-DdRafKQU.js} +1 -1
- package/dist/chat.d.ts +17 -0
- package/dist/chat.js +2539 -52
- package/dist/database.js +2 -2
- package/dist/databaseId.js +1 -11
- package/dist/databaseTable.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -14
- package/dist/modelManage.js +1 -1
- package/dist/package.json +1 -1
- package/dist/sensitive.js +1 -1
- package/dist/streamFilesReader.js +1 -1
- package/dist/worker/pdf.worker1.min.js +23 -0
- package/package.json +6 -6
- package/public/worker/pdf.worker1.min.js +23 -0
- package/scripts/README.md +133 -133
- package/scripts/build-demo.js +88 -88
- package/scripts/demo-selector.js +216 -216
- package/scripts/preview-demo.js +130 -130
- package/scripts/run-demo.bat +34 -34
- package/src/assets/img/close.png +0 -0
- package/src/assets/img/database.png +0 -0
- package/src/assets/img/downLoad.png +0 -0
- package/src/assets/img/graphIcon.png +0 -0
- package/src/assets/img/pdf.png +0 -0
- package/src/assets/img/singleQa.png +0 -0
- package/src/assets/img/webSearch.png +0 -0
- package/src/examples/chat/index.tsx +5 -29
- package/src/main.tsx.backup +5 -5
- package/src/modules/chat/ReferenceBar.tsx +522 -0
- package/src/modules/chat/constants.tsx +29 -6
- package/src/modules/chat/index.tsx +118 -4
- 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 +110 -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 +3 -0
- package/src/modules/chat/utils/index.ts +326 -0
- package/src/utils/gientechCommon/components/Messages/GientechNewChatWelcome.tsx +231 -18
- package/src/utils/testconfigs/index.ts +1 -1
- package/stats.html +1 -1
- package/dist/assets/AppLoading-mci3gLZt.js +0 -414
- package/dist/assets/GientechStreamReader-4496nAm0.js +0 -446
- package/dist/assets/index-Bb8_WB-l.js +0 -1
- package/dist/assets/index-BpJ9Bm5x.js +0 -21
- package/dist/assets/index-CNxDI4h-.js +0 -1078
- package/dist/assets/index-CWzpBU29.js +0 -1
- package/dist/assets/index-D1m34Ij7.js +0 -1429
- package/dist/assets/index-_gBtdXQV.js +0 -585
- package/dist/assets/style4.css +0 -1
|
@@ -9,9 +9,10 @@ import '@mxmweb/rtext/style.css';
|
|
|
9
9
|
import '@mxmweb/aichat/style.css';
|
|
10
10
|
import '@mxmweb/zui/style.css';
|
|
11
11
|
import { defaultTheme, deepMergeTheme, type Styles } from '@mxmweb/zui';
|
|
12
|
-
|
|
13
12
|
import { DefaultSenderConfig } from './constants';
|
|
14
13
|
import GientechConversationPanel from './Conversations';
|
|
14
|
+
import { registerPDFWorker } from '@mxmweb/fviewer';
|
|
15
|
+
registerPDFWorker('/worker/pdf.worker1.min.js');
|
|
15
16
|
import {
|
|
16
17
|
convertQueryReplyPairListToMessages,
|
|
17
18
|
getFileTypeByName,
|
|
@@ -38,6 +39,11 @@ import DisplayError from '../../utils/gientechCommon/components/DisplayError';
|
|
|
38
39
|
import { maxPollCount, maxPollInterval } from '../../utils/gientechCommon/configs/commonConfig';
|
|
39
40
|
import { RenameModal } from '../../utils/gientechCommon/components/RenameModal';
|
|
40
41
|
import { DeleteModal } from '../../utils/gientechCommon/components/DeleteModal';
|
|
42
|
+
import { ReferenceBar } from './ReferenceBar';
|
|
43
|
+
|
|
44
|
+
export enum DrawerType {
|
|
45
|
+
REFERENCELIST = 'referencelist',
|
|
46
|
+
}
|
|
41
47
|
|
|
42
48
|
interface SenderConfig {
|
|
43
49
|
actions?: Array<{
|
|
@@ -450,7 +456,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
450
456
|
.catch(() => {
|
|
451
457
|
setAppStatus(prev => ({ ...prev, app: 'error' }));
|
|
452
458
|
});
|
|
453
|
-
}, [
|
|
459
|
+
}, []);
|
|
454
460
|
|
|
455
461
|
/**
|
|
456
462
|
* 当 activeSessionId 变化时,获取对应的聊天记录
|
|
@@ -464,6 +470,78 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
464
470
|
headers: { Authorization: token },
|
|
465
471
|
})
|
|
466
472
|
.then(res => {
|
|
473
|
+
// const r = {
|
|
474
|
+
// data: {
|
|
475
|
+
// success: true,
|
|
476
|
+
// errorMsg: null,
|
|
477
|
+
// errorCode: null,
|
|
478
|
+
// data: {
|
|
479
|
+
// label: '控制器起不来(控制器右上角RDY灯不亮)',
|
|
480
|
+
// sessionId: '3d752532b3d4510867288e5ac5cb3833',
|
|
481
|
+
// gmtCreate: '2025-11-06 14:30:43',
|
|
482
|
+
// gmtModified: '2025-11-06 14:30:43',
|
|
483
|
+
// createBy: 'admin',
|
|
484
|
+
// updateBy: 'admin',
|
|
485
|
+
// filePath: 'http://10.160.33.221:9000',
|
|
486
|
+
// configId: 703,
|
|
487
|
+
// kbId: null,
|
|
488
|
+
// queryReplyPairList: [
|
|
489
|
+
// {
|
|
490
|
+
// query: {
|
|
491
|
+
// id: 27665,
|
|
492
|
+
// gmtCreate: '2025-11-06T06:31:05.000+00:00',
|
|
493
|
+
// content: '控制器起不来(控制器右上角RDY灯不亮)',
|
|
494
|
+
// type: 'text',
|
|
495
|
+
// queryId: 'query-2532b3d4510867288e5ac5cb38338870',
|
|
496
|
+
// audioUrl: '',
|
|
497
|
+
// filePaths: null,
|
|
498
|
+
// currentFiles: null,
|
|
499
|
+
// },
|
|
500
|
+
// reply: {
|
|
501
|
+
// id: 27638,
|
|
502
|
+
// gmtCreate: '2025-11-06T06:31:15.000+00:00',
|
|
503
|
+
// content:
|
|
504
|
+
// '<think>\n好的,我现在需要回答用户的问题:“控制器起不来(控制器右上角RDY灯不亮)”。首先,我要查看提供的参考资料,看看是否有相关信息。\n\n参考资料0提到了现象“控制器起不来(控制器右上角RDY灯不亮)”,并关联到“包含”和“产生”关系,但没有提供处理方法。参考资料1和2都详细描述了这个现象,并且都给出了处理方法:检查NT255模块是否报红,更换模块,并特别提到机舱检查FS211/N模块。这些处理方法的ID都是10001,说明是同一个解决方案。\n\n用户的问题没有指定版本,根据规则2,我应该使用最新的版本信息。不过,参考资料中没有明确的版本日期,所以只能假设它们都是最新的。因此,我应该综合所有参考资料的信息,提供处理方法。\n\n最后,我需要按照要求,用简洁的语言回答,并标注来源。由于处理方法在参考资料1和2中都有,我会引用这两个来源。\n\n\n</think>\n\n控制器起不来(控制器右上角RDY灯不亮)的处理方法如下:\n\n1. 检查NT255模块是否报红(ERR灯是否亮红)[retrive-tag id="2290607639633892359" image_urls="" fromType="2"][1][/retrive-tag][retrive-tag id="439368868506707299" image_urls="" fromType="2"][2][/retrive-tag]。\n2. 更换NT255模块(注:机舱检查FS211/N模块)[retrive-tag id="2290607639633892359" image_urls="" fromType="2"][1][/retrive-tag][retrive-tag id="439368868506707299" image_urls="" fromType="2"][2][/retrive-tag]。\n\n这些步骤可以帮助解决控制器无法启动的问题。',
|
|
505
|
+
// type: 'text',
|
|
506
|
+
// reference: '[]',
|
|
507
|
+
// webReference: '[]',
|
|
508
|
+
// graphReference:
|
|
509
|
+
// '[{"cyphers":["match (n:`组件`)-[e]-(m) where id(n) == \\"组件101\\" return n,e,m;","match (n:`现象`)-[e]-(m) where id(n) == \\"现象1001\\" return n,e,m;","match (n:`现象`)-[e]-(m) where id(n) == \\"现象1001\\" return n,e,m;"],"fetchUrl":"https://10.160.33.150:30001/jinxin_graph/proxy/search/graph/search/cypherSearch4Rag","graphName":"故障处理图谱","id":"1952195957278367755","traceNodes":[{"graphId":"1952195957278367755","id":"3484145002858895870","name":"控制器","nodeType":"组件","vid":"组件101"},{"graphId":"1952195957278367755","id":"2290607639633892359","name":"控制器起不来(控制器右上角RDY灯不亮)","nodeType":"现象","vid":"现象1001"},{"graphId":"1952195957278367755","id":"439368868506707299","name":"控制器起不来(控制器右上角RDY灯不亮)","nodeType":"现象","vid":"现象1001"}]}]',
|
|
510
|
+
// queryId: 'query-2532b3d4510867288e5ac5cb38338870',
|
|
511
|
+
// feedbackResult: null,
|
|
512
|
+
// feedbackId: null,
|
|
513
|
+
// parsedFilePaths: null,
|
|
514
|
+
// recommendQuestion:
|
|
515
|
+
// '["在检查NT255模块时,ERR灯亮红可能表示哪些具体问题?","更换NT255模块时需要注意哪些步骤或注意事项?","除了检查和更换NT255模块,还有哪些方法可以排查控制器无法启动的问题?"]',
|
|
516
|
+
// llmType: 1,
|
|
517
|
+
// resultType: 1,
|
|
518
|
+
// respTime: 32453,
|
|
519
|
+
// tokens: 824,
|
|
520
|
+
// },
|
|
521
|
+
// },
|
|
522
|
+
// ],
|
|
523
|
+
// searchConfigDTO: {
|
|
524
|
+
// id: 703,
|
|
525
|
+
// status: 1,
|
|
526
|
+
// isDefault: 0,
|
|
527
|
+
// configJson:
|
|
528
|
+
// '{"status":1,"defaultAnswer":"您好!我注意到您的消息中可能包含了一些敏感的内容。为了保证社区的友好氛围,我们无法继续就此话题进行讨论。如果您有其他问题或需要帮助,我很乐意继续为您服务!谢谢您的理解和支持。","dependOnKb":1,"isDel":1,"config_name":"图谱测试","model_name":"deepseek-distill-qwen32b","plan_model_name":"deepseek-distill-qwen32b","prologue":"你好","system_prompt":"","recommend_model_name":"deepseek-distill-qwen32b","temperature":0.3,"top_p":0.8,"top_k":10,"score_threshold":0.1,"max_tokens":4096,"max_round":5,"rerank_model_name":"bge-reranker-v2-m3_xinference","knowledge_base_name_source":"","graph_nb_name":[{"graph_name":"故障处理图谱","index_name":"1952195957278367755"}],"thinking":false,"knowledge_base_name":"","selectedKnowledgeBase":[],"enabled_graph":false,"enabled_nb_graph":true,"need_trace_source":true,"trace_by_llm":true,"is_download":false,"search_policy":1,"enabled_question_rewrite":false,"enabled_faq":true,"enabled_rerank":true,"rerank":false}',
|
|
529
|
+
// name: '图谱测试',
|
|
530
|
+
// des: null,
|
|
531
|
+
// createBy: 'admin',
|
|
532
|
+
// gmtCreate: '2025-11-05 19:37:54',
|
|
533
|
+
// permission: null,
|
|
534
|
+
// sensitiveWordIds: '',
|
|
535
|
+
// defaultAnswer:
|
|
536
|
+
// '您好!我注意到您的消息中可能包含了一些敏感的内容。为了保证社区的友好氛围,我们无法继续就此话题进行讨论。如果您有其他问题或需要帮助,我很乐意继续为您服务!谢谢您的理解和支持。',
|
|
537
|
+
// model: false,
|
|
538
|
+
// enabledFaq: 0,
|
|
539
|
+
// dependOnKb: 1,
|
|
540
|
+
// isDel: 1,
|
|
541
|
+
// },
|
|
542
|
+
// },
|
|
543
|
+
// },
|
|
544
|
+
// };
|
|
467
545
|
// 如果会话没有数据(例如新建的),直接返回
|
|
468
546
|
|
|
469
547
|
if (!res.data.data) {
|
|
@@ -1399,6 +1477,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1399
1477
|
console.log('error', error);
|
|
1400
1478
|
}
|
|
1401
1479
|
};
|
|
1480
|
+
|
|
1402
1481
|
/**
|
|
1403
1482
|
* 统一事件分发器,连接业务逻辑与所有子组件的事件
|
|
1404
1483
|
* @param {string} eventName - 事件名称
|
|
@@ -1592,6 +1671,36 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1592
1671
|
// 处理文件下载事件,透传给父组件
|
|
1593
1672
|
eventsEmit?.('referenceFile_download', data);
|
|
1594
1673
|
break;
|
|
1674
|
+
case 'references:click': {
|
|
1675
|
+
// 使用 AiChat 内置的右侧栏事件
|
|
1676
|
+
const Content = () => {
|
|
1677
|
+
// const safe = (() => {
|
|
1678
|
+
// try {
|
|
1679
|
+
// return typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
1680
|
+
// } catch (e) {
|
|
1681
|
+
// return String(data);
|
|
1682
|
+
// }
|
|
1683
|
+
// })();
|
|
1684
|
+
return (
|
|
1685
|
+
<ReferenceBar
|
|
1686
|
+
type={DrawerType.REFERENCELIST}
|
|
1687
|
+
data={data}
|
|
1688
|
+
token={token}
|
|
1689
|
+
eventsEmit={eventsEmit}
|
|
1690
|
+
is_download={is_download}
|
|
1691
|
+
/>
|
|
1692
|
+
);
|
|
1693
|
+
};
|
|
1694
|
+
const setContentEvent = new CustomEvent('aichat:right_set_content', {
|
|
1695
|
+
detail: { content: <Content /> },
|
|
1696
|
+
});
|
|
1697
|
+
window.dispatchEvent(setContentEvent);
|
|
1698
|
+
const openEvent = new CustomEvent('aichat:right_set', {
|
|
1699
|
+
detail: { collapsed: false },
|
|
1700
|
+
});
|
|
1701
|
+
window.dispatchEvent(openEvent);
|
|
1702
|
+
break;
|
|
1703
|
+
}
|
|
1595
1704
|
case 'retrive_tag:click':
|
|
1596
1705
|
// 处理 retrive-tag 点击事件,透传给父组件
|
|
1597
1706
|
eventsEmit?.('retrive_tag:click', data);
|
|
@@ -1813,6 +1922,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1813
1922
|
<ChatMessageAdapter
|
|
1814
1923
|
key={`${msg?.queryId || msg?.id || idx}-${msg?.istype || 'unknown'}`}
|
|
1815
1924
|
{...msg}
|
|
1925
|
+
referenceMode="button"
|
|
1816
1926
|
reference={safeReference}
|
|
1817
1927
|
webReference={safeWebReference}
|
|
1818
1928
|
graphReference={safeGraphReference}
|
|
@@ -1855,6 +1965,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1855
1965
|
<ChatMessageAdapter
|
|
1856
1966
|
key={`${msg?.queryId || msg?.id || idx}-user`}
|
|
1857
1967
|
{...msg}
|
|
1968
|
+
referenceMode="button"
|
|
1858
1969
|
contentType="plainText"
|
|
1859
1970
|
isUser={true}
|
|
1860
1971
|
displayStatus="ready"
|
|
@@ -1902,7 +2013,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1902
2013
|
// Render - 渲染
|
|
1903
2014
|
// =================================================================
|
|
1904
2015
|
return (
|
|
1905
|
-
|
|
2016
|
+
<div style={{ height: '100%', minWidth: '1116px', overflow: 'hidden' }}>
|
|
1906
2017
|
<FileManager
|
|
1907
2018
|
open={fileManagerOpen}
|
|
1908
2019
|
onCancel={() => setFileManagerOpen(false)}
|
|
@@ -1914,6 +2025,8 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1914
2025
|
eventsEmit={mergedEventsEmit}
|
|
1915
2026
|
/>
|
|
1916
2027
|
|
|
2028
|
+
{/* 右侧栏由 AiChat 内置事件控制,此处不再使用 antd Drawer */}
|
|
2029
|
+
|
|
1917
2030
|
<WrappedComponent
|
|
1918
2031
|
{...rest}
|
|
1919
2032
|
status={appStatus}
|
|
@@ -1927,6 +2040,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1927
2040
|
CustomComponents={mergedCustomComponents}
|
|
1928
2041
|
activeSessionId={activeSessionId}
|
|
1929
2042
|
scrollOld={scrollOld}
|
|
2043
|
+
rightbarWidth={'400px'}
|
|
1930
2044
|
/>
|
|
1931
2045
|
<FeedBackModal
|
|
1932
2046
|
open={openFeed}
|
|
@@ -1946,7 +2060,7 @@ export default function withGientechChatAdopter(WrappedComponent = AiChat) {
|
|
|
1946
2060
|
handleCancel={() => handleEvent('close_remove')}
|
|
1947
2061
|
data={curEditData?.data || {}}
|
|
1948
2062
|
/>
|
|
1949
|
-
|
|
2063
|
+
</div>
|
|
1950
2064
|
);
|
|
1951
2065
|
};
|
|
1952
2066
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Button, ConfigProvider, Form, Input, Modal } from "antd";
|
|
2
|
+
import { useForm } from "antd/es/form/Form";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
export const DeleteModal = ({
|
|
6
|
+
isModalOpen,
|
|
7
|
+
handleOk,
|
|
8
|
+
handleCancel,
|
|
9
|
+
data
|
|
10
|
+
}: any) => {
|
|
11
|
+
const modalStyles = {
|
|
12
|
+
header: {
|
|
13
|
+
height: "60px",
|
|
14
|
+
borderBottom: "1px solid #F0F0F0",
|
|
15
|
+
display: "flex",
|
|
16
|
+
paddingLeft: "24px",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
marginBottom: "16px"
|
|
19
|
+
},
|
|
20
|
+
title: { fontSize: "16px" },
|
|
21
|
+
body: { padding: "0 24px" },
|
|
22
|
+
mask: {},
|
|
23
|
+
footer: { marginTop: "0px", padding: "0 24px 16px 24px" },
|
|
24
|
+
content: { padding: 0 }
|
|
25
|
+
};
|
|
26
|
+
const [rename_form] = useForm();
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!isModalOpen) {
|
|
29
|
+
rename_form.resetFields();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
rename_form.setFieldValue("new_name", data?.label);
|
|
33
|
+
}, [data, isModalOpen]);
|
|
34
|
+
return (
|
|
35
|
+
<ConfigProvider
|
|
36
|
+
modal={{
|
|
37
|
+
styles: modalStyles
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<Modal
|
|
41
|
+
title={<div className="text-[16px]">删除会话</div>}
|
|
42
|
+
closeIcon={null}
|
|
43
|
+
open={isModalOpen}
|
|
44
|
+
width={520}
|
|
45
|
+
centered
|
|
46
|
+
className="[&:[.ant-modal-content]]:bg-red"
|
|
47
|
+
footer={
|
|
48
|
+
<div className="mt-[16px] flex justify-end">
|
|
49
|
+
<Button
|
|
50
|
+
children="取消"
|
|
51
|
+
onClick={handleCancel}
|
|
52
|
+
className="mr-[8px]"
|
|
53
|
+
/>
|
|
54
|
+
<Button
|
|
55
|
+
children="确认"
|
|
56
|
+
onClick={async () => {
|
|
57
|
+
try {
|
|
58
|
+
const data = await rename_form.validateFields();
|
|
59
|
+
handleOk("ok_remove", data);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
console.log(e);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}}
|
|
65
|
+
type="primary"
|
|
66
|
+
className="border-none"
|
|
67
|
+
/>
|
|
68
|
+
</div>
|
|
69
|
+
}
|
|
70
|
+
>
|
|
71
|
+
<div>{`确定要删除会话「${data.label}」吗?删除后无法恢复。`}</div>
|
|
72
|
+
</Modal>
|
|
73
|
+
</ConfigProvider>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { uid } from 'uid';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { dealMinioUrl, getFileName, getFilePath, getFileType, getInitialZoom } from '../utils';
|
|
4
|
+
import { GientechStreamReader } from '@gientech/modual/streamFilesReader';
|
|
5
|
+
export const DrawerContent = ({
|
|
6
|
+
content,
|
|
7
|
+
onClose,
|
|
8
|
+
token,
|
|
9
|
+
}: {
|
|
10
|
+
content: {
|
|
11
|
+
file_source: string;
|
|
12
|
+
contents: any[];
|
|
13
|
+
curMark: string;
|
|
14
|
+
file_type: string;
|
|
15
|
+
title: string;
|
|
16
|
+
metadata: any;
|
|
17
|
+
pdfPages: number | undefined;
|
|
18
|
+
url: string;
|
|
19
|
+
parse_url: string;
|
|
20
|
+
} | null;
|
|
21
|
+
onClose: any;
|
|
22
|
+
token: string;
|
|
23
|
+
}) => {
|
|
24
|
+
const getAnnotations: any = (content: any) => {
|
|
25
|
+
if (!content?.metadata) return;
|
|
26
|
+
const fileType = getFileType(content, '');
|
|
27
|
+
const { page_number, page_size, position, offset, chunk_type } = content.metadata;
|
|
28
|
+
if (fileType === 'markdown_table') {
|
|
29
|
+
if (offset?.length) {
|
|
30
|
+
return {
|
|
31
|
+
annotations: [{ id: uid(), offsets: offset }],
|
|
32
|
+
initialPage: 1,
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
if (!page_size || !position) {
|
|
39
|
+
console.log('%c缺少文件size或者文件坐标', 'color: red');
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
const pageSizes = Array.isArray(page_size) ? page_size : JSON.parse(page_size);
|
|
43
|
+
if (!pageSizes.length) {
|
|
44
|
+
console.log('%c缺少文件size', 'color: red');
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
const positions = Array.isArray(position) ? position : JSON.parse(position);
|
|
48
|
+
if (!positions.length || !page_number) {
|
|
49
|
+
console.log('%c缺少文件坐标或者文件页数', 'color: red');
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
const anno = positions.map((item: any, index: number) => {
|
|
53
|
+
return {
|
|
54
|
+
id: uid(),
|
|
55
|
+
pageNumber: page_number[index],
|
|
56
|
+
x: +(item[0][0] / pageSizes[0][0]).toFixed(4),
|
|
57
|
+
y: +(item[0][1] / pageSizes[0][1]).toFixed(4),
|
|
58
|
+
width: +((item[1][0] - item[0][0]) / pageSizes[0][0]).toFixed(4),
|
|
59
|
+
height: +((item[2][1] - item[0][1]) / pageSizes[0][1]).toFixed(4),
|
|
60
|
+
content: '',
|
|
61
|
+
color: chunk_type === 'image' ? '#60f74f' : '#4FC3F7',
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return { annotations: anno, initialPage: page_number[0] };
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const curData = useMemo(() => {
|
|
69
|
+
console.log('content88888888888', content);
|
|
70
|
+
if (content && token) {
|
|
71
|
+
console.log('content999', content);
|
|
72
|
+
const { annotations, initialPage } = getAnnotations(content);
|
|
73
|
+
const curContent = {
|
|
74
|
+
...content,
|
|
75
|
+
metadata: {
|
|
76
|
+
source: content?.metadata?.source || content.parse_url || content.url,
|
|
77
|
+
page_size: content?.metadata?.page_size,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const filePath = dealMinioUrl(getFilePath(curContent));
|
|
82
|
+
return {
|
|
83
|
+
filePath,
|
|
84
|
+
fileName: getFileName(curContent),
|
|
85
|
+
fileType: getFileType(curContent, filePath),
|
|
86
|
+
totalPages: curContent.pdfPages || 0,
|
|
87
|
+
token,
|
|
88
|
+
annotations,
|
|
89
|
+
initialPage,
|
|
90
|
+
initialZoom: getInitialZoom(598, curContent),
|
|
91
|
+
};
|
|
92
|
+
} else {
|
|
93
|
+
return {};
|
|
94
|
+
}
|
|
95
|
+
}, [content]);
|
|
96
|
+
|
|
97
|
+
const renderFileCom = useMemo(() => {
|
|
98
|
+
if (!curData.filePath) return <></>;
|
|
99
|
+
console.log('curData', curData);
|
|
100
|
+
return (
|
|
101
|
+
<GientechStreamReader
|
|
102
|
+
initialZoom={curData.initialZoom || 100}
|
|
103
|
+
convertedFilePath={curData.filePath}
|
|
104
|
+
fileName={curData.fileName}
|
|
105
|
+
fileType={curData.fileType}
|
|
106
|
+
initialPage={curData.initialPage}
|
|
107
|
+
totalPages={curData.totalPages}
|
|
108
|
+
authorization={curData.token}
|
|
109
|
+
annotations={curData.annotations}
|
|
110
|
+
streamApiUrl="/proxy/index/knowledgeBase/file/stream"
|
|
111
|
+
eventsEmit={name => {
|
|
112
|
+
switch (name) {
|
|
113
|
+
case 'viewer:close':
|
|
114
|
+
onClose();
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}}
|
|
118
|
+
tools={{
|
|
119
|
+
close: true,
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
}, [curData]);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div
|
|
127
|
+
style={{
|
|
128
|
+
fontFamily: 'Source Han Sans CN',
|
|
129
|
+
fontSize: '12px',
|
|
130
|
+
}}
|
|
131
|
+
className="h-full w-full"
|
|
132
|
+
>
|
|
133
|
+
{renderFileCom}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { getUrlPrefix } from '../utils';
|
|
2
|
+
import { Empty, Table, Pagination } from 'antd';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const DrawerDatabase = ({ curFileInfo }: any) => {
|
|
7
|
+
const [pageNo, setPageNo] = useState(1);
|
|
8
|
+
const [pageSize, setPageSize] = useState(10);
|
|
9
|
+
const [columns, setColumn] = useState([]);
|
|
10
|
+
const [dataList, setDataList] = useState([]);
|
|
11
|
+
const [totalData, setTotalData] = useState(0);
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const url = curFileInfo?.metadata?.fetchUrl || curFileInfo?.fetchUrl;
|
|
15
|
+
if (url) {
|
|
16
|
+
toGetDataBaseData(url);
|
|
17
|
+
}
|
|
18
|
+
}, [curFileInfo, pageNo, pageSize]);
|
|
19
|
+
|
|
20
|
+
const getDataBaseData = async ({ url, params }: any) => {
|
|
21
|
+
try {
|
|
22
|
+
const res = await axios.get(
|
|
23
|
+
`${getUrlPrefix()}${url}?${new URLSearchParams(params).toString()}`
|
|
24
|
+
);
|
|
25
|
+
const data = res?.data;
|
|
26
|
+
if (data) {
|
|
27
|
+
const { columns, dataList, totalData } = data;
|
|
28
|
+
setColumn(
|
|
29
|
+
(columns?.slice(1) || []).map((col: any) => ({
|
|
30
|
+
title: col.businessName,
|
|
31
|
+
dataIndex: col.physicalName,
|
|
32
|
+
key: col.physicalName,
|
|
33
|
+
}))
|
|
34
|
+
);
|
|
35
|
+
setDataList(dataList || []);
|
|
36
|
+
setTotalData(totalData || []);
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.log('error', error);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const toGetDataBaseData = async (url: string) => {
|
|
44
|
+
getDataBaseData({
|
|
45
|
+
url: `${url}`,
|
|
46
|
+
params: {
|
|
47
|
+
pageNo,
|
|
48
|
+
pageSize,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const renderTitle = () => {
|
|
54
|
+
const { file, metadata } = curFileInfo;
|
|
55
|
+
const { dataSourceType, databaseName, tableName, businessTableName } = metadata;
|
|
56
|
+
if (dataSourceType == 'DataTable') {
|
|
57
|
+
return `${databaseName} - ${businessTableName}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (dataSourceType == 'DirectDB') {
|
|
61
|
+
return `${databaseName} - ${tableName}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return file;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<div>
|
|
69
|
+
<div className="h-[52px] leading-[52px] font-bold text-[16px] px-[15px] overflow-hidden border-t-none border-l-none border-b-[1px] border-solid border-[rgb(222,226,230)]">
|
|
70
|
+
{renderTitle()}
|
|
71
|
+
</div>
|
|
72
|
+
|
|
73
|
+
{columns?.length > 0 ? (
|
|
74
|
+
<div>
|
|
75
|
+
<div className="p-4 overflow-auto h-[calc(100vh-120px)]">
|
|
76
|
+
<Table
|
|
77
|
+
columns={columns}
|
|
78
|
+
dataSource={dataList}
|
|
79
|
+
pagination={false}
|
|
80
|
+
scroll={{ x: 'max-content' }}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
<div className="flex justify-end px-[18px]">
|
|
84
|
+
<Pagination
|
|
85
|
+
current={pageNo}
|
|
86
|
+
pageSize={pageSize}
|
|
87
|
+
responsive
|
|
88
|
+
simple
|
|
89
|
+
total={totalData}
|
|
90
|
+
showSizeChanger
|
|
91
|
+
showQuickJumper
|
|
92
|
+
onChange={(page, size) => {
|
|
93
|
+
setPageNo(page);
|
|
94
|
+
setPageSize(size || 10);
|
|
95
|
+
}}
|
|
96
|
+
onShowSizeChange={(current, size) => {
|
|
97
|
+
setPageNo(1);
|
|
98
|
+
setPageSize(size);
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
) : (
|
|
104
|
+
<Empty />
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default DrawerDatabase;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { KnowledgeGraphPreview, registerPreviewViewer } from '@mxmweb/nodegraph';
|
|
4
|
+
import DrawerTitle from './DrawerTitle';
|
|
5
|
+
registerPreviewViewer();
|
|
6
|
+
|
|
7
|
+
const DrawerGraphPreview = ({
|
|
8
|
+
curFileInfo,
|
|
9
|
+
onClose,
|
|
10
|
+
token,
|
|
11
|
+
}: {
|
|
12
|
+
curFileInfo: any;
|
|
13
|
+
onClose: any;
|
|
14
|
+
token: string;
|
|
15
|
+
}) => {
|
|
16
|
+
const config = {
|
|
17
|
+
title: '',
|
|
18
|
+
subtitle: '',
|
|
19
|
+
backgroundColor: '#f8f9fa',
|
|
20
|
+
showGrid: true,
|
|
21
|
+
showLegend: false,
|
|
22
|
+
showTooltip: true,
|
|
23
|
+
showFullscreen: false,
|
|
24
|
+
showMinimap: false,
|
|
25
|
+
};
|
|
26
|
+
const [graphList, setGraphList] = useState<any>({
|
|
27
|
+
nodeList: [],
|
|
28
|
+
edgeList: [],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
console.log('curFileInfo', curFileInfo);
|
|
33
|
+
}, [curFileInfo]);
|
|
34
|
+
|
|
35
|
+
const getGraphData = async (curFileInfo: any) => {
|
|
36
|
+
if (!curFileInfo?.id || !curFileInfo?.cyphers || !curFileInfo?.fetchUrl) return;
|
|
37
|
+
try {
|
|
38
|
+
const { cyphers, fetchUrl, id } = curFileInfo || {};
|
|
39
|
+
console.log('getGraphData params', cyphers, fetchUrl, id);
|
|
40
|
+
|
|
41
|
+
const res = await axios.post(
|
|
42
|
+
fetchUrl,
|
|
43
|
+
{ cyphers, ontologyId: id },
|
|
44
|
+
{
|
|
45
|
+
headers: { Authorization: token },
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
console.log('getGraphData res', res);
|
|
49
|
+
setGraphList(res?.data || {});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.log('error', error);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
getGraphData(curFileInfo);
|
|
56
|
+
}, [curFileInfo]);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div>
|
|
60
|
+
<DrawerTitle title={curFileInfo?.graphName} setOpen={onClose} />
|
|
61
|
+
<div style={{ width: '100%', height: 'calc(100vh - 60px)' }}>
|
|
62
|
+
<KnowledgeGraphPreview
|
|
63
|
+
centerNode={{
|
|
64
|
+
vid: curFileInfo?.traceNode?.vid,
|
|
65
|
+
}}
|
|
66
|
+
data={graphList}
|
|
67
|
+
layout={{ type: 'force', linkDistance: 190 }}
|
|
68
|
+
title={config.title}
|
|
69
|
+
subtitle={config.subtitle}
|
|
70
|
+
backgroundColor={config.backgroundColor}
|
|
71
|
+
showGrid={config.showGrid}
|
|
72
|
+
showLegend={config.showLegend}
|
|
73
|
+
showTooltip={config.showTooltip}
|
|
74
|
+
showFullscreen={config.showFullscreen}
|
|
75
|
+
showMinimap={config.showMinimap}
|
|
76
|
+
customPlugins={{}}
|
|
77
|
+
onReady={(graph: any) => {
|
|
78
|
+
console.log('KnowledgeGraphPreview ready:', graph);
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default DrawerGraphPreview;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { dealMinioUrl, getFileName, getFilePath, getFileType, getInitialZoom } from '../utils';
|
|
3
|
+
import { GientechStreamReader } from '@gientech/modual/streamFilesReader';
|
|
4
|
+
|
|
5
|
+
const DrawerPreview = ({
|
|
6
|
+
curFileInfo,
|
|
7
|
+
onClose,
|
|
8
|
+
token,
|
|
9
|
+
}: {
|
|
10
|
+
curFileInfo: any;
|
|
11
|
+
onClose: any;
|
|
12
|
+
token: string;
|
|
13
|
+
}) => {
|
|
14
|
+
const curData = useMemo(() => {
|
|
15
|
+
if (curFileInfo && token) {
|
|
16
|
+
console.log('content999', curFileInfo);
|
|
17
|
+
const content = {
|
|
18
|
+
file_source: curFileInfo.url || curFileInfo.parse_url || curFileInfo.parsedFilePath,
|
|
19
|
+
file_type: curFileInfo.file_type,
|
|
20
|
+
metadata: {
|
|
21
|
+
source: curFileInfo.filePath || curFileInfo.url || curFileInfo?.metadata?.source || '',
|
|
22
|
+
page_size: curFileInfo?.metadata?.page_size,
|
|
23
|
+
},
|
|
24
|
+
pdfPages: curFileInfo.pdfPages,
|
|
25
|
+
};
|
|
26
|
+
const filePath = dealMinioUrl(getFilePath(content));
|
|
27
|
+
return {
|
|
28
|
+
filePath,
|
|
29
|
+
fileName: getFileName(content),
|
|
30
|
+
fileType: getFileType(content, filePath),
|
|
31
|
+
totalPages: content.pdfPages || 0,
|
|
32
|
+
token,
|
|
33
|
+
initialZoom: getInitialZoom(document.getElementById('pdfBox')?.clientWidth || 0, content),
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
}, [curFileInfo]);
|
|
39
|
+
|
|
40
|
+
const renderFileCom = useMemo(() => {
|
|
41
|
+
console.log('curData', curData);
|
|
42
|
+
if (!curData.filePath) return <></>;
|
|
43
|
+
return (
|
|
44
|
+
<GientechStreamReader
|
|
45
|
+
initialZoom={curData.initialZoom || 100}
|
|
46
|
+
convertedFilePath={curData.filePath}
|
|
47
|
+
fileName={curData.fileName}
|
|
48
|
+
fileType={curData.fileType}
|
|
49
|
+
initialPage={1}
|
|
50
|
+
totalPages={curData.totalPages}
|
|
51
|
+
authorization={curData.token}
|
|
52
|
+
streamApiUrl="/proxy/index/knowledgeBase/file/stream"
|
|
53
|
+
eventsEmit={type => {
|
|
54
|
+
switch (type) {
|
|
55
|
+
case 'viewer:close':
|
|
56
|
+
onClose();
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}}
|
|
60
|
+
tools={{
|
|
61
|
+
close: true,
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}, [curData]);
|
|
66
|
+
return (
|
|
67
|
+
<div id="pdfBox" className="h-full overflow-y-auto">
|
|
68
|
+
{renderFileCom}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default DrawerPreview;
|