feat: enable Windows app internet access and improve server discovery

This commit is contained in:
ssbg04 committed 2026-07-26 13:19:59 +08:00
1 parent 443a930b57
commit aebfeca342
5 files changed
+52 -19

No files matched your search

+2 -2
View File
@@ -2,8 +2,8 @@ class ApiConstants {
static const int port = 18484;
// Runtime-mutable base URL — set by ServerDiscoveryService before first use.
// Default: localhost for Windows desktop, Android will discover via LAN scan.
static String _baseUrl = 'http://127.0.0.1:$port/api';
// Default: remote internet/configured server IP or domain.
static String _baseUrl = 'http://198.252.107.197:$port/api';
static String get baseUrl => _baseUrl;
@@ -33,9 +33,12 @@ class ServerDiscoveryService {
static Future<bool> ping(String baseUrl) async {
try {
final rootUrl = baseUrl
.replaceAll(RegExp(r'/+$'), '')
.replaceAll(RegExp(r'/api$'), '');
final dio = Dio(
BaseOptions(
baseUrl: baseUrl,
baseUrl: rootUrl,
connectTimeout: _pingTimeout,
receiveTimeout: _pingTimeout,
),