Commit 0bce7f80 authored by 任建锋's avatar 任建锋

--

parent ef24bbd3
<template> <template>
<div :style="customStyle" @click.self.stop="clickViewHandle(view)" class="zero-custom-cmp zero-custom-node"> <div :style="customStyle" class="zero-custom-cmp zero-custom-node">
<p class="custom-node-html" v-if="selfText">{{selfText}}</p> <p class="custom-node-html" v-if="selfText">{{selfText}}</p>
<slot></slot> <slot></slot>
</div> </div>
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
</style> </style>
<script> <script>
import events from "@/global-events.js"
export default { export default {
name: 'customNode', name: 'customNode',
props: { props: {
...@@ -38,12 +40,15 @@ export default { ...@@ -38,12 +40,15 @@ export default {
}, },
computed: { computed: {
selfText() { selfText() {
return this.properties ? this.properties.text || '' : ''; return this.properties ? '' || '' : '';
//return this.properties ? this.properties.text || '' : '';
} }
}, },
methods: { methods: {
clickViewHandle(data) { clickViewHandle(e) {
this.$store.dispatch('activeComponent', {data, fromPlayground: true}); console.log("click",e.offsetX)
// events.$emit("onClickTouchLayer",e);
// this.$store.dispatch('activeComponent', {data, fromPlayground: true});
} }
} }
}; };
......
...@@ -8,7 +8,7 @@ if (process.env.NODE_ENV === 'development') { ...@@ -8,7 +8,7 @@ if (process.env.NODE_ENV === 'development') {
//API_HOST = '//192.168.1.16:7777'; //API_HOST = '//192.168.1.16:7777';
API_HOST = '//10.10.35.210:3000'; API_HOST = '//10.10.35.210:3000';
//API_HOST = '//192.168.0.105:7777'; //API_HOST = '//192.168.0.105:7777';
//API_HOST = '//localhost:3002'; //API_HOST = '//localhost:8080';
//API_HOST = window.__data.apiHost; //API_HOST = window.__data.apiHost;
//API_HOST = 'http://beacon.duiba.com.cn'; //API_HOST = 'http://beacon.duiba.com.cn';
//API_HOST = 'http://beacon.duibadev.com.cn'; //API_HOST = 'http://beacon.duibadev.com.cn';
......
...@@ -26,6 +26,8 @@ import {packageStore} from "./package" ...@@ -26,6 +26,8 @@ import {packageStore} from "./package"
import {toZeroing} from "psd-parse-web" import {toZeroing} from "psd-parse-web"
import {arrayFind} from "element-ui/src/utils/util"; import {arrayFind} from "element-ui/src/utils/util";
import {uploadFiles} from "./editor"; import {uploadFiles} from "./editor";
import events from "@/global-events.js"
const storeName = 'project'; const storeName = 'project';
const psStoreName = 'pack-history'; const psStoreName = 'pack-history';
...@@ -811,6 +813,9 @@ export const projectStore = { ...@@ -811,6 +813,9 @@ export const projectStore = {
_props[key] = value; _props[key] = value;
}); });
console.log("props",props,state.activeComponent)
events.$emit('canvasKeyVupdate', {props,activeComponent:state.activeComponent});
/*if (hasAssetsDep) { /*if (hasAssetsDep) {
commit('updateAssetDep'); commit('updateAssetDep');
}*/ }*/
......
...@@ -33,10 +33,10 @@ const attrShortMapper = { ...@@ -33,10 +33,10 @@ const attrShortMapper = {
size: 'font-size', size: 'font-size',
font: 'font-family', font: 'font-family',
alpha: 'opacity', alpha: 'opacity',
strokeColor: 'border-color', // strokeColor: 'border-color',
strokeWidth: 'border-width', // strokeWidth: 'border-width',
fillColor: 'background-color', // fillColor: 'background-color',
source: 'background-image', // source: 'background-image',
anchorX:'-webkit-transform-origin-x', anchorX:'-webkit-transform-origin-x',
anchorY:'-webkit-transform-origin-y', anchorY:'-webkit-transform-origin-y',
}; };
...@@ -195,6 +195,7 @@ export const styles = { ...@@ -195,6 +195,7 @@ export const styles = {
return ['transform', [`scaleY(${value})`]]; //`transform: scaleY(${value});`; return ['transform', [`scaleY(${value})`]]; //`transform: scaleY(${value});`;
case 'visible': case 'visible':
return ['display', [value ? 'block' : 'none']]; // `display: ${value ? 'block' : 'none'};`; return ['display', [value ? 'block' : 'none']]; // `display: ${value ? 'block' : 'none'};`;
//return ['display', ['none']]; // `display: ${value ? 'block' : 'none'};`;
case '-webkit-transform-origin-x': case '-webkit-transform-origin-x':
return ['-webkit-transform-origin-x', [`${value}px`]]; // `display: ${value ? 'block' : 'none'};`; return ['-webkit-transform-origin-x', [`${value}px`]]; // `display: ${value ? 'block' : 'none'};`;
case '-webkit-transform-origin-y': case '-webkit-transform-origin-y':
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
</el-form> </el-form>
</div> </div>
<div class="zero-playground-body-center" :style="playgroundStyle" > <div class="zero-playground-body-center" :style="playgroundStyle" ref="zeroPlayground" @mousedown="clickViewHandle" >
<!-- <div class="zero-playground-draw-panel"> --> <!-- <div class="zero-playground-draw-panel"> -->
<draw-canvas-panel></draw-canvas-panel> <draw-canvas-panel></draw-canvas-panel>
<!-- </div> --> <!-- </div> -->
...@@ -51,6 +51,15 @@ export default { ...@@ -51,6 +51,15 @@ export default {
} }
}, },
methods: { methods: {
clickViewHandle(e) {
console.log(e.pageX-this.$refs.zeroPlayground.getBoundingClientRect().left/2)
events.$emit("onClickTouchLayer",{
x:e.pageX-this.$refs.zeroPlayground.getBoundingClientRect().left/2,
y:e.pageY-this.$refs.zeroPlayground.getBoundingClientRect().top/2
});
// this.$store.dispatch('activeComponent', {data, fromPlayground: true});
},
mouseWheel(e){ mouseWheel(e){
if(!this.hasCtrlState){ if(!this.hasCtrlState){
return; return;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
:allow-drag="allowDrag" :allow-drag="allowDrag"
:allow-drop="allowDrop" :allow-drop="allowDrop"
:filter-node-method="filterNodeMethod" :filter-node-method="filterNodeMethod"
@node-click="handleNodeClick" @current-change="handleNodeClick"
@node-drop="onNodeDrop" @node-drop="onNodeDrop"
> >
<div slot-scope="{ node, data }" class="tree-node"> <div slot-scope="{ node, data }" class="tree-node">
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
}, },
mounted() { mounted() {
events.$on('locate-view-node', this.locateViewNode); events.$on('locate-view-node', this.locateViewNode);
events.$on('locate-view-node-active', this.locateViewNodeActive);
}, },
destroyed() { destroyed() {
events.$off('locate-view-node', this.locateViewNode); events.$off('locate-view-node', this.locateViewNode);
...@@ -123,6 +124,13 @@ ...@@ -123,6 +124,13 @@
this.$refs.tree.setCurrentKey(node.uuid); this.$refs.tree.setCurrentKey(node.uuid);
this.expandedKeys = [node.uuid]; this.expandedKeys = [node.uuid];
}, },
locateViewNodeActive(node) {
this.$refs.tree.setCurrentKey(node.uuid);
this.expandedKeys = [node.uuid];
let data=this.$refs.tree.getCurrentNode()
let nodeDom=this.$refs.tree.getNode(data)
this.$store.dispatch('activeComponent', {data, node:nodeDom});
},
updateFilter() { updateFilter() {
if (this.$refs.tree) { if (this.$refs.tree) {
this.$refs.tree.filter(this.filterText); this.$refs.tree.filter(this.filterText);
...@@ -219,7 +227,7 @@ ...@@ -219,7 +227,7 @@
* 点击左侧视图列表 * 点击左侧视图列表
*/ */
handleNodeClick(data, node) { handleNodeClick(data, node) {
console.log('handleNodeClick'); console.log('handleNodeClick',data,node);
this.$store.dispatch('activeComponent', {data, node}); this.$store.dispatch('activeComponent', {data, node});
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<template> <template>
<div class="zero-draw-panel-container" > <div class="zero-draw-panel-container" >
<div class="zero-components-container" > <div class="zero-components-container" >
<views-canvas-tree :views="views"></views-canvas-tree> <views-canvas-tree :views="views" ></views-canvas-tree>
<div class="playground-wrapper"> <div class="playground-wrapper">
<runtime-layer ref="runtimeLayer" <runtime-layer ref="runtimeLayer"
:design-width="parseInt(options.designWidth)" :design-width="parseInt(options.designWidth)"
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
@launched="onRuntimeLayerLaunched" @launched="onRuntimeLayerLaunched"
@select-node="onSelectNode" @select-node="onSelectNode"
/> />
<div class="touch-layer" @click="onClickTouchLayer"></div> <!-- <div class="touch-layer" @click="onClickTouchLayer"></div> -->
</div> </div>
</div> </div>
</div> </div>
...@@ -76,21 +76,33 @@ ...@@ -76,21 +76,33 @@
}, },
getNode() { getNode() {
this.targetNode = this.$refs.runtimeLayer.getNode(this.nodePath); this.targetNode = this.$refs.runtimeLayer.getNode(this.nodePath);
console.log(this.targetNode.name,this.targetNode)
events.$emit('locate-view-node-active', this.targetNode);
}, },
onModifyProp(key, value) { onModifyProp(key,value,data) {
console.log(data.activeComponent.name,this.targetNode.name,this.nodePath)
if(data.activeComponent.uuid==this.targetNode.uuid){
console.log()
this.$refs.runtimeLayer.modifyProps(this.nodePath, { this.$refs.runtimeLayer.modifyProps(this.nodePath, {
[key]: value, [key]: value,
}, () => { }, () => {
this.getNode(); this.getNode();
}) })
}
}, },
onClickTouchLayer(e){ onClickTouchLayer(e){
const {x,y} = e;
const {offsetX: x, offsetY: y} = e;
console.log("sdsd",x/this.zoom,y/this.zoom) console.log("sdsd",x/this.zoom,y/this.zoom)
this.nodePath = this.$refs.runtimeLayer.getNodePathWithPos({x:x/this.zoom, y:y/this.zoom}); this.nodePath = this.$refs.runtimeLayer.getNodePathWithPos({x:x/this.zoom, y:y/this.zoom});
console.log(this.nodePath) console.log(this.nodePath)
console.log(this.targetNode) },
canvasKeyVupdate(data){
console.log(10,data)
for(let item in data.props){
console.log(item)
this.onModifyProp(item, data.props[item],data)
}
} }
}, },
computed: { computed: {
...@@ -103,6 +115,9 @@ ...@@ -103,6 +115,9 @@
events.$on("setPlaygroundZoom", data => { events.$on("setPlaygroundZoom", data => {
this.zoom=data.zoom; this.zoom=data.zoom;
}); });
events.$on("onClickTouchLayer",this.onClickTouchLayer);
events.$on('canvasKeyVupdate', this.canvasKeyVupdate);
}, },
watch: { watch: {
nodePath() { nodePath() {
...@@ -177,48 +192,9 @@ ...@@ -177,48 +192,9 @@
</style> </style>
<style lang="scss"> <style lang="scss">
* {
padding: 0;
margin: 0;
}
html, body, #app {
width: 100%;
height: 100%;
}
input {
width: 100px;
}
.operate-bar {
padding: 5px;
margin-bottom: 5px;
.line {
padding: 3px;
display: flex;
flex-wrap: wrap;
}
.line + .line {
border-top: 1px solid lightgray;
}
}
.playground-wrapper { .playground-wrapper {
position: relative; position: relative;
display: inline-block; display: inline-block;
margin-left: 10px;
}
.touch-layer {
background-color: rgba(0, 0, 0, 0);
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
} }
</style> </style>
...@@ -235,6 +235,7 @@ export default { ...@@ -235,6 +235,7 @@ export default {
} }
}, },
modifyPropertiesCon() { modifyPropertiesCon() {
// events.$emit('canvasKeyVupdate', {properties:this.activeComponent.properties});
if (this.editEvent == "bottomright") { if (this.editEvent == "bottomright") {
this.$store.dispatch("modifyProperties", { this.$store.dispatch("modifyProperties", {
width: parseInt(this.catchWidth + this.changeMoveX * this.zoom), width: parseInt(this.catchWidth + this.changeMoveX * this.zoom),
...@@ -322,9 +323,6 @@ export default { ...@@ -322,9 +323,6 @@ export default {
if (!this.activeComponent) { if (!this.activeComponent) {
return {}; return {};
} }
console.log( this.styleCatch);
let result={ let result={
width: `${ this.styleCatch.width?this.styleCatch.width:(this.styleCatch.imageWidth?this.styleCatch.imageWidth:0)}px`, width: `${ this.styleCatch.width?this.styleCatch.width:(this.styleCatch.imageWidth?this.styleCatch.imageWidth:0)}px`,
height: `${ this.styleCatch.height?this.styleCatch.height:(this.styleCatch.imageHeight?this.styleCatch.imageHeight:0)}px`, height: `${ this.styleCatch.height?this.styleCatch.height:(this.styleCatch.imageHeight?this.styleCatch.imageHeight:0)}px`,
......
<template> <template>
<div class="views-tree"> <div class="views-tree">
<custom-node v-for="view in views" :key="view.uuid" :view="view" :custom-style="styleObject(view)" :properties="view.properties"> <custom-node v-for="view in views" :key="view.uuid" :view="view" :custom-style="styleObject(view)" :properties="view.properties">
<template v-if="view.children"> <template v-if="view.children">
<views-tree :views="view.children"></views-tree> <views-tree :views="view.children"></views-tree>
...@@ -33,6 +32,7 @@ ...@@ -33,6 +32,7 @@
</template> </template>
<script> <script>
import events from "@/global-events.js"
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import { styles } from '../../../utils/common'; import { styles } from '../../../utils/common';
import customNode from '../../../components/customElement/node/index.vue'; import customNode from '../../../components/customElement/node/index.vue';
...@@ -161,4 +161,8 @@ export default { ...@@ -161,4 +161,8 @@ export default {
</script> </script>
<style> <style>
.views-tree{
position: absolute;
z-index: 99;
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment