From c7aece35a62b6e91fd98a625bf0e53f64bfbd18d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 17 八月 2023 16:22:15 +0800 Subject: [PATCH] 2023-08-17 --- src/components/mk-icon/index.jsx | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/mk-icon/index.jsx b/src/components/mk-icon/index.jsx index 9fff348..42e8885 100644 --- a/src/components/mk-icon/index.jsx +++ b/src/components/mk-icon/index.jsx @@ -464,11 +464,28 @@ render() { const { type, ...resProps } = this.props - if (!type || !MkIcons[type]) return null + if (!type) { + return null + } else if (MkIcons[type]) { + return ( + MkIcons[type](resProps) + ) + } else { + let svg = type - return ( - MkIcons[type](resProps) - ) + if (!/<svg/.test(svg)) { + try { + svg = window.decodeURIComponent(window.atob(svg)) + if (!/<svg/.test(svg)) { + svg = '' + } + } catch (e) { + svg = '' + } + } + + return <span className={'anticon anticon-mk ' + (resProps.className || '')} style={resProps.style || null} dangerouslySetInnerHTML={{ __html: svg }}></span> + } } } export default MkIcon \ No newline at end of file -- Gitblit v1.8.0