From b09b821ef36fd1ea979e9a5daa98e95732ac81d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 16 七月 2025 18:16:00 +0800 Subject: [PATCH] 2025-07-16 --- src/components/mkIcon/index.jsx | 48 +++++++++++++++++++++++++++++++++--------------- 1 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/components/mkIcon/index.jsx b/src/components/mkIcon/index.jsx index 0447f06..3427f4b 100644 --- a/src/components/mkIcon/index.jsx +++ b/src/components/mkIcon/index.jsx @@ -46,12 +46,8 @@ } componentDidMount() { - if (!window.GLOB.designView) { - if (sessionStorage.getItem('systemIcons')) { - this.setState({cusicons: JSON.parse(sessionStorage.getItem('systemIcons'))}) - } else { - this.getIcons() - } + if (!window.GLOB.designView && window.GLOB.systemIcons) { + this.setState({cusicons: window.GLOB.systemIcons}) } } @@ -65,28 +61,50 @@ } getIcons = () => { - Api.getSystemConfig({ func: 's_get_icons' }).then(res => { + const { selectIcon } = this.state + + Api.getCloudConfig({ func: 's_get_icons' }).then(res => { if (!res.status) { notification.warning({ top: 92, message: res.message, duration: 5 }) - sessionStorage.setItem('systemIcons', JSON.stringify([])) - return - } else if (!res.data) { + window.GLOB.systemIcons = [] return } - let icons = res.data.map(item => { + let icons = (res.data || []).map(item => { item.icon_svg = window.decodeURIComponent(window.atob(item.icon_svg)) return item }) - sessionStorage.setItem('systemIcons', JSON.stringify(icons)) + window.GLOB.systemIcons = icons this.setState({cusicons: icons}) + + if (icons.length > 0 && selectIcon && /<svg/.test(selectIcon)) { + setTimeout(() => { + let node = document.getElementById('mk-custom-tab') + node && node.click() + }, 200) + } }) + } + + trigger = () => { + const { selectIcon, cusicons } = this.state + + this.setState({visible: true}) + + if (!window.GLOB.designView && !window.GLOB.systemIcons) { + this.getIcons() + } else if (cusicons.length > 0 && selectIcon && /<svg/.test(selectIcon)) { + setTimeout(() => { + let node = document.getElementById('mk-custom-tab') + node && node.click() + }, 200) + } } render() { @@ -95,7 +113,7 @@ return ( <div className="mk-icon-box"> {selectIcon ? <MkIcon type={selectIcon}/> : <span style={{color: '#bcbcbc'}}>璇烽�夋嫨</span>} - <MkIcon className="trigger" onClick={() => this.setState({visible: true})} type="swap"/> + <MkIcon className="trigger" onClick={this.trigger} type="swap"/> {allowClear && selectIcon ? <CloseCircleFilled className="close" onClick={() => this.checkIcon('')}/> : null} <Modal wrapClassName="mk-pop-modal mk-icon-wrap" @@ -118,13 +136,13 @@ </Row> </TabPane> <TabPane tab={ - <span className="tab-control"> + <span className="tab-control" id="mk-custom-tab"> <RedoOutlined onClick={(e) => {this.getIcons()}}/> 鑷畾涔� </span> } key="scripts"> <Row> - {cusicons.map(icon => <Col key={icon.id} span={4} onClick={() => this.checkIcon(icon.icon_svg)}> + {cusicons.map(icon => <Col className={icon.icon_svg === selectIcon ? 'active' : ''} key={icon.id} span={4} onClick={() => this.checkIcon(icon.icon_svg)}> <MkIcon type={icon.icon_svg} /> </Col>)} </Row> -- Gitblit v1.8.0