Skip to content

Commit 794be44

Browse files
committed
异常提示
1 parent 29d326c commit 794be44

14 files changed

+78
-1609
lines changed

.gitignore

+52-48
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
1-
# Miscellaneous
2-
*.class
3-
*.log
4-
*.pyc
5-
*.swp
6-
.DS_Store
7-
.atom/
8-
.buildlog/
9-
.history
10-
.svn/
11-
migrate_working_dir/
12-
13-
# IntelliJ related
14-
*.iml
15-
*.ipr
16-
*.iws
17-
.idea/
18-
19-
# The .vscode folder contains launch configuration and tasks you configure in
20-
# VS Code which you may wish to be included in version control, so this line
21-
# is commented out by default.
22-
#.vscode/
23-
24-
# Flutter/Dart/Pub related
25-
**/doc/api/
26-
**/ios/Flutter/.last_build_id
27-
.dart_tool/
28-
.flutter-plugins
29-
.flutter-plugins-dependencies
30-
.packages
31-
.pub-cache/
32-
.pub/
33-
/build/
34-
35-
# Symbolication related
36-
app.*.symbols
37-
38-
# Obfuscation related
39-
app.*.map.json
40-
41-
# Android Studio will place build artifacts here
42-
/android/app/debug
43-
/android/app/profile
44-
/android/app/release
45-
/ios/DerivedData/
46-
/ios/Pods/
47-
/macos/DerivedData/
48-
/macos/Pods/
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
pubspec.lock
35+
36+
# Symbolication related
37+
app.*.symbols
38+
39+
# Obfuscation related
40+
app.*.map.json
41+
42+
# Android Studio will place build artifacts here
43+
/android/app/debug
44+
/android/app/profile
45+
/android/app/release
46+
/android/local.properties
47+
/ios/DerivedData/
48+
/ios/Pods/
49+
/ios/Podfile.lock
50+
/macos/DerivedData/
51+
/macos/Pods/
52+
/macos/Podfile.lock

android/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ GeneratedPluginRegistrant.java
1111
key.properties
1212
**/*.keystore
1313
**/*.jks
14+
/app/local.properties

android/app/local.properties

-8
This file was deleted.
52.4 KB
Binary file not shown.

android/local.properties

-5
This file was deleted.

ios/Podfile.lock

-187
This file was deleted.

lib/http/http_request.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'dart:io';
44
import 'package:flutter/cupertino.dart';
55
import 'package:http/http.dart' as http;
66
import 'package:package_info_plus/package_info_plus.dart';
7+
import 'package:tubesavely/http/request_exception.dart';
78

89
import '../utils/constants.dart';
910
import 'extend_http_client.dart';
@@ -12,14 +13,14 @@ class HttpRequest {
1213
static final SafeHttpClient _httpClient = SafeHttpClient(http.Client());
1314

1415
static Future<dynamic> request<T>(String url, T Function(dynamic) fromJson,
15-
{method = 'GET', Map<String, dynamic>? params, Function(Object)? exception}) async {
16+
{method = 'GET', Map<String, dynamic>? params, Function(RequestException)? exception}) async {
1617
PackageInfo packageInfo = await PackageInfo.fromPlatform();
1718
var headers = {
1819
'appName': packageInfo.appName,
1920
'platform': Platform.operatingSystem,
2021
'version': packageInfo.version,
2122
'buildNumber': packageInfo.buildNumber,
22-
'systemVersion': Platform.operatingSystemVersion,
23+
// 'systemVersion': Platform.operatingSystemVersion,
2324
};
2425
http.Response? response;
2526

@@ -46,13 +47,12 @@ class HttpRequest {
4647
return fromJson(data);
4748
}
4849
} else {
49-
return fromJson('');
50+
exception?.call(RequestException(content['code'], errorMessage));
5051
}
5152
} catch (e) {
5253
debugPrint(e.toString());
5354
errorMessage = 'server internal exception';
54-
exception?.call(e);
55+
exception?.call(RequestException(-1, errorMessage));
5556
}
56-
throw Exception(errorMessage);
5757
}
5858
}

lib/http/request_exception.dart

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class RequestException implements Exception {
2+
final int code;
3+
final String message;
4+
5+
RequestException(this.code, this.message);
6+
}

lib/screen/desktop/pages/download_page.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ class _DownloadPageState extends State<DownloadPage> with AutomaticKeepAliveClie
4040
Urls.shortVideoParse,
4141
params: {'url': url},
4242
(jsonData) => VideoModel.fromJson(jsonData),
43-
exception: (e) => {debugPrint('parse exception $e'), ToastUtil.error(S.current.toastVideoExecuteError)});
43+
exception: (e) => {
44+
debugPrint('parse exception $e'),
45+
if (e.code == 401) {ToastUtil.error(e.message)} else {ToastUtil.error(S.current.toastVideoExecuteError)}
46+
});
4447

4548
setState(() {
4649
videoModelList.add(videoModel);

lib/screen/mobile/pages/video_detail_page.dart

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
33
import 'package:media_kit/media_kit.dart';
44
import 'package:media_kit_video/media_kit_video.dart';
55
import 'package:tubesavely/core/downloader/downloader.dart';
6+
import 'package:tubesavely/generated/l10n.dart';
67
import 'package:tubesavely/http/http_request.dart';
78
import 'package:tubesavely/model/pair.dart';
89
import 'package:tubesavely/model/video_model.dart';
@@ -15,6 +16,8 @@ import 'package:tubesavely/widget/iconed_button.dart';
1516
import 'package:tubesavely/widget/progress_button.dart';
1617
import 'package:tubesavely/widget/radio_group.dart';
1718

19+
import '../../../utils/toast_util.dart';
20+
1821
class VideoDetailPage extends StatefulWidget {
1922
final String? url;
2023

@@ -46,7 +49,11 @@ class _VideoDetailPagePageState extends State<VideoDetailPage> with SingleTicker
4649
Urls.shortVideoParse,
4750
params: {'url': url},
4851
(jsonData) => VideoModel.fromJson(jsonData),
49-
exception: (e) => {debugPrint('parse exception $e')});
52+
exception: (e) => {
53+
debugPrint('parse exception $e'),
54+
if (e.code == 401) {ToastUtil.error(e.message)} else {ToastUtil.error(S.current.toastVideoExecuteError)},
55+
Navigator.pop(context)
56+
});
5057

5158
setState(() {
5259
//过滤全部全部视频

0 commit comments

Comments
 (0)