Sfoglia il codice sorgente

Add spin for dynamic import

afc163 8 anni fa
parent
commit
9a584109ce
2 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 5 0
      src/index.less
  2. 6 1
      src/router.js

+ 5 - 0
src/index.less

@@ -7,3 +7,8 @@ body {
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
 }
+
+.globalSpin {
+  width: 100%;
+  margin: 40px 0 !important;
+}

+ 6 - 1
src/router.js

@@ -1,8 +1,13 @@
 import React from 'react';
 import { Router, Route, Switch } from 'dva/router';
-import { LocaleProvider } from 'antd';
+import { LocaleProvider, Spin } from 'antd';
 import zhCN from 'antd/lib/locale-provider/zh_CN';
 import dynamic from 'dva/dynamic';
+import styles from './index.less';
+
+dynamic.setDefaultLoadingComponent(() => {
+  return <Spin size="large" className={styles.globalSpin} />;
+});
 
 function RouterConfig({ history, app }) {
   const BasicLayout = dynamic({