优化评论区/个人中心验证登录态相关逻辑,性能提升

This commit is contained in:
ember 2025-04-11 01:56:03 +08:00
parent 1695864e99
commit 0390dd19fe
9 changed files with 54 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/index.html vendored
View File

@ -1 +1 @@
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>NEU小站</title><script defer="defer" src="/js/chunk-vendors.f3a85c9b.js"></script><script defer="defer" src="/js/app.4a2a4607.js"></script><link href="/css/app.91c3e0f8.css" rel="stylesheet"></head><body><noscript><strong>抱歉NEU小站无法在没有 JavaScript 的情况下正常工作。请启用 JavaScript 以继续。</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>NEU小站</title><script defer="defer" src="/js/chunk-vendors.f3a85c9b.js"></script><script defer="defer" src="/js/app.46a2c1d1.js"></script><link href="/css/app.91c3e0f8.css" rel="stylesheet"></head><body><noscript><strong>抱歉NEU小站无法在没有 JavaScript 的情况下正常工作。请启用 JavaScript 以继续。</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

2
dist/js/614.443c84a6.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,8 @@ export default {
}
try {
const response = await fetch('https://newfront.xn--xhq44jb2fzpc.com/user/info', {
// 使 /islogin token
const response = await fetch('https://newfront.xn--xhq44jb2fzpc.com/user/islogin', {
method: 'GET',
headers: {
'Authorization': token
@ -89,11 +90,20 @@ export default {
});
if (!response.ok) {
throw new Error('获取用户信息失败');
// 2xx ( 401 Unauthorized)
throw new Error('Token 验证失败');
}
//
const data = await response.json();
if (data && data.isLoggedIn) {
this.isAuthenticated = true;
} else {
// response.ok true
//
throw new Error('Token 验证成功但返回状态不正确');
}
const userData = await response.json();
this.isAuthenticated = true;
this.isLoading = false;
// /login/user-center