1
0
mirror of https://github.com/sahadev/vue-component-creater-ui.git synced 2025-09-28 07:13:21 +08:00

feat: 支持单文件二次编辑

This commit is contained in:
shangbin
2021-11-16 19:58:28 +08:00
parent 4cde9098bc
commit 2f4b143550
8 changed files with 139 additions and 19 deletions

View File

@@ -47,10 +47,14 @@ export class MainPanelProvider {
const readyForMoutedElement = this.createMountedElement();
// 生成原始代码
const code = this.codeGenerator.outputVueCodeWithJsonObj(rawDataStructure);
let code = this.codeGenerator.outputVueCodeWithJsonObj(rawDataStructure);
// 将xxx: () => {} 转换为xxx(){}
code = code.replace(/:\s*\(([\w\s]*)\)\s*=>/g,"\($1\)");
// 生成展示代码
const codeForShow = code.replace(/\s{1}lc_id=".+"/g, '');
let codeForShow = code.replace(/\s{1}lc_id=".+"/g, '');
codeForShow = codeForShow.replace(/\s{1}lc-mark/g, "");
this.eventEmitter.emit("codeCreated", codeForShow);
console.groupEnd();
@@ -59,9 +63,6 @@ export class MainPanelProvider {
let newScript = script.content.replace(/\s*export default\s*/, "")
// 将xxx: () => {} 转换为xxx(){}
newScript = newScript.replace(/:\s*\(([\w\s]*)\)\s*=>/g,"\($1\)");
const componentOptions = (new Function(`return ${newScript}`))();
const res = Vue.compile(template.content);
@@ -249,7 +250,7 @@ export class MainPanelProvider {
this.eventEmitter.emit('onMerged');
});
this.render(window.tree.root);
this.render(this._rawDataStructure);
}
});
}