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.
package/lib/index.js CHANGED
@@ -37306,35 +37306,19 @@ class XRequest {
37306
37306
  if (!line.trim()) {
37307
37307
  return;
37308
37308
  }
37309
-
37310
37309
  // 处理 data: 开头的行
37311
37310
  if (line.startsWith('data: ')) {
37312
37311
  const dataContent = line.slice(6);
37313
-
37314
- // 检查是否是结束标识
37315
- if (dataContent.trim() === '[DONE]') {
37316
- this._isFinished = true;
37317
- this._onFinish && this._onFinish(this._messages);
37318
- this.abort();
37319
- return;
37320
- }
37321
-
37322
- // 跳过空数据
37323
37312
  if (!dataContent.trim()) {
37324
37313
  return;
37325
37314
  }
37326
37315
  try {
37327
- // 尝试解析和处理数据
37328
37316
  let processedData;
37329
37317
  try {
37330
- // 首先尝试作为 JSON 解析
37331
37318
  processedData = JSON.parse(dataContent);
37332
37319
  } catch {
37333
- // 如果不是 JSON,使用原始数据
37334
37320
  processedData = dataContent;
37335
37321
  }
37336
- // console.log('processedData:', processedData, processedData.answer);
37337
-
37338
37322
  const res = this._transformer ? this._transformer(processedData) : processedData;
37339
37323
  this._messages.push(res);
37340
37324
  this._onMessage && this._onMessage(res);
@@ -37343,8 +37327,27 @@ class XRequest {
37343
37327
  this._onError && this._onError(error);
37344
37328
  this._controller && this._controller.abort();
37345
37329
  }
37330
+ return;
37331
+ }
37332
+
37333
+ // 处理其他 SSE 标准字段
37334
+ // if (line.startsWith('event: ') || line.startsWith('id: ') || line.startsWith('retry: ')) {
37335
+ // console.log('SSE control field:', line);
37336
+ // return;
37337
+ // }
37338
+
37339
+ // 兜底处理
37340
+ if (line.trim()) {
37341
+ try {
37342
+ const res = this._transformer ? this._transformer(line) : line;
37343
+ this._messages.push(res);
37344
+ this._onMessage && this._onMessage(res);
37345
+ } catch (error) {
37346
+ console.error('Error processing non-SSE line:', line, error);
37347
+ this._onError && this._onError(error);
37348
+ this._controller && this._controller.abort();
37349
+ }
37346
37350
  }
37347
- // 可以在这里处理其他类型的行(如果需要)
37348
37351
  }
37349
37352
 
37350
37353
  /**