mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 16:18:22 +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/utils.dart';
|
||||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
|
|
||||||
class DynamicsHttp {
|
class DynamicsHttp {
|
||||||
static Future<LoadingState<DynamicsDataModel>> followDynamic({
|
static Future<LoadingState<DynamicsDataModel>> followDynamic({
|
||||||
@@ -59,8 +60,11 @@ class DynamicsHttp {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Success(data);
|
return Success(data);
|
||||||
} catch (err) {
|
} catch (e, s) {
|
||||||
return Error(err.toString());
|
if (kDebugMode) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Error(code == 4101132 ? '没有数据' : res.data['message']);
|
return Error(code == 4101132 ? '没有数据' : res.data['message']);
|
||||||
@@ -267,8 +271,11 @@ class DynamicsHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
try {
|
try {
|
||||||
return Success(DynamicItemModel.fromJson(res.data['data']['item']));
|
return Success(DynamicItemModel.fromJson(res.data['data']['item']));
|
||||||
} catch (err) {
|
} catch (e, s) {
|
||||||
return Error(err.toString());
|
if (kDebugMode) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Error(res.data['message']);
|
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/app_sign.dart';
|
||||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
|
|
||||||
abstract final class LiveHttp {
|
abstract final class LiveHttp {
|
||||||
static Account get recommend => Accounts.get(AccountType.recommend);
|
static Account get recommend => Accounts.get(AccountType.recommend);
|
||||||
@@ -659,8 +660,11 @@ abstract final class LiveHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
try {
|
try {
|
||||||
return Success(SuperChatData.fromJson(res.data['data']));
|
return Success(SuperChatData.fromJson(res.data['data']));
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
return Error(e.toString());
|
if (kDebugMode) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Error(res.data['message']);
|
return Error(res.data['message']);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:PiliPlus/utils/utils.dart';
|
|||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:encrypt/encrypt.dart';
|
import 'package:encrypt/encrypt.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
|
|
||||||
class LoginHttp {
|
class LoginHttp {
|
||||||
static final String deviceId = LoginUtils.genDeviceId();
|
static final String deviceId = LoginUtils.genDeviceId();
|
||||||
@@ -46,8 +47,11 @@ class LoginHttp {
|
|||||||
try {
|
try {
|
||||||
final Map<String, dynamic> data = res.data['data'];
|
final Map<String, dynamic> data = res.data['data'];
|
||||||
return Success((authCode: data['auth_code'], url: data['url']));
|
return Success((authCode: data['auth_code'], url: data['url']));
|
||||||
} catch (e) {
|
} catch (e, s) {
|
||||||
return Error(e.toString());
|
if (kDebugMode) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Error(res.data['message']);
|
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/utils.dart';
|
||||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
|
|
||||||
class MemberHttp {
|
class MemberHttp {
|
||||||
static Future reportMember(
|
static Future reportMember(
|
||||||
@@ -430,8 +431,11 @@ class MemberHttp {
|
|||||||
return memberDynamic(offset: data.offset, mid: mid);
|
return memberDynamic(offset: data.offset, mid: mid);
|
||||||
}
|
}
|
||||||
return Success(data);
|
return Success(data);
|
||||||
} catch (err) {
|
} catch (e, s) {
|
||||||
return Error(err.toString());
|
if (kDebugMode) {
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Map errMap = const {
|
Map errMap = const {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import 'package:PiliPlus/utils/extension.dart';
|
|||||||
import 'package:PiliPlus/utils/request_utils.dart';
|
import 'package:PiliPlus/utils/request_utils.dart';
|
||||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
|
|
||||||
@@ -118,9 +119,11 @@ class SearchHttp {
|
|||||||
// break;
|
// break;
|
||||||
}
|
}
|
||||||
return Success(data);
|
return Success(data);
|
||||||
} catch (err) {
|
} catch (e, s) {
|
||||||
debugPrint(err.toString());
|
if (kDebugMode) {
|
||||||
return Error(err.toString());
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Error(resData['message'], code: resData['code']);
|
return Error(resData['message'], code: resData['code']);
|
||||||
@@ -164,9 +167,11 @@ class SearchHttp {
|
|||||||
if (res.data['code'] == 0) {
|
if (res.data['code'] == 0) {
|
||||||
try {
|
try {
|
||||||
return Success(SearchAllData.fromJson(res.data['data']));
|
return Success(SearchAllData.fromJson(res.data['data']));
|
||||||
} catch (err) {
|
} catch (e, s) {
|
||||||
debugPrint(err.toString());
|
if (kDebugMode) {
|
||||||
return Error(err.toString());
|
rethrow;
|
||||||
|
}
|
||||||
|
return Error('$e\n\n$s');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Error(res.data['message'] ?? '没有相关数据');
|
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/storage_pref.dart';
|
||||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||||
import 'package:dio/dio.dart';
|
import 'package:dio/dio.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart' show kDebugMode, compute;
|
||||||
|
|
||||||
/// view层根据 status 判断渲染逻辑
|
/// view层根据 status 判断渲染逻辑
|
||||||
class VideoHttp {
|
class VideoHttp {
|
||||||
@@ -256,8 +256,11 @@ class VideoHttp {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Error(_parseVideoErr(res.data['code'], res.data['message']));
|
return Error(_parseVideoErr(res.data['code'], res.data['message']));
|
||||||
} catch (err) {
|
} catch (e, s) {
|
||||||
return Error(err.toString());
|
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/models/model_video.dart';
|
||||||
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
|
||||||
part 'model_owner.g.dart';
|
part 'model_owner.g.dart';
|
||||||
@@ -20,7 +21,7 @@ class Owner implements BaseOwner {
|
|||||||
String? face;
|
String? face;
|
||||||
|
|
||||||
Owner.fromJson(Map<String, dynamic> json) {
|
Owner.fromJson(Map<String, dynamic> json) {
|
||||||
mid = json["mid"];
|
mid = Utils.safeToInt(json["mid"]);
|
||||||
name = json["name"];
|
name = json["name"];
|
||||||
face = json['face'];
|
face = json['face'];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ abstract class Utils {
|
|||||||
static final bool isDesktop =
|
static final bool isDesktop =
|
||||||
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
|
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 {
|
static Future<bool> get isWiFi async {
|
||||||
try {
|
try {
|
||||||
return Utils.isMobile &&
|
return Utils.isMobile &&
|
||||||
|
|||||||
Reference in New Issue
Block a user