Skip to content

Commit 0f97f9c

Browse files
author
shangbin
committed
完成对LCG逻辑初始化的支持
1 parent 722a375 commit 0f97f9c

11 files changed

+23
-14
lines changed

src/components-v2/ToolsBar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</el-col>
1717
<el-col :span="3">
1818
<div style="display:inline-block;">
19-
<el-link type="primary" @click="onEditModeChange">{{editMode ? 'View' : 'Edit'}}
19+
<el-link :type="editMode? 'primary': 'danger'" @click="onEditModeChange">{{editMode ? 'View' : 'Edit'}}
2020
Mode</el-link>
2121
</div>
2222
</el-col>

src/components-v2/VCC.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default {
123123
},
124124
initCodeEntity(newVal) {
125125
if (newVal.JSCode) {
126-
this.mainPanelProvider.saveJSCode(this.convertLogicCode(newVal.JSCode));
126+
this.mainPanelProvider.saveJSCodeOnly(this.convertLogicCode(newVal.JSCode));
127127
}
128128
129129
if (newVal.codeStructure) {
@@ -141,6 +141,7 @@ export default {
141141
mounted() {
142142
Promise.all([import("../map/load")])
143143
.then(res => {
144+
this.$emit("onLoadFinish");
144145
this.init();
145146
});
146147
splitInit();
@@ -155,7 +156,9 @@ export default {
155156
const JSCodeInfo = eval(`(function(){return ${JSCode.replace(/\s+/g, "")}})()`);
156157
// 保留JS代码
157158
this.JSCode = JSCode;
158-
this.$refs.codeEditor.updateLogicCode(JSCode);
159+
if (this.$refs.codeEditor) {
160+
this.$refs.codeEditor.updateLogicCode(JSCode);
161+
}
159162
return JSCodeInfo;
160163
} catch (e) {
161164
console.warn(`外部逻辑代码解析出错,解析的逻辑代码为: ${JSCode}, Error: ${e}`);

src/components/JSCodeEditorDialog.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import dedent from 'dedent'
1717
import CodeEditor from './CodeEditor.vue'
1818
19+
import prettier from "prettier/standalone";
20+
import babel from "prettier/parser-babel";
21+
1922
export default {
2023
props: ['codeDialogVisible'],
2124
components: {
@@ -85,7 +88,10 @@ export default {
8588
methods: {
8689
updateLogicCode(newCode) {
8790
if (newCode) {
88-
this.code = newCode;
91+
const pre = "const a = ";
92+
this.code = prettier.format(pre + newCode, {
93+
plugins: [babel],
94+
}).replace(pre, "");
8995
}
9096
},
9197
handleClose() {

src/libs/bundle-core-esm.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//该文件会遍历Object,获取关键的class,事件,data, 最终拼装为一个完整的SFC文件
22

33
import stringifyObject from 'stringify-object';
4-
import _ from 'lodash';
4+
import { merge, cloneDeep } from 'lodash';
55
import prettier from 'prettier/standalone.js';
66
import parserBabel from 'prettier/parser-babel.js';
77

@@ -424,7 +424,6 @@ const scriptTemplate = `{
424424
fillter: {},
425425
};`;
426426

427-
const { merge, cloneDeep } = _;
428427

429428
const rawAdd = Set.prototype.add;
430429
Set.prototype.add = function (value) {

src/libs/code-generator-factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function createNewCodeGenerator() {
3434
const kav = methodItem.split(":");
3535
const key = kav[0];
3636
// 这里获取的是原始data数据
37-
if (window.methodSourceMap[key]) {
37+
if (window.methodSourceMap && window.methodSourceMap[key]) {
3838
return `${key}: ${window.methodSourceMap[key]}`;
3939
} else {
4040
return methodItem;
-54.6 KB
Binary file not shown.
-27.5 KB
Binary file not shown.

src/libs/element-ui/index.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/libs/element-ui/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/libs/main-panel.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class MainPanelProvider {
130130

131131
saveJSCode(code) {
132132
this.saveJSCodeOnly(code);
133-
this.codeGenerator.setExternalJS(code);
133+
this.codeGenerator && this.codeGenerator.setExternalJS(code);
134134
this.reRender();
135135
}
136136

@@ -287,7 +287,12 @@ export class MainPanelProvider {
287287
enableEditMode() {
288288
const renderControlPanel = this.getControlPanelRoot();
289289
// 加一个延迟的作用是:给el-table这种绘制需要时间的组件留出充足的时间,否则会造成el-table渲染不到页面上
290-
setTimeout(() => {
290+
291+
if (this.enableDelayTask) {
292+
clearTimeout(this.enableDelayTask);
293+
}
294+
295+
this.enableDelayTask = setTimeout(() => {
291296
// 这种方式可以禁用原节点所有的事件
292297
const elClone = renderControlPanel.cloneNode(true);
293298
renderControlPanel.parentNode.replaceChild(elClone, renderControlPanel);

src/main.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import Vue from "vue";
22
import ElementUI from "element-ui";
33
import "element-ui/lib/theme-chalk/index.css";
4-
5-
import AntdUI from "ant-design-vue";
64
import "ant-design-vue/dist/antd.css";
5+
76
import APP from "./App.vue";
87

98
Vue.use(ElementUI);
10-
Vue.use(AntdUI);
119

1210
// 内部需要同样配置的全局Vue
1311
self.Vue = Vue;

0 commit comments

Comments
 (0)