diff --git a/lib/main.dart b/lib/main.dart index dc5f0e8..fd4a119 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -12,7 +12,7 @@ import 'package:window_manager/window_manager.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - if (Platform.isWindows) { + if (Platform.isWindows || Platform.isLinux) { await windowManager.ensureInitialized(); WindowOptions windowOptions = const WindowOptions( size: Size(1280, 830), diff --git a/lib/pages/card/bangumi_panel.dart b/lib/pages/card/bangumi_panel.dart index caf51fd..2514819 100644 --- a/lib/pages/card/bangumi_panel.dart +++ b/lib/pages/card/bangumi_panel.dart @@ -66,7 +66,7 @@ class _BangumiPanelState extends State { Widget build(BuildContext context) { return Column( children: [ - Platform.isWindows + Platform.isWindows || Platform.isLinux ? Column( children: [ const SizedBox(height: 7), @@ -112,12 +112,12 @@ class _BangumiPanelState extends State { ), ), SizedBox( - height: Platform.isWindows ? 72 : 400, + height: Platform.isWindows || Platform.isLinux ? 72 : 400, child: GridView.builder( controller: listViewScrollCtr, scrollDirection: Axis.vertical, // 将滚动方向改为竖直 gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: Platform.isWindows ? 10 : 3, + crossAxisCount: Platform.isWindows || Platform.isLinux ? 10 : 3, crossAxisSpacing: 10, // 间距 mainAxisSpacing: 5, // 间距 childAspectRatio: 1.7, // 子项宽高比 diff --git a/lib/pages/my/my_page.dart b/lib/pages/my/my_page.dart index 782b297..017cee3 100644 --- a/lib/pages/my/my_page.dart +++ b/lib/pages/my/my_page.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:bilineo/pages/my/my_controller.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -70,8 +72,12 @@ class _MyPageState extends State { const SizedBox(height: 5), GestureDetector( onTap: () { - navigationBarState.hideNavigate(); - _mineController.onLogin(); + if (!Platform.isLinux) { + navigationBarState.hideNavigate(); + _mineController.onLogin(); + } else { + SmartDialog.showToast('Linux版本账号功能施工中'); + } }, child: ClipOval( child: Container( diff --git a/lib/pages/player/player_controller.dart b/lib/pages/player/player_controller.dart index 6bedf91..4d680bd 100644 --- a/lib/pages/player/player_controller.dart +++ b/lib/pages/player/player_controller.dart @@ -456,7 +456,7 @@ abstract class _PlayerController with Store { } Future enterFullScreen() async { - if (Platform.isWindows) { + if (Platform.isWindows || Platform.isLinux) { await windowManager.setFullScreen(true); return; } @@ -502,7 +502,7 @@ abstract class _PlayerController with Store { //退出全屏显示 Future exitFullScreen() async { debugPrint('退出全屏模式'); - if (Platform.isWindows) { + if (Platform.isWindows || Platform.isLinux) { await windowManager.setFullScreen(false); } dynamic document; diff --git a/lib/pages/player/player_item.dart b/lib/pages/player/player_item.dart index 7dd4a9c..1050628 100644 --- a/lib/pages/player/player_item.dart +++ b/lib/pages/player/player_item.dart @@ -39,10 +39,10 @@ class _PlayerItemState extends State { // const Text('Video Player Test'), Observer(builder: (context) { return SizedBox( - width: Platform.isWindows + width: Platform.isWindows || Platform.isLinux ? MediaQuery.of(context).size.width : ((!videoPageController.androidFullscreen) ? MediaQuery.of(context).size.width : (MediaQuery.of(context).size.height * 16.0 / 9.0)), - height: Platform.isWindows + height: Platform.isWindows || Platform.isLinux ? (MediaQuery.of(context).size.width * 9.0 / (16.0)) : ((!videoPageController.androidFullscreen) ? MediaQuery.of(context).size.width * 9.0 / 16.0 : MediaQuery.of(context).size.height), child: playerController.dataStatus == 'loaded' @@ -77,10 +77,10 @@ class _PlayerItemState extends State { child: Center( child: CircularProgressIndicator(), ), - height: Platform.isWindows + height: Platform.isWindows || Platform.isLinux ? MediaQuery.of(context).size.width * 9.0 / 32.0 : MediaQuery.of(context).size.width * 9.0 / 16.0, - width: Platform.isWindows + width: Platform.isWindows || Platform.isLinux ? MediaQuery.of(context).size.width / 2 : MediaQuery.of(context).size.width, ), diff --git a/lib/pages/popular/popular_page.dart b/lib/pages/popular/popular_page.dart index 3e6ece5..1a37ab4 100644 --- a/lib/pages/popular/popular_page.dart +++ b/lib/pages/popular/popular_page.dart @@ -158,7 +158,7 @@ class _PopularPageState extends State } Widget contentGrid(bangumiList) { - int crossCount = Platform.isWindows ? 6 : 3; + int crossCount = Platform.isWindows || Platform.isLinux ? 6 : 3; return SliverGrid( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( // 行间距 diff --git a/lib/pages/webview_desktop/webview_desktop_page.dart b/lib/pages/webview_desktop/webview_desktop_page.dart index 138614b..eae4d9a 100644 --- a/lib/pages/webview_desktop/webview_desktop_page.dart +++ b/lib/pages/webview_desktop/webview_desktop_page.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:webview_windows/webview_windows.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index bcfe80a..4c98b15 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -11,6 +11,7 @@ #include #include #include +#include #include void fl_register_plugins(FlPluginRegistry* registry) { @@ -29,6 +30,9 @@ void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); + g_autoptr(FlPluginRegistrar) webview_universal_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "WebviewUniversalPlugin"); + webview_universal_plugin_register_with_registrar(webview_universal_registrar); g_autoptr(FlPluginRegistrar) window_manager_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); window_manager_plugin_register_with_registrar(window_manager_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index c791dd6..3dca5c2 100644 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -8,6 +8,7 @@ list(APPEND FLUTTER_PLUGIN_LIST media_kit_video screen_retriever url_launcher_linux + webview_universal window_manager ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 8e0ba39..5830688 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -18,6 +18,7 @@ import shared_preferences_foundation import sqflite import url_launcher_macos import wakelock_plus +import webview_universal import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { @@ -34,5 +35,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin")) + WebviewUniversalPlugin.register(with: registry.registrar(forPlugin: "WebviewUniversalPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index e336aab..3188584 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1387,6 +1387,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.10.0" + webview_flutter_web: + dependency: transitive + description: + name: webview_flutter_web + sha256: "7f7cb8cfe5a5dee3b55d660a367c00838be56540ccb4097e84601bb6cb354af3" + url: "https://pub.dev" + source: hosted + version: "0.2.2+4" webview_flutter_wkwebview: dependency: transitive description: @@ -1395,6 +1403,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.13.0" + webview_universal: + dependency: "direct main" + description: + name: webview_universal + sha256: "0ee988cb654a64a53edf5f62a0c41777a0f5af2eabf299226ff2dc5b6de3cba8" + url: "https://pub.dev" + source: hosted + version: "0.0.5" webview_windows: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 1e20144..f9fd402 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -80,6 +80,7 @@ dependencies: git: url: https://github.com/Predidit/flutter-webview-windows.git ref: main + webview_universal: ^0.0.5 dev_dependencies: flutter_test: diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 60de164..4d84003 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -31,6 +32,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("ScreenRetrieverPlugin")); UrlLauncherWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("UrlLauncherWindows")); + WebviewUniversalPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("WebviewUniversalPlugin")); WebviewWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("WebviewWindowsPlugin")); WindowManagerPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 618c5f4..46c54da 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -10,6 +10,7 @@ list(APPEND FLUTTER_PLUGIN_LIST screen_brightness_windows screen_retriever url_launcher_windows + webview_universal webview_windows window_manager )