@myun/gimi-chat 0.9.27 → 0.9.29
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/client/components/history-list/index.module.css +6 -6
- package/dist/client/components/new-main/index.css +1 -1
- package/dist/client/components/slider/index.css +7 -7
- package/dist/components/ai-chat-dialogue/index.js +4 -4
- package/dist/components/ai-chat-dialogue/index.module copy.css +7 -7
- package/dist/components/ai-chat-dialogue/index.module.css +16 -9
- package/dist/components/ai-loading/index.module.css +1 -1
- package/dist/components/answer-item/index.module.css +9 -9
- package/dist/components/ask-card/index.js +6 -4
- package/dist/components/ask-card/index.module.css +10 -10
- package/dist/components/chat-input/extension/title-slot/index.less +3 -2
- package/dist/components/chat-input/index.js +13 -9
- package/dist/components/chat-input/index.module.css +11 -7
- package/dist/components/chat-voice/VoiceCommunication.js +5 -8
- package/dist/components/chat-voice/VoiceRecord.js +5 -8
- package/dist/components/dots-loading/index.module.css +1 -1
- package/dist/components/empty/index.module.css +1 -1
- package/dist/components/excel-components/index.module.css +15 -15
- package/dist/components/excel-components/styles.module.css +2 -2
- package/dist/components/file-card/index.js +5 -4
- package/dist/components/file-card/index.module.css +7 -7
- package/dist/components/file-preview/index.module.css +6 -6
- package/dist/components/file-upload/index.js +35 -9
- package/dist/components/iconfont-com/index.js +1 -1
- package/dist/components/knowledge-trace/index.module.css +12 -12
- package/dist/components/message-actions/CopyButton.js +5 -9
- package/dist/components/message-actions/LikeButton.js +7 -11
- package/dist/components/message-actions/RegenerateButton.js +2 -1
- package/dist/components/message-actions/UnLikeButton.js +7 -11
- package/dist/components/message-actions/VoicePlay.js +5 -10
- package/dist/components/message-list/index.module.css +9 -9
- package/dist/components/product-tag/index.module.css +3 -3
- package/dist/components/quoted-content/index.js +5 -6
- package/dist/components/quoted-content/index.module.css +33 -8
- package/dist/components/reasoning-content/index.module.css +5 -5
- package/dist/components/reference-content/index.module.css +5 -5
- package/dist/components/search-course-list/index.module.css +4 -4
- package/dist/components/search-result/index.module.css +12 -12
- package/dist/components/templates/index.module.css +1 -1
- package/dist/components/upload-list/CustomFile.js +20 -10
- package/dist/components/upload-list/ImageFile.js +22 -16
- package/dist/components/upload-list/customFile.module.css +6 -6
- package/dist/components/upload-list/imageFile.module.css +7 -15
- package/dist/components/upload-list/index.module.css +1 -1
- package/dist/components/voice-bars/index.js +1 -1
- package/dist/components/work-flow-content/index.module.css +1 -1
- package/dist/hooks/useFile.d.ts +1 -0
- package/dist/hooks/useFile.js +51 -13
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
package/dist/hooks/useFile.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const retryWithExponentialBackoff: <T>(fn: () => Promise<T>, opti
|
|
|
8
8
|
}) => Promise<T | undefined>;
|
|
9
9
|
export declare const useGimiFileUpload: (onFileUploaded?: ((file: FileItem) => void) | undefined) => {
|
|
10
10
|
fileUploadAbortRef: import("react").MutableRefObject<AbortController | null>;
|
|
11
|
+
abortAll: () => void;
|
|
11
12
|
handleSSEFileAnalyize: (file: FileItem, autoRetry?: boolean) => void;
|
|
12
13
|
fileUpload: (file: any, autoRetry?: boolean) => void;
|
|
13
14
|
};
|
package/dist/hooks/useFile.js
CHANGED
|
@@ -85,6 +85,9 @@ var parseStrToObj = function parseStrToObj(value) {
|
|
|
85
85
|
export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
86
86
|
var _useTranslation = useTranslation(),
|
|
87
87
|
t = _useTranslation.t;
|
|
88
|
+
// 每个 uid 独立维护 AbortController,避免多文件并发解析时互相打断
|
|
89
|
+
var abortControllerMapRef = useRef(new Map());
|
|
90
|
+
// 兼容外部仅持有单个 ref 的调用:取最后一个存入的 controller
|
|
88
91
|
var abortControllerRef = useRef(null);
|
|
89
92
|
var token = useSelector(function (state) {
|
|
90
93
|
return state.gimiMenu.token;
|
|
@@ -97,11 +100,35 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
97
100
|
var IMAGE_ANALYIZE_URL = "https://".concat(baseUrl, "/mflux/api/llmRunning/instruction/run/question");
|
|
98
101
|
var dispatch = useDispatch();
|
|
99
102
|
var store = useStore();
|
|
103
|
+
|
|
104
|
+
/** 设置某个 uid 的 abort controller,并同步到最后存入的引用 */
|
|
105
|
+
var setAbortController = function setAbortController(uid, controller) {
|
|
106
|
+
if (controller) {
|
|
107
|
+
abortControllerMapRef.current.set(uid, controller);
|
|
108
|
+
abortControllerRef.current = controller;
|
|
109
|
+
} else {
|
|
110
|
+
abortControllerMapRef.current.delete(uid);
|
|
111
|
+
// 同步对外 ref:若当前指向的就是被清理的,则置空
|
|
112
|
+
if (abortControllerRef.current && !abortControllerMapRef.current.has(uid)) {
|
|
113
|
+
abortControllerRef.current = null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/** 中断某个 uid 的解析(仅影响该 uid) */
|
|
119
|
+
var abortByUid = function abortByUid(uid) {
|
|
120
|
+
var controller = abortControllerMapRef.current.get(uid);
|
|
121
|
+
if (controller) {
|
|
122
|
+
controller.abort();
|
|
123
|
+
abortControllerMapRef.current.delete(uid);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
100
126
|
var changeFileStatus = function changeFileStatus(newStatus, file) {
|
|
101
127
|
var currentFileList = store.getState().gimiMenu.fileList || [];
|
|
102
128
|
var newFileList = currentFileList.map(function (item) {
|
|
103
129
|
if (item.uid === file.uid) {
|
|
104
|
-
|
|
130
|
+
// 基于 store 中的当前 item 更新,避免用旧快照覆盖并发写入的进度
|
|
131
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
105
132
|
status: newStatus
|
|
106
133
|
});
|
|
107
134
|
}
|
|
@@ -156,7 +183,8 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
156
183
|
currentFileList = store.getState().gimiMenu.fileList || [];
|
|
157
184
|
newFileList = currentFileList.map(function (item) {
|
|
158
185
|
if (item.uid === file.uid) {
|
|
159
|
-
|
|
186
|
+
// 基于 store 中的当前 item 更新,避免覆盖并发写入的进度
|
|
187
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
160
188
|
status: FileStatus.ANALYSE_SUCCESS,
|
|
161
189
|
content: data.result
|
|
162
190
|
});
|
|
@@ -184,7 +212,7 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
184
212
|
_context2.prev = 20;
|
|
185
213
|
_context2.t0 = _context2["catch"](2);
|
|
186
214
|
changeFileStatus(FileStatus.ANALYSE_FAILED, file);
|
|
187
|
-
Toast.error(
|
|
215
|
+
Toast.error(t('upload.parseFailed'));
|
|
188
216
|
case 24:
|
|
189
217
|
case "end":
|
|
190
218
|
return _context2.stop();
|
|
@@ -206,11 +234,10 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
206
234
|
// 非图片文件使用原有的 SSE 解析接口
|
|
207
235
|
var fetchSSE = function fetchSSE() {
|
|
208
236
|
changeFileStatus(FileStatus.PADDING, file);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
237
|
+
// 仅中断该 uid 上一次未完成的解析(如重试场景),不影响其它文件
|
|
238
|
+
abortByUid(file.uid);
|
|
212
239
|
var abortController = new AbortController();
|
|
213
|
-
|
|
240
|
+
setAbortController(file.uid, abortController);
|
|
214
241
|
var params = {
|
|
215
242
|
fileType: file.fileType,
|
|
216
243
|
fileUrl: file.fileUrl,
|
|
@@ -239,10 +266,11 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
239
266
|
var currentFileList = store.getState().gimiMenu.fileList || [];
|
|
240
267
|
var newFileList = currentFileList.map(function (item) {
|
|
241
268
|
if (item.uid === file.uid) {
|
|
242
|
-
|
|
269
|
+
// 基于 store 中的当前 item 更新,避免用旧快照覆盖并发写入的进度
|
|
270
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
243
271
|
status: data.statusCode === 'Success' ? FileStatus.ANALYSE_SUCCESS : FileStatus.PADDING,
|
|
244
272
|
process: data.process,
|
|
245
|
-
content: data.statusCode === 'Success' ? data.mdContent : ''
|
|
273
|
+
content: data.statusCode === 'Success' ? data.mdContent : item.content || ''
|
|
246
274
|
});
|
|
247
275
|
}
|
|
248
276
|
return item;
|
|
@@ -268,11 +296,11 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
268
296
|
}
|
|
269
297
|
},
|
|
270
298
|
onclose: function onclose() {
|
|
271
|
-
|
|
299
|
+
setAbortController(file.uid, null);
|
|
272
300
|
},
|
|
273
301
|
onerror: function onerror(error) {
|
|
274
302
|
abortController.abort();
|
|
275
|
-
|
|
303
|
+
setAbortController(file.uid, null);
|
|
276
304
|
reject(new Error(t('upload.parseFailed'))); // 将错误抛出以触发重试逻辑
|
|
277
305
|
throw error; // 抛出异常阻止默认的ES重连
|
|
278
306
|
}
|
|
@@ -290,13 +318,13 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
290
318
|
}
|
|
291
319
|
}).catch(function () {
|
|
292
320
|
changeFileStatus(FileStatus.ANALYSE_FAILED, file);
|
|
293
|
-
|
|
321
|
+
setAbortController(file.uid, null);
|
|
294
322
|
Toast.error(t('upload.parseFailedMaxRetry'));
|
|
295
323
|
});
|
|
296
324
|
} else {
|
|
297
325
|
fetchSSE().catch(function () {
|
|
298
326
|
changeFileStatus(FileStatus.ANALYSE_FAILED, file);
|
|
299
|
-
|
|
327
|
+
setAbortController(file.uid, null);
|
|
300
328
|
Toast.error(t('upload.parseFailed'));
|
|
301
329
|
});
|
|
302
330
|
}
|
|
@@ -384,8 +412,18 @@ export var useGimiFileUpload = function useGimiFileUpload(onFileUploaded) {
|
|
|
384
412
|
});
|
|
385
413
|
}
|
|
386
414
|
};
|
|
415
|
+
|
|
416
|
+
/** 中断所有正在进行的解析(供外部 abortUpload 调用) */
|
|
417
|
+
var abortAll = function abortAll() {
|
|
418
|
+
abortControllerMapRef.current.forEach(function (controller) {
|
|
419
|
+
return controller.abort();
|
|
420
|
+
});
|
|
421
|
+
abortControllerMapRef.current.clear();
|
|
422
|
+
abortControllerRef.current = null;
|
|
423
|
+
};
|
|
387
424
|
return {
|
|
388
425
|
fileUploadAbortRef: abortControllerRef,
|
|
426
|
+
abortAll: abortAll,
|
|
389
427
|
handleSSEFileAnalyize: handleSSEFileAnalyize,
|
|
390
428
|
fileUpload: fileUpload
|
|
391
429
|
};
|