|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="mainpage">
|
|
|
+ <div :class="['mainpage', theme]" v-contextmenu:contextmenu>
|
|
|
<el-container>
|
|
|
<el-header>
|
|
|
<Header v-if="canvas" :canvasdata="canvas.data" @onMessage="onMessage" @onMenu="onMenu" />
|
|
@@ -42,6 +42,24 @@
|
|
|
</div>
|
|
|
</el-main>
|
|
|
</el-container>
|
|
|
+ <v-contextmenu ref="contextmenu" :theme="theme">
|
|
|
+ <v-contextmenu-item @click="OnTop">置顶</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnBottom">置底</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item divider></v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnCombine" v-if="nodes && nodes.pens && (nodes.pens.length > 1)">组合</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnUncombine" v-if="nodes && nodes.pen && nodes.pen.children">取消组合</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnPenLock">{{ penLocked ? '解锁' : '锁定' }}</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item divider></v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnDelete">删除</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item divider></v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnUndo">撤销 Ctrl+Z</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnRedo">重做 Ctrl+Shift+Z</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item divider></v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnCut">剪切 Ctrl+X</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnCopy">复制 Ctrl+C</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item @click="OnPaste">粘贴 Ctrl+V</v-contextmenu-item>
|
|
|
+ <v-contextmenu-item divider></v-contextmenu-item>
|
|
|
+ </v-contextmenu>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -97,8 +115,6 @@ i {
|
|
|
width: 246px;
|
|
|
overflow-y: auto;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
</style>
|
|
|
<script>
|
|
|
|
|
@@ -117,6 +133,9 @@ export default {
|
|
|
components: {
|
|
|
Header, Pens, Nodepropertys, Filepropertys
|
|
|
},
|
|
|
+ props: {
|
|
|
+ theme: String,
|
|
|
+ },
|
|
|
data()
|
|
|
{
|
|
|
return {
|
|
@@ -143,6 +162,7 @@ export default {
|
|
|
pens: []
|
|
|
},
|
|
|
isSelected: false,
|
|
|
+ penLocked: false,
|
|
|
cpPresetColors: [
|
|
|
'#1890ff',
|
|
|
'#096dd9',
|
|
@@ -209,6 +229,10 @@ export default {
|
|
|
// }
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleSubmenuShow(vm, placement)
|
|
|
+ {
|
|
|
+ console.log(vm, placement)
|
|
|
+ },
|
|
|
init()
|
|
|
{
|
|
|
window.scrollTo(0, 0);
|
|
@@ -231,8 +255,6 @@ export default {
|
|
|
},
|
|
|
onMenu(docmd, value)
|
|
|
{
|
|
|
- console.log(docmd)
|
|
|
- console.log(value)
|
|
|
switch (docmd) {
|
|
|
case "new":
|
|
|
{ this.OnNew(); } break;
|
|
@@ -369,7 +391,7 @@ export default {
|
|
|
} break;
|
|
|
default:
|
|
|
{
|
|
|
- console.log('onMessage_____Default:', event, value);
|
|
|
+ //console.log('onMessage_____Default:', event, value);
|
|
|
} break;
|
|
|
}
|
|
|
console.log('onMessage:', event, value);
|
|
@@ -394,7 +416,7 @@ export default {
|
|
|
|
|
|
onUpdateProps(node)
|
|
|
{
|
|
|
- console.log("canvas.updateProps(node)");
|
|
|
+ //console.log("canvas.updateProps(node)");
|
|
|
// 如果是node属性改变,需要传入node,重新计算node相关属性值
|
|
|
// 如果是line属性改变,无需传参
|
|
|
canvas.updateProps(node)
|
|
@@ -505,23 +527,23 @@ export default {
|
|
|
evt.initEvent('click', true, true)
|
|
|
a.dispatchEvent(evt)
|
|
|
},
|
|
|
- OnUndo(data)
|
|
|
+ OnUndo()
|
|
|
{
|
|
|
this.canvas.undo()
|
|
|
},
|
|
|
- OnRedo(data)
|
|
|
+ OnRedo()
|
|
|
{
|
|
|
this.canvas.redo()
|
|
|
},
|
|
|
- OnCopy(data)
|
|
|
+ OnCopy()
|
|
|
{
|
|
|
this.canvas.copy()
|
|
|
},
|
|
|
- OnCut(data)
|
|
|
+ OnCut()
|
|
|
{
|
|
|
this.canvas.cut()
|
|
|
},
|
|
|
- OnPaste(data)
|
|
|
+ OnPaste()
|
|
|
{
|
|
|
this.canvas.paste()
|
|
|
},
|
|
@@ -543,6 +565,69 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ OnTop()
|
|
|
+ {
|
|
|
+ if (!this.nodes) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.nodes.pen) {
|
|
|
+ this.canvas.top(this.nodes.pen);
|
|
|
+ }
|
|
|
+ if (this.nodes.pens) {
|
|
|
+ for (const item of this.nodes.pens) {
|
|
|
+ this.canvas.top(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.canvas.render();
|
|
|
+ },
|
|
|
+ OnBottom()
|
|
|
+ {
|
|
|
+ if (!this.nodes) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.nodes.pen) {
|
|
|
+ this.canvas.bottom(this.nodes.pen);
|
|
|
+ }
|
|
|
+ if (this.nodes.pens) {
|
|
|
+ for (const item of this.nodes.pens) {
|
|
|
+ this.canvas.bottom(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.canvas.render();
|
|
|
+ },
|
|
|
+ OnCombine(stand = false)
|
|
|
+ {
|
|
|
+ if (!this.nodes || !this.nodes.pens || this.nodes.pens.length < 2) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.canvas.combine(this.nodes.pens, stand);
|
|
|
+ },
|
|
|
+
|
|
|
+ OnUncombine()
|
|
|
+ {
|
|
|
+ if (!this.nodes || !this.nodes.pen || this.nodes.pen.type) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.canvas.uncombine(this.nodes.pen);
|
|
|
+ this.canvas.render();
|
|
|
+ }
|
|
|
+ ,//penLocked
|
|
|
+ OnPenLock()
|
|
|
+ {
|
|
|
+ this.penLocked = !this.penLocked;
|
|
|
+ if (this.nodes.pen) {
|
|
|
+ this.canvas.lockPens([this.nodes.pen], this.penLocked ? 1 : 0);
|
|
|
+ }
|
|
|
+ if (this.nodes.pens) {
|
|
|
+ this.canvas.lockPens(this.nodes.pens, this.penLocked ? 1 : 0);
|
|
|
+ }
|
|
|
+ this.canvas.render(true);
|
|
|
+ },
|
|
|
+ OnDelete()
|
|
|
+ {
|
|
|
+ this.canvas.delete();
|
|
|
+ },
|
|
|
+
|
|
|
destroyed()
|
|
|
{
|
|
|
canvas.destroy()
|