feat: complete TASK-WP0-03 browser gate

This commit is contained in:
suyx
2026-07-27 18:23:20 +08:00
parent dbe3e73b91
commit 878788b1e2
25 changed files with 3227 additions and 21 deletions
+41
View File
@@ -2,6 +2,47 @@
export interface ClientOptions { baseUrl?: string; fetch?: typeof globalThis.fetch; headers?: HeadersInit; }
export async function checkBrowserSupport(body: {
"brands": Array<{
"brand": string;
"version": string;
}>;
"full_version_list": Array<{
"brand": string;
"version": string;
}>;
"platform": string;
}, options: ClientOptions = {}): Promise<{
"app_version": string;
"browser": {
"brand": "Google Chrome" | "Microsoft Edge";
"major": number;
};
"status": "supported";
"supported_browsers": Array<{
"brand": "Google Chrome" | "Microsoft Edge";
"major": number;
}>;
}> {
const request = options.fetch ?? globalThis.fetch;
const headers = new Headers(options.headers);
headers.set("Content-Type", "application/json");
const response = await request(`${options.baseUrl ?? ""}/api/v1/support/check`, { body: JSON.stringify(body), method: "POST", headers });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
return response.json() as Promise<{
"app_version": string;
"browser": {
"brand": "Google Chrome" | "Microsoft Edge";
"major": number;
};
"status": "supported";
"supported_browsers": Array<{
"brand": "Google Chrome" | "Microsoft Edge";
"major": number;
}>;
}>;
}
export async function getBootstrap(options: ClientOptions = {}): Promise<{
"app_version": string;
"dependencies": Array<{