Skip to content

Commit

Permalink
将下载dio单独处理
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleafgo committed Nov 18, 2023
1 parent def6de4 commit db423a8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/app/source/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@ class Request {
),
);

final _dio = Dio(
BaseOptions(
headers: {'User-Agent': 'Clash For Flutter'},
connectTimeout: const Duration(seconds: 3),
),
);

Future<Response> downFile({
required String urlPath,
required String savePath,
void Function(int, int)? onReceiveProgress,
}) {
return Dio(BaseOptions(
headers: {'User-Agent': 'Clash For Flutter'},
connectTimeout: const Duration(seconds: 3),
)).download(urlPath, savePath, onReceiveProgress: onReceiveProgress);
return _dio.download(
urlPath,
savePath,
onReceiveProgress: onReceiveProgress,
);
}

/// 下载订阅
Expand Down

0 comments on commit db423a8

Please sign in to comment.