From b9b1ac7ec592298392c3c99df7c6feb48bcf6740 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 3 Sep 2023 13:22:20 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/video_card_v.dart | 2 +- lib/http/video.dart | 3 +++ lib/pages/search/controller.dart | 4 +++- lib/pages/setting/extra_setting.dart | 12 ++++++++++++ lib/utils/storage.dart | 2 ++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 02c7c217..1a5d4077 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -247,7 +247,7 @@ class VideoContent extends StatelessWidget { }, ), ] else ...[ - const SizedBox(height: 26) + const SizedBox(height: 24) ] ], ), diff --git a/lib/http/video.dart b/lib/http/video.dart index a6084a6c..d0ce616c 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -20,6 +20,8 @@ import 'package:pilipala/utils/storage.dart'; class VideoHttp { static Box localCache = GStrorage.localCache; static Box setting = GStrorage.setting; + static bool enableRcmdDynamic = + setting.get(SettingBoxKey.enableRcmdDynamic, defaultValue: true); // 首页推荐视频 static Future rcmdVideoList({required int ps, required int freshIdx}) async { @@ -73,6 +75,7 @@ class VideoHttp { for (var i in res.data['data']['items']) { // 屏蔽推广和拉黑用户 if (i['card_goto'] != 'ad_av' && + (!enableRcmdDynamic ? i['card_goto'] != 'picture' : true) && (i['args'] != null && !blackMidsList.contains(i['args']['up_mid']))) { list.add(RecVideoItemAppModel.fromJson(i)); diff --git a/lib/pages/search/controller.dart b/lib/pages/search/controller.dart index 64f3cb65..9a93dabe 100644 --- a/lib/pages/search/controller.dart +++ b/lib/pages/search/controller.dart @@ -27,7 +27,9 @@ class SSearchController extends GetxController { @override void onInit() { super.onInit(); - searchDefault(); + if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) { + searchDefault(); + } // 其他页面跳转过来 if (Get.parameters.keys.isNotEmpty) { if (Get.parameters['keyword'] != null) { diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index f9d30f41..f56029e6 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -55,6 +55,18 @@ class _ExtraSettingState extends State { defaultVal: true, callFn: (val) => {SmartDialog.showToast('下次启动时生效')}, ), + const SetSwitchItem( + title: '搜索默认词', + subTitle: '是否展示搜索框默认词', + setKey: SettingBoxKey.enableSearchWord, + defaultVal: true, + ), + const SetSwitchItem( + title: '推荐动态', + subTitle: '是否在推荐内容中展示动态', + setKey: SettingBoxKey.enableRcmdDynamic, + defaultVal: true, + ), const SetSwitchItem( title: '快速收藏', subTitle: '点按收藏至默认,长按选择文件夹', diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index f73b1ba7..b0be21b0 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -113,6 +113,8 @@ class SettingBoxKey { static const String enableHotKey = 'enableHotKey'; static const String enableQuickFav = 'enableQuickFav'; static const String enableWordRe = 'enableWordRe'; + static const String enableSearchWord = 'enableSearchWord'; + static const String enableRcmdDynamic = 'enableRcmdDynamic'; /// 外观 static const String themeMode = 'themeMode'; From aa63007c8aa704f39b21b8c9e618f48fd741b074 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Sun, 3 Sep 2023 13:46:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E4=BB=A3=E7=90=86=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Podfile.lock | 6 ++++++ lib/main.dart | 2 ++ lib/utils/proxy.dart | 26 ++++++++++++++++++++++++++ pubspec.lock | 8 ++++++++ pubspec.yaml | 2 ++ 5 files changed, 44 insertions(+) create mode 100644 lib/utils/proxy.dart diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 32a7bbad..b00a1fff 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -37,6 +37,8 @@ PODS: - FMDB (>= 2.7.5) - status_bar_control (3.2.1): - Flutter + - system_proxy (0.0.1): + - Flutter - url_launcher_ios (0.0.1): - Flutter - volume_controller (0.0.1): @@ -65,6 +67,7 @@ DEPENDENCIES: - share_plus (from `.symlinks/plugins/share_plus/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) - status_bar_control (from `.symlinks/plugins/status_bar_control/ios`) + - system_proxy (from `.symlinks/plugins/system_proxy/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - volume_controller (from `.symlinks/plugins/volume_controller/ios`) - wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`) @@ -109,6 +112,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/sqflite/ios" status_bar_control: :path: ".symlinks/plugins/status_bar_control/ios" + system_proxy: + :path: ".symlinks/plugins/system_proxy/ios" url_launcher_ios: :path: ".symlinks/plugins/url_launcher_ios/ios" volume_controller: @@ -139,6 +144,7 @@ SPEC CHECKSUMS: share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028 sqflite: 31f7eba61e3074736dff8807a9b41581e4f7f15a status_bar_control: 7c84146799e6a076315cc1550f78ef53aae3e446 + system_proxy: bec1a5c5af67dd3e3ebf43979400a8756c04cc44 url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 volume_controller: 531ddf792994285c9b17f9d8a7e4dcdd29b3eae9 wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47 diff --git a/lib/main.dart b/lib/main.dart index 5040edca..d0dbf3ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -15,6 +15,7 @@ import 'package:pilipala/router/app_pages.dart'; import 'package:pilipala/pages/main/view.dart'; import 'package:pilipala/utils/app_scheme.dart'; import 'package:pilipala/utils/data.dart'; +import 'package:pilipala/utils/proxy.dart'; import 'package:pilipala/utils/storage.dart'; import 'package:media_kit/media_kit.dart'; // Provides [Player], [Media], [Playlist] etc. @@ -25,6 +26,7 @@ void main() async { [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]) .then((_) async { await GStrorage.init(); + CustomProxy().init(); runApp(const MyApp()); // 小白条、导航栏沉浸 SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); diff --git a/lib/utils/proxy.dart b/lib/utils/proxy.dart new file mode 100644 index 00000000..a296b057 --- /dev/null +++ b/lib/utils/proxy.dart @@ -0,0 +1,26 @@ +import 'dart:io'; +import 'package:system_proxy/system_proxy.dart'; + +class CustomProxy { + init() async{ + Map? proxy = await SystemProxy.getProxySettings(); + if (proxy != null) { + HttpOverrides.global = ProxiedHttpOverrides(proxy['host']!, proxy['port']!); + } + } +} +class ProxiedHttpOverrides extends HttpOverrides { + final String _port; + final String _host; + + ProxiedHttpOverrides(this._host, this._port); + + @override + HttpClient createHttpClient(SecurityContext? context) { + return super.createHttpClient(context) + // set proxy + ..findProxy = (uri) { + return "PROXY $_host:$_port;"; + }; + } +} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index ed138ca6..84fab3ea 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1211,6 +1211,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" + system_proxy: + dependency: "direct main" + description: + name: system_proxy + sha256: bbdfc9736a963409941fb0e7c494606c1f13c2be34de15833ee385da83cf7ab0 + url: "https://pub.dev" + source: hosted + version: "0.1.0" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index bdb48aaf..fd657437 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -121,6 +121,8 @@ dependencies: ref: master # 状态栏图标控制 status_bar_control: ^3.2.1 + # 代理 + system_proxy: ^0.1.0 dev_dependencies: flutter_test: