@/utils/utils#messageR JavaScript Examples
The following examples show how to use
@/utils/utils#messageR.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: login.js From spring-boot-plus-admin-react with Apache License 2.0 | 5 votes |
Model = {
namespace: 'login',
state: {
status: undefined,
},
effects: {
*login({ payload }, { call, put }) {
const response = yield call(login, payload);
messageR(response);
yield put({
type: 'changeLoginStatus',
payload: {...response, type: payload.type},
}); // Login successfully
if (response.success) {
const { token , loginSysUserVo } = response.data;
if( !loginSysUserVo.avatar ) {
const avatar = "https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png";
loginSysUserVo.avatar = avatar;
}
localStorage.setItem(TOKEN, token );
localStorage.setItem(USER, JSON.stringify(loginSysUserVo));
const urlParams = new URL(window.location.href);
const params = getPageQuery();
let { redirect } = params;
if (redirect) {
const redirectUrlParams = new URL(redirect);
if (redirectUrlParams.origin === urlParams.origin) {
redirect = redirect.substr(urlParams.origin.length);
if (redirect.match(/^\/.*#/)) {
redirect = redirect.substr(redirect.indexOf('#') + 1);
}
} else {
window.location.href = '/';
return;
}
}
router.replace(redirect || '/');
}
},
*getCaptcha({ payload }, { call }) {
yield call(getFakeCaptcha, payload);
},
logout() {
const { redirect } = getPageQuery(); // Note: There may be security issues, please note
if (window.location.pathname !== '/user/login' && !redirect) {
router.replace({
pathname: '/user/login',
search: stringify({
redirect: window.location.href,
}),
});
}
},
},
reducers: {
changeLoginStatus(state, { payload }) {
if (payload.success) {
setAuthority(payload.currentAuthority);
}
return {
...state,
status: payload.success ? 'ok' : 'error',
type: payload.type,
};
},
},
}
Example #2
Source File: model.js From spring-boot-plus-admin-react with Apache License 2.0 | 5 votes |
Model = {
namespace: 'SysDepartmentModel',
state: {
tree: [],
select: [],
total: 0,
department: {},
permissions: [],
},
effects: {
// 获取系统部门Tree
* eSysDepartmentTree({payload}, {call, put}) {
const response = yield call(getAllDepartmentTree, payload);
yield put({type: 'rSysDepartmentTree', payload: response});
},
// 添加系统部门
* eAddSysDepartment({payload}, {call}) {
const response = yield call(addSysDepartment, payload);
return messageR(response);
},
// 修改系统部门
* eUpdateSysDepartment({payload}, {call}) {
const response = yield call(updateSysDepartment, payload);
return messageR(response);
},
// 根据id获取系统部门信息
* eGetSysDepartment({payload}, {call, put}) {
const response = yield call(getSysDepartment, payload.id);
if (response.success) {
yield put({type: 'rGetSysDepartment', payload: response});
return true;
}
return false;
},
// 删除系统部门信息
* eDeleteSysDepartmentById({payload}, {call}) {
const response = yield call(deleteSysDepartment, payload.id);
return messageR(response);
},
// 获取所有权限信息
* eGetSysPermissionList(_, {call, put}) {
const response = yield call(getSysPermissionList);
if (response.success) {
yield put({type: 'rGetSysPermissionList', payload: response});
return true;
}
return false;
},
},
reducers: {
rSysDepartmentTree(state, action) {
const {data, success} = action.payload;
if (success) {
const select = [{id: 0, key: '无', value: '0', title: '无',},...data];
return {...state, tree: data, select};
}
return state;
},
rGetDepartmentList(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, departments: data};
}
return state;
},
rGetSysDepartment(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, department: data};
}
return state;
},
},
}
Example #3
Source File: model.js From spring-boot-plus-admin-react with Apache License 2.0 | 5 votes |
Model = {
namespace: 'SysPermissionModel',
state: {
tree: [],
select: [],
total: 0,
permission: {},
permissions: [],
},
effects: {
// 获取系统权限Tree
* eSysPermissionTree({payload}, {call, put}) {
const response = yield call(getAllPermissionTree, payload);
yield put({type: 'rSysPermissionTree', payload: response});
},
// 添加系统权限
* eAddSysPermission({payload}, {call}) {
const response = yield call(addSysPermission, payload);
return messageR(response);
},
// 修改系统权限
* eUpdateSysPermission({payload}, {call}) {
const response = yield call(updateSysPermission, payload);
return messageR(response);
},
// 根据id获取系统权限信息
* eGetSysPermission({payload}, {call, put}) {
const response = yield call(getSysPermission, payload.id);
if (response.success) {
yield put({type: 'rGetSysPermission', payload: response});
return true;
}
return false;
},
// 删除系统权限信息
* eDeleteSysPermissionById({payload}, {call}) {
const response = yield call(deleteSysPermission, payload.id);
return messageR(response);
},
// 获取所有权限信息
* eGetSysPermissionList(_, {call, put}) {
const response = yield call(getSysPermissionList);
if (response.success) {
yield put({type: 'rGetSysPermissionList', payload: response});
return true;
}
return false;
},
},
reducers: {
rSysPermissionTree(state, action) {
const {data, success} = action.payload;
if (success) {
const select = [{id: 0, key: '无', value: '0', title: '无',},...data];
return {...state, tree: data, select};
}
return state;
},
rGetPermissionList(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, permissions: data};
}
return state;
},
rGetSysPermission(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, permission: data};
}
return state;
},
},
}
Example #4
Source File: model.js From spring-boot-plus-admin-react with Apache License 2.0 | 5 votes |
Model = {
namespace: 'SysRoleModel',
state: {
records: [],
total: 0,
role: {},
permissions: [],
},
effects: {
// 获取分页系统角色列表
* eSysRolePage({payload}, {call, put}) {
const response = yield call(getPageList, payload);
yield put({type: 'rSysRolePage', payload: response});
},
// 添加系统角色
* eAddSysRole({payload}, {call}) {
const response = yield call(addSysRole, payload);
return messageR(response);
},
// 修改系统角色
* eUpdateSysRole({payload}, {call}) {
const response = yield call(updateSysRole, payload);
return messageR(response);
},
// 根据id获取系统角色信息
* eGetSysRole({payload}, {call, put}) {
const response = yield call(getSysRole, payload.id);
if (response.success) {
yield put({type: 'rGetSysRole', payload: response});
return true;
}
return false;
},
// 删除系统角色信息
* eDeleteSysRoleById({payload}, {call}) {
const response = yield call(deleteSysRole, payload.id);
return messageR(response);
},
// 获取所有权限信息
* eGetSysPermissionList(_, {call, put}) {
const response = yield call(getSysPermissionList);
if (response.success) {
yield put({type: 'rGetSysPermissionList', payload: response});
return true;
}
return false;
},
},
reducers: {
rSysRolePage(state, action) {
const {data, success} = action.payload;
if (success) {
const {records, total} = data;
return {...state, records, total};
}
return state;
},
rGetRoleList(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, roles: data};
}
return state;
},
rGetSysPermissionList(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, permissions: data};
}
return state;
},
rGetSysRole(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, role: data};
}
return state;
},
},
}
Example #5
Source File: model.js From spring-boot-plus-admin-react with Apache License 2.0 | 4 votes |
Model = {
namespace: 'SysUserModel',
state: {
records: [],
total: 0,
user: {},
roles: [],
departments: [],
},
effects: {
// 获取分页系统用户列表
* eSysUserPage({payload}, {call, put}) {
const response = yield call(getPageList, payload);
yield put({type: 'rSysUserPage', payload: response});
},
// 添加系统用户
* eAddSysUser({payload}, {call}) {
const response = yield call(addSysUser, payload);
return messageR(response);
},
// 修改系统用户
* eUpdateSysUser({payload}, {call}) {
const response = yield call(updateSysUser, payload);
return messageR(response);
},
// 根据id获取系统用户信息
* eGetSysUser({payload}, {call, put}) {
const response = yield call(getSysUser, payload.id);
if (response.success) {
yield put({type: 'rGetSysUser', payload: response});
return true;
}
return false;
},
// 删除系统用户信息
* eDeleteSysUserById({payload}, {call}) {
const response = yield call(deleteSysUser, payload.id);
return messageR(response);
},
// 获取SysRole列表
* eGetRoleList(_, {call, put}) {
const response = yield call(getRoleList);
yield put({type: 'rGetRoleList', payload: response});
},
// 获取部门树形列表
* eGetAllDepartmentTree(_, {call, put}) {
const response = yield call(getAllDepartmentTree);
yield put({type: 'rGetAllDepartmentTree', payload: response});
}
},
reducers: {
rSysUserPage(state, action) {
const {data, success} = action.payload;
if (success) {
const {records, total} = data;
return {...state, records, total};
}
return state;
},
rGetRoleList(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, roles: data};
}
return state;
},
rGetAllDepartmentTree(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, departments: data};
}
return state;
},
rGetSysUser(state, action) {
const {data, success} = action.payload;
if (success) {
return {...state, user: data};
}
return state;
},
},
}