balibabu
commited on
Commit
·
3951bd3
1
Parent(s):
8337858
fix: new message appears in wrong chat window. #1289 (#1571)
Browse files### What problem does this PR solve?
fix: new message appears in wrong chat window. #1289
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- web/src/hooks/{logicHooks.ts → logic-hooks.ts} +1 -1
- web/src/layouts/components/header/index.tsx +1 -1
- web/src/layouts/components/right-toolbar/index.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +234 -233
- web/src/pages/chat/chat-configuration-modal/index.tsx +4 -1
- web/src/pages/chat/hooks.ts +10 -2
- web/src/pages/chat/index.tsx +381 -381
- web/src/pages/chat/shared-hooks.ts +1 -1
- web/src/pages/file-manager/hooks.ts +1 -1
- web/src/pages/flow/chat/hooks.ts +1 -1
- web/src/pages/flow/hooks.ts +1 -1
- web/src/pages/flow/list/create-flow-modal.tsx +1 -1
- web/src/pages/user-setting/setting-profile/index.tsx +1 -1
web/src/hooks/{logicHooks.ts → logic-hooks.ts}
RENAMED
@@ -214,7 +214,7 @@ export const useSendMessageWithSse = (
|
|
214 |
[url],
|
215 |
);
|
216 |
|
217 |
-
return { send, answer, done };
|
218 |
};
|
219 |
|
220 |
//#region chat hooks
|
|
|
214 |
[url],
|
215 |
);
|
216 |
|
217 |
+
return { send, answer, done, setDone };
|
218 |
};
|
219 |
|
220 |
//#region chat hooks
|
web/src/layouts/components/header/index.tsx
CHANGED
@@ -8,7 +8,7 @@ import { useCallback, useMemo } from 'react';
|
|
8 |
import { useLocation } from 'umi';
|
9 |
import Toolbar from '../right-toolbar';
|
10 |
|
11 |
-
import { useFetchAppConf } from '@/hooks/
|
12 |
import { MessageOutlined } from '@ant-design/icons';
|
13 |
import styles from './index.less';
|
14 |
|
|
|
8 |
import { useLocation } from 'umi';
|
9 |
import Toolbar from '../right-toolbar';
|
10 |
|
11 |
+
import { useFetchAppConf } from '@/hooks/logic-hooks';
|
12 |
import { MessageOutlined } from '@ant-design/icons';
|
13 |
import styles from './index.less';
|
14 |
|
web/src/layouts/components/right-toolbar/index.tsx
CHANGED
@@ -6,7 +6,7 @@ import React from 'react';
|
|
6 |
import User from '../user';
|
7 |
|
8 |
import { LanguageList } from '@/constants/common';
|
9 |
-
import { useChangeLanguage } from '@/hooks/
|
10 |
import { useSelector } from 'umi';
|
11 |
import styled from './index.less';
|
12 |
|
|
|
6 |
import User from '../user';
|
7 |
|
8 |
import { LanguageList } from '@/constants/common';
|
9 |
+
import { useChangeLanguage } from '@/hooks/logic-hooks';
|
10 |
import { useSelector } from 'umi';
|
11 |
import styled from './index.less';
|
12 |
|
web/src/pages/add-knowledge/components/knowledge-dataset/knowledge-upload-file/index.tsx
CHANGED
@@ -15,7 +15,7 @@ import {
|
|
15 |
import {
|
16 |
useChangeDocumentParser,
|
17 |
useSetSelectedRecord,
|
18 |
-
} from '@/hooks/
|
19 |
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
20 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
21 |
import { getExtension, isFileUploadDone } from '@/utils/documentUtils';
|
|
|
15 |
import {
|
16 |
useChangeDocumentParser,
|
17 |
useSetSelectedRecord,
|
18 |
+
} from '@/hooks/logic-hooks';
|
19 |
import { useFetchTenantInfo } from '@/hooks/userSettingHook';
|
20 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
21 |
import { getExtension, isFileUploadDone } from '@/utils/documentUtils';
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
@@ -1,233 +1,234 @@
|
|
1 |
-
import ChunkMethodModal from '@/components/chunk-method-modal';
|
2 |
-
import SvgIcon from '@/components/svg-icon';
|
3 |
-
import {
|
4 |
-
useSelectDocumentList,
|
5 |
-
useSetDocumentStatus,
|
6 |
-
} from '@/hooks/documentHooks';
|
7 |
-
import { useSetSelectedRecord } from '@/hooks/
|
8 |
-
import { useSelectParserList } from '@/hooks/userSettingHook';
|
9 |
-
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
10 |
-
import { getExtension } from '@/utils/documentUtils';
|
11 |
-
import { Divider, Flex, Switch, Table, Typography } from 'antd';
|
12 |
-
import type { ColumnsType } from 'antd/es/table';
|
13 |
-
import { useTranslation } from 'react-i18next';
|
14 |
-
import CreateFileModal from './create-file-modal';
|
15 |
-
import
|
16 |
-
import
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
useNavigateToOtherPage,
|
25 |
-
useRenameDocument,
|
26 |
-
} from './hooks';
|
27 |
-
import ParsingActionCell from './parsing-action-cell';
|
28 |
-
import ParsingStatusCell from './parsing-status-cell';
|
29 |
-
import RenameModal from './rename-modal';
|
30 |
-
|
31 |
-
|
32 |
-
import
|
33 |
-
import
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
const
|
40 |
-
const
|
41 |
-
const
|
42 |
-
const
|
43 |
-
const
|
44 |
-
const {
|
45 |
-
const {
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
<
|
177 |
-
<
|
178 |
-
<
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
|
|
|
1 |
+
import ChunkMethodModal from '@/components/chunk-method-modal';
|
2 |
+
import SvgIcon from '@/components/svg-icon';
|
3 |
+
import {
|
4 |
+
useSelectDocumentList,
|
5 |
+
useSetDocumentStatus,
|
6 |
+
} from '@/hooks/documentHooks';
|
7 |
+
import { useSetSelectedRecord } from '@/hooks/logic-hooks';
|
8 |
+
import { useSelectParserList } from '@/hooks/userSettingHook';
|
9 |
+
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
10 |
+
import { getExtension } from '@/utils/documentUtils';
|
11 |
+
import { Divider, Flex, Switch, Table, Typography } from 'antd';
|
12 |
+
import type { ColumnsType } from 'antd/es/table';
|
13 |
+
import { useTranslation } from 'react-i18next';
|
14 |
+
import CreateFileModal from './create-file-modal';
|
15 |
+
import DocumentToolbar from './document-toolbar';
|
16 |
+
import {
|
17 |
+
useChangeDocumentParser,
|
18 |
+
useCreateEmptyDocument,
|
19 |
+
useFetchDocumentListOnMount,
|
20 |
+
useGetPagination,
|
21 |
+
useGetRowSelection,
|
22 |
+
useHandleUploadDocument,
|
23 |
+
useHandleWebCrawl,
|
24 |
+
useNavigateToOtherPage,
|
25 |
+
useRenameDocument,
|
26 |
+
} from './hooks';
|
27 |
+
import ParsingActionCell from './parsing-action-cell';
|
28 |
+
import ParsingStatusCell from './parsing-status-cell';
|
29 |
+
import RenameModal from './rename-modal';
|
30 |
+
import WebCrawlModal from './web-crawl-modal';
|
31 |
+
|
32 |
+
import FileUploadModal from '@/components/file-upload-modal';
|
33 |
+
import { formatDate } from '@/utils/date';
|
34 |
+
import styles from './index.less';
|
35 |
+
|
36 |
+
const { Text } = Typography;
|
37 |
+
|
38 |
+
const KnowledgeFile = () => {
|
39 |
+
const data = useSelectDocumentList();
|
40 |
+
const { fetchDocumentList } = useFetchDocumentListOnMount();
|
41 |
+
const parserList = useSelectParserList();
|
42 |
+
const { pagination } = useGetPagination(fetchDocumentList);
|
43 |
+
const onChangeStatus = useSetDocumentStatus();
|
44 |
+
const { toChunk } = useNavigateToOtherPage();
|
45 |
+
const { currentRecord, setRecord } = useSetSelectedRecord();
|
46 |
+
const {
|
47 |
+
renameLoading,
|
48 |
+
onRenameOk,
|
49 |
+
renameVisible,
|
50 |
+
hideRenameModal,
|
51 |
+
showRenameModal,
|
52 |
+
} = useRenameDocument(currentRecord.id);
|
53 |
+
const {
|
54 |
+
createLoading,
|
55 |
+
onCreateOk,
|
56 |
+
createVisible,
|
57 |
+
hideCreateModal,
|
58 |
+
showCreateModal,
|
59 |
+
} = useCreateEmptyDocument();
|
60 |
+
const {
|
61 |
+
changeParserLoading,
|
62 |
+
onChangeParserOk,
|
63 |
+
changeParserVisible,
|
64 |
+
hideChangeParserModal,
|
65 |
+
showChangeParserModal,
|
66 |
+
} = useChangeDocumentParser(currentRecord.id);
|
67 |
+
const {
|
68 |
+
documentUploadVisible,
|
69 |
+
hideDocumentUploadModal,
|
70 |
+
showDocumentUploadModal,
|
71 |
+
onDocumentUploadOk,
|
72 |
+
documentUploadLoading,
|
73 |
+
} = useHandleUploadDocument();
|
74 |
+
const {
|
75 |
+
webCrawlUploadVisible,
|
76 |
+
hideWebCrawlUploadModal,
|
77 |
+
showWebCrawlUploadModal,
|
78 |
+
onWebCrawlUploadOk,
|
79 |
+
webCrawlUploadLoading,
|
80 |
+
} = useHandleWebCrawl();
|
81 |
+
const { t } = useTranslation('translation', {
|
82 |
+
keyPrefix: 'knowledgeDetails',
|
83 |
+
});
|
84 |
+
|
85 |
+
const rowSelection = useGetRowSelection();
|
86 |
+
|
87 |
+
const columns: ColumnsType<IKnowledgeFile> = [
|
88 |
+
{
|
89 |
+
title: t('name'),
|
90 |
+
dataIndex: 'name',
|
91 |
+
key: 'name',
|
92 |
+
fixed: 'left',
|
93 |
+
render: (text: any, { id, thumbnail, name }) => (
|
94 |
+
<div className={styles.toChunks} onClick={() => toChunk(id)}>
|
95 |
+
<Flex gap={10} align="center">
|
96 |
+
{thumbnail ? (
|
97 |
+
<img className={styles.img} src={thumbnail} alt="" />
|
98 |
+
) : (
|
99 |
+
<SvgIcon
|
100 |
+
name={`file-icon/${getExtension(name)}`}
|
101 |
+
width={24}
|
102 |
+
></SvgIcon>
|
103 |
+
)}
|
104 |
+
<Text ellipsis={{ tooltip: text }} className={styles.nameText}>
|
105 |
+
{text}
|
106 |
+
</Text>
|
107 |
+
</Flex>
|
108 |
+
</div>
|
109 |
+
),
|
110 |
+
},
|
111 |
+
{
|
112 |
+
title: t('chunkNumber'),
|
113 |
+
dataIndex: 'chunk_num',
|
114 |
+
key: 'chunk_num',
|
115 |
+
},
|
116 |
+
{
|
117 |
+
title: t('uploadDate'),
|
118 |
+
dataIndex: 'create_time',
|
119 |
+
key: 'create_time',
|
120 |
+
render(value) {
|
121 |
+
return formatDate(value);
|
122 |
+
},
|
123 |
+
},
|
124 |
+
{
|
125 |
+
title: t('chunkMethod'),
|
126 |
+
dataIndex: 'parser_id',
|
127 |
+
key: 'parser_id',
|
128 |
+
render: (text) => {
|
129 |
+
return parserList.find((x) => x.value === text)?.label;
|
130 |
+
},
|
131 |
+
},
|
132 |
+
{
|
133 |
+
title: t('enabled'),
|
134 |
+
key: 'status',
|
135 |
+
dataIndex: 'status',
|
136 |
+
render: (_, { status, id }) => (
|
137 |
+
<>
|
138 |
+
<Switch
|
139 |
+
checked={status === '1'}
|
140 |
+
onChange={(e) => {
|
141 |
+
onChangeStatus(e, id);
|
142 |
+
}}
|
143 |
+
/>
|
144 |
+
</>
|
145 |
+
),
|
146 |
+
},
|
147 |
+
{
|
148 |
+
title: t('parsingStatus'),
|
149 |
+
dataIndex: 'run',
|
150 |
+
key: 'run',
|
151 |
+
render: (text, record) => {
|
152 |
+
return <ParsingStatusCell record={record}></ParsingStatusCell>;
|
153 |
+
},
|
154 |
+
},
|
155 |
+
{
|
156 |
+
title: t('action'),
|
157 |
+
key: 'action',
|
158 |
+
render: (_, record) => (
|
159 |
+
<ParsingActionCell
|
160 |
+
setCurrentRecord={setRecord}
|
161 |
+
showRenameModal={showRenameModal}
|
162 |
+
showChangeParserModal={showChangeParserModal}
|
163 |
+
record={record}
|
164 |
+
></ParsingActionCell>
|
165 |
+
),
|
166 |
+
},
|
167 |
+
];
|
168 |
+
|
169 |
+
const finalColumns = columns.map((x) => ({
|
170 |
+
...x,
|
171 |
+
className: `${styles.column}`,
|
172 |
+
}));
|
173 |
+
|
174 |
+
return (
|
175 |
+
<div className={styles.datasetWrapper}>
|
176 |
+
<h3>{t('dataset')}</h3>
|
177 |
+
<p>{t('datasetDescription')}</p>
|
178 |
+
<Divider></Divider>
|
179 |
+
<DocumentToolbar
|
180 |
+
selectedRowKeys={rowSelection.selectedRowKeys as string[]}
|
181 |
+
showCreateModal={showCreateModal}
|
182 |
+
showWebCrawlModal={showWebCrawlUploadModal}
|
183 |
+
showDocumentUploadModal={showDocumentUploadModal}
|
184 |
+
></DocumentToolbar>
|
185 |
+
<Table
|
186 |
+
rowKey="id"
|
187 |
+
columns={finalColumns}
|
188 |
+
dataSource={data}
|
189 |
+
// loading={loading}
|
190 |
+
pagination={pagination}
|
191 |
+
rowSelection={rowSelection}
|
192 |
+
className={styles.documentTable}
|
193 |
+
scroll={{ scrollToFirstRowOnChange: true, x: 1300 }}
|
194 |
+
/>
|
195 |
+
<CreateFileModal
|
196 |
+
visible={createVisible}
|
197 |
+
hideModal={hideCreateModal}
|
198 |
+
loading={createLoading}
|
199 |
+
onOk={onCreateOk}
|
200 |
+
/>
|
201 |
+
<ChunkMethodModal
|
202 |
+
documentId={currentRecord.id}
|
203 |
+
parserId={currentRecord.parser_id}
|
204 |
+
parserConfig={currentRecord.parser_config}
|
205 |
+
documentExtension={getExtension(currentRecord.name)}
|
206 |
+
onOk={onChangeParserOk}
|
207 |
+
visible={changeParserVisible}
|
208 |
+
hideModal={hideChangeParserModal}
|
209 |
+
loading={changeParserLoading}
|
210 |
+
/>
|
211 |
+
<RenameModal
|
212 |
+
visible={renameVisible}
|
213 |
+
onOk={onRenameOk}
|
214 |
+
loading={renameLoading}
|
215 |
+
hideModal={hideRenameModal}
|
216 |
+
initialName={currentRecord.name}
|
217 |
+
></RenameModal>
|
218 |
+
<FileUploadModal
|
219 |
+
visible={documentUploadVisible}
|
220 |
+
hideModal={hideDocumentUploadModal}
|
221 |
+
loading={documentUploadLoading}
|
222 |
+
onOk={onDocumentUploadOk}
|
223 |
+
></FileUploadModal>
|
224 |
+
<WebCrawlModal
|
225 |
+
visible={webCrawlUploadVisible}
|
226 |
+
hideModal={hideWebCrawlUploadModal}
|
227 |
+
loading={webCrawlUploadLoading}
|
228 |
+
onOk={onWebCrawlUploadOk}
|
229 |
+
></WebCrawlModal>
|
230 |
+
</div>
|
231 |
+
);
|
232 |
+
};
|
233 |
+
|
234 |
+
export default KnowledgeFile;
|
web/src/pages/chat/chat-configuration-modal/index.tsx
CHANGED
@@ -15,7 +15,10 @@ import ModelSetting from './model-setting';
|
|
15 |
import PromptEngine from './prompt-engine';
|
16 |
|
17 |
import { useTranslate } from '@/hooks/commonHooks';
|
18 |
-
import {
|
|
|
|
|
|
|
19 |
import { getBase64FromUploadFileList } from '@/utils/fileUtil';
|
20 |
import { removeUselessFieldsFromValues } from '@/utils/form';
|
21 |
import styles from './index.less';
|
|
|
15 |
import PromptEngine from './prompt-engine';
|
16 |
|
17 |
import { useTranslate } from '@/hooks/commonHooks';
|
18 |
+
import {
|
19 |
+
useFetchLlmModelOnVisible,
|
20 |
+
useFetchModelId,
|
21 |
+
} from '@/hooks/logic-hooks';
|
22 |
import { getBase64FromUploadFileList } from '@/utils/fileUtil';
|
23 |
import { removeUselessFieldsFromValues } from '@/utils/form';
|
24 |
import styles from './index.less';
|
web/src/pages/chat/hooks.ts
CHANGED
@@ -23,7 +23,7 @@ import {
|
|
23 |
useShowDeleteConfirm,
|
24 |
useTranslate,
|
25 |
} from '@/hooks/commonHooks';
|
26 |
-
import { useSendMessageWithSse } from '@/hooks/
|
27 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
28 |
import {
|
29 |
IAnswer,
|
@@ -552,7 +552,7 @@ export const useSendMessage = (
|
|
552 |
const { handleInputChange, value, setValue } = useHandleMessageInputChange();
|
553 |
|
554 |
const { handleClickConversation } = useClickConversationCard();
|
555 |
-
const { send, answer, done } = useSendMessageWithSse();
|
556 |
|
557 |
const sendMessage = useCallback(
|
558 |
async (message: string, id?: string) => {
|
@@ -609,11 +609,19 @@ export const useSendMessage = (
|
|
609 |
);
|
610 |
|
611 |
useEffect(() => {
|
|
|
612 |
if (answer.answer && answer?.conversationId === conversationId) {
|
613 |
addNewestAnswer(answer);
|
614 |
}
|
615 |
}, [answer, addNewestAnswer, conversationId]);
|
616 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
617 |
const handlePressEnter = useCallback(() => {
|
618 |
if (trim(value) === '') return;
|
619 |
|
|
|
23 |
useShowDeleteConfirm,
|
24 |
useTranslate,
|
25 |
} from '@/hooks/commonHooks';
|
26 |
+
import { useSendMessageWithSse } from '@/hooks/logic-hooks';
|
27 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
28 |
import {
|
29 |
IAnswer,
|
|
|
552 |
const { handleInputChange, value, setValue } = useHandleMessageInputChange();
|
553 |
|
554 |
const { handleClickConversation } = useClickConversationCard();
|
555 |
+
const { send, answer, done, setDone } = useSendMessageWithSse();
|
556 |
|
557 |
const sendMessage = useCallback(
|
558 |
async (message: string, id?: string) => {
|
|
|
609 |
);
|
610 |
|
611 |
useEffect(() => {
|
612 |
+
// #1289
|
613 |
if (answer.answer && answer?.conversationId === conversationId) {
|
614 |
addNewestAnswer(answer);
|
615 |
}
|
616 |
}, [answer, addNewestAnswer, conversationId]);
|
617 |
|
618 |
+
useEffect(() => {
|
619 |
+
// #1289 switch to another conversion window when the last conversion answer doesn't finish.
|
620 |
+
if (conversationId) {
|
621 |
+
setDone(true);
|
622 |
+
}
|
623 |
+
}, [setDone, conversationId]);
|
624 |
+
|
625 |
const handlePressEnter = useCallback(() => {
|
626 |
if (trim(value) === '') return;
|
627 |
|
web/src/pages/chat/index.tsx
CHANGED
@@ -1,381 +1,381 @@
|
|
1 |
-
import { ReactComponent as ChatAppCube } from '@/assets/svg/chat-app-cube.svg';
|
2 |
-
import RenameModal from '@/components/rename-modal';
|
3 |
-
import {
|
4 |
-
CloudOutlined,
|
5 |
-
DeleteOutlined,
|
6 |
-
EditOutlined,
|
7 |
-
PlusOutlined,
|
8 |
-
} from '@ant-design/icons';
|
9 |
-
import {
|
10 |
-
Avatar,
|
11 |
-
Button,
|
12 |
-
Card,
|
13 |
-
Divider,
|
14 |
-
Dropdown,
|
15 |
-
Flex,
|
16 |
-
MenuProps,
|
17 |
-
Space,
|
18 |
-
Spin,
|
19 |
-
Tag,
|
20 |
-
Typography,
|
21 |
-
} from 'antd';
|
22 |
-
import { MenuItemProps } from 'antd/lib/menu/MenuItem';
|
23 |
-
import classNames from 'classnames';
|
24 |
-
import { useCallback } from 'react';
|
25 |
-
import ChatConfigurationModal from './chat-configuration-modal';
|
26 |
-
import ChatContainer from './chat-container';
|
27 |
-
import {
|
28 |
-
useClickConversationCard,
|
29 |
-
useClickDialogCard,
|
30 |
-
useDeleteConversation,
|
31 |
-
useDeleteDialog,
|
32 |
-
useEditDialog,
|
33 |
-
useFetchConversationListOnMount,
|
34 |
-
useFetchDialogOnMount,
|
35 |
-
useGetChatSearchParams,
|
36 |
-
useHandleItemHover,
|
37 |
-
useRenameConversation,
|
38 |
-
useSelectConversationListLoading,
|
39 |
-
useSelectDerivedConversationList,
|
40 |
-
useSelectDialogListLoading,
|
41 |
-
useSelectFirstDialogOnMount,
|
42 |
-
} from './hooks';
|
43 |
-
|
44 |
-
import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
|
45 |
-
import { useSetSelectedRecord } from '@/hooks/
|
46 |
-
import { IDialog } from '@/interfaces/database/chat';
|
47 |
-
import ChatOverviewModal from './chat-overview-modal';
|
48 |
-
import styles from './index.less';
|
49 |
-
|
50 |
-
const { Text } = Typography;
|
51 |
-
|
52 |
-
const Chat = () => {
|
53 |
-
const dialogList = useSelectFirstDialogOnMount();
|
54 |
-
const { onRemoveDialog } = useDeleteDialog();
|
55 |
-
const { onRemoveConversation } = useDeleteConversation();
|
56 |
-
const { handleClickDialog } = useClickDialogCard();
|
57 |
-
const { handleClickConversation } = useClickConversationCard();
|
58 |
-
const { dialogId, conversationId } = useGetChatSearchParams();
|
59 |
-
const { list: conversationList, addTemporaryConversation } =
|
60 |
-
useSelectDerivedConversationList();
|
61 |
-
const { activated, handleItemEnter, handleItemLeave } = useHandleItemHover();
|
62 |
-
const {
|
63 |
-
activated: conversationActivated,
|
64 |
-
handleItemEnter: handleConversationItemEnter,
|
65 |
-
handleItemLeave: handleConversationItemLeave,
|
66 |
-
} = useHandleItemHover();
|
67 |
-
const {
|
68 |
-
conversationRenameLoading,
|
69 |
-
initialConversationName,
|
70 |
-
onConversationRenameOk,
|
71 |
-
conversationRenameVisible,
|
72 |
-
hideConversationRenameModal,
|
73 |
-
showConversationRenameModal,
|
74 |
-
} = useRenameConversation();
|
75 |
-
const {
|
76 |
-
dialogSettingLoading,
|
77 |
-
initialDialog,
|
78 |
-
onDialogEditOk,
|
79 |
-
dialogEditVisible,
|
80 |
-
clearDialog,
|
81 |
-
hideDialogEditModal,
|
82 |
-
showDialogEditModal,
|
83 |
-
} = useEditDialog();
|
84 |
-
const dialogLoading = useSelectDialogListLoading();
|
85 |
-
const conversationLoading = useSelectConversationListLoading();
|
86 |
-
const { t } = useTranslate('chat');
|
87 |
-
const {
|
88 |
-
visible: overviewVisible,
|
89 |
-
hideModal: hideOverviewModal,
|
90 |
-
showModal: showOverviewModal,
|
91 |
-
} = useSetModalState();
|
92 |
-
const { currentRecord, setRecord } = useSetSelectedRecord<IDialog>();
|
93 |
-
|
94 |
-
useFetchDialogOnMount(dialogId, true);
|
95 |
-
|
96 |
-
const handleAppCardEnter = (id: string) => () => {
|
97 |
-
handleItemEnter(id);
|
98 |
-
};
|
99 |
-
|
100 |
-
const handleConversationCardEnter = (id: string) => () => {
|
101 |
-
handleConversationItemEnter(id);
|
102 |
-
};
|
103 |
-
|
104 |
-
const handleShowChatConfigurationModal =
|
105 |
-
(dialogId?: string): any =>
|
106 |
-
(info: any) => {
|
107 |
-
info?.domEvent?.preventDefault();
|
108 |
-
info?.domEvent?.stopPropagation();
|
109 |
-
showDialogEditModal(dialogId);
|
110 |
-
};
|
111 |
-
|
112 |
-
const handleRemoveDialog =
|
113 |
-
(dialogId: string): MenuItemProps['onClick'] =>
|
114 |
-
({ domEvent }) => {
|
115 |
-
domEvent.preventDefault();
|
116 |
-
domEvent.stopPropagation();
|
117 |
-
onRemoveDialog([dialogId]);
|
118 |
-
};
|
119 |
-
|
120 |
-
const handleShowOverviewModal =
|
121 |
-
(dialog: IDialog): any =>
|
122 |
-
(info: any) => {
|
123 |
-
info?.domEvent?.preventDefault();
|
124 |
-
info?.domEvent?.stopPropagation();
|
125 |
-
setRecord(dialog);
|
126 |
-
showOverviewModal();
|
127 |
-
};
|
128 |
-
|
129 |
-
const handleRemoveConversation =
|
130 |
-
(conversationId: string): MenuItemProps['onClick'] =>
|
131 |
-
({ domEvent }) => {
|
132 |
-
domEvent.preventDefault();
|
133 |
-
domEvent.stopPropagation();
|
134 |
-
onRemoveConversation([conversationId]);
|
135 |
-
};
|
136 |
-
|
137 |
-
const handleShowConversationRenameModal =
|
138 |
-
(conversationId: string): MenuItemProps['onClick'] =>
|
139 |
-
({ domEvent }) => {
|
140 |
-
domEvent.preventDefault();
|
141 |
-
domEvent.stopPropagation();
|
142 |
-
showConversationRenameModal(conversationId);
|
143 |
-
};
|
144 |
-
|
145 |
-
const handleDialogCardClick = (dialogId: string) => () => {
|
146 |
-
handleClickDialog(dialogId);
|
147 |
-
};
|
148 |
-
|
149 |
-
const handleConversationCardClick = (dialogId: string) => () => {
|
150 |
-
handleClickConversation(dialogId);
|
151 |
-
};
|
152 |
-
|
153 |
-
const handleCreateTemporaryConversation = useCallback(() => {
|
154 |
-
addTemporaryConversation();
|
155 |
-
}, [addTemporaryConversation]);
|
156 |
-
|
157 |
-
const items: MenuProps['items'] = [
|
158 |
-
{
|
159 |
-
key: '1',
|
160 |
-
onClick: handleCreateTemporaryConversation,
|
161 |
-
label: (
|
162 |
-
<Space>
|
163 |
-
<PlusOutlined />
|
164 |
-
{t('newChat')}
|
165 |
-
</Space>
|
166 |
-
),
|
167 |
-
},
|
168 |
-
];
|
169 |
-
|
170 |
-
const buildAppItems = (dialog: IDialog) => {
|
171 |
-
const dialogId = dialog.id;
|
172 |
-
|
173 |
-
const appItems: MenuProps['items'] = [
|
174 |
-
{
|
175 |
-
key: '1',
|
176 |
-
onClick: handleShowChatConfigurationModal(dialogId),
|
177 |
-
label: (
|
178 |
-
<Space>
|
179 |
-
<EditOutlined />
|
180 |
-
{t('edit', { keyPrefix: 'common' })}
|
181 |
-
</Space>
|
182 |
-
),
|
183 |
-
},
|
184 |
-
{ type: 'divider' },
|
185 |
-
{
|
186 |
-
key: '2',
|
187 |
-
onClick: handleRemoveDialog(dialogId),
|
188 |
-
label: (
|
189 |
-
<Space>
|
190 |
-
<DeleteOutlined />
|
191 |
-
{t('delete', { keyPrefix: 'common' })}
|
192 |
-
</Space>
|
193 |
-
),
|
194 |
-
},
|
195 |
-
{ type: 'divider' },
|
196 |
-
{
|
197 |
-
key: '3',
|
198 |
-
onClick: handleShowOverviewModal(dialog),
|
199 |
-
label: (
|
200 |
-
<Space>
|
201 |
-
<CloudOutlined />
|
202 |
-
{t('overview')}
|
203 |
-
</Space>
|
204 |
-
),
|
205 |
-
},
|
206 |
-
];
|
207 |
-
|
208 |
-
return appItems;
|
209 |
-
};
|
210 |
-
|
211 |
-
const buildConversationItems = (conversationId: string) => {
|
212 |
-
const appItems: MenuProps['items'] = [
|
213 |
-
{
|
214 |
-
key: '1',
|
215 |
-
onClick: handleShowConversationRenameModal(conversationId),
|
216 |
-
label: (
|
217 |
-
<Space>
|
218 |
-
<EditOutlined />
|
219 |
-
{t('rename', { keyPrefix: 'common' })}
|
220 |
-
</Space>
|
221 |
-
),
|
222 |
-
},
|
223 |
-
{ type: 'divider' },
|
224 |
-
{
|
225 |
-
key: '2',
|
226 |
-
onClick: handleRemoveConversation(conversationId),
|
227 |
-
label: (
|
228 |
-
<Space>
|
229 |
-
<DeleteOutlined />
|
230 |
-
{t('delete', { keyPrefix: 'common' })}
|
231 |
-
</Space>
|
232 |
-
),
|
233 |
-
},
|
234 |
-
];
|
235 |
-
|
236 |
-
return appItems;
|
237 |
-
};
|
238 |
-
|
239 |
-
useFetchConversationListOnMount();
|
240 |
-
|
241 |
-
return (
|
242 |
-
<Flex className={styles.chatWrapper}>
|
243 |
-
<Flex className={styles.chatAppWrapper}>
|
244 |
-
<Flex flex={1} vertical>
|
245 |
-
<Button type="primary" onClick={handleShowChatConfigurationModal()}>
|
246 |
-
{t('createAssistant')}
|
247 |
-
</Button>
|
248 |
-
<Divider></Divider>
|
249 |
-
<Flex className={styles.chatAppContent} vertical gap={10}>
|
250 |
-
<Spin spinning={dialogLoading} wrapperClassName={styles.chatSpin}>
|
251 |
-
{dialogList.map((x) => (
|
252 |
-
<Card
|
253 |
-
key={x.id}
|
254 |
-
hoverable
|
255 |
-
className={classNames(styles.chatAppCard, {
|
256 |
-
[styles.chatAppCardSelected]: dialogId === x.id,
|
257 |
-
})}
|
258 |
-
onMouseEnter={handleAppCardEnter(x.id)}
|
259 |
-
onMouseLeave={handleItemLeave}
|
260 |
-
onClick={handleDialogCardClick(x.id)}
|
261 |
-
>
|
262 |
-
<Flex justify="space-between" align="center">
|
263 |
-
<Space size={15}>
|
264 |
-
<Avatar src={x.icon} shape={'square'} />
|
265 |
-
<section>
|
266 |
-
<b>
|
267 |
-
<Text
|
268 |
-
ellipsis={{ tooltip: x.name }}
|
269 |
-
style={{ width: 130 }}
|
270 |
-
>
|
271 |
-
{x.name}
|
272 |
-
</Text>
|
273 |
-
</b>
|
274 |
-
<div>{x.description}</div>
|
275 |
-
</section>
|
276 |
-
</Space>
|
277 |
-
{activated === x.id && (
|
278 |
-
<section>
|
279 |
-
<Dropdown menu={{ items: buildAppItems(x) }}>
|
280 |
-
<ChatAppCube
|
281 |
-
className={styles.cubeIcon}
|
282 |
-
></ChatAppCube>
|
283 |
-
</Dropdown>
|
284 |
-
</section>
|
285 |
-
)}
|
286 |
-
</Flex>
|
287 |
-
</Card>
|
288 |
-
))}
|
289 |
-
</Spin>
|
290 |
-
</Flex>
|
291 |
-
</Flex>
|
292 |
-
</Flex>
|
293 |
-
<Divider type={'vertical'} className={styles.divider}></Divider>
|
294 |
-
<Flex className={styles.chatTitleWrapper}>
|
295 |
-
<Flex flex={1} vertical>
|
296 |
-
<Flex
|
297 |
-
justify={'space-between'}
|
298 |
-
align="center"
|
299 |
-
className={styles.chatTitle}
|
300 |
-
>
|
301 |
-
<Space>
|
302 |
-
<b>{t('chat')}</b>
|
303 |
-
<Tag>{conversationList.length}</Tag>
|
304 |
-
</Space>
|
305 |
-
<Dropdown menu={{ items }}>
|
306 |
-
{/* <FormOutlined /> */}
|
307 |
-
<PlusOutlined />
|
308 |
-
</Dropdown>
|
309 |
-
</Flex>
|
310 |
-
<Divider></Divider>
|
311 |
-
<Flex vertical gap={10} className={styles.chatTitleContent}>
|
312 |
-
<Spin
|
313 |
-
spinning={conversationLoading}
|
314 |
-
wrapperClassName={styles.chatSpin}
|
315 |
-
>
|
316 |
-
{conversationList.map((x) => (
|
317 |
-
<Card
|
318 |
-
key={x.id}
|
319 |
-
hoverable
|
320 |
-
onClick={handleConversationCardClick(x.id)}
|
321 |
-
onMouseEnter={handleConversationCardEnter(x.id)}
|
322 |
-
onMouseLeave={handleConversationItemLeave}
|
323 |
-
className={classNames(styles.chatTitleCard, {
|
324 |
-
[styles.chatTitleCardSelected]: x.id === conversationId,
|
325 |
-
})}
|
326 |
-
>
|
327 |
-
<Flex justify="space-between" align="center">
|
328 |
-
<div>
|
329 |
-
<Text
|
330 |
-
ellipsis={{ tooltip: x.name }}
|
331 |
-
style={{ width: 150 }}
|
332 |
-
>
|
333 |
-
{x.name}
|
334 |
-
</Text>
|
335 |
-
</div>
|
336 |
-
{conversationActivated === x.id && x.id !== '' && (
|
337 |
-
<section>
|
338 |
-
<Dropdown
|
339 |
-
menu={{ items: buildConversationItems(x.id) }}
|
340 |
-
>
|
341 |
-
<ChatAppCube
|
342 |
-
className={styles.cubeIcon}
|
343 |
-
></ChatAppCube>
|
344 |
-
</Dropdown>
|
345 |
-
</section>
|
346 |
-
)}
|
347 |
-
</Flex>
|
348 |
-
</Card>
|
349 |
-
))}
|
350 |
-
</Spin>
|
351 |
-
</Flex>
|
352 |
-
</Flex>
|
353 |
-
</Flex>
|
354 |
-
<Divider type={'vertical'} className={styles.divider}></Divider>
|
355 |
-
<ChatContainer></ChatContainer>
|
356 |
-
<ChatConfigurationModal
|
357 |
-
visible={dialogEditVisible}
|
358 |
-
initialDialog={initialDialog}
|
359 |
-
showModal={showDialogEditModal}
|
360 |
-
hideModal={hideDialogEditModal}
|
361 |
-
loading={dialogSettingLoading}
|
362 |
-
onOk={onDialogEditOk}
|
363 |
-
clearDialog={clearDialog}
|
364 |
-
></ChatConfigurationModal>
|
365 |
-
<RenameModal
|
366 |
-
visible={conversationRenameVisible}
|
367 |
-
hideModal={hideConversationRenameModal}
|
368 |
-
onOk={onConversationRenameOk}
|
369 |
-
initialName={initialConversationName}
|
370 |
-
loading={conversationRenameLoading}
|
371 |
-
></RenameModal>
|
372 |
-
<ChatOverviewModal
|
373 |
-
visible={overviewVisible}
|
374 |
-
hideModal={hideOverviewModal}
|
375 |
-
dialog={currentRecord}
|
376 |
-
></ChatOverviewModal>
|
377 |
-
</Flex>
|
378 |
-
);
|
379 |
-
};
|
380 |
-
|
381 |
-
export default Chat;
|
|
|
1 |
+
import { ReactComponent as ChatAppCube } from '@/assets/svg/chat-app-cube.svg';
|
2 |
+
import RenameModal from '@/components/rename-modal';
|
3 |
+
import {
|
4 |
+
CloudOutlined,
|
5 |
+
DeleteOutlined,
|
6 |
+
EditOutlined,
|
7 |
+
PlusOutlined,
|
8 |
+
} from '@ant-design/icons';
|
9 |
+
import {
|
10 |
+
Avatar,
|
11 |
+
Button,
|
12 |
+
Card,
|
13 |
+
Divider,
|
14 |
+
Dropdown,
|
15 |
+
Flex,
|
16 |
+
MenuProps,
|
17 |
+
Space,
|
18 |
+
Spin,
|
19 |
+
Tag,
|
20 |
+
Typography,
|
21 |
+
} from 'antd';
|
22 |
+
import { MenuItemProps } from 'antd/lib/menu/MenuItem';
|
23 |
+
import classNames from 'classnames';
|
24 |
+
import { useCallback } from 'react';
|
25 |
+
import ChatConfigurationModal from './chat-configuration-modal';
|
26 |
+
import ChatContainer from './chat-container';
|
27 |
+
import {
|
28 |
+
useClickConversationCard,
|
29 |
+
useClickDialogCard,
|
30 |
+
useDeleteConversation,
|
31 |
+
useDeleteDialog,
|
32 |
+
useEditDialog,
|
33 |
+
useFetchConversationListOnMount,
|
34 |
+
useFetchDialogOnMount,
|
35 |
+
useGetChatSearchParams,
|
36 |
+
useHandleItemHover,
|
37 |
+
useRenameConversation,
|
38 |
+
useSelectConversationListLoading,
|
39 |
+
useSelectDerivedConversationList,
|
40 |
+
useSelectDialogListLoading,
|
41 |
+
useSelectFirstDialogOnMount,
|
42 |
+
} from './hooks';
|
43 |
+
|
44 |
+
import { useSetModalState, useTranslate } from '@/hooks/commonHooks';
|
45 |
+
import { useSetSelectedRecord } from '@/hooks/logic-hooks';
|
46 |
+
import { IDialog } from '@/interfaces/database/chat';
|
47 |
+
import ChatOverviewModal from './chat-overview-modal';
|
48 |
+
import styles from './index.less';
|
49 |
+
|
50 |
+
const { Text } = Typography;
|
51 |
+
|
52 |
+
const Chat = () => {
|
53 |
+
const dialogList = useSelectFirstDialogOnMount();
|
54 |
+
const { onRemoveDialog } = useDeleteDialog();
|
55 |
+
const { onRemoveConversation } = useDeleteConversation();
|
56 |
+
const { handleClickDialog } = useClickDialogCard();
|
57 |
+
const { handleClickConversation } = useClickConversationCard();
|
58 |
+
const { dialogId, conversationId } = useGetChatSearchParams();
|
59 |
+
const { list: conversationList, addTemporaryConversation } =
|
60 |
+
useSelectDerivedConversationList();
|
61 |
+
const { activated, handleItemEnter, handleItemLeave } = useHandleItemHover();
|
62 |
+
const {
|
63 |
+
activated: conversationActivated,
|
64 |
+
handleItemEnter: handleConversationItemEnter,
|
65 |
+
handleItemLeave: handleConversationItemLeave,
|
66 |
+
} = useHandleItemHover();
|
67 |
+
const {
|
68 |
+
conversationRenameLoading,
|
69 |
+
initialConversationName,
|
70 |
+
onConversationRenameOk,
|
71 |
+
conversationRenameVisible,
|
72 |
+
hideConversationRenameModal,
|
73 |
+
showConversationRenameModal,
|
74 |
+
} = useRenameConversation();
|
75 |
+
const {
|
76 |
+
dialogSettingLoading,
|
77 |
+
initialDialog,
|
78 |
+
onDialogEditOk,
|
79 |
+
dialogEditVisible,
|
80 |
+
clearDialog,
|
81 |
+
hideDialogEditModal,
|
82 |
+
showDialogEditModal,
|
83 |
+
} = useEditDialog();
|
84 |
+
const dialogLoading = useSelectDialogListLoading();
|
85 |
+
const conversationLoading = useSelectConversationListLoading();
|
86 |
+
const { t } = useTranslate('chat');
|
87 |
+
const {
|
88 |
+
visible: overviewVisible,
|
89 |
+
hideModal: hideOverviewModal,
|
90 |
+
showModal: showOverviewModal,
|
91 |
+
} = useSetModalState();
|
92 |
+
const { currentRecord, setRecord } = useSetSelectedRecord<IDialog>();
|
93 |
+
|
94 |
+
useFetchDialogOnMount(dialogId, true);
|
95 |
+
|
96 |
+
const handleAppCardEnter = (id: string) => () => {
|
97 |
+
handleItemEnter(id);
|
98 |
+
};
|
99 |
+
|
100 |
+
const handleConversationCardEnter = (id: string) => () => {
|
101 |
+
handleConversationItemEnter(id);
|
102 |
+
};
|
103 |
+
|
104 |
+
const handleShowChatConfigurationModal =
|
105 |
+
(dialogId?: string): any =>
|
106 |
+
(info: any) => {
|
107 |
+
info?.domEvent?.preventDefault();
|
108 |
+
info?.domEvent?.stopPropagation();
|
109 |
+
showDialogEditModal(dialogId);
|
110 |
+
};
|
111 |
+
|
112 |
+
const handleRemoveDialog =
|
113 |
+
(dialogId: string): MenuItemProps['onClick'] =>
|
114 |
+
({ domEvent }) => {
|
115 |
+
domEvent.preventDefault();
|
116 |
+
domEvent.stopPropagation();
|
117 |
+
onRemoveDialog([dialogId]);
|
118 |
+
};
|
119 |
+
|
120 |
+
const handleShowOverviewModal =
|
121 |
+
(dialog: IDialog): any =>
|
122 |
+
(info: any) => {
|
123 |
+
info?.domEvent?.preventDefault();
|
124 |
+
info?.domEvent?.stopPropagation();
|
125 |
+
setRecord(dialog);
|
126 |
+
showOverviewModal();
|
127 |
+
};
|
128 |
+
|
129 |
+
const handleRemoveConversation =
|
130 |
+
(conversationId: string): MenuItemProps['onClick'] =>
|
131 |
+
({ domEvent }) => {
|
132 |
+
domEvent.preventDefault();
|
133 |
+
domEvent.stopPropagation();
|
134 |
+
onRemoveConversation([conversationId]);
|
135 |
+
};
|
136 |
+
|
137 |
+
const handleShowConversationRenameModal =
|
138 |
+
(conversationId: string): MenuItemProps['onClick'] =>
|
139 |
+
({ domEvent }) => {
|
140 |
+
domEvent.preventDefault();
|
141 |
+
domEvent.stopPropagation();
|
142 |
+
showConversationRenameModal(conversationId);
|
143 |
+
};
|
144 |
+
|
145 |
+
const handleDialogCardClick = (dialogId: string) => () => {
|
146 |
+
handleClickDialog(dialogId);
|
147 |
+
};
|
148 |
+
|
149 |
+
const handleConversationCardClick = (dialogId: string) => () => {
|
150 |
+
handleClickConversation(dialogId);
|
151 |
+
};
|
152 |
+
|
153 |
+
const handleCreateTemporaryConversation = useCallback(() => {
|
154 |
+
addTemporaryConversation();
|
155 |
+
}, [addTemporaryConversation]);
|
156 |
+
|
157 |
+
const items: MenuProps['items'] = [
|
158 |
+
{
|
159 |
+
key: '1',
|
160 |
+
onClick: handleCreateTemporaryConversation,
|
161 |
+
label: (
|
162 |
+
<Space>
|
163 |
+
<PlusOutlined />
|
164 |
+
{t('newChat')}
|
165 |
+
</Space>
|
166 |
+
),
|
167 |
+
},
|
168 |
+
];
|
169 |
+
|
170 |
+
const buildAppItems = (dialog: IDialog) => {
|
171 |
+
const dialogId = dialog.id;
|
172 |
+
|
173 |
+
const appItems: MenuProps['items'] = [
|
174 |
+
{
|
175 |
+
key: '1',
|
176 |
+
onClick: handleShowChatConfigurationModal(dialogId),
|
177 |
+
label: (
|
178 |
+
<Space>
|
179 |
+
<EditOutlined />
|
180 |
+
{t('edit', { keyPrefix: 'common' })}
|
181 |
+
</Space>
|
182 |
+
),
|
183 |
+
},
|
184 |
+
{ type: 'divider' },
|
185 |
+
{
|
186 |
+
key: '2',
|
187 |
+
onClick: handleRemoveDialog(dialogId),
|
188 |
+
label: (
|
189 |
+
<Space>
|
190 |
+
<DeleteOutlined />
|
191 |
+
{t('delete', { keyPrefix: 'common' })}
|
192 |
+
</Space>
|
193 |
+
),
|
194 |
+
},
|
195 |
+
{ type: 'divider' },
|
196 |
+
{
|
197 |
+
key: '3',
|
198 |
+
onClick: handleShowOverviewModal(dialog),
|
199 |
+
label: (
|
200 |
+
<Space>
|
201 |
+
<CloudOutlined />
|
202 |
+
{t('overview')}
|
203 |
+
</Space>
|
204 |
+
),
|
205 |
+
},
|
206 |
+
];
|
207 |
+
|
208 |
+
return appItems;
|
209 |
+
};
|
210 |
+
|
211 |
+
const buildConversationItems = (conversationId: string) => {
|
212 |
+
const appItems: MenuProps['items'] = [
|
213 |
+
{
|
214 |
+
key: '1',
|
215 |
+
onClick: handleShowConversationRenameModal(conversationId),
|
216 |
+
label: (
|
217 |
+
<Space>
|
218 |
+
<EditOutlined />
|
219 |
+
{t('rename', { keyPrefix: 'common' })}
|
220 |
+
</Space>
|
221 |
+
),
|
222 |
+
},
|
223 |
+
{ type: 'divider' },
|
224 |
+
{
|
225 |
+
key: '2',
|
226 |
+
onClick: handleRemoveConversation(conversationId),
|
227 |
+
label: (
|
228 |
+
<Space>
|
229 |
+
<DeleteOutlined />
|
230 |
+
{t('delete', { keyPrefix: 'common' })}
|
231 |
+
</Space>
|
232 |
+
),
|
233 |
+
},
|
234 |
+
];
|
235 |
+
|
236 |
+
return appItems;
|
237 |
+
};
|
238 |
+
|
239 |
+
useFetchConversationListOnMount();
|
240 |
+
|
241 |
+
return (
|
242 |
+
<Flex className={styles.chatWrapper}>
|
243 |
+
<Flex className={styles.chatAppWrapper}>
|
244 |
+
<Flex flex={1} vertical>
|
245 |
+
<Button type="primary" onClick={handleShowChatConfigurationModal()}>
|
246 |
+
{t('createAssistant')}
|
247 |
+
</Button>
|
248 |
+
<Divider></Divider>
|
249 |
+
<Flex className={styles.chatAppContent} vertical gap={10}>
|
250 |
+
<Spin spinning={dialogLoading} wrapperClassName={styles.chatSpin}>
|
251 |
+
{dialogList.map((x) => (
|
252 |
+
<Card
|
253 |
+
key={x.id}
|
254 |
+
hoverable
|
255 |
+
className={classNames(styles.chatAppCard, {
|
256 |
+
[styles.chatAppCardSelected]: dialogId === x.id,
|
257 |
+
})}
|
258 |
+
onMouseEnter={handleAppCardEnter(x.id)}
|
259 |
+
onMouseLeave={handleItemLeave}
|
260 |
+
onClick={handleDialogCardClick(x.id)}
|
261 |
+
>
|
262 |
+
<Flex justify="space-between" align="center">
|
263 |
+
<Space size={15}>
|
264 |
+
<Avatar src={x.icon} shape={'square'} />
|
265 |
+
<section>
|
266 |
+
<b>
|
267 |
+
<Text
|
268 |
+
ellipsis={{ tooltip: x.name }}
|
269 |
+
style={{ width: 130 }}
|
270 |
+
>
|
271 |
+
{x.name}
|
272 |
+
</Text>
|
273 |
+
</b>
|
274 |
+
<div>{x.description}</div>
|
275 |
+
</section>
|
276 |
+
</Space>
|
277 |
+
{activated === x.id && (
|
278 |
+
<section>
|
279 |
+
<Dropdown menu={{ items: buildAppItems(x) }}>
|
280 |
+
<ChatAppCube
|
281 |
+
className={styles.cubeIcon}
|
282 |
+
></ChatAppCube>
|
283 |
+
</Dropdown>
|
284 |
+
</section>
|
285 |
+
)}
|
286 |
+
</Flex>
|
287 |
+
</Card>
|
288 |
+
))}
|
289 |
+
</Spin>
|
290 |
+
</Flex>
|
291 |
+
</Flex>
|
292 |
+
</Flex>
|
293 |
+
<Divider type={'vertical'} className={styles.divider}></Divider>
|
294 |
+
<Flex className={styles.chatTitleWrapper}>
|
295 |
+
<Flex flex={1} vertical>
|
296 |
+
<Flex
|
297 |
+
justify={'space-between'}
|
298 |
+
align="center"
|
299 |
+
className={styles.chatTitle}
|
300 |
+
>
|
301 |
+
<Space>
|
302 |
+
<b>{t('chat')}</b>
|
303 |
+
<Tag>{conversationList.length}</Tag>
|
304 |
+
</Space>
|
305 |
+
<Dropdown menu={{ items }}>
|
306 |
+
{/* <FormOutlined /> */}
|
307 |
+
<PlusOutlined />
|
308 |
+
</Dropdown>
|
309 |
+
</Flex>
|
310 |
+
<Divider></Divider>
|
311 |
+
<Flex vertical gap={10} className={styles.chatTitleContent}>
|
312 |
+
<Spin
|
313 |
+
spinning={conversationLoading}
|
314 |
+
wrapperClassName={styles.chatSpin}
|
315 |
+
>
|
316 |
+
{conversationList.map((x) => (
|
317 |
+
<Card
|
318 |
+
key={x.id}
|
319 |
+
hoverable
|
320 |
+
onClick={handleConversationCardClick(x.id)}
|
321 |
+
onMouseEnter={handleConversationCardEnter(x.id)}
|
322 |
+
onMouseLeave={handleConversationItemLeave}
|
323 |
+
className={classNames(styles.chatTitleCard, {
|
324 |
+
[styles.chatTitleCardSelected]: x.id === conversationId,
|
325 |
+
})}
|
326 |
+
>
|
327 |
+
<Flex justify="space-between" align="center">
|
328 |
+
<div>
|
329 |
+
<Text
|
330 |
+
ellipsis={{ tooltip: x.name }}
|
331 |
+
style={{ width: 150 }}
|
332 |
+
>
|
333 |
+
{x.name}
|
334 |
+
</Text>
|
335 |
+
</div>
|
336 |
+
{conversationActivated === x.id && x.id !== '' && (
|
337 |
+
<section>
|
338 |
+
<Dropdown
|
339 |
+
menu={{ items: buildConversationItems(x.id) }}
|
340 |
+
>
|
341 |
+
<ChatAppCube
|
342 |
+
className={styles.cubeIcon}
|
343 |
+
></ChatAppCube>
|
344 |
+
</Dropdown>
|
345 |
+
</section>
|
346 |
+
)}
|
347 |
+
</Flex>
|
348 |
+
</Card>
|
349 |
+
))}
|
350 |
+
</Spin>
|
351 |
+
</Flex>
|
352 |
+
</Flex>
|
353 |
+
</Flex>
|
354 |
+
<Divider type={'vertical'} className={styles.divider}></Divider>
|
355 |
+
<ChatContainer></ChatContainer>
|
356 |
+
<ChatConfigurationModal
|
357 |
+
visible={dialogEditVisible}
|
358 |
+
initialDialog={initialDialog}
|
359 |
+
showModal={showDialogEditModal}
|
360 |
+
hideModal={hideDialogEditModal}
|
361 |
+
loading={dialogSettingLoading}
|
362 |
+
onOk={onDialogEditOk}
|
363 |
+
clearDialog={clearDialog}
|
364 |
+
></ChatConfigurationModal>
|
365 |
+
<RenameModal
|
366 |
+
visible={conversationRenameVisible}
|
367 |
+
hideModal={hideConversationRenameModal}
|
368 |
+
onOk={onConversationRenameOk}
|
369 |
+
initialName={initialConversationName}
|
370 |
+
loading={conversationRenameLoading}
|
371 |
+
></RenameModal>
|
372 |
+
<ChatOverviewModal
|
373 |
+
visible={overviewVisible}
|
374 |
+
hideModal={hideOverviewModal}
|
375 |
+
dialog={currentRecord}
|
376 |
+
></ChatOverviewModal>
|
377 |
+
</Flex>
|
378 |
+
);
|
379 |
+
};
|
380 |
+
|
381 |
+
export default Chat;
|
web/src/pages/chat/shared-hooks.ts
CHANGED
@@ -3,7 +3,7 @@ import {
|
|
3 |
useCreateSharedConversation,
|
4 |
useFetchSharedConversation,
|
5 |
} from '@/hooks/chatHooks';
|
6 |
-
import { useSendMessageWithSse } from '@/hooks/
|
7 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
8 |
import { IAnswer } from '@/interfaces/database/chat';
|
9 |
import api from '@/utils/api';
|
|
|
3 |
useCreateSharedConversation,
|
4 |
useFetchSharedConversation,
|
5 |
} from '@/hooks/chatHooks';
|
6 |
+
import { useSendMessageWithSse } from '@/hooks/logic-hooks';
|
7 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
8 |
import { IAnswer } from '@/interfaces/database/chat';
|
9 |
import api from '@/utils/api';
|
web/src/pages/file-manager/hooks.ts
CHANGED
@@ -10,7 +10,7 @@ import {
|
|
10 |
useSelectParentFolderList,
|
11 |
useUploadFile,
|
12 |
} from '@/hooks/fileManagerHooks';
|
13 |
-
import { useGetPagination, useSetPagination } from '@/hooks/
|
14 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
15 |
import { IFile } from '@/interfaces/database/file-manager';
|
16 |
import { PaginationProps } from 'antd';
|
|
|
10 |
useSelectParentFolderList,
|
11 |
useUploadFile,
|
12 |
} from '@/hooks/fileManagerHooks';
|
13 |
+
import { useGetPagination, useSetPagination } from '@/hooks/logic-hooks';
|
14 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
15 |
import { IFile } from '@/interfaces/database/file-manager';
|
16 |
import { PaginationProps } from 'antd';
|
web/src/pages/flow/chat/hooks.ts
CHANGED
@@ -4,7 +4,7 @@ import {
|
|
4 |
useHandleMessageInputChange,
|
5 |
useScrollToBottom,
|
6 |
useSendMessageWithSse,
|
7 |
-
} from '@/hooks/
|
8 |
import { IAnswer } from '@/interfaces/database/chat';
|
9 |
import { IMessage } from '@/pages/chat/interface';
|
10 |
import api from '@/utils/api';
|
|
|
4 |
useHandleMessageInputChange,
|
5 |
useScrollToBottom,
|
6 |
useSendMessageWithSse,
|
7 |
+
} from '@/hooks/logic-hooks';
|
8 |
import { IAnswer } from '@/interfaces/database/chat';
|
9 |
import { IMessage } from '@/pages/chat/interface';
|
10 |
import api from '@/utils/api';
|
web/src/pages/flow/hooks.ts
CHANGED
@@ -18,7 +18,7 @@ import {
|
|
18 |
ModelVariableType,
|
19 |
settledModelVariableMap,
|
20 |
} from '@/constants/knowledge';
|
21 |
-
import { useFetchModelId, useSendMessageWithSse } from '@/hooks/
|
22 |
import { Variable } from '@/interfaces/database/chat';
|
23 |
import api from '@/utils/api';
|
24 |
import { useDebounceEffect } from 'ahooks';
|
|
|
18 |
ModelVariableType,
|
19 |
settledModelVariableMap,
|
20 |
} from '@/constants/knowledge';
|
21 |
+
import { useFetchModelId, useSendMessageWithSse } from '@/hooks/logic-hooks';
|
22 |
import { Variable } from '@/interfaces/database/chat';
|
23 |
import api from '@/utils/api';
|
24 |
import { useDebounceEffect } from 'ahooks';
|
web/src/pages/flow/list/create-flow-modal.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
2 |
import { useTranslate } from '@/hooks/commonHooks';
|
3 |
import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
|
4 |
-
import { useSelectItem } from '@/hooks/
|
5 |
import { Card, Flex, Form, Input, Modal, Space, Typography } from 'antd';
|
6 |
import classNames from 'classnames';
|
7 |
import { useEffect } from 'react';
|
|
|
1 |
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
2 |
import { useTranslate } from '@/hooks/commonHooks';
|
3 |
import { useFetchFlowTemplates } from '@/hooks/flow-hooks';
|
4 |
+
import { useSelectItem } from '@/hooks/logic-hooks';
|
5 |
import { Card, Flex, Form, Input, Modal, Space, Typography } from 'antd';
|
6 |
import classNames from 'classnames';
|
7 |
import { useEffect } from 'react';
|
web/src/pages/user-setting/setting-profile/index.tsx
CHANGED
@@ -32,7 +32,7 @@ import {
|
|
32 |
|
33 |
import { LanguageList } from '@/constants/common';
|
34 |
import { useTranslate } from '@/hooks/commonHooks';
|
35 |
-
import { useChangeLanguage } from '@/hooks/
|
36 |
import parentStyles from '../index.less';
|
37 |
import styles from './index.less';
|
38 |
|
|
|
32 |
|
33 |
import { LanguageList } from '@/constants/common';
|
34 |
import { useTranslate } from '@/hooks/commonHooks';
|
35 |
+
import { useChangeLanguage } from '@/hooks/logic-hooks';
|
36 |
import parentStyles from '../index.less';
|
37 |
import styles from './index.less';
|
38 |
|