Skip to content

Commit 902eea1

Browse files
committed
修复启动异常逻辑
1 parent a988e8e commit 902eea1

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

lib/app/flutter_unit.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class FlutterUnit extends StatelessWidget {
2525
child: MaterialApp(
2626
showPerformanceOverlay: state.showPerformanceOverlay,
2727
title: StrUnit.appName,
28-
2928
debugShowCheckedModeBanner: false,
3029
onGenerateRoute: UnitRouters.generateRoute,
3130
localizationsDelegates: GlobalMaterialLocalizations.delegates,

lib/app/views/splash/standard_unit_splash.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import 'package:old_fancy_mobile_ui/old_fancy_mobile_ui.dart';
99

1010
import 'package:widget_module/blocs/blocs.dart';
1111

12-
1312
import 'dart:ui' as ui;
1413

1514
import 'package:widget_repository/widget_repository.dart';
@@ -125,10 +124,11 @@ class _StandardUnitSplashState extends State<StandardUnitSplash>
125124
.add(const EventTabTap(WidgetFamily.statelessWidget));
126125
BlocProvider.of<LikeWidgetBloc>(context).add(const EventLoadLikeData());
127126
BlocProvider.of<CategoryBloc>(context).add(const EventLoadCategory());
128-
if (cost < _minCost) {
129-
Future.delayed(Duration(milliseconds: _minCost - cost)).then((value) {
130-
Navigator.of(context).pushReplacementNamed(UnitRouter.nav);
131-
});
132-
}
127+
128+
// 启动耗时小于 _minCost 时,等待 delay 毫秒
129+
int delay = cost < _minCost ? _minCost - cost : 0;
130+
Future.delayed(Duration(milliseconds: delay)).then((value) {
131+
Navigator.of(context).pushReplacementNamed(UnitRouter.nav);
132+
});
133133
}
134134
}

macos/Runner/MainFlutterWindow.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Cocoa
22
import FlutterMacOS
3+
import window_manager
34

45
class MainFlutterWindow: NSWindow {
56
override func awakeFromNib() {
@@ -12,4 +13,9 @@ class MainFlutterWindow: NSWindow {
1213

1314
super.awakeFromNib()
1415
}
16+
17+
override public func order(_ place: NSWindow.OrderingMode, relativeTo otherWin: Int) {
18+
super.order(place, relativeTo: otherWin)
19+
hiddenWindowAtLaunch()
20+
}
1521
}

windows/runner/win32_window.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ bool Win32Window::CreateAndShow(const std::wstring& title,
117117
double scale_factor = dpi / 96.0;
118118

119119
HWND window = CreateWindow(
120-
window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
120+
// window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE,
121+
window_class, title.c_str(),
122+
WS_OVERLAPPEDWINDOW, // do not add WS_VISIBLE since the window will be shown later
121123
Scale(origin.x, scale_factor), Scale(origin.y, scale_factor),
122124
Scale(size.width, scale_factor), Scale(size.height, scale_factor),
123125
nullptr, nullptr, GetModuleHandle(nullptr), this);

0 commit comments

Comments
 (0)