opt: notify-debugger-on-exception (#1750)

This commit is contained in:
My-Responsitories
2025-11-17 21:49:36 +08:00
committed by GitHub
parent 76c2de4394
commit 0f8166620e
14 changed files with 37 additions and 74 deletions

View File

@@ -23,9 +23,9 @@ 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 {
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<DynamicsDataModel>> followDynamic({
DynamicsTabType type = DynamicsTabType.all,
String? offset,
@@ -61,9 +61,6 @@ class DynamicsHttp {
}
return Success(data);
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {
@@ -246,6 +243,7 @@ class DynamicsHttp {
}
//
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<DynamicItemModel>> dynamicDetail({
dynamic id,
dynamic rid,
@@ -272,9 +270,6 @@ class DynamicsHttp {
try {
return Success(DynamicItemModel.fromJson(res.data['data']['item']));
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {

View File

@@ -25,7 +25,6 @@ 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);
@@ -620,8 +619,9 @@ abstract final class LiveHttp {
}
}
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<SuperChatData>> superChatMsg(
dynamic roomId,
Object roomId,
) async {
var res = await Request().get(
Api.superChatMsg,
@@ -633,9 +633,6 @@ abstract final class LiveHttp {
try {
return Success(SuperChatData.fromJson(res.data['data']));
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {

View File

@@ -14,7 +14,6 @@ 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();
@@ -31,6 +30,7 @@ class LoginHttp {
'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
};
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<({String authCode, String url})>>
getHDcode() async {
var params = {
@@ -48,9 +48,6 @@ class LoginHttp {
final Map<String, dynamic> data = res.data['data'];
return Success((authCode: data['auth_code'], url: data['url']));
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {

View File

@@ -29,7 +29,6 @@ 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(
@@ -393,6 +392,7 @@ class MemberHttp {
}
// 用户动态
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<DynamicsDataModel>> memberDynamic({
String? offset,
int? mid,
@@ -432,9 +432,6 @@ class MemberHttp {
}
return Success(data);
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {

View File

@@ -14,7 +14,6 @@ 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';
@@ -44,6 +43,7 @@ class SearchHttp {
}
// 分类搜索
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<R>> searchByType<R extends SearchNumData>({
required SearchType searchType,
required String keyword,
@@ -120,9 +120,6 @@ class SearchHttp {
}
return Success(data);
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {
@@ -133,6 +130,7 @@ class SearchHttp {
}
}
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<SearchAllData>> searchAll({
required String keyword,
required page,
@@ -168,9 +166,6 @@ class SearchHttp {
try {
return Success(SearchAllData.fromJson(res.data['data']));
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
} else {

View File

@@ -34,7 +34,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' show kDebugMode, compute;
import 'package:flutter/foundation.dart' show compute;
/// view层根据 status 判断渲染逻辑
class VideoHttp {
@@ -188,6 +188,7 @@ class VideoHttp {
}
// 视频流
@pragma('vm:notify-debugger-on-exception')
static Future<LoadingState<PlayUrlModel>> videoUrl({
int? avid,
String? bvid,
@@ -259,9 +260,6 @@ class VideoHttp {
}
return Error(_parseVideoErr(res.data['code'], res.data['message']));
} catch (e, s) {
if (kDebugMode) {
rethrow;
}
return Error('$e\n\n$s');
}
}

View File

@@ -26,7 +26,6 @@ import 'package:PiliPlus/utils/utils.dart';
import 'package:PiliPlus/utils/video_utils.dart';
import 'package:canvas_danmaku/canvas_danmaku.dart';
import 'package:easy_debounce/easy_throttle.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
@@ -229,6 +228,7 @@ class LiveRoomController extends GetxController {
_msgStream = null;
}
@pragma('vm:notify-debugger-on-exception')
Future<void> prefetch() async {
final res = await LiveHttp.liveRoomDanmaPrefetch(roomId: roomId);
if (res['status']) {
@@ -238,9 +238,7 @@ class LiveRoomController extends GetxController {
list.cast<Map<String, dynamic>>().map(DanmakuMsg.fromPrefetch),
);
WidgetsBinding.instance.addPostFrameCallback(scrollToBottom);
} catch (e) {
if (kDebugMode) debugPrint(e.toString());
}
} catch (_) {}
}
}
}
@@ -337,6 +335,7 @@ class LiveRoomController extends GetxController {
..init();
}
@pragma('vm:notify-debugger-on-exception')
void _danmakuListener(dynamic obj) {
try {
// logger.i(' 原始弹幕消息 ======> ${jsonEncode(obj)}');
@@ -407,9 +406,7 @@ class LiveRoomController extends GetxController {
}
break;
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
final RxInt likeClickTime = 0.obs;

View File

@@ -190,6 +190,7 @@ class VideoDetailController extends GetxController
}
}
@pragma('vm:notify-debugger-on-exception')
void setVideoHeight() {
try {
final isVertical = firstVideo.width != null && firstVideo.height != null
@@ -243,9 +244,7 @@ class VideoDetailController extends GetxController
animationController.forward(from: 1 - scrollCtr.offset / videoHeight);
}
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
void scrollListener() {
@@ -1992,6 +1991,7 @@ class VideoDetailController extends GetxController
);
}
@pragma('vm:notify-debugger-on-exception')
Future<void> onCast() async {
SmartDialog.showLoading();
final res = await VideoHttp.tvPlayUrl(
@@ -2021,9 +2021,7 @@ class VideoDetailController extends GetxController
tag: heroTag,
).videoDetail.value.title;
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
if (kDebugMode) {
debugPrint(title);
}

View File

@@ -209,6 +209,7 @@ class _DownloadPanelState extends State<DownloadPanel> {
}
late final int? vipStatus = Pref.userInfoCache?.vipStatus;
@pragma('vm:notify-debugger-on-exception')
bool _onDownload({
required int index,
required ugc.BaseEpisodeItem episode,

View File

@@ -9,7 +9,6 @@ import 'package:PiliPlus/utils/request_utils.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart';
import 'package:fixnum/fixnum.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:get/get.dart';
@@ -102,6 +101,7 @@ class VideoReplyReplyController extends ReplyController
ExtendedNestedScrollController? nestedController;
@pragma('vm:notify-debugger-on-exception')
void jumpToItem(int index) {
SchedulerBinding.instance.addPostFrameCallback((_) {
animController.forward(from: 0);
@@ -115,9 +115,7 @@ class VideoReplyReplyController extends ReplyController
scrollController.jumpTo(offset);
}
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
});
}

View File

@@ -4,11 +4,11 @@ import 'dart:io';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:auto_orientation/auto_orientation.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:flutter/services.dart';
bool _isDesktopFullScreen = false;
@pragma('vm:notify-debugger-on-exception')
Future<void> enterDesktopFullscreen({bool inAppFullScreen = false}) async {
if (!inAppFullScreen && !_isDesktopFullScreen) {
_isDesktopFullScreen = true;
@@ -16,12 +16,11 @@ Future<void> enterDesktopFullscreen({bool inAppFullScreen = false}) async {
await const MethodChannel(
'com.alexmercerind/media_kit_video',
).invokeMethod('Utils.EnterNativeFullscreen');
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
}
@pragma('vm:notify-debugger-on-exception')
Future<void> exitDesktopFullscreen() async {
if (_isDesktopFullScreen) {
_isDesktopFullScreen = false;
@@ -29,19 +28,16 @@ Future<void> exitDesktopFullscreen() async {
await const MethodChannel(
'com.alexmercerind/media_kit_video',
).invokeMethod('Utils.ExitNativeFullscreen');
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
}
//横屏
@pragma('vm:notify-debugger-on-exception')
Future<void> landscape() async {
try {
await AutoOrientation.landscapeAutoMode(forceSensor: true);
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
//竖屏

View File

@@ -73,6 +73,7 @@ class DownloadService extends GetxService {
..sort((a, b) => b.timeUpdateStamp.compareTo(a.timeUpdateStamp));
}
@pragma('vm:notify-debugger-on-exception')
Future<List<BiliDownloadEntryInfo>> _readDownloadDirectory(
Directory pageDir,
) async {
@@ -95,9 +96,7 @@ class DownloadService extends GetxService {
if (!entry.isCompleted) {
waitDownloadQueue.add(entry..status = DownloadStatus.wait);
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
}
}

View File

@@ -210,6 +210,7 @@ class LiveMessageStream {
}
}
@pragma('vm:notify-debugger-on-exception')
void _processingData(List<int> data) {
try {
final subHeader = PackageHeaderRes.fromBytesData(
@@ -226,9 +227,7 @@ class LiveMessageStream {
_processingData(data.sublist(subHeader.totalSize));
}
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
Future<void> _heartBeat() async {
@@ -267,6 +266,7 @@ class LiveMessageStream {
_eventListeners.add(func);
}
@pragma('vm:notify-debugger-on-exception')
void onData(dynamic data) {
final header = PackageHeaderRes.fromBytesData(data as Uint8List);
if (header != null) {
@@ -292,9 +292,7 @@ class LiveMessageStream {
//debugPrint('Body: ${utf8.decode()}');
}
_processingData(decompressedData);
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
}

View File

@@ -4,11 +4,11 @@ import 'dart:io';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
import 'package:path_provider/path_provider.dart';
abstract class CacheManager {
// 获取缓存目录
@pragma('vm:notify-debugger-on-exception')
static Future<int> loadApplicationCache([
final num maxSize = double.infinity,
]) async {
@@ -25,13 +25,12 @@ abstract class CacheManager {
if (tempDirectory.existsSync()) {
return await getTotalSizeOfFilesInDir(tempDirectory, maxSize);
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
return 0;
}
// 循环计算文件的大小
@pragma('vm:notify-debugger-on-exception')
static Future<int> getTotalSizeOfFilesInDir(
final Directory file, [
final num maxSize = double.infinity,
@@ -76,9 +75,7 @@ abstract class CacheManager {
await file.delete(recursive: true);
}
}
} catch (_) {
if (kDebugMode) rethrow;
}
} catch (_) {}
}
static Future<void> autoClearCache() async {