king
2023-04-06 0eacb2fbcaa01060f81219d1ce5b406ae50f0c80
src/tabviews/zshare/actionList/index.jsx
@@ -32,27 +32,60 @@
  state = {
    actions: [],
    mores: null
    mores: null,
    listId: ''
  }
  UNSAFE_componentWillMount() {
    const { setting, actions } = this.props
    let listId = (() => {
      let uuid = []
      let options = '0123456789abcdefghigklmnopqrstuv'
      for (let i = 0; i < 32; i++) {
        uuid.push(options.substr(Math.floor(Math.random() * 0x20), 1))
      }
      return uuid.join('')
    })()
    if (!setting.btnlimit || setting.btnlimit >= actions.length) {
      this.setState({actions: actions})
      this.setState({actions: actions, listId})
    } else {
      let mores = fromJS(actions).toJS()
      
      this.setState({
        actions: mores.splice(0, setting.btnlimit),
        mores
        mores,
        listId
      })
    }
  }
  componentDidMount() {
    if (this.buttonRef && this.buttonRef.offsetHeight > 65) {
      this.buttonRef.classList.add('double-line')
    const { actions, listId } = this.state
    if (actions.length > 9) {
      let node = document.getElementById(listId)
      // const resizeObserver = new ResizeObserver((entries) => {
      // })
      // resizeObserver.observe(node)
      let limit = 10
      let index = 1
      let check = () => {
        if (node.offsetHeight > 65) {
          node.classList.add('double-line')
        } else if (index < limit) {
          index++
          setTimeout(() => {
            check()
          }, 100)
        }
      }
      node && check()
    }
  }
@@ -200,14 +233,13 @@
  }
  render() {
    const { setting, MenuID } = this.props
    const { actions, mores } = this.state
    let fixed = setting.actionfixed && setting.tabType === 'main' // 按钮是否固定在头部
    const { setting } = this.props
    const { actions, mores, listId } = this.state
    if (fixed && MenuID) {
    if (setting.actionfixed === 'true') {
      return (
        <Affix offsetTop={48}>
          <div className="button-list toolbar-button" ref={ref => this.buttonRef = ref} id={fixed ? MenuID + 'mainaction' : ''}>
          <div className="button-list toolbar-button" id={listId}>
            {this.getButtonList(actions)}
            {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}>
              <div className="mk-button-more">更多<DownOutlined/></div>
@@ -217,7 +249,7 @@
      )
    } else {
      return (
        <div className="button-list toolbar-button" ref={ref => this.buttonRef = ref} id={fixed ? MenuID + 'mainaction' : ''}>
        <div className="button-list toolbar-button" id={listId}>
          {this.getButtonList(actions)}
          {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}>
            <div className="mk-button-more">更多<DownOutlined/></div>