@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.
- package/dist/{index-DA2x586m.js → index-Cv6Yk83f.js} +1 -1
- package/dist/{index-B-mkNJ8X.js → index-DxYqmpkw.js} +1 -1
- package/dist/{index-Cs2bf-qT.js → index-pFskXRPD.js} +6 -6
- package/dist/{index.es-CZeEzytG.js → index.es-DcGGowg9.js} +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/{wang-editor-C09nwfM5.js → wang-editor-D0vwuhRC.js} +1 -1
- package/dist/{xlsx-util-C0viiHdq.js → xlsx-util-oopIn_S1.js} +1 -1
- package/es/common/rawitem/rawitem.mjs +38 -12
- package/es/editor/ai-chat/embed-ai-chat/embed-ai-chat.mjs +2 -1
- package/es/locale/en/index.mjs +2 -1
- package/es/locale/zh-CN/index.mjs +2 -1
- package/es/util/ai-chat-util/ai-chat-util.mjs +95 -4
- package/lib/common/rawitem/rawitem.cjs +38 -12
- package/lib/editor/ai-chat/embed-ai-chat/embed-ai-chat.cjs +2 -1
- package/lib/locale/en/index.cjs +2 -1
- package/lib/locale/zh-CN/index.cjs +2 -1
- package/lib/util/ai-chat-util/ai-chat-util.cjs +95 -4
- package/package.json +5 -5
- package/src/common/rawitem/rawitem.tsx +50 -19
- package/src/editor/ai-chat/embed-ai-chat/embed-ai-chat.tsx +3 -0
- package/src/locale/en/index.ts +2 -0
- package/src/locale/zh-CN/index.ts +1 -0
- package/src/util/ai-chat-util/ai-chat-util.ts +151 -4
|
@@ -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
|
-
|
|
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
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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,
|
package/src/locale/en/index.ts
CHANGED
|
@@ -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...',
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
-
{
|
|
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,
|