@ibiz-template/vue3-components 0.7.8 → 0.7.10
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-GoU343c8.js +4 -0
- package/dist/index-dsmTOMa5.js +1 -0
- package/dist/index-sGpuIVYT.js +1 -0
- package/dist/index.min.css +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/wang-editor-Vch7U079.js +1 -0
- package/dist/{xlsx-util-3My8gW7-.js → xlsx-util-my1qbty8.js} +1 -1
- package/es/control/dashboard/custom-dashboard-container/custom-dashboard-container.d.ts +2 -1
- package/es/control/dashboard/custom-dashboard-container/custom-dashboard-container.mjs +7 -3
- package/es/control/dashboard/dashboard-design/dashboard-design.mjs +22 -28
- package/es/control/dashboard/portlet/chart-portlet/chart-portlet.mjs +13 -1
- package/es/control/dashboard/portlet/list-portlet/list-portlet.mjs +13 -1
- package/es/control/dashboard/portlet/portlet-layout/portlet-layout.d.ts +1 -0
- package/es/control/dashboard/portlet/portlet-layout/portlet-layout.mjs +10 -1
- package/es/control/dashboard/portlet/view-portlet/view-portlet.mjs +13 -1
- package/es/editor/html/html-editor.controller.d.ts +25 -2
- package/es/editor/html/html-editor.controller.mjs +49 -1
- package/es/editor/html/wang-editor/ai/ai-modules.d.ts +10 -0
- package/es/editor/html/wang-editor/ai/ai-modules.mjs +32 -0
- package/es/editor/html/wang-editor/wang-editor.mjs +88 -3
- package/es/editor/text-box/input/input.mjs +9 -5
- package/es/locale/en/index.d.ts +204 -0
- package/es/locale/en/index.mjs +205 -0
- package/es/locale/zh-CN/index.d.ts +204 -0
- package/es/locale/zh-CN/index.mjs +205 -0
- package/lib/control/dashboard/custom-dashboard-container/custom-dashboard-container.cjs +6 -2
- package/lib/control/dashboard/dashboard-design/dashboard-design.cjs +22 -28
- package/lib/control/dashboard/portlet/chart-portlet/chart-portlet.cjs +12 -0
- package/lib/control/dashboard/portlet/list-portlet/list-portlet.cjs +12 -0
- package/lib/control/dashboard/portlet/portlet-layout/portlet-layout.cjs +10 -1
- package/lib/control/dashboard/portlet/view-portlet/view-portlet.cjs +12 -0
- package/lib/editor/html/html-editor.controller.cjs +48 -0
- package/lib/editor/html/wang-editor/ai/ai-modules.cjs +34 -0
- package/lib/editor/html/wang-editor/wang-editor.cjs +87 -2
- package/lib/editor/text-box/input/input.cjs +9 -5
- package/lib/locale/en/index.cjs +205 -0
- package/lib/locale/zh-CN/index.cjs +205 -0
- package/package.json +7 -7
- package/dist/index-Rqr5SnvQ.js +0 -1
- package/dist/index-oydyrl0O.js +0 -4
- package/dist/index-x-jLCilD.js +0 -1
- package/dist/wang-editor-XnzvMz46.js +0 -1
|
@@ -2056,6 +2056,7 @@ export declare const CustomDashboardContainer: import("vue").DefineComponent<{
|
|
|
2056
2056
|
ownerType: string;
|
|
2057
2057
|
ownerId: string;
|
|
2058
2058
|
loadCustomModelData: () => Promise<IData>;
|
|
2059
|
+
resetCustomModelData: () => Promise<IData>;
|
|
2059
2060
|
saveCustomModelData: (model: IData[], config?: IData | undefined) => Promise<IData>;
|
|
2060
2061
|
};
|
|
2061
2062
|
isShowDesign: import("vue").Ref<boolean>;
|
|
@@ -2064,7 +2065,7 @@ export declare const CustomDashboardContainer: import("vue").DefineComponent<{
|
|
|
2064
2065
|
showTypeDir: import("vue").Ref<boolean>;
|
|
2065
2066
|
openDesign: () => void;
|
|
2066
2067
|
onSaved: (args: IData) => Promise<void>;
|
|
2067
|
-
onReset: () => void
|
|
2068
|
+
onReset: () => Promise<void>;
|
|
2068
2069
|
clickCollapse: (type: string) => void;
|
|
2069
2070
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
2070
2071
|
modelData: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reactive, ref, computed, onMounted, resolveComponent, createVNode, defineComponent } from 'vue';
|
|
1
|
+
import { reactive, ref, nextTick, computed, onMounted, resolveComponent, createVNode, defineComponent } from 'vue';
|
|
2
2
|
import { CustomDashboardController } from '@ibiz-template/runtime';
|
|
3
3
|
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
4
4
|
import './custom-dashboard-container.css';
|
|
@@ -65,13 +65,17 @@ const CustomDashboardContainer = /* @__PURE__ */ defineComponent({
|
|
|
65
65
|
model: tempModelDatas,
|
|
66
66
|
config: args.config
|
|
67
67
|
});
|
|
68
|
+
await props.dashboard.evt.emit("onSavePortlet", void 0);
|
|
68
69
|
emit("changed", {
|
|
69
70
|
model: tempModelDatas
|
|
70
71
|
});
|
|
71
72
|
};
|
|
72
|
-
const onReset = () => {
|
|
73
|
+
const onReset = async () => {
|
|
74
|
+
isInited.value = false;
|
|
73
75
|
isShowDesign.value = false;
|
|
74
|
-
props.dashboard.resetPortlets();
|
|
76
|
+
await props.dashboard.resetPortlets();
|
|
77
|
+
await nextTick();
|
|
78
|
+
isInited.value = true;
|
|
75
79
|
};
|
|
76
80
|
const isShowDefault = computed(() => {
|
|
77
81
|
return customC.customModelData.length === 0;
|
|
@@ -100,12 +100,25 @@ const DashboardDesign = /* @__PURE__ */ defineComponent({
|
|
|
100
100
|
const list2 = [];
|
|
101
101
|
const app = ibiz.hub.getApp(ibiz.env.appId);
|
|
102
102
|
if (app.model.appPortletCats && app.model.appPortlets) {
|
|
103
|
+
const isDEView = customC.model.appDataEntityId;
|
|
104
|
+
const categoryTag = props.dashboard.controlParams.categorytag;
|
|
103
105
|
app.model.appPortlets.forEach((portlet) => {
|
|
104
106
|
var _a;
|
|
107
|
+
if (!isDEView && !portlet.enableAppDashboard) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (isDEView && !portlet.enableDEDashboard) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
105
113
|
const portletCat = (_a = app.model.appPortletCats) == null ? void 0 : _a.find((cat) => {
|
|
106
114
|
var _a2;
|
|
107
115
|
return cat.codeName === ((_a2 = portlet.appPortletCat) == null ? void 0 : _a2.codeName);
|
|
108
116
|
});
|
|
117
|
+
if (categoryTag) {
|
|
118
|
+
if (!portletCat || portletCat.codeName !== categoryTag) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
109
122
|
const temp = {
|
|
110
123
|
type: "app",
|
|
111
124
|
portletCodeName: portlet.codeName,
|
|
@@ -143,11 +156,8 @@ const DashboardDesign = /* @__PURE__ */ defineComponent({
|
|
|
143
156
|
if (filterVal.value) {
|
|
144
157
|
tempOpens = [filterVal.value];
|
|
145
158
|
} else {
|
|
146
|
-
|
|
147
|
-
tempOpens.push(item.
|
|
148
|
-
item.children.forEach((child, index2) => {
|
|
149
|
-
tempOpens.push(child.type + index2);
|
|
150
|
-
});
|
|
159
|
+
groups.value.forEach((item, index) => {
|
|
160
|
+
tempOpens.push(item.value + index);
|
|
151
161
|
});
|
|
152
162
|
}
|
|
153
163
|
return tempOpens;
|
|
@@ -220,8 +230,7 @@ const DashboardDesign = /* @__PURE__ */ defineComponent({
|
|
|
220
230
|
return !!model;
|
|
221
231
|
};
|
|
222
232
|
const onReset = async () => {
|
|
223
|
-
|
|
224
|
-
const res = await customC.saveCustomModelData([]);
|
|
233
|
+
const res = await customC.resetCustomModelData();
|
|
225
234
|
layoutModel.value = res.model;
|
|
226
235
|
layoutConfig.value = res.config;
|
|
227
236
|
emit("reset");
|
|
@@ -362,32 +371,17 @@ const DashboardDesign = /* @__PURE__ */ defineComponent({
|
|
|
362
371
|
"class": this.ns.is("no-filter", true),
|
|
363
372
|
"default-openeds": this.defaultOpens,
|
|
364
373
|
"key": "default"
|
|
365
|
-
}, _isSlot(_slot2 = this.
|
|
374
|
+
}, _isSlot(_slot2 = this.groups.map((group, index) => {
|
|
366
375
|
return createVNode(resolveComponent("el-sub-menu"), {
|
|
367
|
-
"key":
|
|
368
|
-
"index":
|
|
376
|
+
"key": group.value + index,
|
|
377
|
+
"index": group.value + index
|
|
369
378
|
}, {
|
|
370
379
|
title: () => {
|
|
371
|
-
|
|
372
|
-
return ibiz.i18n.t("control.dashboard.dashboardDesign.global");
|
|
373
|
-
}
|
|
374
|
-
return item.name;
|
|
380
|
+
return group.name;
|
|
375
381
|
},
|
|
376
382
|
default: () => {
|
|
377
|
-
return
|
|
378
|
-
return
|
|
379
|
-
"key": child.type + index2,
|
|
380
|
-
"index": child.type + index2
|
|
381
|
-
}, {
|
|
382
|
-
title: () => {
|
|
383
|
-
return child.name;
|
|
384
|
-
},
|
|
385
|
-
default: () => {
|
|
386
|
-
return child.children.map((child2) => {
|
|
387
|
-
return renderElMenuItem(child2);
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
});
|
|
383
|
+
return group.children.map((child) => {
|
|
384
|
+
return renderElMenuItem(child);
|
|
391
385
|
});
|
|
392
386
|
}
|
|
393
387
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isVNode, resolveComponent, h, createVNode, defineComponent } from 'vue';
|
|
1
|
+
import { isVNode, onMounted, onBeforeUnmount, resolveComponent, h, createVNode, defineComponent } from 'vue';
|
|
2
2
|
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
3
3
|
import { ChartPortletController, ControlType } from '@ibiz-template/runtime';
|
|
4
4
|
|
|
@@ -24,6 +24,18 @@ const ChartPortlet = /* @__PURE__ */ defineComponent({
|
|
|
24
24
|
const chart = (_b = props.modelData.controls) == null ? void 0 : _b.find((item) => {
|
|
25
25
|
return item.controlType === ControlType.CHART;
|
|
26
26
|
});
|
|
27
|
+
let timerTag;
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
const timer = props.controller.model.timer;
|
|
30
|
+
if (timer && timer > 0) {
|
|
31
|
+
timerTag = setInterval(() => {
|
|
32
|
+
props.controller.refresh();
|
|
33
|
+
}, timer);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
onBeforeUnmount(() => {
|
|
37
|
+
clearInterval(timerTag);
|
|
38
|
+
});
|
|
27
39
|
return {
|
|
28
40
|
ns,
|
|
29
41
|
chart
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isVNode, resolveComponent, h, createVNode, defineComponent } from 'vue';
|
|
1
|
+
import { isVNode, onMounted, onBeforeUnmount, resolveComponent, h, createVNode, defineComponent } from 'vue';
|
|
2
2
|
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
3
3
|
import { ListPortletController, ControlType } from '@ibiz-template/runtime';
|
|
4
4
|
|
|
@@ -24,6 +24,18 @@ const ListPortlet = /* @__PURE__ */ defineComponent({
|
|
|
24
24
|
const list = (_b = props.modelData.controls) == null ? void 0 : _b.find((item) => {
|
|
25
25
|
return item.controlType === ControlType.LIST;
|
|
26
26
|
});
|
|
27
|
+
let timerTag;
|
|
28
|
+
onMounted(() => {
|
|
29
|
+
const timer = props.controller.model.timer;
|
|
30
|
+
if (timer && timer > 0) {
|
|
31
|
+
timerTag = setInterval(() => {
|
|
32
|
+
props.controller.refresh();
|
|
33
|
+
}, timer);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
onBeforeUnmount(() => {
|
|
37
|
+
clearInterval(timerTag);
|
|
38
|
+
});
|
|
27
39
|
return {
|
|
28
40
|
ns,
|
|
29
41
|
list
|
|
@@ -12,6 +12,7 @@ export declare const PortletLayout: import("vue").DefineComponent<{
|
|
|
12
12
|
}, {
|
|
13
13
|
c: PortletPartController<import("@ibiz/model-core").IDBPortletPart>;
|
|
14
14
|
ns: import("@ibiz-template/core").Namespace;
|
|
15
|
+
popperClass: import("vue").ComputedRef<string[]>;
|
|
15
16
|
portletType: string;
|
|
16
17
|
isShowHeader: import("vue").ComputedRef<string | import("@ibiz/model-core").ISysImage | import("@ibiz/model-core").IUIActionGroup | undefined>;
|
|
17
18
|
onActionClick: (detail: IUIActionGroupDetail, event: MouseEvent) => Promise<void>;
|
|
@@ -17,6 +17,14 @@ const PortletLayout = /* @__PURE__ */ defineComponent({
|
|
|
17
17
|
const ns = useNamespace("portlet-layout");
|
|
18
18
|
const portletType = "portlet-".concat((_a = props.controller.model.portletType) == null ? void 0 : _a.toLowerCase());
|
|
19
19
|
const c = props.controller;
|
|
20
|
+
const popperClass = computed(() => {
|
|
21
|
+
const classNames = [ns.em("toolbar", "".concat(portletType, "-").concat(c.model.id))];
|
|
22
|
+
const {
|
|
23
|
+
codeName
|
|
24
|
+
} = c.dashboard.view.model;
|
|
25
|
+
classNames.push(ns.em("toolbar", codeName));
|
|
26
|
+
return classNames;
|
|
27
|
+
});
|
|
20
28
|
const isShowHeader = computed(() => {
|
|
21
29
|
return c.model.showTitleBar && (c.model.title || c.model.sysImage) || c.model.uiactionGroup;
|
|
22
30
|
});
|
|
@@ -26,6 +34,7 @@ const PortletLayout = /* @__PURE__ */ defineComponent({
|
|
|
26
34
|
return {
|
|
27
35
|
c,
|
|
28
36
|
ns,
|
|
37
|
+
popperClass,
|
|
29
38
|
portletType,
|
|
30
39
|
isShowHeader,
|
|
31
40
|
onActionClick
|
|
@@ -59,7 +68,7 @@ const PortletLayout = /* @__PURE__ */ defineComponent({
|
|
|
59
68
|
"action-details": model.uiactionGroup.uiactionGroupDetails,
|
|
60
69
|
"actions-state": state.actionGroupState,
|
|
61
70
|
"mode": model.actionGroupExtractMode === "ITEMS" ? "dropdown" : "buttons",
|
|
62
|
-
"popperClass": this.
|
|
71
|
+
"popperClass": this.popperClass,
|
|
63
72
|
"onActionClick": this.onActionClick
|
|
64
73
|
}, null)])]), createVNode("div", {
|
|
65
74
|
"key": "content",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isVNode, resolveComponent, h, createVNode, defineComponent } from 'vue';
|
|
1
|
+
import { isVNode, onMounted, onBeforeUnmount, resolveComponent, h, createVNode, defineComponent } from 'vue';
|
|
2
2
|
import { useNamespace } from '@ibiz-template/vue3-util';
|
|
3
3
|
import { ViewPortletController } from '@ibiz-template/runtime';
|
|
4
4
|
|
|
@@ -22,6 +22,18 @@ const ViewPortlet = /* @__PURE__ */ defineComponent({
|
|
|
22
22
|
var _a;
|
|
23
23
|
const ns = useNamespace("portlet-".concat((_a = props.modelData.portletType) == null ? void 0 : _a.toLowerCase()));
|
|
24
24
|
const view = props.modelData.portletAppView;
|
|
25
|
+
let timerTag;
|
|
26
|
+
onMounted(() => {
|
|
27
|
+
const timer = props.controller.model.timer;
|
|
28
|
+
if (timer && timer > 0) {
|
|
29
|
+
timerTag = setInterval(() => {
|
|
30
|
+
props.controller.refresh();
|
|
31
|
+
}, timer);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
onBeforeUnmount(() => {
|
|
35
|
+
clearInterval(timerTag);
|
|
36
|
+
});
|
|
25
37
|
return {
|
|
26
38
|
ns,
|
|
27
39
|
view
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorController } from '@ibiz-template/runtime';
|
|
2
|
-
import { IHtml } from '@ibiz/model-core';
|
|
1
|
+
import { EditorController, IAppDEService } from '@ibiz-template/runtime';
|
|
2
|
+
import { IAppDEACMode, IHtml } from '@ibiz/model-core';
|
|
3
3
|
/**
|
|
4
4
|
* html框编辑器控制器
|
|
5
5
|
*
|
|
@@ -16,5 +16,28 @@ export declare class HtmlEditorController extends EditorController<IHtml> {
|
|
|
16
16
|
* 下载参数
|
|
17
17
|
*/
|
|
18
18
|
exportParams?: IParams;
|
|
19
|
+
/**
|
|
20
|
+
* 应用实体服务
|
|
21
|
+
*
|
|
22
|
+
* @type {IAppDEService}
|
|
23
|
+
* @memberof HtmlEditorController
|
|
24
|
+
*/
|
|
25
|
+
deService?: IAppDEService;
|
|
26
|
+
/**
|
|
27
|
+
* 自填模式
|
|
28
|
+
*
|
|
29
|
+
* @author chitanda
|
|
30
|
+
* @date 2023-10-12 10:10:52
|
|
31
|
+
* @type {IAppDEACMode}
|
|
32
|
+
*/
|
|
33
|
+
deACMode?: IAppDEACMode;
|
|
34
|
+
/**
|
|
35
|
+
* AI 聊天自填模式
|
|
36
|
+
*
|
|
37
|
+
* @author chitanda
|
|
38
|
+
* @date 2023-10-12 10:10:37
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
*/
|
|
41
|
+
chatCompletion: boolean;
|
|
19
42
|
protected onInit(): Promise<void>;
|
|
20
43
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { EditorController } from '@ibiz-template/runtime';
|
|
1
|
+
import { EditorController, getDeACMode } from '@ibiz-template/runtime';
|
|
2
|
+
import { Boot } from '@wangeditor/editor';
|
|
3
|
+
import { AIMenu } from './wang-editor/ai/ai-modules.mjs';
|
|
2
4
|
|
|
3
5
|
"use strict";
|
|
4
6
|
var __defProp = Object.defineProperty;
|
|
@@ -18,6 +20,29 @@ class HtmlEditorController extends EditorController {
|
|
|
18
20
|
* 下载参数
|
|
19
21
|
*/
|
|
20
22
|
__publicField(this, "exportParams");
|
|
23
|
+
/**
|
|
24
|
+
* 应用实体服务
|
|
25
|
+
*
|
|
26
|
+
* @type {IAppDEService}
|
|
27
|
+
* @memberof HtmlEditorController
|
|
28
|
+
*/
|
|
29
|
+
__publicField(this, "deService");
|
|
30
|
+
/**
|
|
31
|
+
* 自填模式
|
|
32
|
+
*
|
|
33
|
+
* @author chitanda
|
|
34
|
+
* @date 2023-10-12 10:10:52
|
|
35
|
+
* @type {IAppDEACMode}
|
|
36
|
+
*/
|
|
37
|
+
__publicField(this, "deACMode");
|
|
38
|
+
/**
|
|
39
|
+
* AI 聊天自填模式
|
|
40
|
+
*
|
|
41
|
+
* @author chitanda
|
|
42
|
+
* @date 2023-10-12 10:10:37
|
|
43
|
+
* @type {boolean}
|
|
44
|
+
*/
|
|
45
|
+
__publicField(this, "chatCompletion", false);
|
|
21
46
|
}
|
|
22
47
|
async onInit() {
|
|
23
48
|
await super.onInit();
|
|
@@ -46,6 +71,29 @@ class HtmlEditorController extends EditorController {
|
|
|
46
71
|
}
|
|
47
72
|
}
|
|
48
73
|
}
|
|
74
|
+
const model = this.model;
|
|
75
|
+
if (model.appDEACModeId) {
|
|
76
|
+
this.deACMode = await getDeACMode(
|
|
77
|
+
model.appDEACModeId,
|
|
78
|
+
model.appDataEntityId,
|
|
79
|
+
this.context.srfappid
|
|
80
|
+
);
|
|
81
|
+
if (this.deACMode) {
|
|
82
|
+
if (this.deACMode.actype === "CHATCOMPLETION") {
|
|
83
|
+
this.deService = await ibiz.hub.getApp(model.appId).deService.getService(this.context, model.appDataEntityId);
|
|
84
|
+
this.chatCompletion = true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!window.aichartRegister) {
|
|
89
|
+
Boot.registerMenu({
|
|
90
|
+
key: "aichart",
|
|
91
|
+
factory() {
|
|
92
|
+
return new AIMenu();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
window.aichartRegister = true;
|
|
96
|
+
}
|
|
49
97
|
}
|
|
50
98
|
}
|
|
51
99
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IButtonMenu, IDomEditor } from '@wangeditor/editor';
|
|
2
|
+
export declare class AIMenu implements IButtonMenu {
|
|
3
|
+
title: string;
|
|
4
|
+
iconSvg: string;
|
|
5
|
+
tag: string;
|
|
6
|
+
isActive(editor: IDomEditor): boolean;
|
|
7
|
+
getValue(editor: IDomEditor): string | boolean;
|
|
8
|
+
isDisabled(editor: IDomEditor): boolean;
|
|
9
|
+
exec(editor: IDomEditor, value: string | boolean): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
class AIMenu {
|
|
9
|
+
constructor() {
|
|
10
|
+
__publicField(this, "title", "AI");
|
|
11
|
+
__publicField(this, "iconSvg", '<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <text x="0" y="15" fill="black">AI</text></svg>');
|
|
12
|
+
__publicField(this, "tag", "button");
|
|
13
|
+
}
|
|
14
|
+
// 菜单是否需要激活(如选中加粗文本,“加粗”菜单会激活),用不到则返回 false
|
|
15
|
+
isActive(editor) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
// 获取菜单执行时的 value ,用不到则返回空 字符串或 false
|
|
19
|
+
getValue(editor) {
|
|
20
|
+
return "aichart";
|
|
21
|
+
}
|
|
22
|
+
// 菜单是否需要禁用(如选中 H1 ,“引用”菜单被禁用),用不到则返回 false
|
|
23
|
+
isDisabled(editor) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// 点击菜单时触发的函数
|
|
27
|
+
exec(editor, value) {
|
|
28
|
+
editor.emit("aiClick");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { AIMenu };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, shallowRef, watch, onBeforeUnmount, nextTick, onMounted, createTextVNode, createVNode, onUnmounted, resolveComponent, defineComponent } from 'vue';
|
|
2
2
|
import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
|
|
3
|
-
import { getCookie } from 'qx-util';
|
|
3
|
+
import { getCookie, createUUID } from 'qx-util';
|
|
4
4
|
import { isNil } from 'ramda';
|
|
5
5
|
import { getHtmlProps, getEditorEmits, useNamespace } from '@ibiz-template/vue3-util';
|
|
6
6
|
import { CoreConst, awaitTimeout } from '@ibiz-template/core';
|
|
@@ -69,7 +69,11 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
69
69
|
return url;
|
|
70
70
|
};
|
|
71
71
|
const toolbarConfig = {
|
|
72
|
-
excludeKeys: ["group-video"]
|
|
72
|
+
excludeKeys: ["group-video"],
|
|
73
|
+
insertKeys: {
|
|
74
|
+
index: 60,
|
|
75
|
+
keys: ["|", "aichart"]
|
|
76
|
+
}
|
|
73
77
|
};
|
|
74
78
|
const editorConfig = {
|
|
75
79
|
placeholder: c.placeHolder,
|
|
@@ -141,9 +145,87 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
141
145
|
return;
|
|
142
146
|
editor.destroy();
|
|
143
147
|
});
|
|
148
|
+
let chatInstance;
|
|
149
|
+
const onClickAI = async () => {
|
|
150
|
+
var _a;
|
|
151
|
+
if (c.deService) {
|
|
152
|
+
const module = await import('@ibiz-template-plugin/ai-chat');
|
|
153
|
+
const chat = module.chat || module.default.chat;
|
|
154
|
+
chatInstance = chat;
|
|
155
|
+
const aiChat = chat.create({
|
|
156
|
+
question: async (arr) => {
|
|
157
|
+
var _a2;
|
|
158
|
+
const id = createUUID();
|
|
159
|
+
await ((_a2 = c.deService) == null ? void 0 : _a2.aiChatSse((msg) => {
|
|
160
|
+
ibiz.log.info("aiChatSse", msg);
|
|
161
|
+
if (msg.actionstate === 20 && msg.actionresult) {
|
|
162
|
+
aiChat.addMessage({
|
|
163
|
+
messageid: id,
|
|
164
|
+
state: msg.actionstate,
|
|
165
|
+
type: "DEFAULT",
|
|
166
|
+
role: "ASSISTANT",
|
|
167
|
+
content: msg.actionresult
|
|
168
|
+
});
|
|
169
|
+
} else if (msg.actionstate === 30 && msg.actionresult) {
|
|
170
|
+
const result = JSON.parse(msg.actionresult);
|
|
171
|
+
const choices = result.choices;
|
|
172
|
+
if (choices && choices.length > 0) {
|
|
173
|
+
aiChat.replaceMessage({
|
|
174
|
+
messageid: id,
|
|
175
|
+
state: msg.actionstate,
|
|
176
|
+
type: "DEFAULT",
|
|
177
|
+
role: "ASSISTANT",
|
|
178
|
+
content: choices[0].content || ""
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
} else if (msg.actionstate === 40) {
|
|
182
|
+
aiChat.replaceMessage({
|
|
183
|
+
messageid: id,
|
|
184
|
+
state: msg.actionstate,
|
|
185
|
+
type: "ERROR",
|
|
186
|
+
role: "ASSISTANT",
|
|
187
|
+
content: msg.actionresult
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}, c.context, {}, {
|
|
191
|
+
messages: arr
|
|
192
|
+
}));
|
|
193
|
+
aiChat.addMessage({
|
|
194
|
+
messageid: id,
|
|
195
|
+
state: 10,
|
|
196
|
+
type: "DEFAULT",
|
|
197
|
+
role: "ASSISTANT",
|
|
198
|
+
content: ""
|
|
199
|
+
});
|
|
200
|
+
return true;
|
|
201
|
+
},
|
|
202
|
+
action: (action, message) => {
|
|
203
|
+
if (action === "backfill") {
|
|
204
|
+
emit("change", message.content);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const res = await ((_a = c.deService) == null ? void 0 : _a.aiChatHistory(c.context, {}));
|
|
209
|
+
if (res.data && Array.isArray(res.data)) {
|
|
210
|
+
res.data.forEach((item) => {
|
|
211
|
+
const msg = {
|
|
212
|
+
messageid: createUUID(),
|
|
213
|
+
state: 30,
|
|
214
|
+
type: "DEFAULT",
|
|
215
|
+
role: item.role,
|
|
216
|
+
content: item.content
|
|
217
|
+
};
|
|
218
|
+
aiChat.addMessage(msg);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
144
223
|
const handleCreated = (editor) => {
|
|
145
224
|
editorRef.value = editor;
|
|
146
225
|
editor.setHtml(valueHtml.value);
|
|
226
|
+
editor.on("aiClick", () => {
|
|
227
|
+
onClickAI();
|
|
228
|
+
});
|
|
147
229
|
};
|
|
148
230
|
const handleChange = (editor) => {
|
|
149
231
|
const html = editor.getHtml();
|
|
@@ -387,6 +469,9 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
387
469
|
if (resizeObserver) {
|
|
388
470
|
resizeObserver.disconnect();
|
|
389
471
|
}
|
|
472
|
+
if (chatInstance) {
|
|
473
|
+
chatInstance.close();
|
|
474
|
+
}
|
|
390
475
|
});
|
|
391
476
|
return {
|
|
392
477
|
ns,
|
|
@@ -422,7 +507,7 @@ const IBizHtml = /* @__PURE__ */ defineComponent({
|
|
|
422
507
|
return !this.isFullScreen ? createVNode("div", {
|
|
423
508
|
"class": [this.ns.b(), {
|
|
424
509
|
[this.ns.b("editor-readonly")]: this.readonlyState
|
|
425
|
-
}]
|
|
510
|
+
}, this.ns.is("show-ai", true)]
|
|
426
511
|
}, [this.renderHeaserToolbar(), this.renderEditorContent(), this.hasEnableEdit && !this.readonlyState ? this.renderFooter() : null]) : createVNode(resolveComponent("el-dialog"), {
|
|
427
512
|
"modelValue": this.isFullScreen,
|
|
428
513
|
"onUpdate:modelValue": ($event) => this.isFullScreen = $event,
|
|
@@ -113,16 +113,16 @@ const IBizInput = /* @__PURE__ */ defineComponent({
|
|
|
113
113
|
};
|
|
114
114
|
let chatInstance;
|
|
115
115
|
const onClick = async () => {
|
|
116
|
-
var _a;
|
|
116
|
+
var _a, _b;
|
|
117
117
|
if (c.deService) {
|
|
118
118
|
const module = await import('@ibiz-template-plugin/ai-chat');
|
|
119
119
|
const chat = module.chat || module.default.chat;
|
|
120
120
|
chatInstance = chat;
|
|
121
121
|
const aiChat = chat.create({
|
|
122
122
|
question: async (arr) => {
|
|
123
|
-
var _a2;
|
|
123
|
+
var _a2, _b2;
|
|
124
124
|
const id = createUUID();
|
|
125
|
-
await ((
|
|
125
|
+
await ((_b2 = c.deService) == null ? void 0 : _b2.aiChatSse((msg) => {
|
|
126
126
|
ibiz.log.info("aiChatSse", msg);
|
|
127
127
|
if (msg.actionstate === 20 && msg.actionresult) {
|
|
128
128
|
aiChat.addMessage({
|
|
@@ -153,7 +153,9 @@ const IBizInput = /* @__PURE__ */ defineComponent({
|
|
|
153
153
|
content: msg.actionresult
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
|
-
}, c.context, {
|
|
156
|
+
}, c.context, {
|
|
157
|
+
srfactag: (_a2 = c.deACMode) == null ? void 0 : _a2.codeName
|
|
158
|
+
}, {
|
|
157
159
|
messages: arr
|
|
158
160
|
}));
|
|
159
161
|
aiChat.addMessage({
|
|
@@ -171,7 +173,9 @@ const IBizInput = /* @__PURE__ */ defineComponent({
|
|
|
171
173
|
}
|
|
172
174
|
}
|
|
173
175
|
});
|
|
174
|
-
const res = await ((
|
|
176
|
+
const res = await ((_b = c.deService) == null ? void 0 : _b.aiChatHistory(c.context, {
|
|
177
|
+
srfactag: (_a = c.deACMode) == null ? void 0 : _a.codeName
|
|
178
|
+
}));
|
|
175
179
|
if (res.data && Array.isArray(res.data)) {
|
|
176
180
|
res.data.forEach((item) => {
|
|
177
181
|
const msg = {
|