|
@ -17,6 +17,7 @@ export interface UPLoginRequest { |
|
|
password: string; |
|
|
password: string; |
|
|
code: string; |
|
|
code: string; |
|
|
} |
|
|
} |
|
|
|
|
|
export interface LoginResponse {} |
|
|
|
|
|
|
|
|
export const authAtom = atom<IAuth>({ |
|
|
export const authAtom = atom<IAuth>({ |
|
|
isLogin: false, |
|
|
isLogin: false, |
|
@ -31,30 +32,30 @@ const devLogin = { |
|
|
export const upLoginFormAtom = atom<UPLoginRequest>({ |
|
|
export const upLoginFormAtom = atom<UPLoginRequest>({ |
|
|
...(isDev ? devLogin : {}), |
|
|
...(isDev ? devLogin : {}), |
|
|
} as UPLoginRequest); |
|
|
} as UPLoginRequest); |
|
|
|
|
|
|
|
|
export const upLoginAtom = atomWithMutation<any, System.LoginRequest>((get) => ({ |
|
|
|
|
|
|
|
|
//============================================================================================================登录 登出
|
|
|
|
|
|
export const upLoginAtom = atomWithMutation<any, UPLoginRequest>((get) => ({ |
|
|
mutationKey: ["uplogin"], |
|
|
mutationKey: ["uplogin"], |
|
|
mutationFn: async (params) => { |
|
|
|
|
|
|
|
|
mutationFn: async (params: UPLoginRequest) => { |
|
|
return await systemServ.uplogin(params); |
|
|
return await systemServ.uplogin(params); |
|
|
}, |
|
|
}, |
|
|
onSuccess: (res) => { |
|
|
onSuccess: (res) => { |
|
|
message.success(t("login.success")); |
|
|
message.success(t("login.success")); |
|
|
// console.log('login success', res)
|
|
|
|
|
|
get(userMenuDataAtom).refetch().then(); |
|
|
get(userMenuDataAtom).refetch().then(); |
|
|
return res.data; |
|
|
return res.data; |
|
|
}, |
|
|
}, |
|
|
retry: false, |
|
|
retry: false, |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const emailCodeAtom = atomWithMutation<any, any>((get) => ({ |
|
|
export const emailCodeAtom = atomWithMutation<any, any>((get) => ({ |
|
|
mutationKey: ["emailCode"], |
|
|
mutationKey: ["emailCode"], |
|
|
mutationFn: async (params) => { |
|
|
mutationFn: async (params) => { |
|
|
return await systemServ.emailCode(params); |
|
|
return await systemServ.emailCode(params); |
|
|
}, |
|
|
}, |
|
|
onSuccess: (res) => { |
|
|
onSuccess: (res) => { |
|
|
message.success(t("login.success")); |
|
|
|
|
|
|
|
|
//message.success(t("login.success"));
|
|
|
// console.log('login success', res)
|
|
|
// console.log('login success', res)
|
|
|
get(userMenuDataAtom).refetch().then(); |
|
|
|
|
|
|
|
|
//get(userMenuDataAtom).refetch().then();
|
|
|
return res.data; |
|
|
return res.data; |
|
|
}, |
|
|
}, |
|
|
retry: false, |
|
|
retry: false, |
|
@ -67,7 +68,6 @@ export const emailLoginAtom = atomWithMutation<any, any>((get) => ({ |
|
|
onSuccess: (res) => { |
|
|
onSuccess: (res) => { |
|
|
message.success(t("login.success")); |
|
|
message.success(t("login.success")); |
|
|
// console.log('login success', res)
|
|
|
// console.log('login success', res)
|
|
|
get(userMenuDataAtom).refetch().then(); |
|
|
|
|
|
return res.data; |
|
|
return res.data; |
|
|
}, |
|
|
}, |
|
|
retry: false, |
|
|
retry: false, |
|
@ -80,7 +80,7 @@ export const logoutAtom = atomWithMutation(() => ({ |
|
|
return true; |
|
|
return true; |
|
|
}, |
|
|
}, |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================================================
|
|
|
export const currentStaticUserAtom = atomWithStorage<IUserInfo | null>("user", null); |
|
|
export const currentStaticUserAtom = atomWithStorage<IUserInfo | null>("user", null); |
|
|
|
|
|
|
|
|
export const currentUserAtom = atomWithQuery<IApiResult<System.IUserInfo>, any, System.IUserInfo>((get) => { |
|
|
export const currentUserAtom = atomWithQuery<IApiResult<System.IUserInfo>, any, System.IUserInfo>((get) => { |
|
|