king
2022-08-19 3b103caa6bfc9ed410e67156c3ca1785bf1cecc9
src/pc/components/login/normal-login/index.jsx
@@ -25,7 +25,7 @@
  state = {
    card: null,
    back: false
    active: 'login'
  }
  UNSAFE_componentWillMount () {
@@ -68,14 +68,17 @@
      if (_card.wrap.link && _card.wrap.link === 'menu') {
        _card.wrap.linkmenu = _card.uuid
      }
      _card.wrap.classify = _card.wrap.classify || 'login'
      let active = 'login'
      if (_card.wrap.classify === 'signin') {
        active = 'signin'
      }
      this.setState({
        active,
        card: _card
      })
    }
  }
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -89,7 +92,6 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
  }
  /**
@@ -115,15 +117,11 @@
  changeStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', [card.uuid], ['width', 'background', 'border', 'padding', 'margin'], card.style)
    MKEmitter.emit('changeStyle', ['width', 'background', 'border', 'padding', 'margin'], card.style, this.getStyle)
  }
  getStyle = (comIds, style) => {
    const { card } = this.state
    if (comIds.length !== 1 || comIds[0] !== card.uuid) return
    let _card = {...card, style}
  getStyle = (style) => {
    let _card = {...this.state.card, style}
    
    this.updateComponent(_card)
  }
@@ -146,17 +144,26 @@
    card.wrap = res
    let active = 'login'
    if (res.classify === 'signin') {
      active = 'signin'
    }
    this.setState({
      active
    })
    this.updateComponent(card)
  }
  render() {
    const { card } = this.state
    const { card, active } = this.state
    let style = resetStyle(card.style)
    if (card.wrap.maxWidth) {
      style.maxWidth = card.wrap.maxWidth
    if (card.style.width) {
      let left = style.marginLeft && style.marginLeft !== '0px' ? style.marginLeft : 'auto'
      let right = style.marginRight && style.marginRight !== '0px' ? style.marginRight : 'auto'
      style.margin = (style.marginTop || 0) + ' ' + right + ' ' + (style.marginBottom || 0) + ' ' + left
      style.maxWidth = `calc(100% - ${style.marginLeft || '0px'} - ${style.marginRight || '0px'})`
      delete style.marginLeft
      delete style.marginRight
      delete style.marginTop
@@ -176,8 +183,8 @@
        } trigger="hover">
          <ToolOutlined />
        </Popover>
        {card.wrap.loginWays ? <LoginForm wrap={card.wrap} /> : null}
        {card.wrap.signWays ? <SignForm wrap={card.wrap} /> : null}
        {card.wrap.loginWays && active === 'login' ? <LoginForm wrap={card.wrap} changeway={() => this.setState({active: 'signin'})}/> : null}
        {card.wrap.signWays && active === 'signin' ? <SignForm wrap={card.wrap} changeway={() => this.setState({active: 'login'})}/> : null}
        <div className="component-name">
          <div className="center">
            <div className="title">{card.name}</div>