This commit is contained in:
1 parent
925a9be18e
commit
ca85b66e87
5 files changed
+85
-52
No files matched your search
@@ -10,6 +10,9 @@ abstract final class ServerEndpoint {
|
||||
/// Preference key used for the runtime server address.
|
||||
static const String preferenceKey = 'dev.api_base_url';
|
||||
|
||||
/// 地址迁移前的开发机默认值;UAT 启动时不能继续使用它。
|
||||
static const String legacyLocalBaseUrl = 'http://192.168.31.120:8081';
|
||||
|
||||
/// Returns a normalized http(s) URL, or null for invalid input.
|
||||
static String? normalize(String? raw) {
|
||||
final value = raw?.trim() ?? '';
|
||||
@@ -38,8 +41,15 @@ abstract final class ServerEndpoint {
|
||||
try {
|
||||
final prefs = preferences ?? SharedPreferencesAsync();
|
||||
final stored = await prefs.getString(preferenceKey);
|
||||
final normalizedStored = normalize(stored);
|
||||
if (normalizedStored == legacyLocalBaseUrl &&
|
||||
normalize(AppConfig.baseUrl) != legacyLocalBaseUrl) {
|
||||
await prefs.remove(preferenceKey);
|
||||
AppConfig.clearRuntimeBaseUrl();
|
||||
return;
|
||||
}
|
||||
AppConfig.applyRuntimeBaseUrl(
|
||||
resolve(stored: stored, fallback: AppConfig.baseUrl),
|
||||
resolve(stored: normalizedStored, fallback: AppConfig.baseUrl),
|
||||
);
|
||||
} catch (_) {
|
||||
AppConfig.clearRuntimeBaseUrl();
|
||||
|
||||
Reference in new issue
Block a user