perf(app): 添加登录状态检查并优化性能
- 在多个页面添加 isLoggedIn 检查,防止未登录时进行不必要的数据获取 - 使用 React.memo 和 useMemo 优化个人页面徽章渲染性能 - 为 badges API 添加节流机制,避免频繁请求 - 优化图片缓存策略和字符串处理 - 移除调试日志并改进推送通知的认证检查
This commit is contained in:
@@ -118,6 +118,7 @@ async function doFetch<T>(path: string, options: ApiRequestOptions = {}): Promis
|
||||
if (token) {
|
||||
headers['Authorization'] = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: options.method ?? 'GET',
|
||||
@@ -128,8 +129,6 @@ async function doFetch<T>(path: string, options: ApiRequestOptions = {}): Promis
|
||||
|
||||
const json = await response.json()
|
||||
|
||||
console.log('json', json);
|
||||
|
||||
if (!response.ok) {
|
||||
// 检查是否为401未授权
|
||||
if (response.status === 401) {
|
||||
|
||||
Reference in New Issue
Block a user