feat;提交管理端和城市合伙人端

This commit is contained in:
ljy
2026-07-05 23:48:20 +08:00
parent fecfc61ec5
commit 569becedaa
73 changed files with 10150 additions and 80 deletions
+8 -1
View File
@@ -9,7 +9,14 @@ export async function request<T>(clientApp: string, path: string, options: Reque
};
if (token) headers.Authorization = `Bearer ${token}`;
const res = await fetch(`${apiBase}${path}`, { ...options, headers });
const json = await res.json();
const json = await res.json().catch(() => ({ code: res.status, message: '网络异常' }));
if (res.status === 401 || json.code === 401) {
clearAuth();
if (typeof window !== 'undefined' && !window.location.pathname.startsWith('/login')) {
window.location.href = '/login';
}
throw new Error(json.message || '登录已过期,请重新登录');
}
if (json.code !== 0) throw new Error(json.message || '请求失败');
return json.data as T;
}