@ibiz-template/vue3-components 0.7.41-alpha.152 → 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.
@@ -10,6 +10,7 @@ import {
10
10
  IRawItemContainer,
11
11
  } from '@ibiz/model-core';
12
12
  import { isBase64, isBase64Image, isSvg } from '@ibiz-template/core';
13
+ import { isObject } from 'lodash-es';
13
14
  import { IControlController, IViewController } from '@ibiz-template/runtime';
14
15
  import { parseHtml } from '../../util';
15
16
  import './rawitem.scss';
@@ -119,8 +120,9 @@ export const IBizRawItem = defineComponent({
119
120
  }
120
121
  } else if (['INFO', 'WARNING', 'ERROR'].includes(contentType!)) {
121
122
  rawItemContent.value = (rawItem as IUnkownItem).rawContent!;
122
- } else if (['VIDEO', 'DIVIDER'].includes(contentType!)) {
123
- // 暂不处理
123
+ // 分割线内容解析,视频模型缺少,暂不处理(有rawItemParams则为面板直接内容)
124
+ } else if (contentType === 'DIVIDER' && !rawItem!.rawItemParams) {
125
+ rawItemContent.value = (rawItem as IUnkownItem).rawContent!;
124
126
  } else if (contentType === 'IMAGE' && sysImage) {
125
127
  rawItemContent.value = sysImage;
126
128
  }
@@ -179,6 +181,21 @@ export const IBizRawItem = defineComponent({
179
181
  // 文本类型显示值
180
182
  const rawItemText: Ref<string | number | IData> = ref('');
181
183
 
184
+ // 获取面板项直接内容项参数
185
+ const getRawItemParams = () => {
186
+ const tempParams: IData = {};
187
+ if (
188
+ rawItem &&
189
+ rawItem.rawItemParams &&
190
+ rawItem.rawItemParams.length > 0
191
+ ) {
192
+ rawItem.rawItemParams.forEach((item: IData) => {
193
+ tempParams[item.key] = item.value;
194
+ });
195
+ }
196
+ return tempParams;
197
+ };
198
+
182
199
  // 转换各类值操作
183
200
  const convertValue = () => {
184
201
  // 图片类型
@@ -243,25 +260,43 @@ export const IBizRawItem = defineComponent({
243
260
  )
244
261
  ) {
245
262
  if (rawItemContent.value) {
246
- let rawConfig = {};
263
+ let rawConfig: IData | string = {};
247
264
  try {
265
+ // 兼容json字符串格式与字符串文本模式
248
266
  if (typeof rawItemContent.value === 'string') {
249
- // eslint-disable-next-line no-new-func
250
- const func = new Function(`return (${rawItemContent.value});`);
251
- rawConfig = func();
267
+ // 以 { 或 [ 开头的使用脚本解析,不是则做为文本字符串
268
+ if (/^[[{]/.test(rawItemContent.value)) {
269
+ // eslint-disable-next-line no-new-func
270
+ const func = new Function(`return (${rawItemContent.value});`);
271
+ rawConfig = func();
272
+ } else {
273
+ rawConfig = rawItemContent.value;
274
+ }
252
275
  switch (rawItemType.value) {
253
276
  case 'VIDEO':
254
- Object.assign(playerParams.value, rawConfig);
277
+ if (isObject(rawConfig)) {
278
+ Object.assign(playerParams.value, rawConfig);
279
+ } else {
280
+ playerParams.value.path = rawConfig;
281
+ }
255
282
  break;
256
283
  case 'DIVIDER':
257
- Object.assign(dividerParams.value, rawConfig);
284
+ if (isObject(rawConfig)) {
285
+ Object.assign(dividerParams.value, rawConfig);
286
+ } else {
287
+ dividerParams.value.html = rawConfig;
288
+ }
258
289
  break;
259
290
  case 'INFO':
260
291
  case 'WARNING':
261
292
  case 'ERROR':
262
293
  alertParams.value.type =
263
294
  rawItemType.value.toLocaleLowerCase();
264
- Object.assign(alertParams.value, rawConfig);
295
+ if (isObject(rawConfig)) {
296
+ Object.assign(alertParams.value, rawConfig);
297
+ } else {
298
+ alertParams.value.title = rawConfig;
299
+ }
265
300
  break;
266
301
  default:
267
302
  break;
@@ -274,17 +309,13 @@ export const IBizRawItem = defineComponent({
274
309
  }),
275
310
  );
276
311
  }
277
- } else if (rawItemType.value === 'VIDEO') {
278
- if (
279
- rawItem &&
280
- rawItem.rawItemParams &&
281
- rawItem.rawItemParams.length > 0
282
- ) {
283
- const tempParams: IData = {};
284
- rawItem.rawItemParams.forEach((item: IData) => {
285
- tempParams[item.key] = item.value;
286
- });
312
+ // 面板中分割线、视频支持直接内容项参数
313
+ } else if (['DIVIDER', 'VIDEO'].includes(rawItemType.value)) {
314
+ const tempParams = getRawItemParams();
315
+ if (rawItemType.value === 'VIDEO') {
287
316
  Object.assign(playerParams.value, tempParams);
317
+ } else {
318
+ Object.assign(dividerParams.value, tempParams);
288
319
  }
289
320
  }
290
321
  }
@@ -130,6 +130,9 @@ export const IBizEmbedAIChat = defineComponent({
130
130
  container: aiChatElementRef.value,
131
131
  compWrapperId: editorParams.compwrapperid || 'DEFAULT',
132
132
  enableBackFill: false,
133
+ isEmbedAiHeaderHidden: editorParams.isembedaiheaderhidden
134
+ ? editorParams.isembedaiheaderhidden === 'true'
135
+ : ibiz.config.common.isEmbedAiHeaderHidden,
133
136
  },
134
137
  topicOptions: {
135
138
  appid: ibiz.env.appId,
@@ -979,6 +979,8 @@ export default {
979
979
  violationPrivacy: 'Violation of Privacy',
980
980
  contentInfringement: 'Content infringement',
981
981
  placeholder: 'Please enter',
982
+ noFilePreviewAddress:
983
+ 'No attachment preview service. Please contact the administrator to add it!',
982
984
  },
983
985
  screenShotUtil: {
984
986
  prepareCanvas: 'Prepare the canvas...',
@@ -922,6 +922,7 @@ export default {
922
922
  violationPrivacy: '侵犯隐私',
923
923
  contentInfringement: '内容侵权',
924
924
  placeholder: '请输入',
925
+ noFilePreviewAddress: '无附件预览服务,请联系管理员添加!',
925
926
  },
926
927
  screenShotUtil: {
927
928
  prepareCanvas: '准备画布中...',
@@ -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,
@@ -1354,6 +1370,14 @@ export class AIChatUtil implements IApiAIChatUtil {
1354
1370
  ibiz.config.common.aiChatMessagePageSize;
1355
1371
  }
1356
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
+
1357
1381
  // 智能体选项(由内部获取,优化打开速度)
1358
1382
  chatOptions.fetchAgentList = (args: IParams = {}) => {
1359
1383
  const { query, agentid } = args;
@@ -1385,8 +1409,17 @@ export class AIChatUtil implements IApiAIChatUtil {
1385
1409
  let abortController: AbortController;
1386
1410
  const { chatInstance, view, ctrl } = args;
1387
1411
  // 文件系统操作参数
1388
- 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);
1389
1421
  chatOptions.fileSystemOptions = fileSystemOptions;
1422
+
1390
1423
  // 查询历史
1391
1424
  chatOptions.history = async (
1392
1425
  ctx: IContext,
@@ -2423,8 +2456,42 @@ export class AIChatUtil implements IApiAIChatUtil {
2423
2456
  * @returns {*} {Promise<IData>}
2424
2457
  * @memberof AIChatUtil
2425
2458
  */
2426
- async getAIFileSystemOptions(): Promise<IData> {
2459
+ async getAIFileSystemOptions(
2460
+ filePreviewMode: 'DEFAULT' | 'CUSTOM',
2461
+ ): Promise<IData> {
2427
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
+ };
2428
2495
  // 查询文件列表
2429
2496
  fileSystemOptions.getFileList = async (
2430
2497
  ctx: IContext,
@@ -2454,11 +2521,91 @@ export class AIChatUtil implements IApiAIChatUtil {
2454
2521
  const response = await deService.aiChatProject(
2455
2522
  ctx,
2456
2523
  { srfactag: param.srfactag },
2457
- { ...other, action: 'UPLOAD' },
2524
+ { action: 'UPLOAD', ...other },
2458
2525
  );
2459
2526
  if (response.ok) return response.data;
2460
2527
  return undefined;
2461
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
+ };
2462
2609
  // 获取文件内容
2463
2610
  fileSystemOptions.getContent = async (
2464
2611
  ctx: IContext,