Skip to content

Commit ca02004

Browse files
committed
feat: 支持画布上的元素再次拖动
1 parent 1c11a0c commit ca02004

21 files changed

+5824
-14199
lines changed

package-lock.json

Lines changed: 3894 additions & 9878 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"lint-staged": "^9.5.0",
6868
"sass": "^1.25.0",
6969
"sass-loader": "^8.0.2",
70+
"@vue/cli-service": "^5.0.8",
7071
"vite": "^2.6.14"
7172
},
7273
"eslintConfig": {

src/components/AttributeInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ export default {
220220
const checkResult = brotherEleEnum().find(item => {
221221
return item.name == this.componentName;
222222
});
223-
return checkResult && checkResult.length != 0;
223+
return checkResult && false;
224224
},
225225
attributeList() {
226226
const result = [];

src/libs/bro-ele-config.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,6 @@ export function initElementHoverAction(element) {
6666

6767
element.addEventListener('mouseover', event => {
6868
event.stopPropagation();
69-
70-
checkIsInVaildElement(event).then((callbackInfo) => {
71-
currentBroInfo = callbackInfo;
72-
const rect = callbackInfo.target.getBoundingClientRect();
73-
addBroIcon.style = `left:${rect.right + 0}px;top:${rect.top}px;`
74-
}, () => {
75-
setTimeout(() => {
76-
if (!isInBroIcon) {
77-
addBroIcon.style = "top:-100px;"
78-
}
79-
});
80-
})
8169
})
8270

8371
return function () {

src/libs/main-panel.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
*
77
*/
88
import { parseComponent } from 'vue-template-compiler/browser';
9-
import { merge, insertPresetAttribute, getSplitTag, replaceRowID, updateLinkTree, findCodeElemNode, findRawVueInfo, removeAllID } from "@/utils/forCode";
10-
import { getRawComponentContent, getRawComponentKey, isObject } from '@/utils/common';
9+
import { merge, insertPresetAttribute, getSplitTag, replaceRowID, updateLinkTree, findCodeElemNode, findRawVueInfo } from "@/utils/forCode";
10+
import { initElement } from '../utils/initRawComponent';
11+
import { getRawComponentContent, getRawComponentKey, isObject, deleteNodeFromParent, isRawComponents, isActiveComponents } from '@/utils/common';
1112
import { createNewCodeGenerator } from "@/libs/code-generator-factory";
1213
import EventEmitter from 'eventemitter3'
1314
import { cloneDeep } from 'lodash-es';
@@ -164,6 +165,8 @@ export class MainPanelProvider {
164165
event.stopPropagation();
165166
this.markElement(element);
166167
})
168+
169+
initElement(element);
167170
})
168171

169172
this.initDropEvent();
@@ -249,14 +252,20 @@ export class MainPanelProvider {
249252

250253
const newDropObj = JSON.parse(rawInfo);
251254

252-
// 插入预设属性
253-
insertPresetAttribute(newDropObj);
255+
if (isRawComponents(newDropObj)) {
256+
257+
// 插入预设属性
258+
insertPresetAttribute(newDropObj);
254259

255-
// 使新拖入的代码与原来的做脱离
256-
replaceRowID(newDropObj, '');
260+
// 使新拖入的代码与原来的做脱离
261+
replaceRowID(newDropObj, '');
257262

258-
// 更新到一个Map上面,维持引用,由于render中统一做了处理,所以这段代码是可以删除的 2021年02月04日11:59:10
259-
updateLinkTree(newDropObj);
263+
// 更新到一个Map上面,维持引用,由于render中统一做了处理,所以这段代码是可以删除的 2021年02月04日11:59:10
264+
updateLinkTree(newDropObj);
265+
} else if (isActiveComponents(newDropObj)) {
266+
// 移动的情况
267+
deleteNodeFromParent(newDropObj);
268+
}
260269

261270
// 更新代码结构关系
262271
const codeTargetElement = findCodeElemNode(this.currentPointDropInfo.target);

src/map/data.index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/map/template.index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/rawComponents/antd/button.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<a-button lc-mark type="primary" lc_id="nAzBA7pWsh">Primary Button</a-button>
77
<a-button lc-mark lc_id="rMeh8dMkYC">Default Button</a-button>
88
<a-button lc-mark type="dashed" lc_id="5+qgpMthx2">Dashed Button</a-button>
9-
<a-button lc-mark type="text" lc_id="UoFnE3nJv9">Text Button</a-button>
9+
<a-button lc-mark text lc_id="UoFnE3nJv9">Text Button</a-button>
1010
<a-button lc-mark type="link" lc_id="kIu/utVuLA">Link Button</a-button>
1111
<a-button lc-mark type="primary" danger lc_id="BQ4AmOTe8D">Primary</a-button>
1212
<a-button lc-mark danger lc_id="98eGo5RB7m">Default</a-button>

src/rawComponents/echart/chart.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template lc_id="Bb1LYS7hJm">
22
<div class="echart-class" lc_id="OT0KmxfA/e">
3-
<div style="font-size: 12px;">
3+
<div style="font-size: 12px">
44
Tips: Vcc使用的是vue-echarts,因此实际使用时也需要将vue-echarts集成至项目中使用。
5-
另外由于渲染器本身的原因,在将eChart拖入到面板之后,<span style="color:red;">会有无法正常展示的问题</span>。
5+
另外由于渲染器本身的原因,在将eChart拖入到面板之后,<span style="color: red">会有无法正常展示的问题</span>。
66
代码本身是没有问题的,在预览模式下也可以正常渲染。
77
</div>
88
<v-chart

src/rawComponents/element/button.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
</div>
3030
<div lc_id="RdvVbD8tRt">
3131
<div class="demonstration-element" lc_id="MCe1tz7lec">Button 文字按钮</div>
32-
<el-button lc-mark type="text" lc_id="VzeBeEyMRU">文字按钮</el-button>
33-
<el-button lc-mark type="text" disabled lc_id="gGBAHuLrE2">文字按钮</el-button>
32+
<el-button lc-mark text lc_id="VzeBeEyMRU">文字按钮</el-button>
33+
<el-button lc-mark text disabled lc_id="gGBAHuLrE2">文字按钮</el-button>
3434
</div>
3535
<div lc_id="fiJ0b+a2C7">
3636
<div class="demonstration-element" lc_id="NadQOxXAQD">Button 按钮组</div>

src/rawComponents/element/container.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,28 @@
6262
<el-col :sm="12" :lg="6" lc_id="deKtOM/g2K">
6363
<el-result icon="success" lc-mark title="成功提示" subtitle="请根据提示进行操作" lc_id="iF6n6EUcmn">
6464
<template #extra lc_id="iJQp/8XeSP">
65-
<el-button type="primary" size="medium" lc_id="UCFmR9EP+q">返回</el-button>
65+
<el-button type="primary" size="default" lc_id="UCFmR9EP+q">返回</el-button>
6666
</template>
6767
</el-result>
6868
</el-col>
6969
<el-col :sm="12" :lg="6" lc_id="1smWMRRuZr">
7070
<el-result icon="warning" lc-mark title="警告提示" subtitle="请根据提示进行操作" lc_id="NIEZCy3gG0">
7171
<template #extra lc_id="c6Unj7eQIv">
72-
<el-button type="primary" size="medium" lc_id="MDEtfbmEZd">返回</el-button>
72+
<el-button type="primary" size="default" lc_id="MDEtfbmEZd">返回</el-button>
7373
</template>
7474
</el-result>
7575
</el-col>
7676
<el-col :sm="12" :lg="6" lc_id="2zio5J9ljq">
7777
<el-result icon="error" lc-mark title="错误提示" subtitle="请根据提示进行操作" lc_id="kLASzKidTD">
7878
<template #extra lc_id="rnIhJqKRjQ">
79-
<el-button type="primary" size="medium" lc_id="MhrCBFBHlN">返回</el-button>
79+
<el-button type="primary" size="default" lc_id="MhrCBFBHlN">返回</el-button>
8080
</template>
8181
</el-result>
8282
</el-col>
8383
<el-col :sm="12" :lg="6" lc_id="h7xNXozZ0s">
8484
<el-result icon="info" lc-mark title="信息提示" subtitle="请根据提示进行操作" lc_id="aDXqAjXsST">
8585
<template #extra lc_id="nHgp3LGSea">
86-
<el-button type="primary" size="medium" lc_id="VURe3Zlhq0">返回</el-button>
86+
<el-button type="primary" size="default" lc_id="VURe3Zlhq0">返回</el-button>
8787
</template>
8888
</el-result>
8989
</el-col>

src/rawComponents/element/dialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div lc_id="tWzGb0zt3I">
44
<div class="demonstration-element" @click="dialogVisible = true" lc_id="cjFRJjmxCw">Dialog 对话框</div>
55
<div lc-mark lc_id="dIDt4KsNEb">
6-
<el-button type="text" lc_id="cmG1+fI232">直接拖我看结果</el-button>
6+
<el-button text lc_id="cmG1+fI232">直接拖我看结果</el-button>
77
<el-dialog title="提示" v-model="dialogVisible" width="30%" :before-close="handleClose" lc_id="W4ORswcE/n">
88
<span lc_id="8Sb2dnGlHq">这是一段信息</span>
99
<span footer class="dialog-footer" lc_id="To3nLHp/kA">

src/rawComponents/element/icon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<template #header lc_id="fcNx1E9u+l">
108108
<div class="clearfix" lc_id="JjiI6DiLa8">
109109
<span lc_id="HyznGRyy1o">卡片名称</span>
110-
<el-button style="float: right; padding: 3px 0" type="text" lc_id="2BV+GEiJPf">操作按钮</el-button>
110+
<el-button style="float: right; padding: 3px 0" text lc_id="2BV+GEiJPf">操作按钮</el-button>
111111
</div>
112112
<div v-for="o in 4" :key="o" class="text item" lc_id="WrqZOeR62/">{{ "列表内容 " + o }}</div>
113113
</template>

src/rawComponents/element/index.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<lc-table></lc-table>
55
<lc-form ></lc-form>
66
<lc-image></lc-image>
7+
<lc-menu></lc-menu>
78
<lc-form-base></lc-form-base>
89
<lc-dialog></lc-dialog>
910
<lc-icon ></lc-icon>
@@ -23,6 +24,7 @@ import formBase from "./form-base";
2324
import dialog from "./dialog";
2425
import image from "./image";
2526
import final from "./final";
27+
import menu from './menu.vue';
2628
2729
import { deepLCEle } from "@/utils/initRawComponent";
2830
@@ -48,6 +50,7 @@ export default {
4850
"lc-dialog": dialog,
4951
"lc-image": image,
5052
"lc-final": final,
53+
"lc-menu": menu
5154
},
5255
};
5356
</script>

src/rawComponents/element/menu.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template lc_id="OmgSokKINq">
2+
<div class="demonstration-element" lc_id="P3YgnZ+f9L">Menu 菜单</div>
3+
<el-menu default-active="2" lc-mark lc_id="Ykd21cdEG5" active-text-color="#ffd04b" background-color="#545c64" style="width: 200px;" text-color="#fff">
4+
<el-sub-menu index="1" lc_id="zZkAuMWuD3">
5+
<template #title lc_id="z7nCiOPj+e">
6+
<el-icon lc_id="DgdrgxdBou">
7+
<location lc_id="g/AfKd/h31"></location>
8+
</el-icon>
9+
<span lc_id="CLxUy1/ICc">Navigator One</span>
10+
</template>
11+
<el-menu-item-group title="Group One" lc_id="bmv3H79LU6">
12+
<el-menu-item index="1-1" lc_id="njnKKJBgKA">item one</el-menu-item>
13+
<el-menu-item index="1-2" lc_id="sPEFzNrF/D">item two</el-menu-item>
14+
</el-menu-item-group>
15+
<el-menu-item-group title="Group Two" lc_id="/aJERvHpKE">
16+
<el-menu-item index="1-3" lc_id="Dj6qsVo8uv">item three</el-menu-item>
17+
</el-menu-item-group>
18+
<el-sub-menu index="1-4" lc_id="IhPwshAQ0i">
19+
<template #title lc_id="7gOGvYliVP">item four</template>
20+
<el-menu-item index="1-4-1" lc_id="RPZbUxYVzQ">item one</el-menu-item>
21+
</el-sub-menu>
22+
</el-sub-menu>
23+
<el-menu-item index="2" lc_id="fpNmVPacmr">
24+
<el-icon lc_id="3S93O9M6BZ">
25+
<icon-menu lc_id="aC5w56Jfie"></icon-menu>
26+
</el-icon>
27+
<span lc_id="cMFe/tho9D">Navigator Two</span>
28+
</el-menu-item>
29+
<el-menu-item index="3" disabled lc_id="rslwNtVgKU">
30+
<el-icon lc_id="MKD3UJ3Gqg">
31+
<document lc_id="OsVpAj1mOT"></document>
32+
</el-icon>
33+
<span lc_id="70yWMx9X+D">Navigator Three</span>
34+
</el-menu-item>
35+
<el-menu-item index="4" lc_id="d4KudeL9g3">
36+
<el-icon lc_id="Uv+alei7wG">
37+
<setting lc_id="qhOEr9XarJ"></setting>
38+
</el-icon>
39+
<span lc_id="HH6bWzTkew">Navigator Four</span>
40+
</el-menu-item>
41+
</el-menu>
42+
</template>

src/rawComponents/iview/button.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<button lc-mark lc_id="x3FZbZaIxW">Default</button>
66
<button lc-mark type="primary" lc_id="45rexSehQc">Primary</button>
77
<button lc-mark type="dashed" lc_id="fKbsFbKR2b">Dashed</button>
8-
<button lc-mark type="text" lc_id="tFTgyHpo+y">Text</button>
8+
<button lc-mark text lc_id="tFTgyHpo+y">Text</button>
99
<button lc-mark type="info" lc_id="hUGfSo7waH">Info</button>
1010
<button lc-mark type="success" lc_id="BgKXbY5mGG">Success</button>
1111
<button lc-mark type="warning" lc_id="X6QHL5F0XR">Warning</button>

src/script/compile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ glob(
1414
{
1515
cwd: componentsPath,
1616
absolute: true,
17-
ignore: ["**/element/index.vue", "**/vant/index.vue", "**/iview/index.vue", "**/antd/index.vue", "**/echart/index.vue"],
17+
ignore: ["**/element/index.vue", "**/vant/index.vue", "**/iview/index.vue", "**/antd/index.vue", "**/echart/index.vue", "**/echart/chart.vue"],
1818
},
1919
function (er, files) {
2020
console.info(`正在对${files.length}个文件进行编译...`);

0 commit comments

Comments
 (0)