|
|
@@ -14,13 +14,15 @@ export default {
|
|
|
mixins: [ viewMixins,actionsMixins,layerMixins,colorMixins,editMixins],
|
|
|
|
|
|
props: {
|
|
|
- width: {
|
|
|
- type: String,
|
|
|
- default: '1024px'
|
|
|
+ data: {
|
|
|
+ type: Array,
|
|
|
+ default:()=>{
|
|
|
+ return []
|
|
|
+ }
|
|
|
},
|
|
|
- height:{
|
|
|
- type: Boolean,
|
|
|
- default: '1024px'
|
|
|
+ select:{
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
},
|
|
|
|
|
|
},
|
|
|
@@ -34,6 +36,7 @@ export default {
|
|
|
|
|
|
|
|
|
canvasForm:{
|
|
|
+ type:'add',
|
|
|
width: '1024',
|
|
|
height: '1024',
|
|
|
color:"#fff",
|
|
|
@@ -44,6 +47,9 @@ export default {
|
|
|
},
|
|
|
template: tpl(),
|
|
|
computed: {
|
|
|
+ isEmpty(){
|
|
|
+ return this.data.length === 0
|
|
|
+ }
|
|
|
},
|
|
|
watch: {
|
|
|
|
|
|
@@ -58,6 +64,9 @@ export default {
|
|
|
methods: {
|
|
|
// 初始化
|
|
|
async init() {
|
|
|
+ if(this.isEmpty ){
|
|
|
+ this.addCanvas()
|
|
|
+ }
|
|
|
await this.viewInit()
|
|
|
await this.$nextTick()
|
|
|
this.fcanvas = new fabric.Canvas('marketing-canvas', {
|
|
|
@@ -75,18 +84,19 @@ export default {
|
|
|
this.layerInit();
|
|
|
await this.$nextTick()
|
|
|
this.$emit('init')
|
|
|
- const img = await this.addMaps('https://ossimg.valimart.net/uploads/vali_ai/20250610/174954546275619.png',{
|
|
|
- name: 'subject',
|
|
|
- left: 0,
|
|
|
- top: 0,
|
|
|
- delable:false,
|
|
|
- erasable:true,
|
|
|
- scaleX: 0.5,
|
|
|
- scaleY: 0.5,
|
|
|
- })
|
|
|
|
|
|
},
|
|
|
+ addCanvas(){
|
|
|
+
|
|
|
+ this.canvasForm.type = 'add'
|
|
|
+ this.canvasForm.name = '画布_'+new Date().getTime()
|
|
|
+ this.canvasForm.width = 1024
|
|
|
+ this.canvasForm.height = 1024
|
|
|
+ this.canvasForm.color = '#fff'
|
|
|
+ this.canvasForm.visible = true;
|
|
|
+ },
|
|
|
handleAdjustCanvas() {
|
|
|
+ this.canvasForm.type = 'edit'
|
|
|
this.canvasForm.name = this.canvas.name
|
|
|
this.canvasForm.width = this.canvas.width
|
|
|
this.canvasForm.height = this.canvas.height
|
|
|
@@ -96,6 +106,8 @@ export default {
|
|
|
submitCanvasInfo() {
|
|
|
// 假设 this.canvasForm 包含最新的 width, height 和 color
|
|
|
|
|
|
+ if(this.canvasForm)
|
|
|
+
|
|
|
this.canvas.name = this.canvasForm.name;
|
|
|
this.canvas.width = this.canvasForm.width;
|
|
|
this.canvas.height = this.canvasForm.height;
|