mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-03-15 04:23:17 +08:00
Merge branch 'main' into flutter-3.19.6
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright 2023 Hongen Wang
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@@ -113,7 +113,8 @@ Widget multiWindow(int windowId, Map<dynamic, dynamic> argument) {
|
||||
|
||||
// 请求拦截
|
||||
if (argument['name'] == 'RequestBreakpointPage') {
|
||||
return RequestBreakpointPage(windowId: windowId);
|
||||
return futureWidget(
|
||||
RequestBreakpointManager.instance, (manager) => RequestBreakpointPage(windowId: windowId, manager: manager));
|
||||
}
|
||||
|
||||
if (argument['name'] == 'QrCodePage') {
|
||||
@@ -387,4 +388,3 @@ Future<void> openScriptConsoleWindow() async {
|
||||
..center();
|
||||
window.show();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,10 @@ import '../../component/http_method_popup.dart';
|
||||
import 'package:proxypin/utils/flutter_compat.dart';
|
||||
|
||||
class RequestBreakpointPage extends StatefulWidget {
|
||||
final RequestBreakpointManager manager;
|
||||
final int? windowId;
|
||||
|
||||
const RequestBreakpointPage({super.key, this.windowId});
|
||||
const RequestBreakpointPage({super.key, this.windowId, required this.manager});
|
||||
|
||||
@override
|
||||
State<RequestBreakpointPage> createState() => _RequestBreakpointPageState();
|
||||
@@ -31,7 +32,8 @@ class _RequestBreakpointPageState extends State<RequestBreakpointPage> {
|
||||
AppLocalizations get localizations => AppLocalizations.of(context)!;
|
||||
List<RequestBreakpointRule> rules = [];
|
||||
bool enabled = false;
|
||||
RequestBreakpointManager? manager;
|
||||
|
||||
RequestBreakpointManager get manager => widget.manager;
|
||||
|
||||
Set<int> selected = {};
|
||||
bool isPressed = false;
|
||||
@@ -44,12 +46,11 @@ class _RequestBreakpointPageState extends State<RequestBreakpointPage> {
|
||||
}
|
||||
|
||||
Future<void> _save() async {
|
||||
await manager?.save();
|
||||
await manager.save();
|
||||
await _refreshConfig();
|
||||
}
|
||||
|
||||
Future<void> _import() async {
|
||||
|
||||
String? path;
|
||||
if (Platform.isMacOS) {
|
||||
path = await DesktopMultiWindow.invokeMethod(0, "pickFiles", {
|
||||
@@ -58,7 +59,7 @@ class _RequestBreakpointPageState extends State<RequestBreakpointPage> {
|
||||
if (widget.windowId != null) WindowController.fromWindowId(widget.windowId!).show();
|
||||
} else {
|
||||
FilePickerResult? result =
|
||||
await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['json']);
|
||||
await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: ['json']);
|
||||
path = result?.files.single.path;
|
||||
}
|
||||
if (path == null) return;
|
||||
@@ -68,11 +69,11 @@ class _RequestBreakpointPageState extends State<RequestBreakpointPage> {
|
||||
List<dynamic> list = jsonDecode(content);
|
||||
var rules = list.map((e) => RequestBreakpointRule.fromJson(e)).toList();
|
||||
for (var rule in rules) {
|
||||
manager?.list.add(rule);
|
||||
manager.list.add(rule);
|
||||
}
|
||||
await _save();
|
||||
setState(() {
|
||||
this.rules = manager!.list;
|
||||
this.rules = manager.list;
|
||||
});
|
||||
|
||||
if (mounted) CustomToast.success(localizations.importSuccess).show(context);
|
||||
@@ -105,14 +106,9 @@ class _RequestBreakpointPageState extends State<RequestBreakpointPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
enabled = manager.enabled;
|
||||
rules = manager.list;
|
||||
HardwareKeyboard.instance.addHandler(onKeyEvent);
|
||||
RequestBreakpointManager.instance.then((value) {
|
||||
manager = value;
|
||||
setState(() {
|
||||
enabled = value.enabled;
|
||||
rules = value.list;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -165,11 +161,9 @@ class _RequestBreakpointPageState extends State<RequestBreakpointPage> {
|
||||
value: enabled,
|
||||
scale: 0.8,
|
||||
onChanged: (val) async {
|
||||
manager?.enabled = val;
|
||||
manager.enabled = val;
|
||||
await _save();
|
||||
setState(() {
|
||||
enabled = val;
|
||||
});
|
||||
enabled = val;
|
||||
}))),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
|
||||
@@ -40,6 +40,7 @@ import 'package:proxypin/ui/mobile/setting/ssl.dart';
|
||||
import 'package:proxypin/ui/mobile/widgets/about.dart';
|
||||
import 'package:proxypin/ui/mobile/setting/request_breakpoint.dart';
|
||||
|
||||
import '../../../network/components/manager/request_breakpoint_manager.dart';
|
||||
import '../../component/widgets.dart';
|
||||
import '../setting/proxy.dart';
|
||||
import '../setting/request_map.dart';
|
||||
@@ -167,7 +168,12 @@ class _ConfigPageState extends State<ConfigPage> {
|
||||
title: Text(localizations.breakpoint),
|
||||
leading: Icon(Icons.bug_report_outlined, color: color),
|
||||
trailing: arrow,
|
||||
onTap: () => navigator(context, const MobileRequestBreakpointPage())),
|
||||
onTap: () async {
|
||||
var manager = await RequestBreakpointManager.instance;
|
||||
if (context.mounted) {
|
||||
navigator(context, MobileRequestBreakpointPage(manager: manager));
|
||||
}
|
||||
})
|
||||
]),
|
||||
const SizedBox(height: 16)
|
||||
],
|
||||
|
||||
@@ -20,10 +20,12 @@ import 'package:proxypin/l10n/app_localizations.dart';
|
||||
import 'package:proxypin/network/bin/server.dart';
|
||||
import 'package:proxypin/network/components/host_filter.dart';
|
||||
import 'package:proxypin/network/components/manager/request_block_manager.dart';
|
||||
import 'package:proxypin/network/components/manager/request_breakpoint_manager.dart';
|
||||
import 'package:proxypin/network/components/manager/request_rewrite_manager.dart';
|
||||
import 'package:proxypin/network/http/http.dart';
|
||||
import 'package:proxypin/network/util/system_proxy.dart';
|
||||
import 'package:proxypin/storage/histories.dart';
|
||||
import 'package:proxypin/ui/mobile/setting/request_breakpoint.dart';
|
||||
import 'package:proxypin/ui/mobile/setting/request_map.dart';
|
||||
import 'package:proxypin/ui/toolbox/toolbox.dart';
|
||||
import 'package:proxypin/ui/component/utils.dart';
|
||||
@@ -86,9 +88,7 @@ class DrawerWidget extends StatelessWidget {
|
||||
Text('ProxyPin', style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: 4),
|
||||
Text(isCN ? "全平台开源免费抓包软件" : "Full platform open source free capture HTTP(S) traffic software",
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: Theme.of(context).textTheme.bodySmall)
|
||||
maxLines: 2, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.bodySmall)
|
||||
])
|
||||
])),
|
||||
// Favorites & History
|
||||
@@ -152,6 +152,15 @@ class DrawerWidget extends StatelessWidget {
|
||||
title: Text(localizations.script),
|
||||
leading: const Icon(Icons.code),
|
||||
onTap: () => navigator(context, const MobileScript())),
|
||||
ListTile(
|
||||
title: Text(localizations.breakpoint),
|
||||
leading: const Icon(Icons.bug_report_outlined),
|
||||
onTap: () async {
|
||||
var manager = await RequestBreakpointManager.instance;
|
||||
if (context.mounted) {
|
||||
navigator(context, MobileRequestBreakpointPage(manager: manager));
|
||||
}
|
||||
}),
|
||||
ListTile(
|
||||
title: Text(localizations.setting),
|
||||
leading: const Icon(Icons.settings),
|
||||
@@ -273,7 +282,8 @@ class _SettingPage extends StatelessWidget {
|
||||
children: [
|
||||
Text(localizations.proxyIgnoreDomain, style: const TextStyle(fontSize: 14)),
|
||||
const SizedBox(height: 3),
|
||||
Text(isEn ? "Use ';' to separate multiple entries": "多个使用;分割", style: TextStyle(fontSize: 11, color: Colors.grey.shade600)),
|
||||
Text(isEn ? "Use ';' to separate multiple entries" : "多个使用;分割",
|
||||
style: TextStyle(fontSize: 11, color: Colors.grey.shade600)),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
@@ -296,9 +306,8 @@ class _SettingPage extends StatelessWidget {
|
||||
configuration.proxyPassDomains = textEditingController.text;
|
||||
proxyServer.configuration.flushConfig();
|
||||
},
|
||||
decoration: const InputDecoration(
|
||||
contentPadding: EdgeInsets.all(10),
|
||||
border: OutlineInputBorder()),
|
||||
decoration:
|
||||
const InputDecoration(contentPadding: EdgeInsets.all(10), border: OutlineInputBorder()),
|
||||
maxLines: 5,
|
||||
minLines: 1)),
|
||||
const SizedBox(height: 10),
|
||||
|
||||
@@ -17,7 +17,9 @@ import 'package:proxypin/utils/flutter_compat.dart';
|
||||
import '../../component/http_method_popup.dart';
|
||||
|
||||
class MobileRequestBreakpointPage extends StatefulWidget {
|
||||
const MobileRequestBreakpointPage({super.key});
|
||||
final RequestBreakpointManager manager;
|
||||
|
||||
const MobileRequestBreakpointPage({super.key, required this.manager});
|
||||
|
||||
@override
|
||||
State<MobileRequestBreakpointPage> createState() => _RequestBreakpointPageState();
|
||||
@@ -27,25 +29,21 @@ class _RequestBreakpointPageState extends State<MobileRequestBreakpointPage> {
|
||||
AppLocalizations get localizations => AppLocalizations.of(context)!;
|
||||
List<RequestBreakpointRule> rules = [];
|
||||
bool enabled = false;
|
||||
RequestBreakpointManager? manager;
|
||||
|
||||
RequestBreakpointManager get manager => widget.manager;
|
||||
|
||||
bool selectionMode = false;
|
||||
final Set<int> selected = HashSet<int>();
|
||||
|
||||
Future<void> _save() async {
|
||||
await manager?.save();
|
||||
await manager.save();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
RequestBreakpointManager.instance.then((value) {
|
||||
manager = value;
|
||||
setState(() {
|
||||
enabled = value.enabled;
|
||||
rules = value.list;
|
||||
});
|
||||
});
|
||||
enabled = manager.enabled;
|
||||
rules = manager.list;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -77,7 +75,7 @@ class _RequestBreakpointPageState extends State<MobileRequestBreakpointPage> {
|
||||
value: enabled,
|
||||
scale: 0.8,
|
||||
onChanged: (val) async {
|
||||
manager?.enabled = val;
|
||||
manager.enabled = val;
|
||||
await _save();
|
||||
setState(() {
|
||||
enabled = val;
|
||||
@@ -218,11 +216,11 @@ class _RequestBreakpointPageState extends State<MobileRequestBreakpointPage> {
|
||||
List<dynamic> list = jsonDecode(content);
|
||||
var newRules = list.map((e) => RequestBreakpointRule.fromJson(e)).toList();
|
||||
for (var rule in newRules) {
|
||||
manager?.list.add(rule);
|
||||
manager.list.add(rule);
|
||||
}
|
||||
await _save();
|
||||
setState(() {
|
||||
rules = manager!.list;
|
||||
rules = manager.list;
|
||||
});
|
||||
|
||||
if (mounted) FlutterToastr.show(localizations.importSuccess, context);
|
||||
|
||||
@@ -9,7 +9,6 @@ import desktop_multi_window
|
||||
import device_info_plus
|
||||
import flutter_desktop_context_menu
|
||||
import flutter_js
|
||||
import path_provider_foundation
|
||||
import proxy_manager
|
||||
import screen_retriever_macos
|
||||
import share_plus
|
||||
@@ -22,7 +21,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
FlutterDesktopContextMenuPlugin.register(with: registry.registrar(forPlugin: "FlutterDesktopContextMenuPlugin"))
|
||||
FlutterJsPlugin.register(with: registry.registrar(forPlugin: "FlutterJsPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ProxyManagerPlugin.register(with: registry.registrar(forPlugin: "ProxyManagerPlugin"))
|
||||
ScreenRetrieverMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverMacosPlugin"))
|
||||
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
|
||||
|
||||
Reference in New Issue
Block a user