import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'wl_base_help_platform_interface.dart'; /// An implementation of [WlBaseHelpPlatform] that uses method channels. class MethodChannelWlBaseHelp extends WlBaseHelpPlatform { /// The method channel used to interact with the native platform. @visibleForTesting final methodChannel = const MethodChannel('wl_base_help'); @override Future getPlatformVersion() async { final version = await methodChannel.invokeMethod('getPlatformVersion'); return version; } @override Future runAsAdministrator() async { try { await methodChannel.invokeMethod('runAsAdministrator'); return null; } on PlatformException catch (e) { return e.code; } } @override Future isRunningAsAdmin() async { final isAdmin = await methodChannel.invokeMethod('isRunningAsAdmin'); return isAdmin; } @override Future showConsole() async { await methodChannel.invokeMethod('showConsole'); } @override Future hideConsole() async { await methodChannel.invokeMethod('hideConsole'); } @override Future isProcessRunning(String processName) async { final isRunning = await methodChannel.invokeMethod('isProcessRunning', {'processName': processName}); return isRunning; } @override Future killProcess(String processName) async { await methodChannel.invokeMethod('killProcess', {'processName': processName}); } @override Future macIsAdmin() async { final isRunning = await methodChannel.invokeMethod('isAdmin'); return isRunning; } @override Future macIsProcessRunning() async { final isRunning = await methodChannel.invokeMethod('isProcessRunning'); return isRunning; } // 新增:启用代理 @override Future startProxy(int port) async { return await methodChannel.invokeMethod('startProxy', {'port': port}); } // 新增:禁用代理 @override Future stopProxy() async { return await methodChannel.invokeMethod('stopProxy'); } // 新增:检测代理是否启用 @override Future isProxyEnabled() async { return await methodChannel.invokeMethod('isProxyEnabled'); } @override Future isDialUpEnabled() async { return await methodChannel.invokeMethod('isDialUpEnabled'); } }