eoss 0.1.0-alpha.21 → 0.1.0-alpha.23
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/lib/account-login.js +125 -125
- package/lib/alert.js +2 -2
- package/lib/aside.js +2 -2
- package/lib/autocomplete.js +239 -239
- package/lib/avatar.js +2 -2
- package/lib/backtop.js +4 -4
- package/lib/badge.js +2 -2
- package/lib/breadcrumb-item.js +2 -2
- package/lib/breadcrumb.js +2 -2
- package/lib/button-group.js +2 -2
- package/lib/button.js +2 -2
- package/lib/ca-login.js +6 -6
- package/lib/calendar.js +2 -2
- package/lib/card.js +2 -2
- package/lib/carousel-item.js +22 -22
- package/lib/carousel.js +40 -26
- package/lib/cascader-panel.js +12 -12
- package/lib/cascader.js +506 -492
- package/lib/checkbox-button.js +2 -2
- package/lib/checkbox-group.js +137 -137
- package/lib/checkbox.js +2 -2
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +1224 -1030
- package/lib/collapse.js +1225 -1030
- package/lib/color-picker.js +12 -12
- package/lib/container.js +2 -2
- package/lib/cron.js +2 -2
- package/lib/data-table.js +121 -121
- package/lib/date-picker.js +225 -225
- package/lib/dialog.js +17 -17
- package/lib/divider.js +2 -2
- package/lib/drawer.js +6 -6
- package/lib/dropdown-item.js +2 -2
- package/lib/dropdown-menu.js +10 -10
- package/lib/dropdown.js +13 -13
- package/lib/email-login.js +365 -365
- package/lib/empty.js +2 -2
- package/lib/eoss.common.js +21402 -20724
- package/lib/flip.js +2 -2
- package/lib/flow-group.js +251 -251
- package/lib/flow.js +15933 -18946
- package/lib/flows.js +9195 -0
- package/lib/footer.js +2 -2
- package/lib/form-item.js +28 -17
- package/lib/form.js +1228 -1033
- package/lib/header.js +2 -2
- package/lib/icon.js +129 -129
- package/lib/icons.js +4 -4
- package/lib/image-viewer.js +6 -6
- package/lib/image.js +4 -4
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +4 -4
- package/lib/input-number.js +11 -11
- package/lib/input.js +28 -14
- package/lib/link.js +2 -2
- package/lib/loading.js +6 -6
- package/lib/login.js +277 -229
- package/lib/lowcode.js +964 -325
- package/lib/main.js +634 -565
- package/lib/marquee.js +6 -6
- package/lib/menu-item-group.js +2 -2
- package/lib/menu-item.js +2 -2
- package/lib/menu.js +1934 -1934
- package/lib/message-box.js +12 -12
- package/lib/message.js +10 -10
- package/lib/notification.js +16 -16
- package/lib/option-group.js +2 -2
- package/lib/option.js +6 -6
- package/lib/page-header.js +2 -2
- package/lib/pagination.js +16 -16
- package/lib/phone-login.js +127 -127
- package/lib/popconfirm.js +4 -4
- package/lib/popover.js +219 -219
- package/lib/progress.js +2 -2
- package/lib/qr-code.js +8 -8
- package/lib/qrcode-login.js +119 -119
- package/lib/radio-button.js +2 -2
- package/lib/radio-group.js +119 -119
- package/lib/radio.js +2 -2
- package/lib/rate.js +6 -6
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +46 -32
- package/lib/select.js +823 -796
- package/lib/selector-panel.js +141 -141
- package/lib/selector.js +1040 -160
- package/lib/slider.js +2 -2
- package/lib/step.js +1225 -1030
- package/lib/steps.js +6 -6
- package/lib/submenu.js +27 -27
- package/lib/switch.js +15 -15
- package/lib/tab-pane.js +2 -2
- package/lib/table-column.js +8 -8
- package/lib/table.js +2530 -2516
- package/lib/tabs.js +28 -14
- package/lib/tag.js +2 -2
- package/lib/theme-chalk/autocomplete.css +1 -1
- package/lib/theme-chalk/base.css +1 -1
- package/lib/theme-chalk/cascader-panel.css +1 -1
- package/lib/theme-chalk/cascader.css +1 -1
- package/lib/theme-chalk/checkbox-group.css +1 -1
- package/lib/theme-chalk/date-picker.css +1 -1
- package/lib/theme-chalk/descriptions-item.css +1 -1
- package/lib/theme-chalk/descriptions.css +1 -1
- package/lib/theme-chalk/empty.css +1 -1
- package/lib/theme-chalk/flow.css +1 -1
- package/lib/theme-chalk/flows.css +1 -0
- package/lib/theme-chalk/form.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/input-number.css +1 -1
- package/lib/theme-chalk/input.css +1 -1
- package/lib/theme-chalk/lowcode.css +1 -1
- package/lib/theme-chalk/main.css +1 -1
- package/lib/theme-chalk/menu.css +1 -1
- package/lib/theme-chalk/message-box.css +1 -1
- package/lib/theme-chalk/message.css +1 -1
- package/lib/theme-chalk/notification.css +1 -1
- package/lib/theme-chalk/pagination.css +1 -1
- package/lib/theme-chalk/scrollbar.css +1 -1
- package/lib/theme-chalk/select.css +1 -1
- package/lib/theme-chalk/selector-panel.css +1 -1
- package/lib/theme-chalk/selector.css +1 -1
- package/lib/theme-chalk/slider.css +1 -1
- package/lib/theme-chalk/table.css +1 -1
- package/lib/theme-chalk/tabs.css +1 -1
- package/lib/theme-chalk/time-picker.css +1 -1
- package/lib/theme-chalk/time-select.css +1 -1
- package/lib/theme-chalk/timeline-item.css +1 -1
- package/lib/theme-chalk/transfer.css +1 -1
- package/lib/theme-chalk/tree.css +1 -1
- package/lib/theme-chalk/upload.css +1 -1
- package/lib/time-picker.js +16 -16
- package/lib/time-select.js +15 -15
- package/lib/timeline-item.js +2 -2
- package/lib/timeline.js +2 -2
- package/lib/tips.js +129 -129
- package/lib/toolbar.js +4 -4
- package/lib/tooltip.js +220 -220
- package/lib/transfer.js +8 -8
- package/lib/tree-group.js +124 -124
- package/lib/tree.js +144 -144
- package/lib/upload.js +155 -155
- package/lib/utils/resize-event.js +20 -6
- package/package.json +3 -1
- package/packages/carousel/src/carousel.vue +2 -2
- package/packages/flow/index.js +4 -4
- package/packages/flow/src/component/FreeCirculation.vue +4 -3
- package/packages/flow/src/component/SendMsg.vue +2 -4
- package/packages/flow/src/component/opinions.vue +203 -226
- package/packages/flow/src/component/taskUnionExamine.vue +2 -4
- package/packages/flow/src/freeStartFlow.vue +2 -2
- package/packages/flow/src/selectUser.vue +36 -1
- package/packages/flow/src/supervise.vue +4 -2
- package/packages/flows/index.js +7 -0
- package/packages/flows/readme.md +600 -0
- package/packages/flows/src/components/basis.vue +108 -0
- package/packages/flows/src/components/distribute.vue +42 -0
- package/packages/flows/src/components/opinions-file.vue +123 -0
- package/packages/{flow-copy/src/component → flows/src/components}/opinions.vue +227 -204
- package/packages/flows/src/components/quick-actions.vue +64 -0
- package/packages/flows/src/components/reject.vue +83 -0
- package/packages/flows/src/components/start-flow.vue +210 -0
- package/packages/flows/src/flow.vue +510 -0
- package/packages/{flow/src/flow.vue → flows/src/flows.vue} +40 -1327
- package/packages/form/src/form-item.vue +9 -2
- package/packages/form/src/label-wrap.vue +4 -1
- package/packages/login/src/login.vue +61 -32
- package/packages/lowcode/src/aside.vue +15 -2
- package/packages/lowcode/src/editor.vue +187 -0
- package/packages/lowcode/src/lowcode.vue +195 -41
- package/packages/lowcode/src/pages.vue +174 -26
- package/packages/lowcode/src/toolbar.vue +3 -18
- package/packages/main/src/components/pages.vue +97 -65
- package/packages/main/src/components/router-page.vue +0 -2
- package/packages/main/src/gzw.vue +3 -2
- package/packages/main/src/minxs.js +72 -51
- package/packages/menu/src/menu.vue +4 -4
- package/packages/select/src/select.vue +5 -0
- package/packages/selector/src/selector.vue +147 -17
- package/packages/theme-chalk/src/base.scss +6 -0
- package/packages/theme-chalk/src/checkbox-group.scss +1 -0
- package/packages/theme-chalk/src/common/var.scss +1 -1
- package/packages/theme-chalk/src/flow.scss +7 -4
- package/packages/theme-chalk/src/flows.scss +141 -0
- package/packages/theme-chalk/src/form.scss +1 -1
- package/packages/theme-chalk/src/index.scss +1 -0
- package/packages/theme-chalk/src/input.scss +1 -0
- package/packages/theme-chalk/src/lowcode.scss +21 -18
- package/packages/theme-chalk/src/select.scss +3 -1
- package/packages/theme-chalk/src/selector.scss +11 -5
- package/src/index.js +4 -1
- package/src/utils/resize-event.js +21 -7
- package/packages/flow/src/component/quick-actions.vue +0 -1168
- package/packages/flow-copy/index.js +0 -7
- package/packages/flow-copy/src/component/Circulate.vue +0 -452
- package/packages/flow-copy/src/component/CustomPreset.vue +0 -333
- package/packages/flow-copy/src/component/FreeCirculation.vue +0 -275
- package/packages/flow-copy/src/component/Preset.vue +0 -273
- package/packages/flow-copy/src/component/SendMsg.vue +0 -290
- package/packages/flow-copy/src/component/TimeLimit.vue +0 -205
- package/packages/flow-copy/src/component/taskUnionExamine.vue +0 -818
- package/packages/flow-copy/src/freeStartFlow.vue +0 -2912
- package/packages/flow-copy/src/processForm.vue +0 -1411
- package/packages/flow-copy/src/processReject.vue +0 -319
- package/packages/flow-copy/src/reset.vue +0 -944
- package/packages/flow-copy/src/selectUser.vue +0 -513
- package/packages/flow-copy/src/startTaskRead.vue +0 -723
- package/packages/flow-copy/src/supervise.vue +0 -182
- package/packages/flow-copy/src/table.vue +0 -65
- /package/packages/{flow-copy → flow}/src/component/FileList.vue +0 -0
- /package/packages/{flow-copy → flow}/src/main.vue +0 -0
- /package/packages/{flow-copy/src → flows/src/components}/form.vue +0 -0
- /package/packages/{flow/src/component → flows/src/components}/message.vue +0 -0
- /package/packages/{flow/src/component → flows/src/components}/opinions-list.vue +0 -0
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
:style="itemStyle"
|
|
5
5
|
:class="[
|
|
6
6
|
{
|
|
7
|
-
|
|
7
|
+
'es-form-item--feedback': esForm && esForm.statusIcon,
|
|
8
|
+
'es-form--label-top': labelPosition === 'top',
|
|
8
9
|
'is-error': validateState === 'error',
|
|
9
10
|
'is-validating': validateState === 'validating',
|
|
10
11
|
'is-success': validateState === 'success',
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
:class="labelClass"
|
|
22
23
|
:labelFor="labelFor"
|
|
23
24
|
:contents="label"
|
|
25
|
+
:position="labelPosition"
|
|
24
26
|
v-if="label || $slots.label"
|
|
25
27
|
>
|
|
26
28
|
<slot name="label" v-if="$slots.label"></slot>
|
|
@@ -100,10 +102,15 @@ export default {
|
|
|
100
102
|
* 标签文本
|
|
101
103
|
*/
|
|
102
104
|
label: [String, Array],
|
|
105
|
+
/**
|
|
106
|
+
* 标签位置
|
|
107
|
+
*/
|
|
108
|
+
labelPosition: String,
|
|
103
109
|
/**
|
|
104
110
|
* 标签宽度
|
|
105
111
|
*/
|
|
106
112
|
labelWidth: String,
|
|
113
|
+
|
|
107
114
|
/**
|
|
108
115
|
* 字段名,用于表单验证和数据绑定
|
|
109
116
|
*/
|
|
@@ -257,7 +264,7 @@ export default {
|
|
|
257
264
|
const labelWidth = this.labelWidth || form.labelWidth;
|
|
258
265
|
const label = this.label || this.$slots.label;
|
|
259
266
|
// 快速路径:无需计算样式
|
|
260
|
-
if (!label || form.labelPosition === 'top' || form.inline) return {};
|
|
267
|
+
if (!label || this.labelPosition === 'top' || form.labelPosition === 'top' || form.inline) return {};
|
|
261
268
|
if (!this.labelWidth && this.isNested) return {};
|
|
262
269
|
|
|
263
270
|
// 构建样式对象
|
|
@@ -44,6 +44,8 @@ export default {
|
|
|
44
44
|
componentsName: 'LabelWrap',
|
|
45
45
|
inheritAttrs: false,
|
|
46
46
|
props: {
|
|
47
|
+
// 标签位置
|
|
48
|
+
position: String,
|
|
47
49
|
// 标签关联的表单字段ID,确保label与form field正确关联
|
|
48
50
|
labelFor: String,
|
|
49
51
|
// 统一使用isAutoWidth来控制自动宽度计算
|
|
@@ -82,7 +84,8 @@ export default {
|
|
|
82
84
|
if (
|
|
83
85
|
!this.autoWidth &&
|
|
84
86
|
this.esForm &&
|
|
85
|
-
this.esForm.labelPosition !== 'top'
|
|
87
|
+
this.esForm.labelPosition !== 'top' &&
|
|
88
|
+
this.position !== 'top'
|
|
86
89
|
) {
|
|
87
90
|
const labelWidth = parseInt(
|
|
88
91
|
(this.esFormItem || {}).labelWidth ||
|
|
@@ -148,7 +148,9 @@
|
|
|
148
148
|
<transition name="launch-fade">
|
|
149
149
|
<div class="es-launch" :style="launchStyles" v-show="showLaunch">
|
|
150
150
|
<div class="es-launch__text is-user">{{ userName }},您好!</div>
|
|
151
|
-
<div class="es-launch__text"
|
|
151
|
+
<div class="es-launch__text">
|
|
152
|
+
欢迎进入{{ welcome || subsystemName }}
|
|
153
|
+
</div>
|
|
152
154
|
</div>
|
|
153
155
|
</transition>
|
|
154
156
|
|
|
@@ -602,7 +604,7 @@ export default {
|
|
|
602
604
|
beforeCreate() {},
|
|
603
605
|
created() {
|
|
604
606
|
this.initLogin();
|
|
605
|
-
this.alertNotice = throttle(300,
|
|
607
|
+
this.alertNotice = throttle(300, this.doAlert);
|
|
606
608
|
},
|
|
607
609
|
mounted() {},
|
|
608
610
|
/**
|
|
@@ -797,42 +799,69 @@ export default {
|
|
|
797
799
|
}
|
|
798
800
|
},
|
|
799
801
|
/**
|
|
800
|
-
*
|
|
802
|
+
* 显示弹窗提示
|
|
803
|
+
* @param {string|Object} contents - 弹窗内容,字符串表示内容文本,对象表示完整配置
|
|
801
804
|
*/
|
|
802
805
|
doAlert(contents) {
|
|
803
|
-
let
|
|
806
|
+
let content, title, config;
|
|
807
|
+
if (typeof contents === 'string') {
|
|
808
|
+
content = contents;
|
|
809
|
+
title = '提示';
|
|
810
|
+
config = {};
|
|
811
|
+
} else {
|
|
812
|
+
({ content, title, ...config } = contents);
|
|
813
|
+
}
|
|
804
814
|
const regex = /\.md$/;
|
|
805
815
|
let isMarkdown = regex.test(content);
|
|
816
|
+
const showAlert = () => {
|
|
817
|
+
console.log('showAlert called', { content, isMarkdown, title });
|
|
818
|
+
MessageBox.alert(content, title, {
|
|
819
|
+
dangerouslyUseHTMLString: isMarkdown,
|
|
820
|
+
setHeight: isMarkdown,
|
|
821
|
+
notice: true,
|
|
822
|
+
...config
|
|
823
|
+
})
|
|
824
|
+
.then(() => {
|
|
825
|
+
this.$emit('notice', 1, { content, title, ...config });
|
|
826
|
+
})
|
|
827
|
+
.catch(() => {
|
|
828
|
+
this.$emit('notice', 0, { content, title, ...config });
|
|
829
|
+
});
|
|
830
|
+
};
|
|
806
831
|
if (isMarkdown) {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
832
|
+
ajax({ url: content })
|
|
833
|
+
.then((mdContent) => {
|
|
834
|
+
// 兼容接口返回对象的情况(如 { rCode: 0, results: '...' })
|
|
835
|
+
if (mdContent && typeof mdContent === 'object') {
|
|
836
|
+
mdContent =
|
|
837
|
+
mdContent.results || mdContent.data || mdContent.content || '';
|
|
838
|
+
}
|
|
839
|
+
mdContent = String(mdContent || '');
|
|
840
|
+
content = mdContent
|
|
841
|
+
? mdContent
|
|
842
|
+
.replace(/^#{1,6}\s+(.*?)$/gm, (match, text) => {
|
|
843
|
+
const hLevel = match.indexOf('#');
|
|
844
|
+
return `<h${hLevel}>${text}</h${hLevel}>`;
|
|
845
|
+
})
|
|
846
|
+
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
|
847
|
+
.replace(/\*(.*?)\*/g, '<em>$1</em>')
|
|
848
|
+
.replace(
|
|
849
|
+
/\[(.*?)\]\((.*?)\)/g,
|
|
850
|
+
'<a href="$2" target="_blank">$1</a>'
|
|
851
|
+
)
|
|
852
|
+
.replace(/^(.*?)$/gm, '<p>$1</p>')
|
|
853
|
+
: content;
|
|
854
|
+
content = DOMPurify.sanitize(content);
|
|
855
|
+
showAlert();
|
|
856
|
+
})
|
|
857
|
+
.catch((error) => {
|
|
858
|
+
console.error('加载 Markdown 内容失败:', error);
|
|
859
|
+
content = '内容加载失败';
|
|
860
|
+
isMarkdown = false;
|
|
861
|
+
});
|
|
862
|
+
} else {
|
|
863
|
+
showAlert();
|
|
823
864
|
}
|
|
824
|
-
MessageBox.alert(content, title, {
|
|
825
|
-
dangerouslyUseHTMLString: isMarkdown,
|
|
826
|
-
setHeight: isMarkdown,
|
|
827
|
-
notice: true,
|
|
828
|
-
...config
|
|
829
|
-
})
|
|
830
|
-
.then(() => {
|
|
831
|
-
this.$emit('notice', 1, { content, title, ...config });
|
|
832
|
-
})
|
|
833
|
-
.catch(() => {
|
|
834
|
-
this.$emit('notice', 0, { content, title, ...config });
|
|
835
|
-
});
|
|
836
865
|
},
|
|
837
866
|
/**
|
|
838
867
|
* 打开下载APP弹窗
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="es-lowcode__aside" :style="styles">
|
|
3
|
-
<div
|
|
3
|
+
<div
|
|
4
|
+
class="es-lowcode__aside--handle"
|
|
5
|
+
v-show="!hide"
|
|
6
|
+
@click.self="handleClick"
|
|
7
|
+
></div>
|
|
4
8
|
<es-tabs
|
|
5
9
|
tab-position="left"
|
|
6
10
|
type="card"
|
|
@@ -58,7 +62,7 @@
|
|
|
58
62
|
</div>
|
|
59
63
|
</es-form>
|
|
60
64
|
</es-dialog>
|
|
61
|
-
<Pages :pages="pages" v-if="pages.length" />
|
|
65
|
+
<Pages :pages="pages" v-if="pages.length" @add="handleAdd" />
|
|
62
66
|
<div class="es-lowcode__aside--empty" v-else>暂无数据</div>
|
|
63
67
|
</es-tab-pane>
|
|
64
68
|
<es-tab-pane name="component">
|
|
@@ -278,6 +282,10 @@ export default {
|
|
|
278
282
|
/**
|
|
279
283
|
* 处理新增页面事件
|
|
280
284
|
*/
|
|
285
|
+
handleAdd(page) {
|
|
286
|
+
this.form.pid = page.id;
|
|
287
|
+
this.handleAddPage();
|
|
288
|
+
},
|
|
281
289
|
handleAddPage() {
|
|
282
290
|
const page = localStorage.getItem('pageList');
|
|
283
291
|
if (page) {
|
|
@@ -302,6 +310,7 @@ export default {
|
|
|
302
310
|
const id = `page_${uuid()}`;
|
|
303
311
|
bus.$emit('addPage', {
|
|
304
312
|
id: id, // id
|
|
313
|
+
pid: this.form.pid,
|
|
305
314
|
title: '', // 页面标题
|
|
306
315
|
name: this.form.name, // 名称
|
|
307
316
|
description: this.form.description, // 描述
|
|
@@ -324,6 +333,10 @@ export default {
|
|
|
324
333
|
components: [] // 子组件
|
|
325
334
|
});
|
|
326
335
|
}
|
|
336
|
+
this.form = {
|
|
337
|
+
name: '',
|
|
338
|
+
description: ''
|
|
339
|
+
};
|
|
327
340
|
});
|
|
328
341
|
}
|
|
329
342
|
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="es-lowcode__editor">
|
|
3
|
+
<div v-if="loading" class="es-lowcode__editor--loading">
|
|
4
|
+
编辑器加载中...
|
|
5
|
+
</div>
|
|
6
|
+
<div class="es-lowcode__editor--instance" ref="editor"></div>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
// monaco 模块加载缓存,多个编辑器实例共用同一次动态加载
|
|
12
|
+
let monacoLoader = null;
|
|
13
|
+
|
|
14
|
+
function loadMonaco() {
|
|
15
|
+
if (!monacoLoader) {
|
|
16
|
+
monacoLoader = import(
|
|
17
|
+
/* webpackChunkName: "monaco-editor" */ 'monaco-editor'
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return monacoLoader;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
name: 'Editor',
|
|
25
|
+
|
|
26
|
+
props: {
|
|
27
|
+
// 编辑器内容,支持 v-model
|
|
28
|
+
value: {
|
|
29
|
+
type: String,
|
|
30
|
+
default: ''
|
|
31
|
+
},
|
|
32
|
+
// 代码语言:javascript / json / html / css 等
|
|
33
|
+
language: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: 'javascript'
|
|
36
|
+
},
|
|
37
|
+
// 主题:vs / vs-dark / hc-black
|
|
38
|
+
theme: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: 'vs'
|
|
41
|
+
},
|
|
42
|
+
// 是否只读
|
|
43
|
+
readonly: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: false
|
|
46
|
+
},
|
|
47
|
+
// monaco 原生配置,会覆盖默认配置
|
|
48
|
+
options: {
|
|
49
|
+
type: Object,
|
|
50
|
+
default: () => ({})
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
data() {
|
|
55
|
+
return {
|
|
56
|
+
loading: true
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
watch: {
|
|
61
|
+
// 外部值变化时同步到编辑器,与内部输入区分避免循环触发
|
|
62
|
+
value(val) {
|
|
63
|
+
if (this.editor && val !== this.editor.getValue()) {
|
|
64
|
+
this.editor.setValue(val || '');
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
language(val) {
|
|
68
|
+
if (this.editor && this.monaco) {
|
|
69
|
+
this.monaco.editor.setModelLanguage(this.editor.getModel(), val);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
theme(val) {
|
|
73
|
+
this.monaco && this.monaco.editor.setTheme(val);
|
|
74
|
+
},
|
|
75
|
+
readonly(val) {
|
|
76
|
+
this.editor && this.editor.updateOptions({ readOnly: val });
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
mounted() {
|
|
81
|
+
this.initEditor();
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
methods: {
|
|
85
|
+
// 动态加载 monaco 并创建编辑器实例
|
|
86
|
+
initEditor() {
|
|
87
|
+
loadMonaco()
|
|
88
|
+
.then((monaco) => {
|
|
89
|
+
// 加载完成前组件可能已被销毁
|
|
90
|
+
if (this.isDestroyed || !this.$refs.editor) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.monaco = monaco;
|
|
94
|
+
this.loading = false;
|
|
95
|
+
this.editor = monaco.editor.create(
|
|
96
|
+
this.$refs.editor,
|
|
97
|
+
Object.assign(
|
|
98
|
+
{
|
|
99
|
+
value: this.value,
|
|
100
|
+
language: this.language,
|
|
101
|
+
theme: this.theme,
|
|
102
|
+
readOnly: this.readonly,
|
|
103
|
+
automaticLayout: true, // 容器尺寸变化时自动重新布局
|
|
104
|
+
minimap: { enabled: false },
|
|
105
|
+
scrollBeyondLastLine: false,
|
|
106
|
+
fontSize: 13,
|
|
107
|
+
tabSize: 2
|
|
108
|
+
},
|
|
109
|
+
this.options
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
// 内容变化通知父组件
|
|
113
|
+
this.editor.onDidChangeModelContent(() => {
|
|
114
|
+
const value = this.editor.getValue();
|
|
115
|
+
if (value !== this.value) {
|
|
116
|
+
this.$emit('input', value);
|
|
117
|
+
this.$emit('change', value);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
// 失焦事件,常用于保存
|
|
121
|
+
this.editor.onDidBlurEditorText(() => {
|
|
122
|
+
this.$emit('blur', this.editor.getValue());
|
|
123
|
+
});
|
|
124
|
+
// 编辑器就绪,抛出实例供外部扩展(注册补全、快捷键等)
|
|
125
|
+
this.$emit('ready', this.editor, monaco);
|
|
126
|
+
})
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
this.loading = false;
|
|
129
|
+
console.error('[Editor] monaco-editor 加载失败', error);
|
|
130
|
+
this.$emit('error', error);
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
// 获取编辑器实例
|
|
134
|
+
getEditor() {
|
|
135
|
+
return this.editor;
|
|
136
|
+
},
|
|
137
|
+
// 获取当前内容
|
|
138
|
+
getValue() {
|
|
139
|
+
return this.editor ? this.editor.getValue() : this.value;
|
|
140
|
+
},
|
|
141
|
+
// 格式化代码
|
|
142
|
+
format() {
|
|
143
|
+
this.editor &&
|
|
144
|
+
this.editor.getAction('editor.action.formatDocument').run();
|
|
145
|
+
},
|
|
146
|
+
// 聚焦编辑器
|
|
147
|
+
focus() {
|
|
148
|
+
this.editor && this.editor.focus();
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
beforeDestroy() {
|
|
153
|
+
this.isDestroyed = true;
|
|
154
|
+
if (this.editor) {
|
|
155
|
+
this.editor.dispose();
|
|
156
|
+
this.editor = null;
|
|
157
|
+
}
|
|
158
|
+
this.monaco = null;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
</script>
|
|
162
|
+
<style lang="scss" scoped>
|
|
163
|
+
.es-lowcode__editor {
|
|
164
|
+
position: relative;
|
|
165
|
+
width: 100%;
|
|
166
|
+
height: 100%;
|
|
167
|
+
min-height: 200px;
|
|
168
|
+
|
|
169
|
+
&--loading {
|
|
170
|
+
position: absolute;
|
|
171
|
+
top: 0;
|
|
172
|
+
left: 0;
|
|
173
|
+
right: 0;
|
|
174
|
+
bottom: 0;
|
|
175
|
+
display: flex;
|
|
176
|
+
align-items: center;
|
|
177
|
+
justify-content: center;
|
|
178
|
+
color: #909399;
|
|
179
|
+
font-size: 13px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
&--instance {
|
|
183
|
+
width: 100%;
|
|
184
|
+
height: 100%;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
</style>
|