@ibiz-template/vue3-components 0.7.41-alpha.151 → 0.7.41-alpha.153

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.
@@ -345,6 +345,14 @@ export class AIChatUtil implements IApiAIChatUtil {
345
345
  ibiz.config.common.aiChatMessagePageSize;
346
346
  }
347
347
 
348
+ // AI会话是否启用工作空间文件系统相关操作
349
+ if (editorParams.srfaienableworkspace) {
350
+ chatOptions.enableWorkSpace =
351
+ editorParams.srfaienableworkspace === 'true';
352
+ } else {
353
+ chatOptions.enableWorkSpace = ibiz.config.common.aiEnableWorkSpace;
354
+ }
355
+
348
356
  // 智能体选项(由内部获取,优化打开速度)
349
357
  chatOptions.fetchAgentList = (args: IParams = {}) => {
350
358
  const { query, agentid } = args;
@@ -378,9 +386,17 @@ export class AIChatUtil implements IApiAIChatUtil {
378
386
  let id: string = '';
379
387
  let abortController: AbortController;
380
388
  const { chatInstance, view, ctrl } = args;
389
+
381
390
  // 文件系统操作参数
382
- const fileSystemOptions = await this.getAIFileSystemOptions();
391
+ // AI聊天框文件预览模式
392
+ let filePreviewMode = ibiz.config.common.aiFilePreviewMode;
393
+ if (editorParams.srfaifilepreviewmode) {
394
+ filePreviewMode = editorParams.srfaifilepreviewmode;
395
+ }
396
+ const fileSystemOptions =
397
+ await this.getAIFileSystemOptions(filePreviewMode);
383
398
  chatOptions.fileSystemOptions = fileSystemOptions;
399
+
384
400
  // 请求历史
385
401
  chatOptions.history = async (
386
402
  ctx: IContext,
@@ -508,10 +524,14 @@ export class AIChatUtil implements IApiAIChatUtil {
508
524
  if (extParams && Object.keys(extParams).length > 0) {
509
525
  Object.assign(questionRequestData, { srfextparams: extParams });
510
526
  }
527
+ // 新增等待回复消息(AI首条内容到达前显示loading气泡)
528
+ aiChat.addWaitingMessage(id);
511
529
  await deService.aiChatSse(
512
530
  (msg: IPortalAsyncAction) => {
513
531
  // 20: 持续回答中,消息会持续推送。同一个消息 id 会显示在同一个框内
514
532
  if (msg.actionstate === 20 && msg.actionresult) {
533
+ // 移除等待回复消息
534
+ aiChat.removeWaitingMessage(id);
515
535
  // 更新用户消息真实id
516
536
  if (msg.asextparam && localMsgID && updateFlag) {
517
537
  aiChat.updateMsgRealMessageID(localMsgID, msg.asextparam);
@@ -588,6 +608,8 @@ export class AIChatUtil implements IApiAIChatUtil {
588
608
  }
589
609
  abortController?.abort();
590
610
  } finally {
611
+ // 移除等待回复消息
612
+ aiChat.removeWaitingMessage(id);
591
613
  // 标记当前消息已经交互完成
592
614
  aiChat.completeMessage(id, true);
593
615
  // 清空异步消息任务
@@ -667,10 +689,14 @@ export class AIChatUtil implements IApiAIChatUtil {
667
689
  srfproject: other.srfproject,
668
690
  });
669
691
  try {
692
+ // 新增等待回复消息(AI首条内容到达前显示loading气泡)
693
+ aiChat.addWaitingMessage(id);
670
694
  await deService.aiResumeSse(
671
695
  (msg: IPortalAsyncAction) => {
672
696
  // 20: 持续回答中,消息会持续推送。同一个消息 id 会显示在同一个框内
673
697
  if (msg.actionstate === 20 && msg.actionresult) {
698
+ // 移除等待回复消息
699
+ aiChat.removeWaitingMessage(id);
674
700
  // 设置当前聊天在加载中
675
701
  aiChat.isLoading.value = true;
676
702
  // 不存在才设置,存在则不设置(下方设置的时候需要去存储话题数据中)
@@ -748,6 +774,8 @@ export class AIChatUtil implements IApiAIChatUtil {
748
774
  }
749
775
  abortController?.abort();
750
776
  } finally {
777
+ // 移除等待回复消息
778
+ aiChat.removeWaitingMessage(id);
751
779
  // 设置当前聊天加载状态已完成
752
780
  aiChat.isLoading.value = false;
753
781
  // 标记当前消息已经交互完成
@@ -1342,6 +1370,14 @@ export class AIChatUtil implements IApiAIChatUtil {
1342
1370
  ibiz.config.common.aiChatMessagePageSize;
1343
1371
  }
1344
1372
 
1373
+ // AI会话是否启用工作空间文件系统相关操作
1374
+ if (params.hasOwnProperty('srfaienableworkspace')) {
1375
+ chatOptions.enableWorkSpace = params.srfaienableworkspace === 'true';
1376
+ delete params.srfaienableworkspace;
1377
+ } else {
1378
+ chatOptions.enableWorkSpace = ibiz.config.common.aiEnableWorkSpace;
1379
+ }
1380
+
1345
1381
  // 智能体选项(由内部获取,优化打开速度)
1346
1382
  chatOptions.fetchAgentList = (args: IParams = {}) => {
1347
1383
  const { query, agentid } = args;
@@ -1373,8 +1409,17 @@ export class AIChatUtil implements IApiAIChatUtil {
1373
1409
  let abortController: AbortController;
1374
1410
  const { chatInstance, view, ctrl } = args;
1375
1411
  // 文件系统操作参数
1376
- const fileSystemOptions = await this.getAIFileSystemOptions();
1412
+
1413
+ // AI聊天框文件预览模式
1414
+ let filePreviewMode = ibiz.config.common.aiFilePreviewMode;
1415
+ if (params.hasOwnProperty('srfaifilepreviewmode')) {
1416
+ filePreviewMode = params.srfaifilepreviewmode;
1417
+ delete params.srfaifilepreviewmode;
1418
+ }
1419
+ const fileSystemOptions =
1420
+ await this.getAIFileSystemOptions(filePreviewMode);
1377
1421
  chatOptions.fileSystemOptions = fileSystemOptions;
1422
+
1378
1423
  // 查询历史
1379
1424
  chatOptions.history = async (
1380
1425
  ctx: IContext,
@@ -1500,10 +1545,14 @@ export class AIChatUtil implements IApiAIChatUtil {
1500
1545
  if (extParams && Object.keys(extParams).length > 0) {
1501
1546
  Object.assign(questionRequestData, { srfextparams: extParams });
1502
1547
  }
1548
+ // 新增等待回复消息(AI首条内容到达前显示loading气泡)
1549
+ aiChat.addWaitingMessage(id);
1503
1550
  await deService.aiChatSse(
1504
1551
  (msg: IPortalAsyncAction) => {
1505
1552
  // 20: 持续回答中,消息会持续推送。同一个消息 id 会显示在同一个框内
1506
1553
  if (msg.actionstate === 20 && msg.actionresult) {
1554
+ // 移除等待回复消息
1555
+ aiChat.removeWaitingMessage(id);
1507
1556
  // 更新用户消息真实id
1508
1557
  if (msg.asextparam && localMsgID && updateFlag) {
1509
1558
  aiChat.updateMsgRealMessageID(localMsgID, msg.asextparam);
@@ -1580,6 +1629,8 @@ export class AIChatUtil implements IApiAIChatUtil {
1580
1629
  }
1581
1630
  abortController?.abort();
1582
1631
  } finally {
1632
+ // 移除等待回复消息
1633
+ aiChat.removeWaitingMessage(id);
1583
1634
  // 清空异步消息任务
1584
1635
  aiChat.setActiveAsyncacitonId('');
1585
1636
  // 标记当前消息已经交互完成
@@ -1659,10 +1710,14 @@ export class AIChatUtil implements IApiAIChatUtil {
1659
1710
  srfproject: other.srfproject,
1660
1711
  });
1661
1712
  try {
1713
+ // 新增等待回复消息(AI首条内容到达前显示loading气泡)
1714
+ aiChat.addWaitingMessage(id);
1662
1715
  await deService.aiResumeSse(
1663
1716
  (msg: IPortalAsyncAction) => {
1664
1717
  // 20: 持续回答中,消息会持续推送。同一个消息 id 会显示在同一个框内
1665
1718
  if (msg.actionstate === 20 && msg.actionresult) {
1719
+ // 移除等待回复消息
1720
+ aiChat.removeWaitingMessage(id);
1666
1721
  // 设置当前聊天在加载中
1667
1722
  aiChat.isLoading.value = true;
1668
1723
  // 不存在才设置,存在则不设置(下方设置的时候需要去存储话题数据中)
@@ -1740,6 +1795,8 @@ export class AIChatUtil implements IApiAIChatUtil {
1740
1795
  }
1741
1796
  abortController?.abort();
1742
1797
  } finally {
1798
+ // 移除等待回复消息
1799
+ aiChat.removeWaitingMessage(id);
1743
1800
  // 设置当前聊天加载状态已完成
1744
1801
  aiChat.isLoading.value = false;
1745
1802
  // 标记当前消息已经交互完成
@@ -2399,8 +2456,42 @@ export class AIChatUtil implements IApiAIChatUtil {
2399
2456
  * @returns {*} {Promise<IData>}
2400
2457
  * @memberof AIChatUtil
2401
2458
  */
2402
- async getAIFileSystemOptions(): Promise<IData> {
2459
+ async getAIFileSystemOptions(
2460
+ filePreviewMode: 'DEFAULT' | 'CUSTOM',
2461
+ ): Promise<IData> {
2403
2462
  const fileSystemOptions: IData = {};
2463
+ // 文件预览模式
2464
+ fileSystemOptions.filePreviewMode = filePreviewMode;
2465
+ // 获取自定义文件预览路径
2466
+ fileSystemOptions.getCustomFilePreviewUrl = async (
2467
+ ctx: IContext,
2468
+ param: IParams,
2469
+ other: IParams,
2470
+ ): Promise<string> => {
2471
+ const filePreviewAddress = ibiz.env.customParams?.file_preview_address;
2472
+ if (!filePreviewAddress) {
2473
+ ibiz.message.error(
2474
+ ibiz.i18n.t('util.aiChartUtil.noFilePreviewAddress'),
2475
+ );
2476
+ return '';
2477
+ }
2478
+ const { id, name, folder } = other;
2479
+ let { downloadUrl } = ibiz.util.file.calcFileUpDownUrl(
2480
+ ctx,
2481
+ param,
2482
+ {},
2483
+ { osscat: folder },
2484
+ );
2485
+ downloadUrl = downloadUrl.replace('%fileId%', id);
2486
+ const { protocol, hostname, port } = window.location;
2487
+ // 没有端口使用默认端口
2488
+ const actualPort = port || (protocol === 'https:' ? '443' : '80');
2489
+ const windowInfo = `${protocol}//${hostname}:${actualPort}`;
2490
+ const filedownloadurl = `${windowInfo}${downloadUrl}?fullfilename=${name}`;
2491
+ const b64Encoded = ibiz.util.base64.encode(filedownloadurl);
2492
+ const previewUrl = `${filePreviewAddress}/onlinePreview?url=${encodeURIComponent(b64Encoded)}`;
2493
+ return previewUrl;
2494
+ };
2404
2495
  // 查询文件列表
2405
2496
  fileSystemOptions.getFileList = async (
2406
2497
  ctx: IContext,
@@ -2430,11 +2521,91 @@ export class AIChatUtil implements IApiAIChatUtil {
2430
2521
  const response = await deService.aiChatProject(
2431
2522
  ctx,
2432
2523
  { srfactag: param.srfactag },
2433
- { ...other, action: 'UPLOAD' },
2524
+ { action: 'UPLOAD', ...other },
2434
2525
  );
2435
2526
  if (response.ok) return response.data;
2436
2527
  return undefined;
2437
2528
  };
2529
+ // 新建目录
2530
+ fileSystemOptions.createFolder = async (
2531
+ ctx: IContext,
2532
+ param: IParams,
2533
+ other: IParams,
2534
+ ): Promise<IData> => {
2535
+ const deService = await ibiz.hub
2536
+ .getApp(ctx.srfappid)
2537
+ .deService.getService(ctx, param.appDataEntityId);
2538
+ const response = await deService.aiChatProject(
2539
+ ctx,
2540
+ { srfactag: param.srfactag },
2541
+ { action: 'MKDIR', ...other },
2542
+ );
2543
+ return response.data;
2544
+ };
2545
+ // 新建文件
2546
+ fileSystemOptions.createFile = async (
2547
+ ctx: IContext,
2548
+ param: IParams,
2549
+ other: IParams,
2550
+ ): Promise<IData> => {
2551
+ const deService = await ibiz.hub
2552
+ .getApp(ctx.srfappid)
2553
+ .deService.getService(ctx, param.appDataEntityId);
2554
+ const response = await deService.aiChatProject(
2555
+ ctx,
2556
+ { srfactag: param.srfactag },
2557
+ { action: 'WRITE', ...other },
2558
+ );
2559
+ return response.data;
2560
+ };
2561
+ // 移动文件夹/文件
2562
+ fileSystemOptions.move = async (
2563
+ ctx: IContext,
2564
+ param: IParams,
2565
+ other: IParams,
2566
+ ): Promise<IData> => {
2567
+ const deService = await ibiz.hub
2568
+ .getApp(ctx.srfappid)
2569
+ .deService.getService(ctx, param.appDataEntityId);
2570
+ const response = await deService.aiChatProject(
2571
+ ctx,
2572
+ { srfactag: param.srfactag },
2573
+ { action: 'MOVE', ...other },
2574
+ );
2575
+ return response.data;
2576
+ };
2577
+ // 删除文件夹/文件
2578
+ fileSystemOptions.delete = async (
2579
+ ctx: IContext,
2580
+ param: IParams,
2581
+ other: IParams,
2582
+ ): Promise<IData> => {
2583
+ const deService = await ibiz.hub
2584
+ .getApp(ctx.srfappid)
2585
+ .deService.getService(ctx, param.appDataEntityId);
2586
+ const response = await deService.aiChatProject(
2587
+ ctx,
2588
+ { srfactag: param.srfactag },
2589
+ { recursive: true, action: 'DELETE', ...other },
2590
+ );
2591
+ return response.data;
2592
+ };
2593
+ // 读取文件内容
2594
+ fileSystemOptions.readFile = async (
2595
+ ctx: IContext,
2596
+ param: IParams,
2597
+ other: IParams,
2598
+ ): Promise<IData> => {
2599
+ const deService = await ibiz.hub
2600
+ .getApp(ctx.srfappid)
2601
+ .deService.getService(ctx, param.appDataEntityId);
2602
+ const response = await deService.aiChatProject(
2603
+ ctx,
2604
+ { srfactag: param.srfactag },
2605
+ { action: 'READ', ...other },
2606
+ );
2607
+ return response.data;
2608
+ };
2438
2609
  // 获取文件内容
2439
2610
  fileSystemOptions.getContent = async (
2440
2611
  ctx: IContext,