global.js
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { queryNotices } from '@/services/user';
const GlobalModel = {
namespace: 'global',
state: {
collapsed: false,
loading: false,
urlFileExport: '',
dataModal: {
modalType: '',
modalShow: false,
modalData: {},
},
preImgDataModal: {
modalType: '',
modalShow: false,
modalData: {},
},
},
effects: {},
reducers: {
changeLayoutCollapsed(
state = {
notices: [],
collapsed: true,
},
{ payload },
) {
return { ...state, collapsed: payload };
},
},
subscriptions: {
setup({ history, dispatch }) {
// Subscribe history(url) change, trigger `load` action if pathname is `/`
history.listen(({ pathname, search }) => {
// 路由发生变化的时候切换菜单
const whiteList = ['/user/login'];
if (!whiteList.includes(pathname)) {
// 获取用户信息
dispatch({ type: 'user/fetchCurrent' });
}
});
},
},
};
export default GlobalModel;