|
@@ -7,16 +7,12 @@ import { State, ReadonlyState, StateAction, LoginStore } from './types';
|
|
|
|
|
|
|
|
// 定义状态
|
|
// 定义状态
|
|
|
const stateGenerator = (): ReadonlyState => ({
|
|
const stateGenerator = (): ReadonlyState => ({
|
|
|
- rememberChecked: false,
|
|
|
|
|
buttonLoading: false,
|
|
buttonLoading: false,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 修改状态
|
|
// 修改状态
|
|
|
const stateActionsGenerator = (state: State): StateAction => {
|
|
const stateActionsGenerator = (state: State): StateAction => {
|
|
|
return {
|
|
return {
|
|
|
- setRememberChecked: (checked) => {
|
|
|
|
|
- state.rememberChecked = checked;
|
|
|
|
|
- },
|
|
|
|
|
setButtonLoading: (loading) => {
|
|
setButtonLoading: (loading) => {
|
|
|
state.buttonLoading = loading;
|
|
state.buttonLoading = loading;
|
|
|
},
|
|
},
|
|
@@ -47,14 +43,14 @@ const useLoginStore = (): LoginStore => {
|
|
|
id: info.user_id,
|
|
id: info.user_id,
|
|
|
name: info.user_name,
|
|
name: info.user_name,
|
|
|
});
|
|
});
|
|
|
- if (state.rememberChecked) {// 记住密码
|
|
|
|
|
- LocalStorage.setAccountPassword({
|
|
|
|
|
- account: data.phone_number,
|
|
|
|
|
- password: data.password,
|
|
|
|
|
- });
|
|
|
|
|
- } else {// 不记住密码
|
|
|
|
|
- LocalStorage.setAccountPassword(undefined);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (state.rememberChecked) {// 记住密码
|
|
|
|
|
+ // LocalStorage.setAccountPassword({
|
|
|
|
|
+ // account: data.account,
|
|
|
|
|
+ // password: data.password,
|
|
|
|
|
+ // });
|
|
|
|
|
+ // } else {// 不记住密码
|
|
|
|
|
+ // LocalStorage.setAccountPassword(undefined);
|
|
|
|
|
+ // }
|
|
|
router.navigate({ pathname: '/' }, { replace: true });
|
|
router.navigate({ pathname: '/' }, { replace: true });
|
|
|
message.success('登录成功');
|
|
message.success('登录成功');
|
|
|
} catch (error: any) {
|
|
} catch (error: any) {
|
|
@@ -66,11 +62,6 @@ const useLoginStore = (): LoginStore => {
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 更改记住密码
|
|
|
|
|
- const onChangeRemember: LoginStore['onChangeRemember'] = (checked) => {
|
|
|
|
|
- actions.setRememberChecked(checked);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
// 点击登录
|
|
// 点击登录
|
|
|
const onClickLogin: LoginStore['onClickLogin'] = async (data) => {
|
|
const onClickLogin: LoginStore['onClickLogin'] = async (data) => {
|
|
|
// 登录
|
|
// 登录
|
|
@@ -84,23 +75,20 @@ const useLoginStore = (): LoginStore => {
|
|
|
form.setFieldsValue({
|
|
form.setFieldsValue({
|
|
|
account: accountPassword.account,
|
|
account: accountPassword.account,
|
|
|
password: accountPassword.password,
|
|
password: accountPassword.password,
|
|
|
|
|
+ remember: true,
|
|
|
});
|
|
});
|
|
|
- actions.setRememberChecked(true);
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 状态重置
|
|
// 状态重置
|
|
|
const reset: LoginStore['reset'] = () => {
|
|
const reset: LoginStore['reset'] = () => {
|
|
|
- const initialRememberChecked = stateGenerator().rememberChecked;
|
|
|
|
|
const initialButtonLoading = stateGenerator().buttonLoading;
|
|
const initialButtonLoading = stateGenerator().buttonLoading;
|
|
|
|
|
|
|
|
- actions.setRememberChecked(initialRememberChecked);
|
|
|
|
|
actions.setButtonLoading(initialButtonLoading);
|
|
actions.setButtonLoading(initialButtonLoading);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
state,
|
|
state,
|
|
|
- onChangeRemember,
|
|
|
|
|
onClickLogin,
|
|
onClickLogin,
|
|
|
init,
|
|
init,
|
|
|
reset
|
|
reset
|