mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-20 09:20:13 +08:00
fix parse dyn
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -23,6 +23,7 @@ import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
|
||||
class DynamicsHttp {
|
||||
static Future<LoadingState<DynamicsDataModel>> followDynamic({
|
||||
@@ -59,8 +60,11 @@ class DynamicsHttp {
|
||||
);
|
||||
}
|
||||
return Success(data);
|
||||
} catch (err) {
|
||||
return Error(err.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
return Error(code == 4101132 ? '没有数据' : res.data['message']);
|
||||
@@ -267,8 +271,11 @@ class DynamicsHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
try {
|
||||
return Success(DynamicItemModel.fromJson(res.data['data']['item']));
|
||||
} catch (err) {
|
||||
return Error(err.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
|
||||
@@ -25,6 +25,7 @@ import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/app_sign.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
|
||||
abstract final class LiveHttp {
|
||||
static Account get recommend => Accounts.get(AccountType.recommend);
|
||||
@@ -659,8 +660,11 @@ abstract final class LiveHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
try {
|
||||
return Success(SuperChatData.fromJson(res.data['data']));
|
||||
} catch (e) {
|
||||
return Error(e.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:encrypt/encrypt.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
|
||||
class LoginHttp {
|
||||
static final String deviceId = LoginUtils.genDeviceId();
|
||||
@@ -46,8 +47,11 @@ class LoginHttp {
|
||||
try {
|
||||
final Map<String, dynamic> data = res.data['data'];
|
||||
return Success((authCode: data['auth_code'], url: data['url']));
|
||||
} catch (e) {
|
||||
return Error(e.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
return Error(res.data['message']);
|
||||
|
||||
@@ -29,6 +29,7 @@ import 'package:PiliPlus/utils/app_sign.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
|
||||
class MemberHttp {
|
||||
static Future reportMember(
|
||||
@@ -430,8 +431,11 @@ class MemberHttp {
|
||||
return memberDynamic(offset: data.offset, mid: mid);
|
||||
}
|
||||
return Success(data);
|
||||
} catch (err) {
|
||||
return Error(err.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
Map errMap = const {
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:PiliPlus/utils/extension.dart';
|
||||
import 'package:PiliPlus/utils/request_utils.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
|
||||
@@ -118,9 +119,11 @@ class SearchHttp {
|
||||
// break;
|
||||
}
|
||||
return Success(data);
|
||||
} catch (err) {
|
||||
debugPrint(err.toString());
|
||||
return Error(err.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
return Error(resData['message'], code: resData['code']);
|
||||
@@ -164,9 +167,11 @@ class SearchHttp {
|
||||
if (res.data['code'] == 0) {
|
||||
try {
|
||||
return Success(SearchAllData.fromJson(res.data['data']));
|
||||
} catch (err) {
|
||||
debugPrint(err.toString());
|
||||
return Error(err.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
} else {
|
||||
return Error(res.data['message'] ?? '没有相关数据');
|
||||
|
||||
@@ -33,7 +33,7 @@ import 'package:PiliPlus/utils/recommend_filter.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode, compute;
|
||||
|
||||
/// view层根据 status 判断渲染逻辑
|
||||
class VideoHttp {
|
||||
@@ -256,8 +256,11 @@ class VideoHttp {
|
||||
);
|
||||
}
|
||||
return Error(_parseVideoErr(res.data['code'], res.data['message']));
|
||||
} catch (err) {
|
||||
return Error(err.toString());
|
||||
} catch (e, s) {
|
||||
if (kDebugMode) {
|
||||
rethrow;
|
||||
}
|
||||
return Error('$e\n\n$s');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/models/model_video.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
|
||||
part 'model_owner.g.dart';
|
||||
@@ -20,7 +21,7 @@ class Owner implements BaseOwner {
|
||||
String? face;
|
||||
|
||||
Owner.fromJson(Map<String, dynamic> json) {
|
||||
mid = json["mid"];
|
||||
mid = Utils.safeToInt(json["mid"]);
|
||||
name = json["name"];
|
||||
face = json['face'];
|
||||
}
|
||||
|
||||
@@ -25,6 +25,13 @@ abstract class Utils {
|
||||
static final bool isDesktop =
|
||||
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
||||
|
||||
static int? safeToInt(dynamic value) => switch (value) {
|
||||
int e => e,
|
||||
String e => int.tryParse(e),
|
||||
num e => e.toInt(),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
static Future<bool> get isWiFi async {
|
||||
try {
|
||||
return Utils.isMobile &&
|
||||
|
||||
Reference in New Issue
Block a user