From 31871ca836e6fcbea9b1c54e2ec15f49667bf093 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 23 十二月 2022 14:14:04 +0800 Subject: [PATCH] 2022-12-23 --- src/tabviews/zshare/actionList/index.jsx | 32 +++++++++++++++++++++++++++++--- 1 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index dca525f..911e141 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -1,7 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Affix } from 'antd' +import { Affix, Dropdown } from 'antd' +import { DownOutlined } from '@ant-design/icons' import asyncComponent from './asyncButtonComponent' import './index.scss' @@ -29,7 +30,25 @@ setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 } - state = {} + state = { + actions: [], + mores: null + } + + UNSAFE_componentWillMount() { + const { setting, actions } = this.props + + if (!setting.btnlimit || setting.btnlimit >= actions.length) { + this.setState({actions: actions}) + } else { + let mores = fromJS(actions).toJS() + + this.setState({ + actions: mores.splice(0, setting.btnlimit), + mores + }) + } + } shouldComponentUpdate (nextProps, nextState) { return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) @@ -174,7 +193,8 @@ } render() { - const { setting, MenuID, actions } = this.props + const { setting, MenuID } = this.props + const { actions, mores } = this.state let fixed = setting.actionfixed && setting.tabType === 'main' // 鎸夐挳鏄惁鍥哄畾鍦ㄥご閮� if (fixed && MenuID) { @@ -182,6 +202,9 @@ <Affix offsetTop={48}> <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}> {this.getButtonList(actions)} + {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}> + <div className="mk-more">鏇村<DownOutlined/></div> + </Dropdown> : null} </div> </Affix> ) @@ -189,6 +212,9 @@ return ( <div className="button-list toolbar-button" id={fixed ? MenuID + 'mainaction' : ''}> {this.getButtonList(actions)} + {mores ? <Dropdown overlay={<div className="mk-button-dropdown-wrap">{this.getButtonList(mores)}</div>} trigger={['hover']}> + <div className="mk-more">鏇村<DownOutlined/></div> + </Dropdown> : null} </div> ) } -- Gitblit v1.8.0