提交 b96ccbb2 作者: ZhangLingKun

功能:登录问题修复

上级 9aa1dd84
......@@ -11,7 +11,7 @@ const service = axios.create({
service.interceptors.request.use(
(config: any) => {
const token = Cookies.get('SHAREFLY-TOKEN');
const token = Cookies.get('SHAREFLY-WEB-TOKEN');
// console.log('config ==========>', config);
if (token) {
// eslint-disable-next-line no-param-reassign
......@@ -40,7 +40,7 @@ service.interceptors.response.use(
)
) {
message.error(data.message).then();
Cookies.remove('SHAREFLY-TOKEN');
Cookies.remove('SHAREFLY-WEB-TOKEN');
localStorage.removeItem('persist:SHAREFLY-WEB-STORAGE');
setTimeout(() => {
window.location.reload();
......
......@@ -17,6 +17,7 @@ import getLocationByIP from '@/utils/getLocationByIP';
const HeaderView: React.FC<{
placeholder: boolean;
}> = ({ placeholder }) => {
const token = Cookies.get('SHAREFLY-WEB-TOKEN');
// 当前的路由数据
const router = useRouter();
// store
......@@ -41,7 +42,7 @@ const HeaderView: React.FC<{
};
// 获取用户信息
const getAccountInfo = async () => {
if (!system?.token) return;
if (!system?.token || !token) return;
const res = await CommonAPI.getAccountInfo();
if (res && res.code === '200') {
dispatch(setUserInfo(res.result));
......@@ -58,7 +59,7 @@ const HeaderView: React.FC<{
}, []);
// 当前是否登录
useEffect(() => {
if (!system?.token) return;
if (!system?.token || !token) return;
getAccountInfo().then();
}, [system?.token]);
// 右上角按钮
......
......@@ -162,7 +162,7 @@ const LoginModalView = ({
// 设置token
dispatch(setSystem({ token: res.result.token }));
// 设置token
Cookies.set('SHAREFLY-TOKEN', res.result.token);
Cookies.set('SHAREFLY-WEB-TOKEN', res.result.token);
message.success('登录成功');
}
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论