feat: 更新了部分依赖包的开发状态标记

This commit is contained in:
zyh
2024-10-22 02:46:31 +00:00
parent 663bc4c3b0
commit cd5b6243a5
14 changed files with 366 additions and 46 deletions

17
app/utils/api.ts Normal file
View File

@@ -0,0 +1,17 @@
export async function authenticatedFetch(url: string, options: RequestInit = {}) {
const token = localStorage.getItem('token');
const headers = {
...options.headers,
'Authorization': `Bearer ${token}`,
};
const response = await fetch(url, { ...options, headers });
if (response.status === 401) {
// Token is invalid or expired
localStorage.removeItem('token');
window.location.href = '/login';
}
return response;
}