From 0da0262bc236cfce928429fc4c48e1666eab3402 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 一月 2021 17:12:04 +0800
Subject: [PATCH] 2021-01-07

---
 src/menu/components/card/prop-card/index.jsx |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/menu/components/card/prop-card/index.jsx b/src/menu/components/card/prop-card/index.jsx
index 0483f9f..d04fe68 100644
--- a/src/menu/components/card/prop-card/index.jsx
+++ b/src/menu/components/card/prop-card/index.jsx
@@ -107,6 +107,7 @@
   componentDidMount () {
     MKEmitter.addListener('submitStyle', this.getStyle)
     MKEmitter.addListener('logButton', this.logButton)
+    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -122,6 +123,24 @@
     }
     MKEmitter.removeListener('submitStyle', this.getStyle)
     MKEmitter.removeListener('logButton', this.logButton)
+    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
+  }
+
+  updateComponentStyle = (parentId, keys, style) => {
+    const { card } = this.state
+
+    if (card.uuid !== parentId) return
+
+    let subcards = card.subcards.map(item => {
+      if (keys.includes(item.uuid)) {
+        item.style = {...item.style, ...style}
+      }
+      return item
+    })
+
+    this.setState({card: {...card, subcards: []}}, () => {
+      this.updateComponent({...card, subcards: subcards})
+    })
   }
 
   logButton = (id, item) => {
@@ -327,7 +346,7 @@
   }
 
   clickComponent = (e) => {
-    if (sessionStorage.getItem('style-control') === 'true') {
+    if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
       e.stopPropagation()
       MKEmitter.emit('clickComponent', this.state.card)
     }

--
Gitblit v1.8.0