fix(app): 对齐 release 修复(播放明文HTTP、shared_preferences 降级防崩溃、双网络访问)
This commit is contained in:
1 parent
190e4f9c67
commit
de941c841c
7 files changed
+67
-84
No files matched your search
@@ -39,11 +39,11 @@ abstract final class ServerEndpoint {
|
||||
/// In release builds this returns immediately without reading preferences.
|
||||
static Future<void> load({
|
||||
bool debug = kDebugMode,
|
||||
SharedPreferencesAsync? preferences,
|
||||
SharedPreferences? preferences,
|
||||
}) async {
|
||||
if (!debug) return;
|
||||
try {
|
||||
final prefs = preferences ?? SharedPreferencesAsync();
|
||||
final prefs = preferences ?? await SharedPreferences.getInstance();
|
||||
final stored = await prefs.getString(preferenceKey);
|
||||
AppConfig.applyRuntimeBaseUrl(
|
||||
resolve(
|
||||
@@ -60,12 +60,12 @@ abstract final class ServerEndpoint {
|
||||
/// Persists a normalized runtime endpoint.
|
||||
static Future<bool> save(
|
||||
String raw, {
|
||||
SharedPreferencesAsync? preferences,
|
||||
SharedPreferences? preferences,
|
||||
}) async {
|
||||
final normalized = normalize(raw);
|
||||
if (normalized == null) return false;
|
||||
try {
|
||||
await (preferences ?? SharedPreferencesAsync()).setString(
|
||||
await (preferences ?? await SharedPreferences.getInstance()).setString(
|
||||
preferenceKey,
|
||||
normalized,
|
||||
);
|
||||
@@ -76,9 +76,9 @@ abstract final class ServerEndpoint {
|
||||
}
|
||||
|
||||
/// Removes the persisted runtime endpoint.
|
||||
static Future<void> clear({SharedPreferencesAsync? preferences}) async {
|
||||
static Future<void> clear({SharedPreferences? preferences}) async {
|
||||
try {
|
||||
await (preferences ?? SharedPreferencesAsync()).remove(preferenceKey);
|
||||
await (preferences ?? await SharedPreferences.getInstance()).remove(preferenceKey);
|
||||
} catch (_) {
|
||||
// Clearing an optional developer override is best effort.
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user