|
|
@@ -1,3 +1,5 @@
|
|
|
+import router from 'umi/router';
|
|
|
+import { getAuthority } from 'utils/authority';
|
|
|
import { queryNotices } from '../services/api';
|
|
|
|
|
|
export default {
|
|
|
@@ -31,6 +33,13 @@ export default {
|
|
|
payload: count,
|
|
|
});
|
|
|
},
|
|
|
+ *init({ payload }, { put }) {
|
|
|
+ if (payload.hasAuthority) {
|
|
|
+ yield put(router.push('/User/Login'));
|
|
|
+ } else {
|
|
|
+ yield put(router.push('/Dashboard/Analysis'));
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
reducers: {
|
|
|
@@ -55,12 +64,21 @@ export default {
|
|
|
},
|
|
|
|
|
|
subscriptions: {
|
|
|
- setup({ history }) {
|
|
|
+ setup({ history, dispatch }) {
|
|
|
// Subscribe history(url) change, trigger `load` action if pathname is `/`
|
|
|
return history.listen(({ pathname, search }) => {
|
|
|
if (typeof window.ga !== 'undefined') {
|
|
|
window.ga('send', 'pageview', pathname + search);
|
|
|
}
|
|
|
+ if (pathname === '/') {
|
|
|
+ const author = getAuthority();
|
|
|
+ dispatch({
|
|
|
+ type: 'init',
|
|
|
+ payload: {
|
|
|
+ hasAuthority: author === 'guest' || !author,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
},
|