From 55b5be9f06669f8be0314e05b47ca0e8c314911b Mon Sep 17 00:00:00 2001 From: wanghongenpin Date: Sun, 18 Aug 2024 05:10:39 +0800 Subject: [PATCH] fix script change url wrong (#283) --- lib/network/components/script_manager.dart | 3 ++- lib/ui/desktop/desktop.dart | 22 ++++++++++------------ lib/ui/desktop/left_menus/navigation.dart | 5 +---- linux/build.sh | 1 + 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/lib/network/components/script_manager.dart b/lib/network/components/script_manager.dart index b5a39d9..d705206 100644 --- a/lib/network/components/script_manager.dart +++ b/lib/network/components/script_manager.dart @@ -315,7 +315,8 @@ async function onResponse(context, request, response) { query += '$key=$value&'; }); - request.uri = map['path'] + (query.isEmpty ? query : '?${query.substring(0, query.length - 1)}'); + var requestUri = request.requestUri!.replace(path: map['path'], query: query); + request.uri = requestUri.path + (requestUri.hasQuery ? '?${requestUri.query}' : ''); map['headers'].forEach((key, value) { if (value is List) { diff --git a/lib/ui/desktop/desktop.dart b/lib/ui/desktop/desktop.dart index 4ce7732..cb6e9b6 100644 --- a/lib/ui/desktop/desktop.dart +++ b/lib/ui/desktop/desktop.dart @@ -35,7 +35,6 @@ class _DesktopHomePagePageState extends State implements EventL static final container = ListenableList(); final domainStateKey = GlobalKey(); - final PageController pageController = PageController(); final ValueNotifier _selectIndex = ValueNotifier(0); late ProxyServer proxyServer = ProxyServer(widget.configuration); @@ -80,22 +79,21 @@ class _DesktopHomePagePageState extends State implements EventL body: Row( children: [ LeftNavigationBar( - controller: pageController, - selectIndex: _selectIndex, - appConfiguration: widget.appConfiguration, - proxyServer: proxyServer), + selectIndex: _selectIndex, appConfiguration: widget.appConfiguration, proxyServer: proxyServer), Expanded( child: VerticalSplitView( ratio: 0.3, minRatio: 0.15, maxRatio: 0.9, - left: PageView(controller: pageController, physics: const NeverScrollableScrollPhysics(), children: [ - DomainList(key: domainStateKey, proxyServer: proxyServer, panel: panel, list: container), - Favorites(panel: panel), - KeepAliveWrapper( - child: HistoryPageWidget(proxyServer: proxyServer, container: container, panel: panel)), - const Toolbox() - ]), + left: ValueListenableBuilder( + valueListenable: _selectIndex, + builder: (_, index, __) => IndexedStack(index: index, children: [ + DomainList(key: domainStateKey, proxyServer: proxyServer, panel: panel, list: container), + Favorites(panel: panel), + KeepAliveWrapper( + child: HistoryPageWidget(proxyServer: proxyServer, container: container, panel: panel)), + const Toolbox() + ])), right: panel), ) ], diff --git a/lib/ui/desktop/left_menus/navigation.dart b/lib/ui/desktop/left_menus/navigation.dart index dd2391f..24f5fc2 100644 --- a/lib/ui/desktop/left_menus/navigation.dart +++ b/lib/ui/desktop/left_menus/navigation.dart @@ -8,14 +8,12 @@ import 'package:url_launcher/url_launcher.dart'; class LeftNavigationBar extends StatefulWidget { final AppConfiguration appConfiguration; final ProxyServer proxyServer; - final PageController controller; final ValueNotifier selectIndex; const LeftNavigationBar( {super.key, required this.appConfiguration, required this.proxyServer, - required this.controller, required this.selectIndex}); @override @@ -54,7 +52,7 @@ class _LeftNavigationBarState extends State { if (index == -1) { return const SizedBox(); } - print('index: $index'); + return Container( width: localizations.localeName == 'zh' ? 58 : 72, decoration: @@ -105,7 +103,6 @@ class _LeftNavigationBarState extends State { destinations: destinations, selectedIndex: index, onDestinationSelected: (int index) { - widget.controller.jumpToPage(index); widget.selectIndex.value = index; }); } diff --git a/linux/build.sh b/linux/build.sh index 26c291e..cf4f159 100644 --- a/linux/build.sh +++ b/linux/build.sh @@ -1,5 +1,6 @@ #!/bin/bash + pwd cd ../build/linux/x64/release rm -rf package