mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
committed by
GitHub
parent
56756c5c85
commit
41c8e1a538
@@ -11,8 +11,7 @@ import 'package:flutter/widgets.dart';
|
||||
/// Adapted from [WidgetsFlutterBinding]
|
||||
///
|
||||
class ScaledWidgetsFlutterBinding extends WidgetsFlutterBinding {
|
||||
ScaledWidgetsFlutterBinding._({double scaleFactor = 1.0})
|
||||
: _scaleFactor = scaleFactor;
|
||||
ScaledWidgetsFlutterBinding._({this._scaleFactor = 1.0});
|
||||
|
||||
/// Calculate scale factor from device size.
|
||||
double _scaleFactor;
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
|
||||
import 'package:PiliPlus/router/app_pages.dart';
|
||||
import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/services/download/download_service.dart';
|
||||
import 'package:PiliPlus/services/logger.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/utils/cache_manager.dart';
|
||||
import 'package:PiliPlus/utils/calc_window_position.dart';
|
||||
@@ -201,32 +202,12 @@ void main() async {
|
||||
'${NativePlayer.apiVersion >> 16}.${NativePlayer.apiVersion & 0xFFFF}',
|
||||
};
|
||||
final fileHandler = await JsonFileHandler.init();
|
||||
final Catcher2Options debugConfig = Catcher2Options(
|
||||
SilentReportMode(),
|
||||
[
|
||||
?fileHandler,
|
||||
ConsoleHandler(
|
||||
enableDeviceParameters: false,
|
||||
enableApplicationParameters: false,
|
||||
enableCustomParameters: true,
|
||||
),
|
||||
],
|
||||
customParameters: customParameters,
|
||||
);
|
||||
|
||||
final Catcher2Options releaseConfig = Catcher2Options(
|
||||
SilentReportMode(),
|
||||
[
|
||||
?fileHandler,
|
||||
ConsoleHandler(enableCustomParameters: true),
|
||||
],
|
||||
customParameters: customParameters,
|
||||
);
|
||||
|
||||
Catcher2(
|
||||
debugConfig: debugConfig,
|
||||
releaseConfig: releaseConfig,
|
||||
rootWidget: const MyApp(),
|
||||
[?fileHandler, const ConsoleHandler()],
|
||||
const MyApp(),
|
||||
logger: logger,
|
||||
customParameters: customParameters,
|
||||
);
|
||||
} else {
|
||||
runApp(const MyApp());
|
||||
|
||||
@@ -15,7 +15,6 @@ import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
import 'package:PiliPlus/pages/dynamics/widgets/vote.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/extension/num_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/string_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/image_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
|
||||
@@ -56,25 +56,20 @@ class _FavFolderSortPageState extends State<FavFolderSortPage>
|
||||
);
|
||||
}
|
||||
|
||||
void onReorder(int oldIndex, int newIndex) {
|
||||
void onReorderItem(int oldIndex, int newIndex) {
|
||||
if (oldIndex == 0 || newIndex == 0) {
|
||||
SmartDialog.showToast('默认收藏夹不支持排序');
|
||||
return;
|
||||
}
|
||||
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
|
||||
final tabsItem = sortList.removeAt(oldIndex);
|
||||
sortList.insert(newIndex, tabsItem);
|
||||
sortList.insert(newIndex, sortList.removeAt(oldIndex));
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget get _buildBody {
|
||||
return ReorderableListView.builder(
|
||||
onReorder: onReorder,
|
||||
onReorderItem: onReorderItem,
|
||||
proxyDecorator: proxyDecorator,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
itemCount: sortList.length,
|
||||
|
||||
@@ -81,11 +81,7 @@ class _FavSortPageState extends State<FavSortPage> with ReorderMixin {
|
||||
);
|
||||
}
|
||||
|
||||
void onReorder(int oldIndex, int newIndex) {
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
|
||||
void onReorderItem(int oldIndex, int newIndex) {
|
||||
final oldItem = sortList[oldIndex];
|
||||
final newItem = sortList.getOrNull(
|
||||
oldIndex > newIndex ? newIndex - 1 : newIndex, // might be Negative
|
||||
@@ -94,15 +90,14 @@ class _FavSortPageState extends State<FavSortPage> with ReorderMixin {
|
||||
'${newItem == null ? '0:0' : '${newItem.id}:${newItem.type}'}:${oldItem.id}:${oldItem.type}',
|
||||
);
|
||||
|
||||
final tabsItem = sortList.removeAt(oldIndex);
|
||||
sortList.insert(newIndex, tabsItem);
|
||||
sortList.insert(newIndex, sortList.removeAt(oldIndex));
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget get _buildBody {
|
||||
final child = ReorderableListView.builder(
|
||||
onReorder: onReorder,
|
||||
onReorderItem: onReorderItem,
|
||||
proxyDecorator: proxyDecorator,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding:
|
||||
|
||||
@@ -71,20 +71,14 @@ class _FollowTagSortPageState extends State<FollowTagSortPage>
|
||||
);
|
||||
}
|
||||
|
||||
void onReorder(int oldIndex, int newIndex) {
|
||||
if (newIndex > oldIndex) {
|
||||
newIndex -= 1;
|
||||
}
|
||||
|
||||
final tabsItem = _customTags.removeAt(oldIndex);
|
||||
_customTags.insert(newIndex, tabsItem);
|
||||
|
||||
void onReorderItem(int oldIndex, int newIndex) {
|
||||
_customTags.insert(newIndex, _customTags.removeAt(oldIndex));
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget get _buildBody {
|
||||
return ReorderableListView.builder(
|
||||
onReorder: onReorder,
|
||||
onReorderItem: onReorderItem,
|
||||
proxyDecorator: proxyDecorator,
|
||||
physics: const AlwaysScrollableScrollPhysics(),
|
||||
padding: EdgeInsets.only(
|
||||
|
||||
@@ -52,8 +52,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
SmartDialog.showToast('重置成功,下次启动时生效');
|
||||
}
|
||||
|
||||
void onReorder(int oldIndex, int newIndex) {
|
||||
if (newIndex > oldIndex) newIndex -= 1;
|
||||
void onReorderItem(int oldIndex, int newIndex) {
|
||||
list.insert(newIndex, list.removeAt(oldIndex));
|
||||
setState(() {});
|
||||
}
|
||||
@@ -71,7 +70,7 @@ class _BarSetPageState extends State<BarSetPage> with ReorderMixin {
|
||||
],
|
||||
),
|
||||
body: ReorderableListView(
|
||||
onReorder: onReorder,
|
||||
onReorderItem: onReorderItem,
|
||||
proxyDecorator: proxyDecorator,
|
||||
footer: Padding(
|
||||
padding:
|
||||
|
||||
@@ -11,8 +11,8 @@ import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:catcher_2/model/platform_type.dart';
|
||||
import 'package:catcher_2/model/report.dart' as catcher;
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
import 'package:catcher_2/utils/log_printer.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
@@ -27,25 +27,25 @@ class LogsPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LogsPageState extends State<LogsPage> {
|
||||
List<Report> logsContent = [];
|
||||
Report? latestLog;
|
||||
List<_ExpandedItem<Report>> logsContent = [];
|
||||
_ExpandedItem<_DeviceInfo>? _deviceInfo;
|
||||
late bool enableLog = Pref.enableLog;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_initDeviceInfo();
|
||||
getLog();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
if (latestLog != null) {
|
||||
final time = latestLog!.dateTime;
|
||||
if (DateTime.now().difference(time) >= const Duration(days: 14)) {
|
||||
LoggerUtils.clearLogs();
|
||||
}
|
||||
void _initDeviceInfo() {
|
||||
if (Catcher2.instance case final c?) {
|
||||
_deviceInfo = _ExpandedItem((
|
||||
c.deviceParameters,
|
||||
c.applicationParameters,
|
||||
c.customParameters,
|
||||
));
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> getLog() async {
|
||||
@@ -53,19 +53,18 @@ class _LogsPageState extends State<LogsPage> {
|
||||
logsContent = (await logsPath.readAsLines()).reversed.map((i) {
|
||||
try {
|
||||
final log = Report.fromJson(jsonDecode(i));
|
||||
latestLog ??= log;
|
||||
return log;
|
||||
return _ExpandedItem(log);
|
||||
} catch (e, s) {
|
||||
return Report(
|
||||
'Parse log failed: $e\n\n\n$i',
|
||||
s,
|
||||
DateTime.now(),
|
||||
const {},
|
||||
const {},
|
||||
const {},
|
||||
null,
|
||||
PlatformType.unknown,
|
||||
null,
|
||||
return _ExpandedItem(
|
||||
Report(
|
||||
'Parse log failed: $e\n\n\n$i',
|
||||
s,
|
||||
DateTime.now(),
|
||||
const {},
|
||||
const {},
|
||||
const {},
|
||||
null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}).toList();
|
||||
@@ -119,7 +118,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
onTap: () => Timer.periodic(
|
||||
const Duration(milliseconds: 3500),
|
||||
(timer) {
|
||||
Utils.reportError('Manual');
|
||||
Utils.reportError('Manual', StackTrace.current);
|
||||
if (timer.tick > 3) {
|
||||
timer.cancel();
|
||||
if (mounted) getLog();
|
||||
@@ -146,10 +145,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
child: const Text('错误反馈'),
|
||||
),
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
latestLog = null;
|
||||
clearLogs();
|
||||
},
|
||||
onTap: clearLogs,
|
||||
child: const Text('清空日志'),
|
||||
),
|
||||
],
|
||||
@@ -157,7 +153,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
),
|
||||
body: logsContent.isNotEmpty
|
||||
body: logsContent.isNotEmpty || _deviceInfo != null
|
||||
? Padding(
|
||||
padding: EdgeInsets.only(
|
||||
left: padding.left + 12,
|
||||
@@ -165,11 +161,11 @@ class _LogsPageState extends State<LogsPage> {
|
||||
),
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
if (latestLog != null)
|
||||
if (_deviceInfo != null)
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const .only(bottom: 12),
|
||||
child: InfoCard(report: latestLog!),
|
||||
child: _InfoCard(info: _deviceInfo!),
|
||||
),
|
||||
),
|
||||
SliverPadding(
|
||||
@@ -177,7 +173,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||
sliver: SliverList.separated(
|
||||
itemCount: logsContent.length,
|
||||
itemBuilder: (context, index) =>
|
||||
ReportCard(report: logsContent[index]),
|
||||
_ReportCard(report: logsContent[index]),
|
||||
separatorBuilder: (_, _) => const SizedBox(height: 12),
|
||||
),
|
||||
),
|
||||
@@ -189,10 +185,16 @@ class _LogsPageState extends State<LogsPage> {
|
||||
}
|
||||
}
|
||||
|
||||
class InfoCard extends StatelessWidget {
|
||||
final Report report;
|
||||
typedef _DeviceInfo = (
|
||||
Map<String, dynamic>,
|
||||
Map<String, dynamic>,
|
||||
Map<String, dynamic>,
|
||||
);
|
||||
|
||||
const InfoCard({super.key, required this.report});
|
||||
class _InfoCard extends StatelessWidget {
|
||||
final _ExpandedItem<_DeviceInfo> info;
|
||||
|
||||
const _InfoCard({required this.info});
|
||||
|
||||
Widget _buildMapSection(
|
||||
Color color,
|
||||
@@ -210,11 +212,7 @@ class InfoCard extends StatelessWidget {
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
fontSize: 15,
|
||||
),
|
||||
style: TextStyle(fontWeight: .bold, color: color, fontSize: 15),
|
||||
),
|
||||
...map.entries.map(
|
||||
(entry) => Text.rich(
|
||||
@@ -250,58 +248,47 @@ class InfoCard extends StatelessWidget {
|
||||
const Expanded(
|
||||
child: Text(
|
||||
'相关信息',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
style: TextStyle(fontWeight: .bold, fontSize: 15),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
),
|
||||
iconButton(
|
||||
size: 34,
|
||||
iconSize: 22,
|
||||
tooltip: info.isExpanded ? '收起' : '展开',
|
||||
icon: Icon(
|
||||
report.isExpanded ? Icons.expand_less : Icons.expand_more,
|
||||
info.isExpanded ? Icons.expand_less : Icons.expand_more,
|
||||
),
|
||||
onPressed: () {
|
||||
report.isExpanded = !report.isExpanded;
|
||||
info.isExpanded = !info.isExpanded;
|
||||
(context as Element).markNeedsBuild();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
if (report.isExpanded) ...[
|
||||
_buildMapSection(
|
||||
colorScheme.primary,
|
||||
'设备信息',
|
||||
report.deviceParameters,
|
||||
),
|
||||
_buildMapSection(
|
||||
colorScheme.primary,
|
||||
'应用信息',
|
||||
report.applicationParameters,
|
||||
),
|
||||
_buildMapSection(
|
||||
colorScheme.primary,
|
||||
'编译信息',
|
||||
report.customParameters,
|
||||
),
|
||||
if (info.isExpanded) ...[
|
||||
_buildMapSection(colorScheme.primary, '设备信息', info.item.$1),
|
||||
_buildMapSection(colorScheme.primary, '应用信息', info.item.$2),
|
||||
_buildMapSection(colorScheme.primary, '编译信息', info.item.$3),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
class ReportCard extends StatelessWidget {
|
||||
final Report report;
|
||||
class _ReportCard extends StatelessWidget {
|
||||
final _ExpandedItem<Report> report;
|
||||
|
||||
const ReportCard({super.key, required this.report});
|
||||
const _ReportCard({required this.report});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = ColorScheme.of(context);
|
||||
late final stackTrace = report.stackTrace.toString().trim();
|
||||
final dateTime = DateFormatUtils.longFormatDs.format(report.dateTime);
|
||||
late final stackTrace = PrettyLogPrinter.formatStackString(
|
||||
report.item.stackTrace?.toString(),
|
||||
-1,
|
||||
);
|
||||
final dateTime = DateFormatUtils.longFormatDs.format(report.item.dateTime);
|
||||
return _card([
|
||||
Row(
|
||||
crossAxisAlignment: .start,
|
||||
@@ -312,13 +299,10 @@ class ReportCard extends StatelessWidget {
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
Text(
|
||||
report.error.toString(),
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 15,
|
||||
),
|
||||
report.item.error.toString(),
|
||||
style: const TextStyle(fontWeight: .bold, fontSize: 15),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
),
|
||||
Text(
|
||||
dateTime,
|
||||
@@ -334,6 +318,7 @@ class ReportCard extends StatelessWidget {
|
||||
iconButton(
|
||||
size: 34,
|
||||
iconSize: 22,
|
||||
tooltip: '复制',
|
||||
onPressed: () {
|
||||
Utils.copyText('```\n$report```', needToast: false);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
@@ -343,14 +328,12 @@ class ReportCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
icon: const Icon(
|
||||
Icons.copy_outlined,
|
||||
size: 16,
|
||||
),
|
||||
icon: const Icon(Icons.copy_outlined, size: 16),
|
||||
),
|
||||
iconButton(
|
||||
size: 34,
|
||||
iconSize: 22,
|
||||
tooltip: report.isExpanded ? '收起' : '展开',
|
||||
icon: Icon(
|
||||
report.isExpanded ? Icons.expand_less : Icons.expand_more,
|
||||
),
|
||||
@@ -373,16 +356,14 @@ class ReportCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const .all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withValues(alpha: 0.5),
|
||||
),
|
||||
borderRadius: const .all(.circular(8)),
|
||||
border: .all(color: colorScheme.outline.withValues(alpha: 0.5)),
|
||||
),
|
||||
child: SelectableText(
|
||||
report.error.toString(),
|
||||
report.item.error.toString(),
|
||||
style: TextStyle(
|
||||
fontFamily: 'Monospace',
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
@@ -390,7 +371,7 @@ class ReportCard extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
// stackTrace may be null or String("null") or blank
|
||||
if (stackTrace.isNotEmpty && stackTrace != 'null') ...[
|
||||
if (stackTrace != null && stackTrace.isNotEmpty) ...[
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'堆栈跟踪',
|
||||
@@ -402,21 +383,29 @@ class ReportCard extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: const .all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.surface,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||||
border: Border.all(
|
||||
color: colorScheme.outline.withValues(alpha: 0.5),
|
||||
),
|
||||
borderRadius: const .all(.circular(8)),
|
||||
border: .all(color: colorScheme.outline.withValues(alpha: 0.5)),
|
||||
),
|
||||
child: SelectableText(
|
||||
stackTrace,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Monospace',
|
||||
fontSize: 13,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
child: SelectableText.rich(
|
||||
TextSpan(
|
||||
children: stackTrace
|
||||
.map(
|
||||
(i) => TextSpan(
|
||||
text: '$i\n',
|
||||
style: i.contains('(package:${Constants.appName}')
|
||||
? TextStyle(
|
||||
color: colorScheme.onSurface,
|
||||
fontWeight: .w600,
|
||||
)
|
||||
: TextStyle(color: colorScheme.onSurfaceVariant),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
style: const TextStyle(fontFamily: 'Monospace', fontSize: 13),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -437,45 +426,12 @@ Widget _card(List<Widget> contents) {
|
||||
);
|
||||
}
|
||||
|
||||
class Report extends catcher.Report {
|
||||
Report(
|
||||
super.error,
|
||||
super.stackTrace,
|
||||
super.dateTime,
|
||||
super.deviceParameters,
|
||||
super.applicationParameters,
|
||||
super.customParameters,
|
||||
super.errorDetails,
|
||||
super.platformType,
|
||||
super.screenshot,
|
||||
);
|
||||
|
||||
class _ExpandedItem<T> {
|
||||
bool isExpanded = false;
|
||||
final T item;
|
||||
|
||||
factory Report.fromJson(Map<String, dynamic> json) => Report(
|
||||
json['error'],
|
||||
json['stackTrace'],
|
||||
DateTime.tryParse(json['dateTime'] ?? '') ?? DateTime(1970),
|
||||
json['deviceParameters'] ?? const {},
|
||||
json['applicationParameters'] ?? const {},
|
||||
json['customParameters'] ?? const {},
|
||||
null,
|
||||
PlatformType.values.byName(json['platformType']),
|
||||
null,
|
||||
);
|
||||
|
||||
static String _params2String(Map<String, dynamic> params) {
|
||||
return params.entries
|
||||
.map((entry) => '${entry.key}: ${entry.value}\n')
|
||||
.join();
|
||||
}
|
||||
_ExpandedItem(this.item);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '------- DEVICE INFO -------\n${_params2String(deviceParameters)}'
|
||||
'------- APP INFO -------\n${_params2String(applicationParameters)}'
|
||||
'------- ERROR -------\n$error\n'
|
||||
'------- STACK TRACE -------\n${stackTrace.toString().trim()}\n'
|
||||
'------- CUSTOM INFO -------\n${_params2String(customParameters)}';
|
||||
}
|
||||
String toString() => item.toString();
|
||||
}
|
||||
|
||||
@@ -317,8 +317,8 @@ class _DanmakuTip extends SingleChildRenderObjectWidget {
|
||||
|
||||
class _RenderDanmakuTip extends RenderProxyBox {
|
||||
_RenderDanmakuTip({
|
||||
required double offset,
|
||||
}) : _offset = offset;
|
||||
required this._offset,
|
||||
});
|
||||
|
||||
double _offset;
|
||||
double get offset => _offset;
|
||||
|
||||
@@ -2,30 +2,19 @@ import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/utils/json_file_handler.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
import 'package:catcher_2/utils/log_printer.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logger/logger.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
final logger = PiliLogger();
|
||||
|
||||
class PiliLogger extends Logger {
|
||||
PiliLogger() : super();
|
||||
|
||||
@override
|
||||
void log(
|
||||
Level level,
|
||||
dynamic message, {
|
||||
Object? error,
|
||||
StackTrace? stackTrace,
|
||||
DateTime? time,
|
||||
}) {
|
||||
if (level == Level.error || level == Level.fatal) {
|
||||
Catcher2.reportCheckedError(error, stackTrace);
|
||||
}
|
||||
super.log(level, message, error: error, stackTrace: stackTrace, time: time);
|
||||
}
|
||||
}
|
||||
final logger = Logger(
|
||||
filter: ProductionFilter(),
|
||||
printer: PrettyLogPrinter(
|
||||
dateTimeFormat: PrettyLogPrinter.toEncodableFallback,
|
||||
),
|
||||
level: kDebugMode ? .trace : .warning,
|
||||
);
|
||||
|
||||
abstract final class LoggerUtils {
|
||||
static File? _logFile;
|
||||
|
||||
@@ -49,7 +49,7 @@ class PackageHeaderRes extends PackageHeader {
|
||||
|
||||
static PackageHeaderRes? fromBytesData(Uint8List data) {
|
||||
if (data.length < 10) {
|
||||
logger.i('数据不足以解析PackageHeader');
|
||||
logger.w('数据不足以解析PackageHeader');
|
||||
return null;
|
||||
}
|
||||
final byteData = ByteData.sublistView(data);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/services/logger.dart' show LoggerUtils;
|
||||
import 'package:catcher_2/model/platform_type.dart';
|
||||
import 'package:catcher_2/model/report.dart';
|
||||
import 'package:catcher_2/model/report_handler.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:PiliPlus/services/logger.dart';
|
||||
import 'package:catcher_2/catcher_2.dart';
|
||||
|
||||
class JsonFileHandler extends ReportHandler {
|
||||
final bool enableDeviceParameters;
|
||||
@@ -48,7 +45,7 @@ class JsonFileHandler extends ReportHandler {
|
||||
handleWhenRejected: handleWhenRejected,
|
||||
);
|
||||
} catch (e, s) {
|
||||
debugPrintStack(stackTrace: s, label: e.toString());
|
||||
logger.e('Init log file', error: e, stackTrace: s);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -62,18 +59,24 @@ class JsonFileHandler extends ReportHandler {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> handle(Report report, BuildContext? context) async {
|
||||
Future<bool> handle(Report report) async {
|
||||
try {
|
||||
await _processReport(report);
|
||||
return true;
|
||||
} catch (exc, stackTrace) {
|
||||
_printLog('Exception occurred: $exc stack: $stackTrace');
|
||||
logger.e(
|
||||
'Write Json Exception occurred',
|
||||
error: exc,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _processReport(Report report) {
|
||||
_printLog('Writing report to file');
|
||||
if (printLogs) {
|
||||
logger.d('Writing report to file');
|
||||
}
|
||||
final json = report.toJson(
|
||||
enableDeviceParameters: enableDeviceParameters,
|
||||
enableApplicationParameters: enableApplicationParameters,
|
||||
@@ -82,22 +85,4 @@ class JsonFileHandler extends ReportHandler {
|
||||
);
|
||||
return add((raf) => raf.writeString('${jsonEncode(json)}\n'));
|
||||
}
|
||||
|
||||
void _printLog(String log) {
|
||||
if (printLogs) {
|
||||
logger.info(log);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<PlatformType> getSupportedPlatforms() => const [
|
||||
PlatformType.android,
|
||||
PlatformType.iOS,
|
||||
PlatformType.linux,
|
||||
PlatformType.macOS,
|
||||
PlatformType.windows,
|
||||
];
|
||||
|
||||
@override
|
||||
bool shouldHandleWhenRejected() => handleWhenRejected;
|
||||
}
|
||||
|
||||
58
pubspec.lock
58
pubspec.lock
@@ -239,8 +239,8 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: dev
|
||||
resolved-ref: a20878e9fe5375252c9ea22697d4dc4823544b1a
|
||||
url: "https://github.com/bggRGjQaUbCoE/catcher_2.git"
|
||||
resolved-ref: "9138d8d2aeefc564efd2f35fde3f54ad1b7e89a7"
|
||||
url: "https://github.com/My-Responsitories/catcher_2.git"
|
||||
source: git
|
||||
version: "2.1.9"
|
||||
characters:
|
||||
@@ -409,10 +409,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: dio_http2_adapter
|
||||
sha256: "79f3d69b155b92a786c8734bd11860390b986210d4e07cbb6a5c8c806a7187b2"
|
||||
sha256: c56522c50bb3bab7e3ca77c153b0f03ae672a87d8c32e46be8f2868693ec9f0a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.7.0"
|
||||
version: "2.7.1"
|
||||
dio_web_adapter:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -707,14 +707,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_mailer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_mailer
|
||||
sha256: e1c0b4425e3cc789f8dd914fd08b5da660c3ac46c8ebf3e7db183d39775a8fa6
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
flutter_native_splash:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -1097,14 +1089,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
mailer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mailer
|
||||
sha256: "7b8691b080809ea1b2fa2f1b0d49c7c089fb328bd23e68aa5818b9cf5f4b420d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.1.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1466,14 +1450,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.0"
|
||||
punycoder:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: punycoder
|
||||
sha256: aed79c05986a18782caa9bad649a4a786e840e1baaf6a2e1aa3a25d143d28e6e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.2"
|
||||
qr:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1499,7 +1475,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
rxdart:
|
||||
dependency: "direct overridden"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rxdart
|
||||
sha256: "5c3004a4a8dbb94bd4bf5412a4def4acdaa12e12f269737a5751369e12d1a962"
|
||||
@@ -1510,12 +1486,12 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: saver_gallery
|
||||
sha256: "3f983d4be63aff52523c3e097a9b00ce9ab8444f9a982c878cde9d0359f4681d"
|
||||
sha256: c24cfec2d94a0db9a2ae02d6a21847ba49a369c9b6c3a83f3da17d14720c0888
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.1.1"
|
||||
version: "4.1.2"
|
||||
screen_brightness_android:
|
||||
dependency: "direct overridden"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_brightness_android
|
||||
sha256: "2df5e0488a22a73271a43d92dbcd80643df6910cf69690faacaf9929ae9ade3b"
|
||||
@@ -1523,7 +1499,7 @@ packages:
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
screen_brightness_ios:
|
||||
dependency: "direct overridden"
|
||||
dependency: transitive
|
||||
description:
|
||||
name: screen_brightness_ios
|
||||
sha256: "0792d8f98852558f831b4b75241c46047b884598b3f4d982b37dc2dd43e2b2e1"
|
||||
@@ -1578,14 +1554,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
sentry:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sentry
|
||||
sha256: f04095a25ff02b202a914174c73ec309570aa93d61098cb4a0a9e715b4aaa465
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "9.20.0"
|
||||
share_plus:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -1824,14 +1792,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.1"
|
||||
unorm_dart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: unorm_dart
|
||||
sha256: "0c69186b03ca6addab0774bcc0f4f17b88d4ce78d9d4d8f0619e30a99ead58e7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.2"
|
||||
upower:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
18
pubspec.yaml
18
pubspec.yaml
@@ -48,7 +48,7 @@ dependencies:
|
||||
ref: main
|
||||
catcher_2:
|
||||
git:
|
||||
url: https://github.com/bggRGjQaUbCoE/catcher_2.git
|
||||
url: https://github.com/My-Responsitories/catcher_2.git
|
||||
ref: dev
|
||||
characters: ^1.4.1
|
||||
chat_bottom_container:
|
||||
@@ -66,7 +66,7 @@ dependencies:
|
||||
ref: main
|
||||
device_info_plus: ^13.1.0
|
||||
dio: ^5.9.1
|
||||
dio_http2_adapter: ^2.5.3
|
||||
dio_http2_adapter: ^2.7.1
|
||||
dlna_dart: ^0.1.0
|
||||
dynamic_color: ^1.8.1
|
||||
easy_debounce: ^2.0.3
|
||||
@@ -127,11 +127,7 @@ dependencies:
|
||||
material_new_shapes: ^1.0.0
|
||||
media_kit: 1.1.11
|
||||
media_kit_libs_video: 1.0.5
|
||||
media_kit_video:
|
||||
git:
|
||||
url: https://github.com/bggRGjQaUbCoE/media-kit.git
|
||||
path: media_kit_video
|
||||
ref: version_1.2.5
|
||||
media_kit_video: 1.2.5
|
||||
mime: ^2.0.0
|
||||
native_device_orientation:
|
||||
git:
|
||||
@@ -146,7 +142,7 @@ dependencies:
|
||||
pretty_qr_code: ^3.3.0
|
||||
protobuf: ^6.0.0
|
||||
re_highlight: ^0.0.3
|
||||
saver_gallery: ^4.1.0
|
||||
saver_gallery: ^4.1.2
|
||||
screen_brightness_platform_interface: ^2.1.0
|
||||
screen_retriever: ^0.2.0
|
||||
share_plus: ^13.1.0
|
||||
@@ -215,12 +211,6 @@ dependency_overrides:
|
||||
url: https://github.com/My-Responsitories/media-kit.git
|
||||
path: media_kit_video
|
||||
ref: version_1.2.5
|
||||
mime: ^2.0.0
|
||||
path: ^1.9.1
|
||||
rxdart: ^0.28.0
|
||||
screen_brightness_android: ^2.1.4
|
||||
screen_brightness_ios: ^2.1.3
|
||||
screen_brightness_platform_interface: ^2.1.1
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user