refactor(config): 服务地址改为 dev/prod 配置文件与单个环境开关
启动时按环回、局域网、公网顺序探测地址,换网络后会静默切到别处,排查 困难。改为代码内一个布尔开关选择环境,地址分别放在 dev_config.dart 与 prod_config.dart,不再探测;调试条改地址后直接重载,不再重新探测。 release 构建若仍是开发开关会启动即报错,避免线上包连开发机。
This commit is contained in:
1 parent
57f84c45bd
commit
a6d6b66d31
13 files changed
+101
-382
No files matched your search
@@ -10,7 +10,6 @@ import 'package:provider/provider.dart';
|
||||
import '../../core/data/models/drama.dart';
|
||||
import '../../core/data/repositories/catalog_repository.dart';
|
||||
import '../../core/data/repositories/search_repository.dart';
|
||||
import '../../core/data/services/catalog_retry.dart';
|
||||
import '../../core/data/services/category_controller.dart';
|
||||
import '../../core/data/services/theater_feed_controller.dart';
|
||||
import '../../core/formatting/error_text.dart';
|
||||
@@ -408,15 +407,11 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
||||
);
|
||||
|
||||
Future<void> _retryCategories(CategoryController categories) {
|
||||
return retryCatalogLoad(reload: categories.load);
|
||||
return categories.load();
|
||||
}
|
||||
|
||||
Future<void> _retryTheater() async {
|
||||
await retryCatalogLoad(
|
||||
reload: () async {
|
||||
await theater.refreshCurrent();
|
||||
},
|
||||
);
|
||||
Future<void> _retryTheater() {
|
||||
return theater.refreshCurrent();
|
||||
}
|
||||
|
||||
Future<void> _editTheaterEndpoint() {
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../core/config/app_config.dart';
|
||||
import '../../core/data/remote/catalog_api.dart';
|
||||
import '../../core/data/services/home_feed_controller.dart';
|
||||
import '../../core/data/services/catalog_controller.dart';
|
||||
@@ -67,7 +66,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
) async {
|
||||
_resumeRetryInFlight = true;
|
||||
try {
|
||||
await AppConfig.probeAndApplyBaseUrl();
|
||||
// 地址是构建期常量,回前台只需要重试失败的数据请求。
|
||||
await Future.wait([
|
||||
if (catalog.error != null) catalog.load(),
|
||||
if (categories.error != null) categories.load(),
|
||||
@@ -80,10 +79,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final catalog = context.watch<CatalogController>();
|
||||
return Theme(
|
||||
data: AppTheme.dark(),
|
||||
child: _buildHome(context, catalog),
|
||||
);
|
||||
return Theme(data: AppTheme.dark(), child: _buildHome(context, catalog));
|
||||
}
|
||||
|
||||
Widget _buildHome(BuildContext context, CatalogController catalog) {
|
||||
|
||||
Reference in new issue
Block a user