This commit is contained in:
zhutao
2025-08-22 14:15:02 +08:00
parent 5853bdf004
commit 99a1ce601e
120 changed files with 5297 additions and 101 deletions

13
lib/api/network/safe.dart Normal file
View File

@@ -0,0 +1,13 @@
import 'package:dio/dio.dart';
/// 网络请求的错误处理封装
Future<T> safeRequest<T>(Future<T> request, {
void Function(DioException error)? onError,
}) async {
try {
return await request;
} on DioException catch (e) {
onError?.call(e); // 额外 hook
rethrow; // 继续往上传
}
}