eoss-ui 0.6.38 → 0.6.40

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.
Files changed (90) hide show
  1. package/lib/button-group.js +572 -374
  2. package/lib/button.js +572 -374
  3. package/lib/checkbox-group.js +573 -375
  4. package/lib/config/api.js +31 -19
  5. package/lib/data-table-form.js +584 -386
  6. package/lib/data-table.js +597 -392
  7. package/lib/date-picker.js +572 -374
  8. package/lib/dialog.js +572 -374
  9. package/lib/eoss-ui.common.js +10749 -3855
  10. package/lib/error-page.js +4 -4
  11. package/lib/flow-group.js +590 -377
  12. package/lib/flow-list.js +577 -379
  13. package/lib/flow.js +9723 -2852
  14. package/lib/form.js +577 -379
  15. package/lib/handle-user.js +573 -375
  16. package/lib/handler.js +573 -375
  17. package/lib/icon.js +573 -375
  18. package/lib/index.js +1 -1
  19. package/lib/input-number.js +572 -374
  20. package/lib/input.js +572 -374
  21. package/lib/layout.js +2 -2
  22. package/lib/login.js +587 -389
  23. package/lib/main.js +609 -411
  24. package/lib/nav.js +572 -374
  25. package/lib/notify.js +127 -109
  26. package/lib/page.js +572 -374
  27. package/lib/pagination.js +572 -374
  28. package/lib/player.js +572 -374
  29. package/lib/qr-code.js +572 -374
  30. package/lib/radio-group.js +573 -375
  31. package/lib/retrial-auth.js +575 -377
  32. package/lib/select-ganged.js +573 -375
  33. package/lib/select.js +573 -375
  34. package/lib/selector-panel.js +595 -396
  35. package/lib/selector.js +576 -378
  36. package/lib/sizer.js +578 -380
  37. package/lib/steps.js +572 -374
  38. package/lib/switch.js +572 -374
  39. package/lib/table-form.js +572 -374
  40. package/lib/tabs.js +576 -378
  41. package/lib/theme-chalk/flow.css +1 -1
  42. package/lib/theme-chalk/index.css +1 -1
  43. package/lib/tips.js +573 -375
  44. package/lib/tree-group.js +572 -374
  45. package/lib/tree.js +573 -375
  46. package/lib/upload.js +582 -384
  47. package/lib/utils/util.js +448 -268
  48. package/lib/wujie.js +572 -374
  49. package/lib/wxlogin.js +572 -374
  50. package/package.json +2 -1
  51. package/packages/.DS_Store +0 -0
  52. package/packages/data-table/.DS_Store +0 -0
  53. package/packages/data-table/src/column.vue +9 -3
  54. package/packages/data-table/src/main.vue +5 -1
  55. package/packages/data-table-form/.DS_Store +0 -0
  56. package/packages/data-table-form/src/table.vue +6 -6
  57. package/packages/error-page/.DS_Store +0 -0
  58. package/packages/error-page/src/main.vue +2 -2
  59. package/packages/flow/.DS_Store +0 -0
  60. package/packages/flow/src/component/CommonOpinions.vue +5 -1
  61. package/packages/flow/src/component/taskUnionExamine.vue +83 -27
  62. package/packages/flow/src/freeStartFlow.vue +2843 -0
  63. package/packages/flow/src/main.vue +769 -636
  64. package/packages/flow/src/processForm.vue +62 -9
  65. package/packages/flow/src/reset.vue +901 -0
  66. package/packages/flow/src/selectUser.vue +5 -0
  67. package/packages/flow-group/src/main.vue +4 -0
  68. package/packages/form/.DS_Store +0 -0
  69. package/packages/form/src/main.vue +3 -3
  70. package/packages/login/.DS_Store +0 -0
  71. package/packages/login/src/main.vue +4 -6
  72. package/packages/main/.DS_Store +0 -0
  73. package/packages/main/src/.DS_Store +0 -0
  74. package/packages/selector/.DS_Store +0 -0
  75. package/packages/selector/src/main.vue +1 -1
  76. package/packages/selector-panel/.DS_Store +0 -0
  77. package/packages/selector-panel/src/main.vue +3 -2
  78. package/packages/sizer/.DS_Store +0 -0
  79. package/packages/sizer/src/main.vue +5 -5
  80. package/packages/tabs/.DS_Store +0 -0
  81. package/packages/tabs/src/main.vue +2 -2
  82. package/packages/theme-chalk/lib/flow.css +1 -1
  83. package/packages/theme-chalk/lib/index.css +1 -1
  84. package/packages/theme-chalk/src/.DS_Store +0 -0
  85. package/packages/theme-chalk/src/flow.scss +2 -0
  86. package/packages/upload/.DS_Store +0 -0
  87. package/src/.DS_Store +0 -0
  88. package/src/config/api.js +31 -19
  89. package/src/index.js +157 -157
  90. package/src/utils/util.js +433 -258
package/lib/utils/util.js CHANGED
@@ -52,6 +52,7 @@ var $darkColorCount = 4;
52
52
  var publicKey = 'abcdefghijklmnopqrstuvwxyz12345678';
53
53
  var loginMsg = void 0;
54
54
  var initAuth = void 0;
55
+ var $_http = void 0;
55
56
 
56
57
  var JSONbigToString = (0, _jsonBigint2.default)({ storeAsString: true });
57
58
 
@@ -121,216 +122,219 @@ var ajax = function ajax(_ref) {
121
122
  } else {
122
123
  method = method.toLowerCase();
123
124
  }
124
- var baseURL = host === true ? getStorage('host') : host === false ? '' : host;
125
- var http = _axios2.default.create({
126
- baseURL: baseURL,
127
- timeout: 99000,
128
- transformResponse: [function (data) {
129
- try {
130
- return JSONbigToString.parse(data);
131
- } catch (err) {
132
- return data;
133
- }
134
- }]
135
- });
136
- // 请求拦截
137
- http.interceptors.request.use(function (config) {
138
- config.headers.common = getStorage();
139
- // 根据请求的信息(请求方式,url,请求get/post数据),产生map的key
140
- // let requestKey = getRequestKey(config);
141
- // // 判断请求是否重复
142
- // if (pendingRequest.has(requestKey)) {
143
- // // 取消上次请求
144
- // let cancel = pendingRequest.get(requestKey);
145
- // cancel();
146
- // // 删除请求信息
147
- // pendingRequest.delete(requestKey);
148
- // }
149
- // // 把请求信息,添加请求到map当中
150
- // // 生成取消方法
151
- // config.cancelToken =
152
- // config.cancelToken ||
153
- // new axios.CancelToken(cancel => {
154
- // // 把取消方法添加到map
155
- // if (!pendingRequest.has(requestKey)) {
156
- // pendingRequest.set(requestKey, cancel);
157
- // }
158
- // });
159
- return config;
160
- }, function (err) {
161
- return err;
162
- });
163
- // 响应拦截
164
- http.interceptors.response.use(function (response) {
165
- // delPendingRequest(response.config);
166
- loading && loading.close();
167
- if (response.headers.authorization && response.headers.authorization !== getStorage('token')) {
168
- if (localStorage.getItem('storage') === 'localStorage' || localStorage.getItem('token') || localStorage.getItem('Authorization')) {
169
- localStorage.setItem('token', response.headers.authorization);
170
- localStorage.setItem('Authorization', response.headers.authorization);
171
- } else {
172
- sessionStorage.setItem('token', response.headers.authorization);
173
- sessionStorage.setItem('Authorization', response.headers.authorization);
174
- }
175
- }
176
- if ((response.headers.ssId || response.headers.Ssid || response.headers.ssid) && (response.headers.ssId || response.headers.SsId || response.headers.ssid) !== getStorage('ssId')) {
177
- if (localStorage.getItem('storage') === 'localStorage' || localStorage.getItem('ssId')) {
178
- localStorage.setItem('ssId', response.headers.ssId || response.headers.SsId || response.headers.ssid);
179
- } else {
180
- sessionStorage.setItem('ssId', response.headers.ssId || response.headers.SsId || response.headers.ssid);
181
- }
182
- }
183
- if (response.status === 200) {
184
- if (response.data.rCode === 64 || response.data.rCode === 65 || response.data.rCode === 67 || response.data.rCode === 69) {
185
- removeStorage(['Authorization', 'token', 'ssId', 'userId', 'userName', 'deviceUnique', 'menus', 'useCaseCodes', 'mainConfig', 'jump', 'showLaunch']);
186
- var href = '';
125
+ var http = $_http;
126
+ if (!http) {
127
+ var baseURL = host === true ? getStorage('host') : host === false ? '' : host;
128
+ http = _axios2.default.create({
129
+ baseURL: baseURL,
130
+ timeout: 99000,
131
+ transformResponse: [function (data) {
187
132
  try {
188
- href = win.top.location.href;
189
- } catch (error) {
190
- href = win.location.href;
133
+ return JSONbigToString.parse(data);
134
+ } catch (err) {
135
+ return data;
191
136
  }
192
- if (href.indexOf('#/login') === -1 && href.indexOf('/login.html') === -1) {
193
- var remind = sessionStorage.getItem('remind');
194
- if (!remind) {
195
- clearTimeout(loginMsg);
196
- loginMsg = setTimeout(function () {
197
- sessionStorage.setItem('remind', 1);
198
- _eossElement.MessageBox.confirm(response.data.rCode === 69 ? '该账号在其他地方已登陆!' : '登录已过期,请重新登录!', '提示', response.data.rCode === 69 ? {
199
- confirmButtonText: '确定',
200
- closeOnClickModal: false,
201
- type: 'warning'
202
- } : {
203
- confirmButtonText: '确定',
204
- cancelButtonText: '取消',
205
- closeOnClickModal: false,
206
- type: 'warning'
207
- }).then(function () {
208
- try {
209
- var loginPage = getStorage('login') || getStorage('loginPage');
210
- if (loginPage) {
211
- var src = void 0;
212
- if (!startWith(loginPage, ['http', '/'], true)) {
213
- var pathname = win.top.location.pathname;
214
- if (pathname !== '/') {
215
- pathname = pathname.split('/');
216
- pathname.splice(pathname.length - 1);
217
- pathname = pathname.join('/');
218
- src = pathname + '/' + loginPage.replace('./', '');
137
+ }]
138
+ });
139
+ // 请求拦截
140
+ http.interceptors.request.use(function (config) {
141
+ config.headers.common = getStorage();
142
+ // 根据请求的信息(请求方式,url,请求get/post数据),产生map的key
143
+ // let requestKey = getRequestKey(config);
144
+ // // 判断请求是否重复
145
+ // if (pendingRequest.has(requestKey)) {
146
+ // // 取消上次请求
147
+ // let cancel = pendingRequest.get(requestKey);
148
+ // cancel();
149
+ // // 删除请求信息
150
+ // pendingRequest.delete(requestKey);
151
+ // }
152
+ // // 把请求信息,添加请求到map当中
153
+ // // 生成取消方法
154
+ // config.cancelToken =
155
+ // config.cancelToken ||
156
+ // new axios.CancelToken(cancel => {
157
+ // // 把取消方法添加到map
158
+ // if (!pendingRequest.has(requestKey)) {
159
+ // pendingRequest.set(requestKey, cancel);
160
+ // }
161
+ // });
162
+ return config;
163
+ }, function (err) {
164
+ return err;
165
+ });
166
+ // 响应拦截
167
+ http.interceptors.response.use(function (response) {
168
+ // delPendingRequest(response.config);
169
+ loading && loading.close();
170
+ if (response.headers.authorization && response.headers.authorization !== getStorage('token')) {
171
+ if (localStorage.getItem('storage') === 'localStorage' || localStorage.getItem('token') || localStorage.getItem('Authorization')) {
172
+ localStorage.setItem('token', response.headers.authorization);
173
+ localStorage.setItem('Authorization', response.headers.authorization);
174
+ } else {
175
+ sessionStorage.setItem('token', response.headers.authorization);
176
+ sessionStorage.setItem('Authorization', response.headers.authorization);
177
+ }
178
+ }
179
+ if ((response.headers.ssId || response.headers.Ssid || response.headers.ssid) && (response.headers.ssId || response.headers.SsId || response.headers.ssid) !== getStorage('ssId')) {
180
+ if (localStorage.getItem('storage') === 'localStorage' || localStorage.getItem('ssId')) {
181
+ localStorage.setItem('ssId', response.headers.ssId || response.headers.SsId || response.headers.ssid);
182
+ } else {
183
+ sessionStorage.setItem('ssId', response.headers.ssId || response.headers.SsId || response.headers.ssid);
184
+ }
185
+ }
186
+ if (response.status === 200) {
187
+ if (response.data.rCode === 64 || response.data.rCode === 65 || response.data.rCode === 67 || response.data.rCode === 69) {
188
+ removeStorage(['Authorization', 'token', 'ssId', 'userId', 'userName', 'deviceUnique', 'menus', 'useCaseCodes', 'mainConfig', 'jump', 'showLaunch']);
189
+ var href = '';
190
+ try {
191
+ href = win.top.location.href;
192
+ } catch (error) {
193
+ href = win.location.href;
194
+ }
195
+ if (href.indexOf('#/login') === -1 && href.indexOf('/login.html') === -1) {
196
+ var remind = sessionStorage.getItem('remind');
197
+ if (!remind) {
198
+ clearTimeout(loginMsg);
199
+ loginMsg = setTimeout(function () {
200
+ sessionStorage.setItem('remind', 1);
201
+ _eossElement.MessageBox.confirm(response.data.rCode === 69 ? '该账号在其他地方已登陆!' : '登录已过期,请重新登录!', '提示', response.data.rCode === 69 ? {
202
+ confirmButtonText: '确定',
203
+ closeOnClickModal: false,
204
+ type: 'warning'
205
+ } : {
206
+ confirmButtonText: '确定',
207
+ cancelButtonText: '取消',
208
+ closeOnClickModal: false,
209
+ type: 'warning'
210
+ }).then(function () {
211
+ try {
212
+ var loginPage = getStorage('login') || getStorage('loginPage');
213
+ if (loginPage) {
214
+ var src = void 0;
215
+ if (!startWith(loginPage, ['http', '/'], true)) {
216
+ var pathname = win.top.location.pathname;
217
+ if (pathname !== '/') {
218
+ pathname = pathname.split('/');
219
+ pathname.splice(pathname.length - 1);
220
+ pathname = pathname.join('/');
221
+ src = pathname + '/' + loginPage.replace('./', '');
222
+ } else {
223
+ src = pathname + loginPage.replace('./', '');
224
+ }
219
225
  } else {
220
- src = pathname + loginPage.replace('./', '');
226
+ src = loginPage;
221
227
  }
228
+ win.top.location.href = src;
229
+ } else if (win.top.location.href.indexOf('main.html') > -1) {
230
+ win.top.location.href = './login.html';
222
231
  } else {
223
- src = loginPage;
224
- }
225
- win.top.location.href = src;
226
- } else if (win.top.location.href.indexOf('main.html') > -1) {
227
- win.top.location.href = './login.html';
228
- } else {
229
- var hash = win.top.location.hash;
230
- if (hash) {
231
- var len = win.top.location.href.indexOf(hash);
232
- win.top.location.href = win.location.href.slice(0, len) + '#/login';
233
- } else {
234
- win.top.location.href = '/login.html';
232
+ var hash = win.top.location.hash;
233
+ if (hash) {
234
+ var len = win.top.location.href.indexOf(hash);
235
+ win.top.location.href = win.location.href.slice(0, len) + '#/login';
236
+ } else {
237
+ win.top.location.href = '/login.html';
238
+ }
235
239
  }
240
+ } catch (error) {
241
+ win.postMessage({ type: 1 }, '*');
236
242
  }
237
- } catch (error) {
238
- win.postMessage({ type: 1 }, '*');
239
- }
240
- }).catch(function (e) {
241
- sessionStorage.removeItem('remind');
242
- });
243
- }, 2000);
243
+ }).catch(function (e) {
244
+ sessionStorage.removeItem('remind');
245
+ });
246
+ }, 2000);
247
+ }
244
248
  }
249
+ } else if (response.data.rCode === 61) {
250
+ clearTimeout(initAuth);
251
+ initAuth = setTimeout(function () {
252
+ (0, _eossElement.MessageBox)({
253
+ title: '请进行二次鉴权',
254
+ closeOnClickModal: false,
255
+ closeOnPressEscape: false,
256
+ showConfirmButton: false,
257
+ dangerouslyUseHTMLString: true,
258
+ scroll: false,
259
+ customClass: 'es-retrial-auth-msg',
260
+ render: function render(h, msgBox) {
261
+ return h('es-retrial-auth', {
262
+ ref: 'auth',
263
+ props: {
264
+ reload: response.data.results.reload || response.data.results.refresh,
265
+ group: response.data.results.retrialAuthGroupIds,
266
+ type: response.data.results.retrialAuthType,
267
+ msgBox: msgBox
268
+ }
269
+ });
270
+ },
271
+ callback: function callback(res, obj) {
272
+ obj.$children.forEach(function (item) {
273
+ item.clearTimeouts && item.clearTimeouts();
274
+ return;
275
+ });
276
+ }
277
+ });
278
+ }, 1000);
245
279
  }
246
- } else if (response.data.rCode === 61) {
247
- clearTimeout(initAuth);
248
- initAuth = setTimeout(function () {
249
- (0, _eossElement.MessageBox)({
250
- title: '请进行二次鉴权',
251
- closeOnClickModal: false,
252
- closeOnPressEscape: false,
253
- showConfirmButton: false,
254
- dangerouslyUseHTMLString: true,
255
- scroll: false,
256
- customClass: 'es-retrial-auth-msg',
257
- render: function render(h, msgBox) {
258
- return h('es-retrial-auth', {
259
- ref: 'auth',
260
- props: {
261
- reload: response.data.results.reload || response.data.results.refresh,
262
- group: response.data.results.retrialAuthGroupIds,
263
- type: response.data.results.retrialAuthType,
264
- msgBox: msgBox
265
- }
266
- });
267
- },
268
- callback: function callback(res, obj) {
269
- obj.$children.forEach(function (item) {
270
- item.clearTimeouts && item.clearTimeouts();
271
- return;
272
- });
273
- }
274
- });
275
- }, 1000);
280
+ // eslint-disable-next-line no-undef
281
+ return Promise.resolve(JSON.parse(JSON.stringify(response.data)));
276
282
  }
277
- // eslint-disable-next-line no-undef
278
- return Promise.resolve(JSON.parse(JSON.stringify(response.data)));
279
- }
280
- }, function (error) {
281
- loading && loading.close();
282
- // if (!axios.isCancel(error)) {
283
- // delPendingRequest(error.config || {});
284
- // }
285
- if (error && error.response) {
286
- if (error.response.status) {
287
- switch (error.response.status) {
288
- case 400:
289
- error.message = '错误请求';
290
- break;
291
- case 401:
292
- error.message = '未授权,请重新登录';
293
- break;
294
- case 403:
295
- error.message = '服务器错误';
296
- break;
297
- case 404:
298
- error.message = '网络请求不存在';
299
- break;
300
- case 405:
301
- error.message = '请求方法错误';
302
- break;
303
- case 408:
304
- error.message = '请求超时';
305
- break;
306
- case 500:
307
- error.message = '服务器错误';
308
- break;
309
- case 501:
310
- error.message = '网络未实现';
311
- break;
312
- case 502:
313
- error.message = '网络错误';
314
- break;
315
- case 503:
316
- error.message = '服务不可用';
317
- break;
318
- case 504:
319
- error.message = '网络超时';
320
- break;
321
- case 505:
322
- error.message = 'http版本不支持该请求';
323
- break;
324
- default:
325
- error.message = '\u8FDE\u63A5\u9519\u8BEF' + error.response.status;
283
+ }, function (error) {
284
+ loading && loading.close();
285
+ // if (!axios.isCancel(error)) {
286
+ // delPendingRequest(error.config || {});
287
+ // }
288
+ if (error && error.response) {
289
+ if (error.response.status) {
290
+ switch (error.response.status) {
291
+ case 400:
292
+ error.message = '错误请求';
293
+ break;
294
+ case 401:
295
+ error.message = '未授权,请重新登录';
296
+ break;
297
+ case 403:
298
+ error.message = '服务器错误';
299
+ break;
300
+ case 404:
301
+ error.message = '网络请求不存在';
302
+ break;
303
+ case 405:
304
+ error.message = '请求方法错误';
305
+ break;
306
+ case 408:
307
+ error.message = '请求超时';
308
+ break;
309
+ case 500:
310
+ error.message = '服务器错误';
311
+ break;
312
+ case 501:
313
+ error.message = '网络未实现';
314
+ break;
315
+ case 502:
316
+ error.message = '网络错误';
317
+ break;
318
+ case 503:
319
+ error.message = '服务不可用';
320
+ break;
321
+ case 504:
322
+ error.message = '网络超时';
323
+ break;
324
+ case 505:
325
+ error.message = 'http版本不支持该请求';
326
+ break;
327
+ default:
328
+ error.message = '\u8FDE\u63A5\u9519\u8BEF' + error.response.status;
329
+ }
330
+ } else {
331
+ error.message = '无法请求,请联系管理员';
326
332
  }
327
- } else {
328
- error.message = '无法请求,请联系管理员';
329
333
  }
330
- }
331
- // eslint-disable-next-line no-undef
332
- return Promise.reject(error);
333
- });
334
+ // eslint-disable-next-line no-undef
335
+ return Promise.reject(error);
336
+ });
337
+ }
334
338
  var userId = getStorage('userId');
335
339
  if (!Object.prototype.hasOwnProperty.call(data, 'userId') && userId && defaults) {
336
340
  data.userId = userId;
@@ -421,7 +425,182 @@ var ajax = function ajax(_ref) {
421
425
  headers: header
422
426
  }, configs));
423
427
  };
428
+ /**
429
+ * ajaxStream
430
+ * @desc:ajax流式请求
431
+ * @author huangbo
432
+ * @date 2022年5月7日
433
+ * @param {Object} [controller] - controller
434
+ * @param {String} [method] - 请求类型
435
+ * @param {String} [url] - 请求地址
436
+ * @param {String} [host] - host
437
+ * @param {Object} [data] - 请求参数
438
+ * @param {Object} [params] - 请求参数
439
+ **/
440
+ var ajaxStream = function ajaxStream(_ref2) {
441
+ var controller = _ref2.controller,
442
+ _ref2$method = _ref2.method,
443
+ method = _ref2$method === undefined ? 'post' : _ref2$method,
444
+ host = _ref2.host,
445
+ url = _ref2.url,
446
+ data = _ref2.data,
447
+ params = _ref2.params,
448
+ progress = _ref2.progress,
449
+ success = _ref2.success,
450
+ fail = _ref2.fail,
451
+ final = _ref2.final,
452
+ configs = _objectWithoutProperties(_ref2, ['controller', 'method', 'host', 'url', 'data', 'params', 'progress', 'success', 'fail', 'final']);
453
+
454
+ try {
455
+ // 如果有正在进行的请求,取消它
456
+ if (controller) {
457
+ controller.abort();
458
+ }
459
+ controller = new AbortController();
460
+ var baseURL = host || getStorage('baseHost') || '';
461
+ var userId = getStorage('userId');
462
+ if (data && !Object.prototype.hasOwnProperty.call(data, 'userId') && userId) {
463
+ data.userId = userId;
464
+ }
465
+ if (params && !Object.prototype.hasOwnProperty.call(params, 'userId') && userId) {
466
+ params.userId = getStorage('userId');
467
+ }
468
+ var info = {
469
+ time: 0,
470
+ conversationId: '',
471
+ content: '',
472
+ thinkContent: '',
473
+ primeval: '',
474
+ chunk: ''
475
+ };
476
+ var partialData = '';
477
+ var lastProcessedIndex = 0;
478
+ var done = false;
479
+ var finishThink = false;
480
+ ajax(_extends({
481
+ timeout: 990000,
482
+ format: false,
483
+ method: method,
484
+ url: baseURL + url,
485
+ signal: controller.signal,
486
+ responseType: 'text',
487
+ data: data,
488
+ params: params
489
+ }, configs, {
490
+ onDownloadProgress: function onDownloadProgress(progressEvent) {
491
+ // 获取从上次处理后新增的数据
492
+ var currentResponse = (progressEvent.event || progressEvent).currentTarget.responseText;
493
+ var chunk = currentResponse.slice(lastProcessedIndex);
494
+ if (chunk === 'data:') {
495
+ return;
496
+ }
497
+
498
+ // 更新偏移量
499
+ lastProcessedIndex = currentResponse.length;
500
+
501
+ // 假设数据是以 'data:' 开头的 SSE 格式
502
+ partialData += chunk;
503
+ var lines = partialData.split('\n');
504
+ var remainingData = ''; // 用于保存未完整处理的部分数据
505
+ var primeval = '';
506
+ var chunks = '';
507
+ lines.forEach(function (line) {
508
+ if (line === '') {
509
+ return;
510
+ }
511
+ if (line.startsWith('data:')) {
512
+ var _data = line.replace('data:', '').trim();
513
+ if (_data) {
514
+ try {
515
+ // 假设数据是 JSON 格式
516
+ var parsedData = JSON.parse(_data);
517
+ info.time = parsedData.time;
518
+ info.conversationId = parsedData.conversationId;
519
+ var thinkRegex = /<think>([\s\S]*?)<\/think>([\s\S]*)?/;
520
+ var match = parsedData.message.match(thinkRegex);
521
+ if (match) {
522
+ var thinkContent = match[1] ? match[1].trim() : ''; // <think> 标签内的数据
523
+ var content = match[2] ? match[2].trim() : ''; // <think> 标签后的数据
524
+ // 更新 AI 消息内容
525
+ info.thinkContent += thinkContent;
526
+ info.content += content;
527
+ } else {
528
+ var startRegex = /<think>([\s\S]*)/;
529
+ var endRegex = /([\s\S]*?)<\/think>([\s\S]*)?/;
530
+ var start = parsedData.message.match(startRegex);
531
+ var end = parsedData.message.match(endRegex);
532
+ if (start) {
533
+ var _thinkContent = start[1] ? start[1].trim() : ''; // <think> 标签内的数据
534
+ info.thinkContent += _thinkContent;
535
+ } else {
536
+ if (end) {
537
+ finishThink = true;
538
+ var _thinkContent2 = end[1] ? end[1].trim() : ''; // <think> 标签后的数据
539
+ var _content = end[2] ? end[2].trim() : '';
540
+ // 更新 AI 消息内容
541
+ info.thinkContent += _thinkContent2;
542
+ info.content += _content;
543
+ chunks += _content;
544
+ } else if (finishThink) {
545
+ info.content += parsedData.message;
546
+ chunks += parsedData.message;
547
+ } else {
548
+ info.thinkContent += parsedData.message;
549
+ }
550
+ }
551
+ }
552
+ primeval += parsedData.message;
553
+ done = parsedData.done;
554
+ } catch (parseError) {
555
+ console.error('解析数据出错:', parseError);
556
+ }
557
+ }
558
+ } else {
559
+ // 保存未处理完的部分数据
560
+ remainingData += line + '\n';
561
+ }
562
+ });
563
+ info.primeval = primeval;
564
+ info.chunk = chunks;
424
565
 
566
+ // 将未完整处理的数据保留到 partialData 中
567
+ partialData = remainingData;
568
+ progress && progress({ message: info, controller: controller, done: done });
569
+ }
570
+ })).then(function () {
571
+ // 处理请求完成后的信息
572
+ var originalText = info.content;
573
+ var regex = /<think>([\s\S]*?)<\/think>([\s\S]*)/;
574
+ var match = originalText.match(regex);
575
+ if (match) {
576
+ info.thinkContent = match ? match[1].trim() : '';
577
+ info.content = match ? match[2].trim() : '';
578
+ }
579
+ success && success({ message: info, controller: controller });
580
+ }).catch(function () {
581
+ // 处理请求完成后的信息
582
+ var originalText = info.content || '';
583
+ var regex = /<think>([\s\S]*?)<\/think>([\s\S]*)/;
584
+ var match = originalText.match(regex);
585
+ if (match) {
586
+ info.thinkContent = match ? match[1].trim() : '';
587
+ info.content = match ? match[2].trim() : '';
588
+ }
589
+ fail && fail({ status: 1, message: info, controller: controller });
590
+ });
591
+ } catch (error) {
592
+ console.error('聊天请求出错:', error);
593
+ var errorMessage = '抱歉,发生了一个错误,请稍后再试。';
594
+ if (error.code === 'ERR_NETWORK') {
595
+ errorMessage = '网络连接错误,请检查服务器是否正在运行或网络连接是否正常。';
596
+ } else if (error.response) {
597
+ errorMessage = '\u670D\u52A1\u5668\u9519\u8BEF (' + error.response.status + '): ' + (error.response.data || '未知错误');
598
+ }
599
+ fail && fail({ status: 0, message: { role: 'assistant', content: errorMessage }, controller: controller });
600
+ } finally {
601
+ final && final({ status: -1, message: null, controller: controller });
602
+ }
603
+ };
425
604
  /**
426
605
  * arrUnique
427
606
  * @desc:数组元素对象去重
@@ -500,9 +679,9 @@ var browser = function browser() {
500
679
  **/
501
680
  var busEmit = function busEmit() {
502
681
  var vm = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this;
503
- var _ref2 = arguments[1];
504
- var method = _ref2.method,
505
- args = _ref2.args;
682
+ var _ref3 = arguments[1];
683
+ var method = _ref3.method,
684
+ args = _ref3.args;
506
685
 
507
686
  var bus = win.$wujie ? win.$wujie.bus : vm.bus || vm.$root.Bus;
508
687
  bus && bus.$emit(method, args);
@@ -732,9 +911,9 @@ var debounce = function debounce(callback, wait) {
732
911
  * @param {String} [url] - url地址
733
912
  * @param {String,Array} [key] - 参数名
734
913
  **/
735
- var delUrlParam = function delUrlParam(_ref3) {
736
- var url = _ref3.url,
737
- key = _ref3.key;
914
+ var delUrlParam = function delUrlParam(_ref4) {
915
+ var url = _ref4.url,
916
+ key = _ref4.key;
738
917
 
739
918
  var pUrl = '';
740
919
  try {
@@ -860,10 +1039,10 @@ var esDecode = function esDecode(value) {
860
1039
  * @param {string} [data] - 被加密的字符串
861
1040
  * @param {string} [key] - 公钥
862
1041
  **/
863
- var esmEncrypt = function esmEncrypt(_ref4) {
864
- var data = _ref4.data,
865
- key = _ref4.key,
866
- mode = _ref4.mode;
1042
+ var esmEncrypt = function esmEncrypt(_ref5) {
1043
+ var data = _ref5.data,
1044
+ key = _ref5.key,
1045
+ mode = _ref5.mode;
867
1046
 
868
1047
  var cipherMode = mode ? mode : 1;
869
1048
  if (!new RegExp('^04').test(key)) {
@@ -881,10 +1060,10 @@ var esmEncrypt = function esmEncrypt(_ref4) {
881
1060
  * @param {string} [data] - 被解密的加密字符串
882
1061
  * @param {string} [key] - 私钥
883
1062
  **/
884
- var esmDecode = function esmDecode(_ref5) {
885
- var data = _ref5.data,
886
- key = _ref5.key,
887
- mode = _ref5.mode;
1063
+ var esmDecode = function esmDecode(_ref6) {
1064
+ var data = _ref6.data,
1065
+ key = _ref6.key,
1066
+ mode = _ref6.mode;
888
1067
 
889
1068
  var cipherMode = mode ? mode : 1;
890
1069
  if (new RegExp('^04').test(key)) {
@@ -901,10 +1080,10 @@ var esmDecode = function esmDecode(_ref5) {
901
1080
  * @date 2022年5月7日
902
1081
  * @param {String/Array} [attrs] - 要排除的属性
903
1082
  **/
904
- var exclAttribute = function exclAttribute(_ref6) {
905
- var _ref6$attrs = _ref6.attrs,
906
- attrs = _ref6$attrs === undefined ? 'value' : _ref6$attrs,
907
- data = _ref6.data;
1083
+ var exclAttribute = function exclAttribute(_ref7) {
1084
+ var _ref7$attrs = _ref7.attrs,
1085
+ attrs = _ref7$attrs === undefined ? 'value' : _ref7$attrs,
1086
+ data = _ref7.data;
908
1087
 
909
1088
  var obj = extend(true, {}, data);
910
1089
  if (Array.isArray(attrs)) {
@@ -929,14 +1108,14 @@ var exclAttribute = function exclAttribute(_ref6) {
929
1108
  * @param {name} [string] - 导出文件名
930
1109
  * @param {numbers} [boolean] - 序号
931
1110
  **/
932
- var exportXls = function exportXls(_ref7) {
933
- var _ref7$thead = _ref7.thead,
934
- thead = _ref7$thead === undefined ? [] : _ref7$thead,
935
- _ref7$data = _ref7.data,
936
- data = _ref7$data === undefined ? [] : _ref7$data,
937
- name = _ref7.name,
938
- numbers = _ref7.numbers,
939
- option = _ref7.option;
1111
+ var exportXls = function exportXls(_ref8) {
1112
+ var _ref8$thead = _ref8.thead,
1113
+ thead = _ref8$thead === undefined ? [] : _ref8$thead,
1114
+ _ref8$data = _ref8.data,
1115
+ data = _ref8$data === undefined ? [] : _ref8$data,
1116
+ name = _ref8.name,
1117
+ numbers = _ref8.numbers,
1118
+ option = _ref8.option;
940
1119
 
941
1120
  var tbody = '';
942
1121
  var aligns = [];
@@ -1936,11 +2115,11 @@ var hsvTorgb = function hsvTorgb($h, $s, $v) {
1936
2115
  * @param {value} [array] - 需要对比的值的数组集合
1937
2116
  * @param {callback} [function] - 回调函数
1938
2117
  **/
1939
- var identical = function identical(_ref8) {
1940
- var value = _ref8.value,
1941
- callback = _ref8.callback,
1942
- _ref8$msg = _ref8.msg,
1943
- msg = _ref8$msg === undefined ? ['请输入值', '请再次输入', '输入不一致!'] : _ref8$msg;
2118
+ var identical = function identical(_ref9) {
2119
+ var value = _ref9.value,
2120
+ callback = _ref9.callback,
2121
+ _ref9$msg = _ref9.msg,
2122
+ msg = _ref9$msg === undefined ? ['请输入值', '请再次输入', '输入不一致!'] : _ref9$msg;
1944
2123
 
1945
2124
  if (value && value.length > 1) {
1946
2125
  var val = value[0];
@@ -2077,15 +2256,15 @@ var isFunction = function isFunction(obj) {
2077
2256
  * @param {sting} [loginPage] - 第三方登录页面地址
2078
2257
  * @param {boolean} [redirect] - 是否重定向(用于新脚手架)
2079
2258
  **/
2080
- var isLogined = function isLogined(_ref9) {
2081
- var to = _ref9.to,
2082
- from = _ref9.from,
2083
- next = _ref9.next,
2084
- _ref9$exclude = _ref9.exclude,
2085
- exclude = _ref9$exclude === undefined ? [] : _ref9$exclude,
2086
- cookie = _ref9.cookie,
2087
- loginPage = _ref9.loginPage,
2088
- redirect = _ref9.redirect;
2259
+ var isLogined = function isLogined(_ref10) {
2260
+ var to = _ref10.to,
2261
+ from = _ref10.from,
2262
+ next = _ref10.next,
2263
+ _ref10$exclude = _ref10.exclude,
2264
+ exclude = _ref10$exclude === undefined ? [] : _ref10$exclude,
2265
+ cookie = _ref10.cookie,
2266
+ loginPage = _ref10.loginPage,
2267
+ redirect = _ref10.redirect;
2089
2268
 
2090
2269
  if (cookie === undefined) {
2091
2270
  cookie = getParams({ name: 'cookie' });
@@ -2300,9 +2479,9 @@ var isObjectEqual = function isObjectEqual(obj, _obj) {
2300
2479
  * @param {string/array} [url] - 地址
2301
2480
  * @param {boolean} [single] - 是否做js沙箱隔离
2302
2481
  **/
2303
- var jointUrl = function jointUrl(_ref10) {
2304
- var url = _ref10.url,
2305
- reg = _ref10.reg;
2482
+ var jointUrl = function jointUrl(_ref11) {
2483
+ var url = _ref11.url,
2484
+ reg = _ref11.reg;
2306
2485
 
2307
2486
  if (startWith(url, ['https', 'http', 'blob:'], true) || !reg || !reg.length) {
2308
2487
  return url;
@@ -2317,13 +2496,13 @@ var jointUrl = function jointUrl(_ref10) {
2317
2496
  return startWith(url, reg) ? url : reg + url;
2318
2497
  };
2319
2498
 
2320
- var loadJs = function loadJs(_ref11) {
2321
- var url = _ref11.url,
2322
- _ref11$type = _ref11.type,
2323
- type = _ref11$type === undefined ? 'text/javascript' : _ref11$type,
2324
- id = _ref11.id,
2325
- _ref11$single = _ref11.single,
2326
- single = _ref11$single === undefined ? true : _ref11$single;
2499
+ var loadJs = function loadJs(_ref12) {
2500
+ var url = _ref12.url,
2501
+ _ref12$type = _ref12.type,
2502
+ type = _ref12$type === undefined ? 'text/javascript' : _ref12$type,
2503
+ id = _ref12.id,
2504
+ _ref12$single = _ref12.single,
2505
+ single = _ref12$single === undefined ? true : _ref12$single;
2327
2506
 
2328
2507
  return new Promise(function (resolve, reject) {
2329
2508
  var script = document.getElementById(id) || document.createElement('script');
@@ -2458,11 +2637,11 @@ var queryParams = function queryParams(obj) {
2458
2637
  * @param {string} [url] - 消息源的 URI
2459
2638
  * @param {function} [callback] - 回调函数
2460
2639
  **/
2461
- var receiveMessage = function receiveMessage(_ref12) {
2462
- var _ref12$data = _ref12.data,
2463
- data = _ref12$data === undefined ? {} : _ref12$data,
2464
- url = _ref12.url,
2465
- callback = _ref12.callback;
2640
+ var receiveMessage = function receiveMessage(_ref13) {
2641
+ var _ref13$data = _ref13.data,
2642
+ data = _ref13$data === undefined ? {} : _ref13$data,
2643
+ url = _ref13.url,
2644
+ callback = _ref13.callback;
2466
2645
 
2467
2646
  win.addEventListener('message', function (e) {
2468
2647
  if (url !== undefined) {
@@ -2506,9 +2685,9 @@ var removeStorage = function removeStorage(key) {
2506
2685
  * @param {string、number} [data] - 数字或字符串型数字
2507
2686
  * @param {number} [precision] - 需要的小数位数
2508
2687
  **/
2509
- var replenish = function replenish(_ref13) {
2510
- var data = _ref13.data,
2511
- precision = _ref13.precision;
2688
+ var replenish = function replenish(_ref14) {
2689
+ var data = _ref14.data,
2690
+ precision = _ref14.precision;
2512
2691
 
2513
2692
  if (data && precision && precision > 0) {
2514
2693
  var power = Math.pow(10, precision);
@@ -2654,10 +2833,10 @@ var setScale = function setScale() {
2654
2833
  * @param {object} [data] - 数据---其中type必须表示操作类型
2655
2834
  * @param {string} [url] - 指定的消息发送URI地址
2656
2835
  **/
2657
- var sendMessage = function sendMessage(_ref14) {
2658
- var _ref14$data = _ref14.data,
2659
- data = _ref14$data === undefined ? {} : _ref14$data,
2660
- url = _ref14.url;
2836
+ var sendMessage = function sendMessage(_ref15) {
2837
+ var _ref15$data = _ref15.data,
2838
+ data = _ref15$data === undefined ? {} : _ref15$data,
2839
+ url = _ref15.url;
2661
2840
 
2662
2841
  var iframes = document.getElementsByTagName('iframe');
2663
2842
  for (var i = 0; i < iframes.length; i++) {
@@ -2701,10 +2880,10 @@ var setFavicon = function setFavicon(url) {
2701
2880
  * @param {String, Array, Object} [key] - 数据的名称,array类型表示多个key保存同一个value,object类型时对象的属性名称作为key属性值作为value
2702
2881
  * @param {String} [value] - 数据的值
2703
2882
  **/
2704
- var setStorage = function setStorage(_ref15) {
2705
- var type = _ref15.type,
2706
- key = _ref15.key,
2707
- value = _ref15.value;
2883
+ var setStorage = function setStorage(_ref16) {
2884
+ var type = _ref16.type,
2885
+ key = _ref16.key,
2886
+ value = _ref16.value;
2708
2887
 
2709
2888
  if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
2710
2889
  value = JSON.stringify(value);
@@ -2998,10 +3177,10 @@ var upperCase = function upperCase(text) {
2998
3177
  * @param {Object} [url] - url地址
2999
3178
  * @param {Object} [param] - 被转换的对象
3000
3179
  **/
3001
- var urlJoinParams = function urlJoinParams(_ref16) {
3002
- var url = _ref16.url,
3003
- param = _ref16.param,
3004
- timestamp = _ref16.timestamp;
3180
+ var urlJoinParams = function urlJoinParams(_ref17) {
3181
+ var url = _ref17.url,
3182
+ param = _ref17.param,
3183
+ timestamp = _ref17.timestamp;
3005
3184
 
3006
3185
  var arry = decodeURI(url).split('?');
3007
3186
  var times = new Date().getTime();
@@ -3119,6 +3298,7 @@ var watermark = function watermark(option) {
3119
3298
 
3120
3299
  exports.default = {
3121
3300
  ajax: ajax,
3301
+ ajaxStream: ajaxStream,
3122
3302
  arrUnique: arrUnique,
3123
3303
  average: average,
3124
3304
  browser: browser,