windows webview

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-09-26 17:53:48 +08:00
parent 93e64a0988
commit 59fd89ae5d
7 changed files with 82 additions and 17 deletions

View File

@@ -34,6 +34,7 @@ class _MainAppState extends State<MainApp>
with RouteAware, WidgetsBindingObserver, WindowListener, TrayListener {
final MainController _mainController = Get.put(MainController());
late final _setting = GStorage.setting;
static const MethodChannel _channel = MethodChannel('window_control');
@override
void initState() {
@@ -131,6 +132,14 @@ class _MainAppState extends State<MainApp>
void onWindowClose() {
if (_mainController.minimizeOnExit) {
windowManager.hide();
} else {
_onClose();
}
}
void _onClose() {
if (Platform.isWindows) {
_channel.invokeMethod('closeWindow');
} else {
exit(0);
}
@@ -157,7 +166,7 @@ class _MainAppState extends State<MainApp>
case 'show':
windowManager.show();
case 'exit':
exit(0);
_onClose();
}
}

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:PiliPlus/http/ua_type.dart';
import 'package:PiliPlus/main.dart';
import 'package:PiliPlus/models/common/webview_menu_type.dart';
import 'package:PiliPlus/utils/app_scheme.dart';
import 'package:PiliPlus/utils/cache_manage.dart';
@@ -60,7 +61,7 @@ class _WebviewPageState extends State<WebviewPage> {
@override
Widget build(BuildContext context) {
if (Platform.isWindows || Platform.isLinux) {
if (Platform.isLinux) {
return Scaffold(
appBar: AppBar(),
body: Center(
@@ -156,6 +157,7 @@ class _WebviewPageState extends State<WebviewPage> {
),
body: SafeArea(
child: InAppWebView(
webViewEnvironment: webViewEnvironment,
initialSettings: InAppWebViewSettings(
clearCache: true,
javaScriptEnabled: true,