From c96108bd84050feb01b47db3f5cae96670fda435 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 30 十月 2024 12:54:24 +0800
Subject: [PATCH] 2024-10-30

---
 src/menu/components/share/normalheader/index.jsx |   62 +++++++++++++++++++-----------
 1 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/src/menu/components/share/normalheader/index.jsx b/src/menu/components/share/normalheader/index.jsx
index dc85e5b..e0ed3f4 100644
--- a/src/menu/components/share/normalheader/index.jsx
+++ b/src/menu/components/share/normalheader/index.jsx
@@ -1,7 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Popover, Icon } from 'antd'
+import { Popover } from 'antd'
+import { FontColorsOutlined, SearchOutlined } from '@ant-design/icons'
 
 import asyncComponent from '@/utils/asyncComponent'
 import MKEmitter from '@/utils/events.js'
@@ -21,10 +22,6 @@
     appType: sessionStorage.getItem('appType')
   }
 
-  componentDidMount () {
-    MKEmitter.addListener('submitStyle', this.getStyle)
-  }
-
   shouldComponentUpdate (nextProps, nextState) {
     return !is(fromJS(this.props.config), fromJS(nextProps.config))
   }
@@ -36,15 +33,25 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('submitStyle', this.getStyle)
   }
 
-  getStyle = (comIds, style) => {
-    const { config } = this.props
+  getStyle = (style) => {
+    let _style = fromJS(style).toJS()
+    if (!_style.borderBottomWidth) {
+      _style.borderBottomWidth = '0px'
+    }
+    if (_style.fontFamily) {
+      if (_style.fontFamily.length === 0) {
+        delete _style.fontFamily
+      } else {
+        _style.fontFamily = _style.fontFamily.join(',')
+      }
+    }
+    if (_style.lineHeight === 2.8) {
+      delete _style.lineHeight
+    }
 
-    if (comIds[0] !== config.uuid || comIds[1] !== 'header') return
-
-    let _config = {...config, headerStyle: style}
+    let _config = {...this.props.config, headerStyle: _style}
     
     this.props.updateComponent(_config)
   }
@@ -52,23 +59,27 @@
   changeStyle = () => {
     const { config } = this.props
 
-    let options = ['font', 'border']
-    if (config.type === 'menubar') {
-      options.push('padding')
-    }
+    let _style = config.headerStyle ? fromJS(config.headerStyle).toJS() : {}
+    let options = ['font', 'border', 'background', 'padding', 'fontFamily']
 
-    MKEmitter.emit('changeStyle', [config.uuid, 'header'], options, config.headerStyle)
+    _style.fontFamily = _style.fontFamily ? _style.fontFamily.split(',') : []
+    _style.lineHeight = _style.lineHeight || 2.8
+
+    MKEmitter.emit('changeStyle', options, _style, this.getStyle)
   }
 
   render() {
     const { config, hideSearch } = this.props
-    const { appType } = this.state
 
-    let title = config.plot ? config.plot.title : config.wrap.title
+    let title = ''
     let show = true
 
-    if (!title && appType === 'mob' && config.type === 'card' && config.subtype === 'datacard' && config.action && config.action.length) {
-      title = ' '
+    if (config.plot) {
+      title = config.plot.title
+    } else if (config.type === 'group') {
+      title = config.setting.title || ''
+    } else if (config.wrap) {
+      title = config.wrap.title || ''
     }
 
     if (!title && (!config.search || config.search.length === 0 || hideSearch === 'true')) {
@@ -76,16 +87,21 @@
     }
     let _style = resetStyle(config.headerStyle)
 
+    let _s = {display: 'block', flex: 1}
+    if (show && ((config.wrap && config.wrap.searchable === 'true') || (hideSearch !== 'true' && config.search && config.search.length))) {
+      _s = null
+    }
+
     return (
       <div className={'normal-header' + (!show ? ' hidden' : '') + (config.wrap && config.wrap.searchable === 'true' ? ' tree-search' : '')} style={_style}>
         <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
           <div className="mk-popover-control">
-            <Icon className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle} type="font-colors" />
+            <FontColorsOutlined className="style" title="璋冩暣鏍峰紡" onClick={this.changeStyle}/>
           </div>
         } trigger="hover">
-          <span className="title">{title}</span>
+          <span className="title" style={_s}>{title}</span>
         </Popover>
-        {config.wrap && config.wrap.searchable === 'true' ? <span className="ant-input-search ant-input-affix-wrapper"><span className="ant-input-suffix"><Icon type="search" /></span></span> : null}
+        {config.wrap && config.wrap.searchable === 'true' ? <span className="ant-input-search ant-input-affix-wrapper"><span className="ant-input-suffix"><SearchOutlined /></span></span> : null}
         {hideSearch !== 'true' && config.search ? <SearchComponent config={config} updatesearch={this.props.updateComponent}/> : null}
       </div>
     )

--
Gitblit v1.8.0