提交 24d917c8 作者: 翁进城

模拟登录改为正式登录

上级 01f1d24c
......@@ -83,7 +83,12 @@ export default function request(url: string, method: String = 'get', data?: any,
}
if (data.code !== '200') {
errMsg(data.message || '请求出错');
//未登录判断
if(data.code === '5008'){
errMsg('请先登录');
}else{
errMsg(data.message || '请求出错');
}
}
return data;
......
......@@ -136,7 +136,7 @@ export default function NavHeader() {
) : (
<Button
type="text"
onClick={() => testLogin()}
onClick={() => setOpenLoginModal(true)}
style={{ fontWeight: "bold", fontSize: 16 }}
>
登录
......
......@@ -62,14 +62,15 @@ export default function LoginModal(props: Props) {
})
.then((res) => {
if (res.code === "200") {
setUserInfo({
...res.result,
id: res.result?.userAccountId,
});
window.messageApi.success("登录成功");
clearInterval(handle);
setTimeHandle(null);
props.onCancel();
window.localStorage.setItem("token", res.result.token);
api.userInfo().then((res) => {
setUserInfo(res.result || "");
window.messageApi.success("登录成功");
props.onCancel();
});
}
});
}, 1000);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论