From 2f14cd1f40f7d664fe217b6b2809533051ad0296 Mon Sep 17 00:00:00 2001 From: lxh2875931338 Date: Thu, 20 Aug 2026 00:14:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E5=80=9F=E5=8A=A9release?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=AE=9A=E4=BD=8D=E9=A6=96=E5=B8=A7=E9=98=BB?= =?UTF-8?q?=E5=A1=9E=E7=9A=84=E9=97=AE=E9=A2=98=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 931aa2e..705feea 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,11 +12,15 @@ import 'widgets/global_mini_player.dart'; final GlobalKey navigatorKey = GlobalKey(); -// ═══════════════════════════════════════════════════ -// main: 只做 runApp,不做任何初始化 -// ═══════════════════════════════════════════════════ +// ⏱️ 全局计时器 +final stopwatch = Stopwatch(); + void main() { + stopwatch.start(); + debugPrint('⏱️ T0 main: ${stopwatch.elapsedMilliseconds}ms'); + WidgetsFlutterBinding.ensureInitialized(); + debugPrint('⏱️ T0.5 ensureInitialized: ${stopwatch.elapsedMilliseconds}ms'); runApp( MultiProvider( @@ -27,11 +31,10 @@ void main() { child: const QTPlayerApp(), ), ); + + debugPrint('⏱️ T0.8 runApp 完成: ${stopwatch.elapsedMilliseconds}ms'); } -// ═══════════════════════════════════════════════════ -// RouteManager - 路由状态 -// ═══════════════════════════════════════════════════ class RouteManager extends ChangeNotifier { static final RouteManager _instance = RouteManager._internal(); factory RouteManager() => _instance; @@ -53,9 +56,6 @@ class RouteManager extends ChangeNotifier { } } -// ═══════════════════════════════════════════════════ -// MiniPlayerNavigatorObserver - 路由监听 -// ═══════════════════════════════════════════════════ class MiniPlayerNavigatorObserver extends NavigatorObserver { void _updateRoute(Route? route) { final name = route?.settings.name ?? '/'; @@ -78,9 +78,6 @@ class MiniPlayerNavigatorObserver extends NavigatorObserver { } } -// ═══════════════════════════════════════════════════ -// QTPlayerApp - 主应用 -// ═══════════════════════════════════════════════════ class QTPlayerApp extends StatefulWidget { const QTPlayerApp({super.key}); @@ -92,17 +89,17 @@ class _QTPlayerAppState extends State { @override void initState() { super.initState(); + debugPrint('⏱️ T1.5 initState: ${stopwatch.elapsedMilliseconds}ms'); - // 首帧完成后才开始初始化 WidgetsBinding.instance.addPostFrameCallback((_) { - debugPrint('🖼️ Flutter 首帧已完成'); + debugPrint('⏱️ T2 首帧回调: ${stopwatch.elapsedMilliseconds}ms'); _initializeServices(); }); } @override Widget build(BuildContext context) { - debugPrint('🎨 QTPlayerApp.build()'); + debugPrint('⏱️ T1 build: ${stopwatch.elapsedMilliseconds}ms'); return MaterialApp( title: '清听', @@ -148,23 +145,24 @@ class _QTPlayerAppState extends State { } } -// ═══════════════════════════════════════════════════ -// 后台初始化 - 在首帧完成后执行 -// ═══════════════════════════════════════════════════ void _initializeServices() async { + debugPrint('⏱️ T3 开始初始化: ${stopwatch.elapsedMilliseconds}ms'); final lifecycle = AppLifecycleService(); try { lifecycle.updateStatus(AppStatus.mediaKitInitializing); MediaKit.ensureInitialized(); + debugPrint('⏱️ T4 MediaKit 完成: ${stopwatch.elapsedMilliseconds}ms'); lifecycle.updateStatus(AppStatus.mediaKitReady); lifecycle.updateStatus(AppStatus.playerInitializing); PlaybackService().init(); + debugPrint('⏱️ T5 Player 完成: ${stopwatch.elapsedMilliseconds}ms'); lifecycle.updateStatus(AppStatus.playerReady); lifecycle.updateStatus(AppStatus.webdavChecking); final hasCred = await WebDAVService.instance.loadCredentials(); + debugPrint('⏱️ T6 WebDAV 完成: ${stopwatch.elapsedMilliseconds}ms'); if (hasCred) { lifecycle.updateStatus(AppStatus.webdavReady); } else { @@ -172,7 +170,7 @@ void _initializeServices() async { } lifecycle.updateStatus(AppStatus.fullReady); - debugPrint('✅ 应用完全就绪'); + debugPrint('✅ 应用完全就绪: ${stopwatch.elapsedMilliseconds}ms'); } catch (e) { debugPrint('❌ 初始化错误: $e'); lifecycle.updateStatus(AppStatus.error);