From ba815bccdafce38996594e038607d40d7965a860 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Sep 2023 23:26:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E8=A7=86=E9=A2=91=E7=AE=80?= =?UTF-8?q?=E4=BB=8B=E9=93=BE=E6=8E=A5=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../introduction/widgets/intro_detail.dart | 46 ++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/pages/video/detail/introduction/widgets/intro_detail.dart b/lib/pages/video/detail/introduction/widgets/intro_detail.dart index d9846b193..1db23a1d7 100644 --- a/lib/pages/video/detail/introduction/widgets/intro_detail.dart +++ b/lib/pages/video/detail/introduction/widgets/intro_detail.dart @@ -1,5 +1,6 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/common/widgets/stat/danmu.dart'; @@ -129,7 +130,50 @@ class IntroDetail extends StatelessWidget { final currentDesc = descV2[index]; switch (currentDesc.type) { case 1: - return TextSpan(text: currentDesc.rawText); + List spanChildren = []; + RegExp urlRegExp = RegExp(r'https?://\S+\b'); + Iterable matches = urlRegExp.allMatches(currentDesc.rawText); + + int previousEndIndex = 0; + for (Match match in matches) { + if (match.start > previousEndIndex) { + spanChildren.add(TextSpan( + text: currentDesc.rawText + .substring(previousEndIndex, match.start))); + } + spanChildren.add( + TextSpan( + text: match.group(0), + style: TextStyle( + color: Theme.of(context).colorScheme.primary), // 设置颜色为蓝色 + recognizer: TapGestureRecognizer() + ..onTap = () { + // 处理点击事件 + try { + Get.toNamed( + '/webview', + parameters: { + 'url': match.group(0)!, + 'type': 'url', + 'pageTitle': match.group(0)!, + }, + ); + } catch (err) { + SmartDialog.showToast(err.toString()); + } + }, + ), + ); + previousEndIndex = match.end; + } + + if (previousEndIndex < currentDesc.rawText.length) { + spanChildren.add(TextSpan( + text: currentDesc.rawText.substring(previousEndIndex))); + } + + TextSpan result = TextSpan(children: spanChildren); + return result; case 2: final colorSchemePrimary = Theme.of(context).colorScheme.primary; final heroTag = Utils.makeHeroTag(currentDesc.bizId); From d1272efad4f15dd168cf395e9a9e84b2647747c0 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Sep 2023 23:31:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?mod:=20=E8=A1=A5=E5=85=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=89=93=E5=BC=80=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/webview/view.dart | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/pages/webview/view.dart b/lib/pages/webview/view.dart index 301b1dfaf..8edd21896 100644 --- a/lib/pages/webview/view.dart +++ b/lib/pages/webview/view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'controller.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -24,11 +25,20 @@ class _WebviewPageState extends State { style: Theme.of(context).textTheme.titleMedium, ), actions: [ - TextButton( + const SizedBox(width: 4), + IconButton( onPressed: () { _webviewController.controller.reload(); }, - child: const Text('刷新'), + icon: Icon(Icons.refresh_outlined, + color: Theme.of(context).colorScheme.primary), + ), + IconButton( + onPressed: () { + launchUrl(Uri.parse(_webviewController.url)); + }, + icon: Icon(Icons.open_in_browser_outlined, + color: Theme.of(context).colorScheme.primary), ), Obx( () => _webviewController.type.value == 'login' @@ -38,7 +48,7 @@ class _WebviewPageState extends State { ) : const SizedBox(), ), - const SizedBox(width: 10) + const SizedBox(width: 12) ], ), body: Column( From 97268c36dc0a71184dc50fce5554d10fe0c00ce0 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Wed, 20 Sep 2023 23:52:04 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E9=80=BB=E8=BE=91=20issues=20#133?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/rcmd/controller.dart | 9 ++++++++- lib/pages/setting/extra_setting.dart | 6 ++++++ lib/utils/storage.dart | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/pages/rcmd/controller.dart b/lib/pages/rcmd/controller.dart index 1f21ab0d6..f3acb67da 100644 --- a/lib/pages/rcmd/controller.dart +++ b/lib/pages/rcmd/controller.dart @@ -14,6 +14,7 @@ class RcmdController extends GetxController { Box recVideo = GStrorage.recVideo; Box setting = GStrorage.setting; RxInt crossAxisCount = 2.obs; + late bool enableSaveLastData; @override void onInit() { @@ -28,6 +29,8 @@ class RcmdController extends GetxController { } videoList.value = list; } + enableSaveLastData = + setting.get(SettingBoxKey.enableSaveLastData, defaultValue: false); } // 获取推荐 @@ -49,7 +52,11 @@ class RcmdController extends GetxController { videoList.value = res['data']; } } else if (type == 'onRefresh') { - videoList.value = res['data']; + if (enableSaveLastData) { + videoList.insertAll(0, res['data']); + } else { + videoList.value = res['data']; + } } else if (type == 'onLoad') { videoList.addAll(res['data']); } diff --git a/lib/pages/setting/extra_setting.dart b/lib/pages/setting/extra_setting.dart index f56029e67..4bbb841cc 100644 --- a/lib/pages/setting/extra_setting.dart +++ b/lib/pages/setting/extra_setting.dart @@ -79,6 +79,12 @@ class _ExtraSettingState extends State { setKey: SettingBoxKey.enableWordRe, defaultVal: false, ), + const SetSwitchItem( + title: '首页推荐刷新', + subTitle: '下拉刷新时保留上次内容', + setKey: SettingBoxKey.enableSaveLastData, + defaultVal: false, + ), ListTile( dense: false, title: Text('评论展示', style: titleStyle), diff --git a/lib/utils/storage.dart b/lib/utils/storage.dart index 6ecd60831..fdf0fb0aa 100644 --- a/lib/utils/storage.dart +++ b/lib/utils/storage.dart @@ -121,6 +121,7 @@ class SettingBoxKey { static const String enableWordRe = 'enableWordRe'; static const String enableSearchWord = 'enableSearchWord'; static const String enableRcmdDynamic = 'enableRcmdDynamic'; + static const String enableSaveLastData = 'enableSaveLastData'; /// 外观 static const String themeMode = 'themeMode';