vue-element-ui-x 1.0.43-beta → 1.0.51

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.
@@ -290,35 +290,19 @@ class XRequest {
290
290
  if (!line.trim()) {
291
291
  return;
292
292
  }
293
-
294
293
  // 处理 data: 开头的行
295
294
  if (line.startsWith('data: ')) {
296
295
  const dataContent = line.slice(6);
297
-
298
- // 检查是否是结束标识
299
- if (dataContent.trim() === '[DONE]') {
300
- this._isFinished = true;
301
- this._onFinish && this._onFinish(this._messages);
302
- this.abort();
303
- return;
304
- }
305
-
306
- // 跳过空数据
307
296
  if (!dataContent.trim()) {
308
297
  return;
309
298
  }
310
299
  try {
311
- // 尝试解析和处理数据
312
300
  let processedData;
313
301
  try {
314
- // 首先尝试作为 JSON 解析
315
302
  processedData = JSON.parse(dataContent);
316
303
  } catch {
317
- // 如果不是 JSON,使用原始数据
318
304
  processedData = dataContent;
319
305
  }
320
- // console.log('processedData:', processedData, processedData.answer);
321
-
322
306
  const res = this._transformer ? this._transformer(processedData) : processedData;
323
307
  this._messages.push(res);
324
308
  this._onMessage && this._onMessage(res);
@@ -327,8 +311,27 @@ class XRequest {
327
311
  this._onError && this._onError(error);
328
312
  this._controller && this._controller.abort();
329
313
  }
314
+ return;
315
+ }
316
+
317
+ // 处理其他 SSE 标准字段
318
+ // if (line.startsWith('event: ') || line.startsWith('id: ') || line.startsWith('retry: ')) {
319
+ // console.log('SSE control field:', line);
320
+ // return;
321
+ // }
322
+
323
+ // 兜底处理
324
+ if (line.trim()) {
325
+ try {
326
+ const res = this._transformer ? this._transformer(line) : line;
327
+ this._messages.push(res);
328
+ this._onMessage && this._onMessage(res);
329
+ } catch (error) {
330
+ console.error('Error processing non-SSE line:', line, error);
331
+ this._onError && this._onError(error);
332
+ this._controller && this._controller.abort();
333
+ }
330
334
  }
331
- // 可以在这里处理其他类型的行(如果需要)
332
335
  }
333
336
 
334
337
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-element-ui-x",
3
- "version": "1.0.43-beta",
3
+ "version": "1.0.51",
4
4
  "description": "基于Vue 2 + Element UI的AI聊天组件库",
5
5
  "module": "lib/index.esm.js",
6
6
  "main": "lib/index.common.js",
package/lib/index.ssr.js DELETED
@@ -1,90 +0,0 @@
1
- // SSR 安全的 Element UI X 入口文件
2
- // 在服务器端渲染时使用,避免浏览器API调用
3
-
4
- // 检查是否在SSR环境
5
- const isSSR = typeof window === 'undefined';
6
-
7
- let ElementUIX;
8
-
9
- if (isSSR) {
10
- // SSR环境:提供一个空的插件对象,避免任何浏览器API调用
11
- ElementUIX = {
12
- version: '1.0.4',
13
- install(Vue, opts = {}) {
14
- // 在SSR环境下,我们不注册任何组件
15
- // 只是确保不会出错
16
- console.warn('[ElementUIX] SSR mode: Components will be registered on client side only');
17
- },
18
- locale: {
19
- use() {},
20
- i18n() {},
21
- },
22
- lang: {},
23
- // 导出空的组件,避免undefined错误
24
- ElXTypewriter: {},
25
- ElXBubble: {},
26
- ElXBubbleList: {},
27
- ElXPrompts: {},
28
- ElXConversations: {},
29
- ElXThinking: {},
30
- ElXThoughtChain: {},
31
- ElXSender: {},
32
- ElXFilesCard: {},
33
- ElXAttachments: {},
34
- ElXWelcome: {},
35
- // 导出空的mixins
36
- streamMixin: {
37
- data() { return { streamData: [], streamError: null, streamLoading: false }; },
38
- methods: {
39
- startStream() {},
40
- cancelStream() {},
41
- resetStream() {},
42
- createStreamProcessor() { return { close() {} }; },
43
- },
44
- },
45
- sendMixin: {
46
- data() { return { loading: false }; },
47
- methods: {
48
- initSend() {},
49
- handleSend() {},
50
- handleFinish() {},
51
- handleAbort() {},
52
- },
53
- },
54
- recordMixin: {
55
- data() {
56
- return {
57
- recordLoading: false,
58
- recordValue: '',
59
- recordRecognition: null,
60
- recordOptions: {},
61
- };
62
- },
63
- methods: {
64
- initRecord() {},
65
- startRecord() {},
66
- stopRecord() {},
67
- cleanupRecord() {},
68
- },
69
- },
70
- createSendUtils() { return {}; },
71
- createStreamUtils() { return {}; },
72
- XRequest: class {
73
- constructor() {}
74
- send() { return Promise.resolve(); }
75
- },
76
- XStream: class {
77
- constructor() {}
78
- },
79
- };
80
- } else {
81
- // 客户端环境:动态导入真实的组件库
82
- try {
83
- ElementUIX = require('./index.common.js');
84
- } catch (e) {
85
- console.warn('[ElementUIX] Failed to load client components:', e);
86
- ElementUIX = { install() {} };
87
- }
88
- }
89
-
90
- module.exports = ElementUIX;