Skip to content

Commit

Permalink
feature: 二次开发尝试
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrow-js committed Jan 16, 2021
1 parent c33b205 commit a980222
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default class Base {
xmlMode: true,
decodeEntities: false
});
;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import VueParse from './VueParse';
const uuid = require('@lukeed/uuid');
import * as cheerio from 'cheerio';
import Container from '../box/Container';
import storage from '../../../storage';

export default class Vue2Dynamic{
rootTemplate: string = '';
vueParse: any;
uuid:string = '';
$fragment: any;
components: any = [];
widgetType: string = 'DVue';
dComponents: any = [];

constructor (template: string = '') {
this.uuid = uuid().split('-')[0];
Expand All @@ -15,6 +20,7 @@ export default class Vue2Dynamic{
this.templateParse();
this.injectionSlot();
this.activeCode();
this.components.push(new Container({}, storage));
console.log(this.$fragment.html());
}

Expand Down Expand Up @@ -46,10 +52,29 @@ export default class Vue2Dynamic{

// 注入占位
injectionSlot () {
this.$fragment('template').children('div').append('<div class="test">test</div>')
this.$fragment('template').children('div').append('<div class="drag-box">empty</div>')
}

public setPreview () {
this.renderComp();
}

public renderComp () {
this.$fragment('.drag-box').first().empty();
this.components.forEach(component => {
this.$fragment('.drag-box').first().append(component.getFragment(0).html());
});

if (this.components.length === 0) {
this.$fragment('.drag-box').attr('data-empty', true);
}
}

public addComponent (data) {}


public getFragment(index: number): any {
return this.$fragment;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class Scene {
const fn = function (boxs) {
if (Array.isArray(boxs)) {
boxs.forEach(item => {
if (item.widgetType === 'box' || item.widgetType === 'api' || item.isBox) {
if (item.widgetType === 'DVue' || item.widgetType === 'box' || item.widgetType === 'api' || item.isBox) {
leafToRoot.unshift(item);
}
if (item.components) {
Expand Down
13 changes: 11 additions & 2 deletions packages/sparrow-view/src/views/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="home drag-box" data-id="c3723dcc" style="">
<div class="home drag-box" data-id="30aec502" style="">
<template>
<div>
<el-form
Expand All @@ -16,7 +16,16 @@
<el-button @click="resetForm('ruleForm')">重置</el-button>
</el-form-item>
</el-form>
<div class="test">test</div>
<div class="drag-box">
<div
class="drag-box clearfix"
data-design-mode="design-border-box"
data-instance-name="Container"
data-id="c5021563"
style="display: block;flex-direction: column;"
data-empty="true"
/>
</div>
</div>
</template>
<div />
Expand Down

0 comments on commit a980222

Please sign in to comment.