Commit e2aeb7c9 authored by xiaohu's avatar xiaohu

set init route

parent 7494ac09
...@@ -93,6 +93,9 @@ export default { ...@@ -93,6 +93,9 @@ export default {
}, },
alias: { alias: {
components: path.resolve(__dirname, '../src/components/'), components: path.resolve(__dirname, '../src/components/'),
utils: path.resolve(__dirname, '../src/utils/'),
assets: path.resolve(__dirname, '../src/assets/'),
common: path.resolve(__dirname, '../src/common/'),
}, },
ignoreMomentLocale: true, ignoreMomentLocale: true,
theme: './src/theme.js', theme: './src/theme.js',
......
import router from 'umi/router';
import { getAuthority } from 'utils/authority';
import { queryNotices } from '../services/api'; import { queryNotices } from '../services/api';
export default { export default {
...@@ -31,6 +33,13 @@ export default { ...@@ -31,6 +33,13 @@ export default {
payload: count, payload: count,
}); });
}, },
*init({ payload }, { put }) {
if (payload.hasAuthority) {
yield put(router.push('/User/Login'));
} else {
yield put(router.push('/Dashboard/Analysis'));
}
},
}, },
reducers: { reducers: {
...@@ -55,12 +64,21 @@ export default { ...@@ -55,12 +64,21 @@ export default {
}, },
subscriptions: { subscriptions: {
setup({ history }) { setup({ history, dispatch }) {
// Subscribe history(url) change, trigger `load` action if pathname is `/` // Subscribe history(url) change, trigger `load` action if pathname is `/`
return history.listen(({ pathname, search }) => { return history.listen(({ pathname, search }) => {
if (typeof window.ga !== 'undefined') { if (typeof window.ga !== 'undefined') {
window.ga('send', 'pageview', pathname + search); window.ga('send', 'pageview', pathname + search);
} }
if (pathname === '/') {
const author = getAuthority();
dispatch({
type: 'init',
payload: {
hasAuthority: author === 'guest' || !author,
},
});
}
}); });
}, },
}, },
......
import React from 'react';
export default () => <div />;
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