Unverified Commit 5684b5d5 authored by ι™ˆεΈ…'s avatar ι™ˆεΈ… Committed by GitHub

feat: remove import lib (#3736)

parent cb5a0834
...@@ -6,7 +6,7 @@ import defaultSettings from '../src/defaultSettings'; ...@@ -6,7 +6,7 @@ import defaultSettings from '../src/defaultSettings';
import slash from 'slash2'; import slash from 'slash2';
const { pwa, primaryColor } = defaultSettings; const { pwa, primaryColor } = defaultSettings;
const { NODE_ENV, APP_TYPE, TEST } = process.env; const { APP_TYPE, TEST } = process.env;
const plugins = [ const plugins = [
[ [
......
import React from 'react';
import PageLoading from '../PageLoading';
import { importCDN } from '@/utils/utils';
let isLoaderBizChart = false;
const loadBizCharts = async () => {
if (isLoaderBizChart) {
return Promise.resolve(true);
}
await Promise.all([
importCDN('//gw.alipayobjects.com/os/lib/bizcharts/3.4.3/umd/BizCharts.min.js'),
importCDN('//gw.alipayobjects.com/os/lib/antv/data-set/0.10.1/dist/data-set.min.js'),
]);
// eslint-disable-next-line no-console
console.log('bizCharts load success');
isLoaderBizChart = true;
return Promise.resolve(true);
};
class AsyncLoadBizCharts extends React.Component {
state = {
loading: !isLoaderBizChart,
};
async componentDidMount() {
await loadBizCharts();
requestAnimationFrame(() => {
this.setState({
loading: false,
});
});
}
render() {
const { children } = this.props;
const { loading } = this.state;
if (!loading) {
return children;
}
return <PageLoading />;
}
}
export { loadBizCharts, AsyncLoadBizCharts };
import React, { Suspense } from 'react';
import numeral from 'numeral'; import numeral from 'numeral';
import ChartCard from './ChartCard'; import ChartCard from './ChartCard';
import Field from './Field'; import Field from './Field';
import Bar from './Bar';
const getComponent = Component => props => ( import Pie from './Pie';
<Suspense fallback="..."> import Radar from './Radar';
<Component {...props} /> import Gauge from './Gauge';
</Suspense> import MiniArea from './MiniArea';
); import MiniBar from './MiniBar';
import MiniProgress from './MiniProgress';
const Bar = getComponent(React.lazy(() => import('./Bar'))); import WaterWave from './WaterWave';
const Pie = getComponent(React.lazy(() => import('./Pie'))); import TagCloud from './TagCloud';
const Radar = getComponent(React.lazy(() => import('./Radar'))); import TimelineChart from './TimelineChart';
const Gauge = getComponent(React.lazy(() => import('./Gauge')));
const MiniArea = getComponent(React.lazy(() => import('./MiniArea')));
const MiniBar = getComponent(React.lazy(() => import('./MiniBar')));
const MiniProgress = getComponent(React.lazy(() => import('./MiniProgress')));
const WaterWave = getComponent(React.lazy(() => import('./WaterWave')));
const TagCloud = getComponent(React.lazy(() => import('./TagCloud')));
const TimelineChart = getComponent(React.lazy(() => import('./TimelineChart')));
const yuan = val => `Β₯ ${numeral(val).format('0,0')}`; const yuan = val => `Β₯ ${numeral(val).format('0,0')}`;
......
...@@ -5,7 +5,6 @@ import GridContent from '@/components/PageHeaderWrapper/GridContent'; ...@@ -5,7 +5,6 @@ import GridContent from '@/components/PageHeaderWrapper/GridContent';
import { getTimeDistance } from '@/utils/utils'; import { getTimeDistance } from '@/utils/utils';
import styles from './Analysis.less'; import styles from './Analysis.less';
import PageLoading from '@/components/PageLoading'; import PageLoading from '@/components/PageLoading';
import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
const IntroduceRow = React.lazy(() => import('./IntroduceRow')); const IntroduceRow = React.lazy(() => import('./IntroduceRow'));
const SalesCard = React.lazy(() => import('./SalesCard')); const SalesCard = React.lazy(() => import('./SalesCard'));
...@@ -182,8 +181,4 @@ class Analysis extends Component { ...@@ -182,8 +181,4 @@ class Analysis extends Component {
} }
} }
export default props => ( export default Analysis;
<AsyncLoadBizCharts>
<Analysis {...props} />
</AsyncLoadBizCharts>
);
import React, { Component } from 'react'; import React, { Component } from 'react';
import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
import { connect } from 'dva'; import { connect } from 'dva';
import { formatMessage, FormattedMessage } from 'umi/locale'; import { formatMessage, FormattedMessage } from 'umi/locale';
import { Row, Col, Card, Tooltip } from 'antd'; import { Row, Col, Card, Tooltip } from 'antd';
...@@ -242,8 +241,4 @@ class Monitor extends Component { ...@@ -242,8 +241,4 @@ class Monitor extends Component {
} }
} }
export default props => ( export default Monitor;
<AsyncLoadBizCharts>
<Monitor {...props} />
</AsyncLoadBizCharts>
);
...@@ -3,7 +3,6 @@ import moment from 'moment'; ...@@ -3,7 +3,6 @@ import moment from 'moment';
import { connect } from 'dva'; import { connect } from 'dva';
import Link from 'umi/link'; import Link from 'umi/link';
import { Row, Col, Card, List, Avatar } from 'antd'; import { Row, Col, Card, List, Avatar } from 'antd';
import { AsyncLoadBizCharts } from '@/components/Charts/AsyncLoadBizCharts';
import { Radar } from '@/components/Charts'; import { Radar } from '@/components/Charts';
import EditableLinkGroup from '@/components/EditableLinkGroup'; import EditableLinkGroup from '@/components/EditableLinkGroup';
import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import PageHeaderWrapper from '@/components/PageHeaderWrapper';
...@@ -253,8 +252,4 @@ class Workplace extends PureComponent { ...@@ -253,8 +252,4 @@ class Workplace extends PureComponent {
} }
} }
export default props => ( export default Workplace;
<AsyncLoadBizCharts>
<Workplace {...props} />
</AsyncLoadBizCharts>
);
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