2026-05-11 12:06:17 +08:00
|
|
|
|
function trimTrailingSlashes(value: string): string {
|
|
|
|
|
|
return value.replace(/\/+$/, '');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-19 01:12:17 +08:00
|
|
|
|
export const config = {
|
2026-05-11 12:06:17 +08:00
|
|
|
|
apiBaseUrl: trimTrailingSlashes(
|
|
|
|
|
|
process.env.EXPO_PUBLIC_API_URL ?? 'http://192.168.10.151:8000',
|
|
|
|
|
|
),
|
|
|
|
|
|
wsBaseUrl: trimTrailingSlashes(
|
|
|
|
|
|
process.env.EXPO_PUBLIC_WS_URL ?? 'ws://192.168.10.151:8000',
|
|
|
|
|
|
),
|
2026-03-19 01:12:17 +08:00
|
|
|
|
isDebugMode: __DEV__,
|
|
|
|
|
|
|
|
|
|
|
|
api: {
|
|
|
|
|
|
timeoutMs: 30_000,
|
|
|
|
|
|
refreshPath: '/api/auth/refresh',
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
ws: {
|
|
|
|
|
|
reconnectMaxRetries: 10,
|
|
|
|
|
|
reconnectBaseDelayMs: 1_000,
|
|
|
|
|
|
reconnectMaxDelayMs: 30_000,
|
|
|
|
|
|
heartbeatIntervalMs: 30_000,
|
2026-05-13 17:12:08 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 仅当 App 处于 `background` 连续超过该毫秒数才释放当前会话 WebSocket。
|
|
|
|
|
|
* 短暂切到其它应用再返回时保持连接,避免反复重连。
|
|
|
|
|
|
*/
|
|
|
|
|
|
backgroundDisconnectAfterMs: 300_000,
|
2026-03-19 01:12:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
} as const;
|