Browse Source

完成窗体的大小设置

liuyuqi-dellpc 3 months ago
parent
commit
c33721b021
1 changed files with 18 additions and 18 deletions
  1. 18 18
      lib/main.dart

+ 18 - 18
lib/main.dart

@@ -15,27 +15,27 @@ void main() async {
   AppUtils.setOverrideForDesktop();
   
   // Initialize window manager for desktop platforms
-  // if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
-  //   await windowManager.ensureInitialized();
+  if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
+    await windowManager.ensureInitialized();
     
-  //   // Calculate window size with 16:9 portrait ratio
-  //   // Common phone resolution is 1080x1920 (16:9 portrait)
-  //   const double width = 360.0;  // Phone width
-  //   const double height = 640.0;  // Phone height (16:9 ratio)
+    // Calculate window size with 16:9 portrait ratio
+    // Common phone resolution is 1080x1920 (16:9 portrait)
+    const double width = 360.0;  // Phone width
+    const double height = 640.0;  // Phone height (16:9 ratio)
     
-  //   WindowOptions windowOptions = WindowOptions(
-  //     size: Size(width, height),
-  //     center: true,
-  //     backgroundColor: Colors.transparent,
-  //     skipTaskbar: false,
-  //     titleBarStyle: TitleBarStyle.normal,
-  //   );
+    WindowOptions windowOptions = WindowOptions(
+      size: Size(width, height),
+      center: true,
+      backgroundColor: Colors.transparent,
+      skipTaskbar: false,
+      titleBarStyle: TitleBarStyle.normal,
+    );
     
-  //   await windowManager.waitUntilReadyToShow(windowOptions, () async {
-  //     await windowManager.show();
-  //     await windowManager.focus();
-  //   });
-  // }
+    await windowManager.waitUntilReadyToShow(windowOptions, () async {
+      await windowManager.show();
+      await windowManager.focus();
+    });
+  }
   
   // Configure system settings for better background execution
   if (Platform.isAndroid) {