chore(auth): 未登录时 /auth/me 返回 loggedIn:false,避免登录页控制台 401 噪音
This commit is contained in:
+3
-3
@@ -284,10 +284,10 @@ a { color: inherit; text-decoration: none; }
|
||||
return '/home.html';
|
||||
}
|
||||
|
||||
// 已登录则直接跳转
|
||||
// 已登录则直接跳转(未登录时接口返回 loggedIn:false,不产生控制台报错)
|
||||
fetch(API_BASE + '/api/v1/auth/me', { credentials: 'include' })
|
||||
.then(function (r) { return r.ok ? r.json() : Promise.reject(); })
|
||||
.then(function () { location.replace(nextUrl()); })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) { if (d && d.ok && d.data && d.data.loggedIn) location.replace(nextUrl()); })
|
||||
.catch(function () { /* 未登录,停留 */ });
|
||||
|
||||
passEl.addEventListener('input', function () { setMsg(''); });
|
||||
|
||||
Reference in New Issue
Block a user