Commit 6481a3af authored by afc163's avatar afc163

fix danger warning

parent df0ffd6d
...@@ -13,7 +13,7 @@ import WaterWave from './WaterWave'; ...@@ -13,7 +13,7 @@ import WaterWave from './WaterWave';
import TagCloud from './TagCloud'; import TagCloud from './TagCloud';
import TimelineChart from './TimelineChart'; import TimelineChart from './TimelineChart';
const yuan = val => `¥ ${numeral(val).format('0,0')}`; const yuan = val => `¥ ${numeral(val).format('0,0')}`;
const Charts = { const Charts = {
yuan, yuan,
......
...@@ -42,6 +42,10 @@ for (let i = 0; i < 7; i += 1) { ...@@ -42,6 +42,10 @@ for (let i = 0; i < 7; i += 1) {
}); });
} }
const Yuan = ({ children }) => (
<span dangerouslySetInnerHTML={{ __html: yuan(children) }} /> /* eslint-disable-line react/no-danger */
);
@connect(({ chart, loading }) => ({ @connect(({ chart, loading }) => ({
chart, chart,
loading: loading.effects['chart/fetch'], loading: loading.effects['chart/fetch'],
...@@ -252,7 +256,7 @@ export default class Analysis extends Component { ...@@ -252,7 +256,7 @@ export default class Analysis extends Component {
<Icon type="info-circle-o" /> <Icon type="info-circle-o" />
</Tooltip> </Tooltip>
} }
total={() => <span dangerouslySetInnerHTML={{ __html: yuan(126560) }} />} total={() => <Yuan>126560</Yuan>}
footer={<Field label="日均销售额" value={`¥${numeral(12423).format('0,0')}`} />} footer={<Field label="日均销售额" value={`¥${numeral(12423).format('0,0')}`} />}
contentHeight={46} contentHeight={46}
> >
...@@ -451,15 +455,11 @@ export default class Analysis extends Component { ...@@ -451,15 +455,11 @@ export default class Analysis extends Component {
<Pie <Pie
hasLegend hasLegend
subTitle="销售额" subTitle="销售额"
total={() => ( total={
<span () => <Yuan>{salesPieData.reduce((pre, now) => now.y + pre, 0)}</Yuan>
dangerouslySetInnerHTML={{ }
__html: yuan(salesPieData.reduce((pre, now) => now.y + pre, 0)),
}}
/>
)}
data={salesPieData} data={salesPieData}
valueFormat={val => <span dangerouslySetInnerHTML={{ __html: yuan(val) }} />} valueFormat={value => <Yuan>{value}</Yuan>}
height={248} height={248}
lineWidth={4} lineWidth={4}
/> />
......
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