feat: add network configuration for mobile testing

This commit is contained in:
张翔
2026-03-05 14:32:46 +08:00
parent 7777675e3e
commit c4d758ad6e
+50
View File
@@ -0,0 +1,50 @@
export interface NetworkConfig {
name: string;
offline: boolean;
downloadThroughput?: number;
uploadThroughput?: number;
latency?: number;
}
export const networkConfigs: Record<string, NetworkConfig> = {
'2g-slow': {
name: '2G Slow',
offline: false,
downloadThroughput: 250 * 1024,
uploadThroughput: 50 * 1024,
latency: 2000,
},
'3g-fast': {
name: '3G Fast',
offline: false,
downloadThroughput: 1.6 * 1024 * 1024,
uploadThroughput: 750 * 1024,
latency: 100,
},
'4g-lte': {
name: '4G LTE',
offline: false,
downloadThroughput: 4 * 1024 * 1024,
uploadThroughput: 3 * 1024 * 1024,
latency: 20,
},
'wifi-fast': {
name: 'WiFi Fast',
offline: false,
downloadThroughput: 30 * 1024 * 1024,
uploadThroughput: 15 * 1024 * 1024,
latency: 2,
},
'offline': {
name: 'Offline',
offline: true,
},
};
export function getNetworkConfig(key: string): NetworkConfig {
return networkConfigs[key] || networkConfigs['wifi-fast'];
}
export function getAllNetworkConfigs(): NetworkConfig[] {
return Object.values(networkConfigs);
}