Commit 159b3e6d authored by 李纪文's avatar 李纪文

feat: 缺省页增加图片默认取值路径

parent 8b6816e7
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { ConfigProvider } from 'antd'; import { ConfigProvider, Image } from 'antd';
import noDataLight from './assets/noDataLight.png'; import noDataLight from './assets/noDataLight.png';
import noDataDark from './assets/noDataDark.png'; import noDataDark from './assets/noDataDark.png';
import errorLight from './assets/errorLight.png'; import errorLight from './assets/errorLight.png';
...@@ -22,6 +22,7 @@ const Empty = ({ description, image, theme, size, statusCode, imageStyle, childr ...@@ -22,6 +22,7 @@ const Empty = ({ description, image, theme, size, statusCode, imageStyle, childr
const des = description || DESC_DATA[`${statusCode}`]; const des = description || DESC_DATA[`${statusCode}`];
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
const imageSrc = image || IMAGE_DATA[theme][statusCode == '0' ? 0 : 1]; const imageSrc = image || IMAGE_DATA[theme][statusCode == '0' ? 0 : 1];
const defaultSrc = image || IMAGE_DATA_DEFAULT[theme][statusCode == '0' ? 0 : 1];
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('panda-empty'); const prefixCls = getPrefixCls('panda-empty');
...@@ -29,7 +30,16 @@ const Empty = ({ description, image, theme, size, statusCode, imageStyle, childr ...@@ -29,7 +30,16 @@ const Empty = ({ description, image, theme, size, statusCode, imageStyle, childr
let imageNode = null; let imageNode = null;
if (typeof image === 'string') { if (typeof image === 'string') {
imageNode = <img alt={alt} src={imageSrc} />; imageNode = <Image
rootClassName={`${prefixCls}-image-nodebox`}
alt={alt}
src={defaultSrc}
fallback={imageSrc}
preview={false}
onError={(e) => {
if (window.__POWERED_BY_QIANKUN__) console.clear();
}}
/>;
} else { } else {
imageNode = image; imageNode = image;
} }
...@@ -81,3 +91,8 @@ const IMAGE_DATA = { ...@@ -81,3 +91,8 @@ const IMAGE_DATA = {
light: [noDataLight, errorLight], light: [noDataLight, errorLight],
dark: [noDataDark, errorDark], dark: [noDataDark, errorDark],
}; };
const IMAGE_DATA_DEFAULT = {
light: ['/iconlibrary/empty/noDataLight.png', '/iconlibrary/empty/errorLight.png'],
dark: ['/iconlibrary/empty/noDataDark.png', '/iconlibrary/empty/errorDark.png'],
};
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,14 @@
&-image { &-image {
margin-bottom: 10px; margin-bottom: 10px;
&-nodebox {
height: 100%;
img {
width: auto;
}
}
img { img {
height: 100%; height: 100%;
......
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