mirror of
https://github.com/sahadev/vue-component-creater-ui.git
synced 2025-06-08 14:34:05 +08:00
VCC完成脱离及验证
This commit is contained in:
parent
58f104799c
commit
92065271ff
4
main.js
4
main.js
@ -4,13 +4,13 @@ import "element-ui/lib/theme-chalk/index.css";
|
|||||||
|
|
||||||
import AntdUI from "ant-design-vue";
|
import AntdUI from "ant-design-vue";
|
||||||
import "ant-design-vue/dist/antd.css";
|
import "ant-design-vue/dist/antd.css";
|
||||||
import Main from "./dist/vcc.umd.min.js";
|
import APP from "./src/App.vue";
|
||||||
|
|
||||||
Vue.use(ElementUI);
|
Vue.use(ElementUI);
|
||||||
Vue.use(AntdUI);
|
Vue.use(AntdUI);
|
||||||
|
|
||||||
new Vue({
|
new Vue({
|
||||||
el: "#app",
|
el: "#app",
|
||||||
render: (h) => h(Main),
|
render: (h) => h(APP),
|
||||||
});
|
});
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
"main": "./src/main.js",
|
"main": "./src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve --open --port 8008",
|
"serve": "vue-cli-service serve --open --port 8008",
|
||||||
"build": "vue-cli-service build --target lib --name vcc ./src/components-v2/Main.vue",
|
"build": "vue-cli-service build --target lib --name vcc ./src/components-v2/VCC.vue",
|
||||||
"compileAndbuild:dev": "npm run compileComponent && vue-cli-service build",
|
"compileAndbuild:dev": "npm run compileComponent && vue-cli-service build",
|
||||||
"lint": "vue-cli-service lint",
|
"lint": "vue-cli-service lint",
|
||||||
"build:prod": "vue-cli-service build --mode production",
|
"build:prod": "vue-cli-service build --mode production",
|
||||||
|
26
src/App.vue
Normal file
26
src/App.vue
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<vcc :initCodeEntity="codeStructure" @updateCodeEntity="onCodeUpdate"></vcc>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 以这样一段结构初始化VCC组件
|
||||||
|
const initCodeStr = '{"template":{"lc_id":"root","__children":[{"div":{"class":"container","style":"min-height: 100%; padding-bottom: 100px;","lc_id":"container","__text__":"Hello,欢迎使用LCG,请往此区域拖拽组件","__children":[{"el-button":{"lc-mark":"","type":"danger","lc_id":"COAAYXizyI","__children":[],"__text__":"危险按钮","@click":"onButtonClick","size":"small"}}]}}]}}'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
vcc: () => import('./components-v2/VCC.vue')
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
codeStructure: JSON.parse(initCodeStr),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onCodeUpdate(newCodeEntity) {
|
||||||
|
// 编辑后新的代码结构
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -73,7 +73,7 @@ window.styleSourceMap = styleData;
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "vcc",
|
name: "vcc",
|
||||||
props: [],
|
props: ['initCodeEntity'],
|
||||||
components: {
|
components: {
|
||||||
RawComponents,
|
RawComponents,
|
||||||
ToolsBar,
|
ToolsBar,
|
||||||
@ -103,15 +103,13 @@ export default {
|
|||||||
attributeContainter.style = "right: calc(-300px - 20px); display:none;";
|
attributeContainter.style = "right: calc(-300px - 20px); display:none;";
|
||||||
this.$refs['attributeInput'].onHide();
|
this.$refs['attributeInput'].onHide();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
},
|
},
|
||||||
beforeCreate() { },
|
beforeCreate() { },
|
||||||
created() {
|
created() {
|
||||||
this.mainPanelProvider = new MainPanelProvider();
|
this.mainPanelProvider = new MainPanelProvider();
|
||||||
// 方便调试追踪
|
|
||||||
window.mainPanelProvider = this.mainPanelProvider;
|
|
||||||
},
|
},
|
||||||
beforeMount() { },
|
beforeMount() { },
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -151,11 +149,12 @@ export default {
|
|||||||
if (this.$refs.codeStructure) {
|
if (this.$refs.codeStructure) {
|
||||||
this.$refs.codeStructure.updateCode(codeRawVueInfo);
|
this.$refs.codeStructure.updateCode(codeRawVueInfo);
|
||||||
}
|
}
|
||||||
|
this.$emit('updateCodeEntity', codeRawVueInfo);
|
||||||
}).onNodeDeleted(() => {
|
}).onNodeDeleted(() => {
|
||||||
this.currentEditRawInfo = null;
|
this.currentEditRawInfo = null;
|
||||||
}).onSelectElement(rawInfo => {
|
}).onSelectElement(rawInfo => {
|
||||||
this.currentEditRawInfo = rawInfo;
|
this.currentEditRawInfo = rawInfo;
|
||||||
}).render(this.getFakeData());
|
}).render(this.initCodeEntity ? this.initCodeEntity : this.getFakeData());
|
||||||
},
|
},
|
||||||
|
|
||||||
// 指向将要插入哪个元素之前
|
// 指向将要插入哪个元素之前
|
@ -156,11 +156,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
createNew() {
|
createNew() {
|
||||||
window.trackManager.track("lc_on_attribute_add");
|
|
||||||
this.localAttributes.push({ key: "", value: "" });
|
this.localAttributes.push({ key: "", value: "" });
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
window.trackManager.track("lc_on_attribute_save");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -193,11 +191,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove() {
|
remove() {
|
||||||
window.trackManager.track("lc_on_attribute_remove");
|
|
||||||
this.$emit("remove", { lc_id: this.rawInfoID });
|
this.$emit("remove", { lc_id: this.rawInfoID });
|
||||||
},
|
},
|
||||||
deleteItem(index) {
|
deleteItem(index) {
|
||||||
window.trackManager.track("lc_on_element_delete");
|
|
||||||
this.localAttributes.splice(index, 1);
|
this.localAttributes.splice(index, 1);
|
||||||
},
|
},
|
||||||
copyBro() {
|
copyBro() {
|
||||||
|
@ -66,7 +66,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
download() {
|
download() {
|
||||||
window.trackManager.track("lc_on_code_download");
|
|
||||||
let blob = new Blob([this.prettyCode], {
|
let blob = new Blob([this.prettyCode], {
|
||||||
type: "text/plain;charset=utf-8",
|
type: "text/plain;charset=utf-8",
|
||||||
});
|
});
|
||||||
|
@ -35,12 +35,6 @@ export function initElement(element) {
|
|||||||
}${getSplitTag()}${JSON.stringify(raw)}`;
|
}${getSplitTag()}${JSON.stringify(raw)}`;
|
||||||
event.dataTransfer.setData("text/plain", str);
|
event.dataTransfer.setData("text/plain", str);
|
||||||
|
|
||||||
try {
|
|
||||||
const tag = getRawComponentKey(raw);
|
|
||||||
window.trackManager.track("lc_on_start_drag", {
|
|
||||||
tag,
|
|
||||||
});
|
|
||||||
} catch (error) { }
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user