fix(api): 处理401错误时重定向到登录页
docs(guide): 更新免费计划适用场景的描述
This commit is contained in:
@@ -35,6 +35,20 @@ async function request<T>(method: HttpMethod, path: string, body?: unknown): Pro
|
||||
}
|
||||
if (!res.ok) {
|
||||
const message = data && data.message ? data.message : `请求失败,状态码 ${res.status}`;
|
||||
if (res.status === 401 && (message === 'Token expired or invalid' || message === 'Unauthorized')) {
|
||||
localStorage.removeItem('cwd_admin_token');
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
const url = new URL(window.location.href);
|
||||
url.pathname = '/login';
|
||||
url.search = '';
|
||||
url.hash = '';
|
||||
window.location.href = url.toString();
|
||||
} catch {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error(message);
|
||||
}
|
||||
return data as T;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
| 行写入 | 10 万 | ~2 次/次访问 | 5 万次页面访问 |
|
||||
| 存储 | 5GB | 1-2KB/评论 | 250 万 + 评论 |
|
||||
|
||||
**足以满足以下场景:**
|
||||
**足以满足以下场景:** 对于个人博客或中小型站点来说,免费计划完全够用。
|
||||
|
||||
- 日访问量:30,000 - 50,000 次页面加载
|
||||
- 日评论量:100 - 200 条新评论
|
||||
|
||||
Reference in New Issue
Block a user