king
2022-10-19 8f394e7ef20cc0abba3f47c23a63b069e9dd0e45
src/mob/components/topbar/normal-navbar/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Popover } from 'antd'
import { ExpandOutlined, ReloadOutlined, EllipsisOutlined, LogoutOutlined, ToolOutlined, ScanOutlined, LeftOutlined, EditOutlined, FontColorsOutlined, DeleteOutlined, SearchOutlined } from '@ant-design/icons'
import { ExpandOutlined, ReloadOutlined, EllipsisOutlined, LogoutOutlined, ToolOutlined, ScanOutlined, LeftOutlined, EditOutlined, FontColorsOutlined, DeleteOutlined, SearchOutlined, MenuOutlined } from '@ant-design/icons'
import asyncIconComponent from '@/utils/asyncIconComponent'
import getWrapForm from './options'
@@ -64,7 +64,6 @@
  }
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
    MKEmitter.addListener('submitSearch', this.getSearch)
  }
@@ -79,7 +78,6 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
    MKEmitter.removeListener('submitSearch', this.getSearch)
  }
  
@@ -94,20 +92,28 @@
    this.props.updateConfig(component)
  }
  getStyle = (comIds, style) => {
    const { card } = this.state
  getStyle = (style) => {
    let _card = {...this.state.card, style}
    if (comIds[0] !== card.uuid) return
    this.setState({
      card: _card
    })
    this.props.updateConfig(_card)
  }
    let _card = fromJS(card).toJS()
  getSearchStyle = (style) => {
    let _card = {...this.state.card, searchStyle: style}
    if (comIds[1] === 'search') {
      _card.searchStyle = style
    } else if (comIds[1] === 'title') {
      _card.titleStyle = style
    } else {
      _card.style = style
    }
    this.setState({
      card: _card
    })
    this.props.updateConfig(_card)
  }
  getTitleStyle = (style) => {
    let _card = {...this.state.card, titleStyle: style}
    this.setState({
      card: _card
@@ -119,26 +125,19 @@
  changeStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', [card.uuid], ['font', 'background', 'border', 'padding', 'shadow'], card.style)
    MKEmitter.emit('changeStyle', ['font', 'background', 'border', 'padding', 'shadow'], card.style, this.getStyle)
  }
  changeTitleStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', [card.uuid, 'title'], ['font'], card.titleStyle || {})
    MKEmitter.emit('changeStyle', ['font'], card.titleStyle || {}, this.getTitleStyle)
  }
  changeSearchStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', [card.uuid, 'search'], ['font', 'background', 'border'], card.searchStyle || {})
  }
  clickComponent = (e) => {
    if (sessionStorage.getItem('style-control') === 'true' || sessionStorage.getItem('style-control') === 'component') {
      e.stopPropagation()
      MKEmitter.emit('clickComponent', this.state.card)
    }
    MKEmitter.emit('changeStyle', ['font', 'background', 'border'], card.searchStyle || {}, this.getSearchStyle)
  }
  getSearch = (config) => {
@@ -175,6 +174,14 @@
  }
  updateWrap = (res) => {
    let funs = res.funs || []
    delete res.funs
    funs.forEach(n => {
      res[n] = 'true'
    })
    this.updateComponent({...this.state.card, wrap: res})
  }
@@ -204,12 +211,15 @@
    if (card.wrap.refresh === 'true') {
      right = !right ? <ReloadOutlined /> : <EllipsisOutlined onDoubleClick={this.skip}/>
    }
    if (card.wrap.menus && card.wrap.menus.length > 0) {
      right = !right ? <MenuOutlined /> : <EllipsisOutlined onDoubleClick={this.skip}/>
    }
    return (
      <div className="normal-topbar-edit-box" style={card.style} onClick={this.clickComponent} id={card.uuid}>
      <div className="normal-topbar-edit-box" style={card.style} id={card.uuid}>
        <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <NormalForm title="导航栏设置" width={850} update={this.updateWrap} getForms={this.getWrapForms}>
            <NormalForm title="导航栏设置" width={900} update={this.updateWrap} getForms={this.getWrapForms}>
              <EditOutlined style={{color: '#1890ff'}} title="编辑"/>
            </NormalForm>
            <CopyComponent type="topbar" card={card}/>
@@ -221,7 +231,7 @@
        </Popover>
        <div className="am-navbar">
          <div className="am-navbar-left">
            {card.wrap.back !== 'false' && card.wrap.menuPosition !== 'left' ? <LeftOutlined /> : null}
            {card.wrap.back === 'true' && card.wrap.menuPosition !== 'left' ? <LeftOutlined /> : null}
            {card.wrap.menuPosition === 'left' ? <div className="img" style={{backgroundImage: `url(${avatar})`}}></div> : null}
          </div>
          {card.wrap.type !== 'search' ?