system.js
1.2 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
import { take, select, call, takeEvery, put } from 'redux-saga/effects';
import * as types from '../actionTypes';
import { getSystemSelect } from '../../utils/commonUtils';
//切换菜单
export const changeSystemMenu = (values) => {
return { type: types.SYSTEM_MENU_SELECTED_KEYS, payload: values };
};
/*
* 路由改变菜单回填
*/
export function* selectSysMenus(uaa_perms) {
const state = yield select();
const { router } = state;
const { location = {} } = router;
const { pathname = '' } = location;
if (uaa_perms.length > 0) {
const menuAction = getSystemSelect(pathname, uaa_perms);
yield put({
type: types.SYSTEM_MENU_SELECTED_KEYS,
payload: menuAction
});
}
}
/*
路由跳转切点,做页面权限判断
*/
function* handldRouter() {
while (true) {
const routerAction = yield take(['@@router/LOCATION_CHANGE']);
const state = yield select();
const { payload = {} } = routerAction;
const { location = {} } = payload;
const { pathname = '' } = location;
// const { uaa: { uaa_perms = [] } } = state;
// yield selectSysMenus(uaa_perms);
yield selectSysMenus([]);
}
}
export default [handldRouter()];