Commit c1ce6ec8 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ…

use isUrl judgment icon

parent 27562512
...@@ -5,6 +5,7 @@ import isEqual from 'lodash/isEqual'; ...@@ -5,6 +5,7 @@ import isEqual from 'lodash/isEqual';
import memoizeOne from 'memoize-one'; import memoizeOne from 'memoize-one';
import { urlToList } from '../_utils/pathTools'; import { urlToList } from '../_utils/pathTools';
import { getMenuMatches } from './SiderMenuUtils'; import { getMenuMatches } from './SiderMenuUtils';
import { isUrl } from '@/utils/utils';
import styles from './index.less'; import styles from './index.less';
const { SubMenu } = Menu; const { SubMenu } = Menu;
...@@ -14,7 +15,7 @@ const { SubMenu } = Menu; ...@@ -14,7 +15,7 @@ const { SubMenu } = Menu;
// icon: 'http://demo.com/icon.png', // icon: 'http://demo.com/icon.png',
// icon: <Icon type="setting" />, // icon: <Icon type="setting" />,
const getIcon = icon => { const getIcon = icon => {
if (typeof icon === 'string' && icon.indexOf('http') === 0) { if (typeof icon === 'string' && isUrl(icon)) {
return <img src={icon} alt="icon" className={styles.icon} />; return <img src={icon} alt="icon" className={styles.icon} />;
} }
if (typeof icon === 'string') { if (typeof icon === 'string') {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment