@@ -43,7 +43,7 @@ void main() async {
4343 // init-queue:
4444 // window(first)->migration->media_kit->Hive->services->start
4545 // window(second)->open
46- await initWindow ();
46+ await firstOpen ();
4747 await MigrationService .migrateData ();
4848 MediaKit .ensureInitialized ();
4949 await Hive .initFlutter (
@@ -53,7 +53,7 @@ void main() async {
5353 );
5454 //初始化服务
5555 await initServices ();
56- WindowService .instance. init ();
56+ await initWindow ();
5757
5858 MigrationService .migrateDataByVersion ();
5959 SystemChrome .setEnabledSystemUIMode (SystemUiMode .edgeToEdge);
@@ -67,13 +67,9 @@ void main() async {
6767 runApp (const MyApp ());
6868}
6969
70- Future initWindow () async {
71- if (! (Platform .isMacOS || Platform .isWindows || Platform .isLinux)) {
72- return ;
73- }
74- await windowManager.ensureInitialized ();
70+ Future firstOpen () async {
7571 // 判定程序是否启动-- windows 交给原生
76- if (Platform .isWindows == false ) {
72+ if (Platform .isWindows == false ) {
7773 if (! await FlutterSingleInstance ().isFirstInstance ()) {
7874 Log .i ("App is already running" );
7975 final err = await FlutterSingleInstance ().focus ();
@@ -85,6 +81,14 @@ Future initWindow() async {
8581 }
8682}
8783
84+ Future initWindow () async {
85+ if (! (Platform .isMacOS || Platform .isWindows || Platform .isLinux)) {
86+ return ;
87+ }
88+ await windowManager.ensureInitialized ();
89+ WindowService .instance.init ();
90+ }
91+
8892Future initServices () async {
8993 Hive .registerAdapter (FollowUserAdapter ());
9094 Hive .registerAdapter (HistoryAdapter ());
0 commit comments