|
@@ -11,7 +11,7 @@ import {REQ_STATUS} from "@api/config";
|
|
|
import {buildReqReducer, reqGetRoutes, reqLogin, reqLogout, reqRegister} from "@features/api";
|
|
import {buildReqReducer, reqGetRoutes, reqLogin, reqLogout, reqRegister} from "@features/api";
|
|
|
import {toast} from 'react-toastify';
|
|
import {toast} from 'react-toastify';
|
|
|
import {localStorageGet, localStorageSet} from "@utils/helpers";
|
|
import {localStorageGet, localStorageSet} from "@utils/helpers";
|
|
|
-import {LOCAL_IS_LOGIN, LOCAL_USER_INFO} from "@constants/localkey";
|
|
|
|
|
|
|
+import {LOCAL_IS_LOGIN, LOCAL_SIGN, LOCAL_USER_INFO} from "@constants/localkey";
|
|
|
const i18n=global.i18n;
|
|
const i18n=global.i18n;
|
|
|
const generateNavs=(routes)=>{
|
|
const generateNavs=(routes)=>{
|
|
|
const navs=[];
|
|
const navs=[];
|
|
@@ -118,7 +118,16 @@ const reducerRoutes=(state,action)=>{
|
|
|
let generData=generateRoutes(state.routes,data);
|
|
let generData=generateRoutes(state.routes,data);
|
|
|
let styles=parseStyles(json.styles);
|
|
let styles=parseStyles(json.styles);
|
|
|
let blocks=parseBlocks(json.blocks);
|
|
let blocks=parseBlocks(json.blocks);
|
|
|
- Object.assign(state, {routes:state.routes,asyncRoutes:data,styles:styles,blocks:blocks,...generData});
|
|
|
|
|
|
|
+ let user=json.user;
|
|
|
|
|
+ let isLogin=0;
|
|
|
|
|
+ let userInfo={};
|
|
|
|
|
+ if (user){
|
|
|
|
|
+ if (typeof user=="object"){
|
|
|
|
|
+ isLogin=1;
|
|
|
|
|
+ userInfo=user;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Object.assign(state, {routes:state.routes,asyncRoutes:data,styles:styles,blocks:blocks,...generData,isLogin:isLogin,userInfo:userInfo});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
const routesStatus=(state,status,arg)=>{
|
|
const routesStatus=(state,status,arg)=>{
|
|
@@ -159,8 +168,10 @@ const parseLogin=(state,action,arg)=>{
|
|
|
let data=payload.data;
|
|
let data=payload.data;
|
|
|
state.userInfo=data;
|
|
state.userInfo=data;
|
|
|
state.isLogin=1;
|
|
state.isLogin=1;
|
|
|
- localStorageSet(LOCAL_USER_INFO,JSON.stringify(data));
|
|
|
|
|
- localStorageSet(LOCAL_IS_LOGIN,1);
|
|
|
|
|
|
|
+ // localStorageSet(LOCAL_USER_INFO,JSON.stringify(data));
|
|
|
|
|
+ // localStorageSet(LOCAL_IS_LOGIN,1);
|
|
|
|
|
+ let sign=data.sign;
|
|
|
|
|
+ if (sign!=null)localStorageSet(LOCAL_SIGN,sign);
|
|
|
toast.success(msg);
|
|
toast.success(msg);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -190,8 +201,9 @@ const reducerLogout=(state,action,arg)=>{
|
|
|
if (code==200){
|
|
if (code==200){
|
|
|
state.userInfo={};
|
|
state.userInfo={};
|
|
|
state.isLogin=0;
|
|
state.isLogin=0;
|
|
|
- localStorageSet(LOCAL_USER_INFO,"");
|
|
|
|
|
- localStorageSet(LOCAL_IS_LOGIN,0);
|
|
|
|
|
|
|
+ localStorageSet(LOCAL_SIGN,"");
|
|
|
|
|
+ // localStorageSet(LOCAL_USER_INFO,"");
|
|
|
|
|
+ // localStorageSet(LOCAL_IS_LOGIN,0);
|
|
|
toast.success(msg);
|
|
toast.success(msg);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
@@ -217,15 +229,15 @@ export const Main=createSlice({
|
|
|
register:REQ_STATUS.NONE,
|
|
register:REQ_STATUS.NONE,
|
|
|
logout:REQ_STATUS.NONE,
|
|
logout:REQ_STATUS.NONE,
|
|
|
},
|
|
},
|
|
|
- userInfo:getLocalUserInfo(),
|
|
|
|
|
- isLogin:getLocalIsLogin()
|
|
|
|
|
|
|
+ userInfo: {},
|
|
|
|
|
+ isLogin:0
|
|
|
},
|
|
},
|
|
|
reducers: {
|
|
reducers: {
|
|
|
logout:(state, action)=>{
|
|
logout:(state, action)=>{
|
|
|
state.userInfo={};
|
|
state.userInfo={};
|
|
|
state.isLogin=0;
|
|
state.isLogin=0;
|
|
|
- localStorageSet(LOCAL_USER_INFO,"");
|
|
|
|
|
- localStorageSet(LOCAL_IS_LOGIN,0);
|
|
|
|
|
|
|
+ // localStorageSet(LOCAL_USER_INFO,"");
|
|
|
|
|
+ // localStorageSet(LOCAL_IS_LOGIN,0);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
extraReducers: (builder) => {
|
|
extraReducers: (builder) => {
|
|
@@ -320,6 +332,9 @@ export const isLogined=(state)=>{
|
|
|
return state.main.isLogin;
|
|
return state.main.isLogin;
|
|
|
// return 1;
|
|
// return 1;
|
|
|
}
|
|
}
|
|
|
|
|
+export const getUserInfo=(state)=>{
|
|
|
|
|
+ return state.main.userInfo;
|
|
|
|
|
+}
|
|
|
//数据获取
|
|
//数据获取
|
|
|
export default Main.reducer;
|
|
export default Main.reducer;
|
|
|
|
|
|