调整前端目录结构

This commit is contained in:
2025-05-10 12:08:04 +08:00
parent 3c7d84165c
commit 8e09da9912
41 changed files with 2909 additions and 355 deletions

View File

@@ -0,0 +1,27 @@
export interface StanderResponse<T> {
statusCode: number;
message: string;
data?: T;
}
const fetcher = async<T>(url: string, options?: RequestInit): Promise<StanderResponse<T>> => {
const res = await fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
// 自动带上 token
...(typeof window !== 'undefined' && localStorage.getItem('token')
? { Authorization: `Bearer ${localStorage.getItem('token')}` }
: {}),
},
...options,
});
if (!res.ok) {
return await res.json();
}
return await res.json();
}
export default fetcher