feat: add google oauth

This commit is contained in:
liuyuanchuang
2026-03-06 14:30:30 +08:00
parent bc4b547e03
commit f70a9a85c8
24 changed files with 3593 additions and 334 deletions

View File

@@ -73,6 +73,7 @@ export class ApiError extends Error {
*/
interface RequestConfig extends RequestInit {
skipAuth?: boolean;
successCodes?: number[];
}
/**
@@ -82,7 +83,7 @@ async function request<T>(
endpoint: string,
config: RequestConfig = {}
): Promise<ApiResponse<T>> {
const { skipAuth = false, headers: customHeaders, ...restConfig } = config;
const { skipAuth = false, successCodes = [200], headers: customHeaders, ...restConfig } = config;
const headers: HeadersInit = {
'Content-Type': 'application/json',
@@ -108,7 +109,7 @@ async function request<T>(
const data: ApiResponse<T> = await response.json();
// 统一处理业务错误
if (data.code !== 200) {
if (!successCodes.includes(data.code)) {
throw new ApiError(data.code, data.message, data.request_id);
}
@@ -153,4 +154,3 @@ export const http = {
};
export default http;