diff --git a/lib/network/bin/server.dart b/lib/network/bin/server.dart index 3e8f2eb..dedebdb 100644 --- a/lib/network/bin/server.dart +++ b/lib/network/bin/server.dart @@ -134,7 +134,7 @@ class ProxyServer { return; } Map config = jsonDecode(await file.readAsString()); - logger.i('加载配置文件 [$file] $config'); + logger.i('加载配置文件 [$file]'); enableSsl = config['enableSsl'] == true; port = config['port'] ?? port; HostFilter.whitelist.load(config['whitelist']); diff --git a/lib/ui/desktop/toolbar/toolbar.dart b/lib/ui/desktop/toolbar/toolbar.dart index a4b04fa..ce3f66f 100644 --- a/lib/ui/desktop/toolbar/toolbar.dart +++ b/lib/ui/desktop/toolbar/toolbar.dart @@ -92,6 +92,8 @@ class _ToolbarState extends State { builder: (context) { return AlertDialog( title: const Text("手机连接", style: TextStyle(fontSize: 16)), + contentPadding: const EdgeInsets.only(top: 5), + actionsPadding: const EdgeInsets.only(bottom: 5), content: SizedBox( height: 250, width: 300, diff --git a/lib/ui/mobile/menu.dart b/lib/ui/mobile/menu.dart index 8234042..b64b12e 100644 --- a/lib/ui/mobile/menu.dart +++ b/lib/ui/mobile/menu.dart @@ -12,6 +12,7 @@ import 'package:network_proxy/ui/mobile/setting/filter.dart'; import 'package:network_proxy/ui/mobile/setting/request_rewrite.dart'; import 'package:network_proxy/ui/mobile/setting/ssl.dart'; import 'package:network_proxy/utils/ip.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:qrscan/qrscan.dart' as scanner; import 'package:url_launcher/url_launcher.dart'; @@ -33,7 +34,7 @@ class DrawerWidget extends StatelessWidget { ), PortWidget(proxyServer: proxyServer), ListTile( - title: const Text("Https代理"), + title: const Text("HTTPS抓包"), trailing: const Icon(Icons.arrow_right), onTap: () => navigator(context, MobileSslWidget(proxyServer: proxyServer))), const ThemeSetting(), @@ -93,8 +94,10 @@ class MoreEnum extends StatelessWidget { itemBuilder: (BuildContext context) { return [ PopupMenuItem( + padding: const EdgeInsets.only(left: 0), child: ListTile( - title: const Text("Https代理"), + dense: true, + title: const Text("HTTPS抓包"), leading: Icon(Icons.https, color: proxyServer.enableSsl ? null : Colors.red), onTap: () { Navigator.of(context).push( @@ -104,24 +107,28 @@ class MoreEnum extends StatelessWidget { ); })), PopupMenuItem( + padding: const EdgeInsets.only(left: 0), child: ListTile( - leading: const Icon(Icons.qr_code_scanner_outlined), - title: const Text("连接终端"), - onTap: () { - connectRemote(context); - }, - )), + dense: true, + leading: const Icon(Icons.qr_code_scanner_outlined), + title: const Text("连接终端"), + onTap: () { + connectRemote(context); + }, + )), PopupMenuItem( + padding: const EdgeInsets.only(left: 0), child: ListTile( - leading: const Icon(Icons.phone_iphone), - title: const Text("我的二维码"), - onTap: () async { - var ip = await localIp(); - if (context.mounted) { - phoneConnect(context, ip, proxyServer.port); - } - }, - )), + dense: true, + leading: const Icon(Icons.phone_iphone), + title: const Text("我的二维码"), + onTap: () async { + var ip = await localIp(); + if (context.mounted) { + phoneConnect(context, ip, proxyServer.port); + } + }, + )), ]; }, ); @@ -130,6 +137,10 @@ class MoreEnum extends StatelessWidget { connectRemote(BuildContext context) async { String scanRes; if (Platform.isAndroid) { + var status = await Permission.camera.status; + if (!status.isGranted) { + status = await Permission.camera.request(); + } scanRes = await scanner.scan() ?? "-1"; } else { scanRes = await FlutterBarcodeScanner.scanBarcode("#ff6666", "取消", true, ScanMode.QR); @@ -190,6 +201,8 @@ class MoreEnum extends StatelessWidget { context: context, builder: (context) { return AlertDialog( + contentPadding: const EdgeInsets.only(top: 5), + actionsPadding: const EdgeInsets.only(bottom: 5), title: const Text("远程连接,将请求转发到其他终端", style: TextStyle(fontSize: 16)), content: SizedBox( height: 240, diff --git a/pubspec.lock b/pubspec.lock index 3eec9b1..f22d7b7 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -352,6 +352,46 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.7" + permission_handler: + dependency: "direct main" + description: + name: permission_handler + sha256: "415af30ba76a84faccfe1eb251fe1e4fdc790f876924c65ad7d6ed7a1404bcd6" + url: "https://pub.dev" + source: hosted + version: "10.4.2" + permission_handler_android: + dependency: transitive + description: + name: permission_handler_android + sha256: "3b61f3da3b1c83bc3fb6a2b431e8dab01d0e5b45f6a3d9c7609770ec88b2a89e" + url: "https://pub.dev" + source: hosted + version: "10.3.0" + permission_handler_apple: + dependency: transitive + description: + name: permission_handler_apple + sha256: "7a187b671a39919462af2b5e813148365b71a615979165a119868d667fe90c03" + url: "https://pub.dev" + source: hosted + version: "9.1.3" + permission_handler_platform_interface: + dependency: transitive + description: + name: permission_handler_platform_interface + sha256: "463a07cb7cc6c758a7a1c7da36ce666bb80a0b4b5e92df0fa36872e0ed456993" + url: "https://pub.dev" + source: hosted + version: "3.11.1" + permission_handler_windows: + dependency: transitive + description: + name: permission_handler_windows + sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098 + url: "https://pub.dev" + source: hosted + version: "0.1.3" platform: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 84a1cb9..f598bf5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,6 +21,7 @@ dependencies: proxy_manager: ^0.0.3 chinese_font_library: qr_flutter: ^4.1.0 + permission_handler: ^10.4.2 qrscan: ^0.3.3 flutter_barcode_scanner: ^2.0.0 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index bb1a7e2..f03d8c1 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,6 +7,7 @@ #include "generated_plugin_registrant.h" #include +#include #include #include #include @@ -15,6 +16,8 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { FileSelectorWindowsRegisterWithRegistrar( registry->GetRegistrarForPlugin("FileSelectorWindows")); + PermissionHandlerWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); ProxyManagerPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ProxyManagerPlugin")); ScreenRetrieverPluginRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 8cd3f07..bf7312f 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST file_selector_windows + permission_handler_windows proxy_manager screen_retriever url_launcher_windows