From bdfec44c9f3a37dbbe05bf14a252ffec04132a86 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 06 九月 2022 21:24:28 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/menu/stylecontroller/index.jsx |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx
index a98c24b..b2bb476 100644
--- a/src/menu/stylecontroller/index.jsx
+++ b/src/menu/stylecontroller/index.jsx
@@ -51,11 +51,12 @@
   state = {
     card: null,
     fonts: null,
-    comIds: [],
     backgroundImage: '',
     options: [],
     borposition: 'outer'
   }
+
+  callback = null
 
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.state), fromJS(nextState))
@@ -75,7 +76,7 @@
     MKEmitter.removeListener('changeStyle', this.initStyle)
   }
 
-  initStyle = (comIds, options, style = {}) => {
+  initStyle = (options, style = {}, callback) => {
     let backgroundImage = ''
     if (style.backgroundImage && /^url/ig.test(style.backgroundImage)) {
       backgroundImage = style.backgroundImage.replace(/^url\(/ig, '').replace(/\)$/ig, '')
@@ -95,10 +96,11 @@
       }
     }
 
+    this.callback = callback
+
     this.setState({
       visible: true,
       fonts: fonts,
-      comIds: comIds,
       card: fromJS(style).toJS(),
       options: options,
       borposition: 'outer',
@@ -134,21 +136,21 @@
     }
 
     if (check) {
-      MKEmitter.emit('submitStyle', this.state.comIds, card)
+      this.callback && this.callback(card)
     }
 
     this.setState({
       visible: false,
-      comIds: [],
       card: null,
       options: [],
       backgroundImage: ''
     })
     window.GLOB.styling = false
+    this.callback = null
   }
 
   updateStyle = (style) => {
-    const { comIds, card } = this.state
+    const { card } = this.state
 
     let _style = {
       ...card,
@@ -159,7 +161,7 @@
       card: _style,
     })
 
-    MKEmitter.emit('submitStyle', comIds, _style)
+    this.callback && this.callback(_style)
   }
 
   /**
@@ -262,7 +264,7 @@
   }
 
   changeBackground = (val) => {
-    const { comIds, card } = this.state
+    const { card } = this.state
 
     let _style = { ...card }
 
@@ -280,7 +282,7 @@
     })
 
     if (!val || /(^linear-gradient|^radial-gradient)\(.*\)$/.test(val)) {
-      MKEmitter.emit('submitStyle', comIds, _style)
+      this.callback && this.callback(_style)
     }
   }
 

--
Gitblit v1.8.0