From 2b4b1ecca5b6170bcbf3364b7ea81a248d0d6593 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 12 十月 2021 18:02:09 +0800 Subject: [PATCH] 2021-10-12 --- src/tabviews/custom/components/tabs/antv-tabs/index.jsx | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx index 23aa817..6ad66b0 100644 --- a/src/tabviews/custom/components/tabs/antv-tabs/index.jsx +++ b/src/tabviews/custom/components/tabs/antv-tabs/index.jsx @@ -22,7 +22,8 @@ state = { tabs: null, parentIds: [], - bids: {} + bids: {}, + activeIndex: 1 } UNSAFE_componentWillMount () { @@ -39,7 +40,13 @@ } componentDidMount () { + const { config } = this.props + + if (config.setting.autoSwitch === 'true' && config.subtabs.length > 1 && config.setting.interval) { + this.autoSwitch(config.setting.interval) + } MKEmitter.addListener('resetSelectLine', this.resetParentParam) + } /** @@ -62,12 +69,36 @@ }) } + autoSwitch = (interval) => { + const { tabs, activeIndex } = this.state + + if (!tabs) return + + let index = activeIndex + + if (!tabs.subtabs[index]) { + index = 0 + } + + let id = 'tab' + tabs.subtabs[index].uuid + + this.setState({activeIndex: ++index}) + + setTimeout(() => { + let node = document.getElementById(id) + if (node) { + node.click() + this.autoSwitch(interval) + } + }, interval * 1000) + } + render() { const { mainSearch, BID } = this.props const { tabs, bids } = this.state return ( - <div className="menu-antv-tabs-wrap" style={tabs.style}> + <div className={'menu-antv-tabs-wrap ' + tabs.setting.tabLabel} style={tabs.style}> <Tabs defaultActiveKey="1" tabPosition={tabs.setting.position} type={tabs.setting.tabStyle}> {tabs.subtabs.map(tab => ( <TabPane tab={<span id={'tab' + tab.uuid}>{tab.icon ? <Icon type={tab.icon} /> : null}{tab.label}</span>} key={tab.uuid}> -- Gitblit v1.8.0