From 0eacb2fbcaa01060f81219d1ce5b406ae50f0c80 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 06 四月 2023 17:48:10 +0800 Subject: [PATCH] Merge branch 'develop' --- src/tabviews/zshare/actionList/index.jsx | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 6880a1f..df5de33 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/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> -- Gitblit v1.8.0