diff --git a/lib/models_new/pgc/pgc_timeline/result.dart b/lib/models_new/pgc/pgc_timeline/result.dart index 0862ca80b..89350fe8b 100644 --- a/lib/models_new/pgc/pgc_timeline/result.dart +++ b/lib/models_new/pgc/pgc_timeline/result.dart @@ -25,7 +25,7 @@ class TimelineResult { isToday: json['is_today'] as int?, ); - void operator +(TimelineResult other) { + void addAll(TimelineResult other) { if (dateTs == other.dateTs) { if (other.episodes case final list?) { (episodes ??= []).addAll(list); diff --git a/lib/pages/msg_feed_top/sys_msg/view.dart b/lib/pages/msg_feed_top/sys_msg/view.dart index e7b0b6dcc..857b8ec77 100644 --- a/lib/pages/msg_feed_top/sys_msg/view.dart +++ b/lib/pages/msg_feed_top/sys_msg/view.dart @@ -137,29 +137,38 @@ class _SysMsgPageState extends State { content.splitMapJoin( urlRegExp, onMatch: (Match match) { - String matchStr = match[0]!; + final matchStr = match[0]!; if (matchStr.startsWith('#')) { - spanChildren.add( - TextSpan( - text: match[1], - style: TextStyle(color: theme.colorScheme.primary), - recognizer: TapGestureRecognizer() - ..onTap = () { - try { - PiliScheme.routePushFromUrl(match[2]!.replaceAll('"', '')); - } catch (err) { - SmartDialog.showToast(err.toString()); - } - }, - ), - ); + try { + final url = match[2]!.replaceAll('"', ''); + spanChildren.add( + TextSpan( + text: match[1], + style: TextStyle(color: theme.colorScheme.primary), + recognizer: TapGestureRecognizer() + ..onTap = () { + try { + PiliScheme.routePushFromUrl(url); + } catch (err) { + SmartDialog.showToast(err.toString()); + } + }, + ), + ); + } catch (e) { + spanChildren.add(TextSpan(text: matchStr)); + } } else if (matchStr.startsWith('【')) { try { - bool isBV = match[3]?.startsWith('BV') == true; + final isBV = match[3]!.startsWith('BV'); + final int validAv; + final String validBv; if (isBV) { - IdUtils.bv2av(match[3]!); + validBv = match[3]!; + validAv = IdUtils.bv2av(validBv); } else { - IdUtils.av2bv(int.parse(match[3]!)); + validAv = int.parse(match[3]!); + validBv = IdUtils.av2bv(validAv); } spanChildren ..add(const TextSpan(text: '【')) @@ -169,24 +178,17 @@ class _SysMsgPageState extends State { style: TextStyle(color: theme.colorScheme.primary), recognizer: TapGestureRecognizer() ..onTap = () { - try { - PiliScheme.videoPush( - isBV ? null : int.parse(match[3]!), - isBV ? match[3]! : null, - ); - } catch (err) { - SmartDialog.showToast(err.toString()); - } + PiliScheme.videoPush(validAv, validBv); }, ), ) ..add(const TextSpan(text: '】')); } catch (e) { - spanChildren.add(TextSpan(text: match[0])); + spanChildren.add(TextSpan(text: matchStr)); } } else if (matchStr.startsWith('(')) { try { - match[4]; // dynId + final dynId = match[4]!; // check dynId spanChildren ..add(const TextSpan(text: '(')) ..add( @@ -195,17 +197,15 @@ class _SysMsgPageState extends State { style: TextStyle(color: theme.colorScheme.primary), recognizer: TapGestureRecognizer() ..onTap = () { - try { - PageUtils.pushDynFromId(id: match[4]); - } catch (err) { - SmartDialog.showToast(err.toString()); - } + PageUtils.pushDynFromId(id: dynId).catchError( + (err) => SmartDialog.showToast(err.toString()), + ); }, ), ) ..add(const TextSpan(text: ')')); } catch (e) { - spanChildren.add(TextSpan(text: match[0])); + spanChildren.add(TextSpan(text: matchStr)); } } else { spanChildren.add( @@ -214,12 +214,7 @@ class _SysMsgPageState extends State { style: TextStyle(color: theme.colorScheme.primary), recognizer: TapGestureRecognizer() ..onTap = () { - try { - PiliScheme.routePushFromUrl(match[0]!); - } catch (err) { - SmartDialog.showToast(err.toString()); - Utils.copyText(match[0] ?? ''); - } + PiliScheme.routePushFromUrl(matchStr); }, ), ); diff --git a/lib/pages/pgc/controller.dart b/lib/pages/pgc/controller.dart index 69749bf00..2607804f9 100644 --- a/lib/pages/pgc/controller.dart +++ b/lib/pages/pgc/controller.dart @@ -75,7 +75,7 @@ class PgcController list1.isNotEmpty && list2.isNotEmpty) { for (var i = 0; i < list1.length; i++) { - list1[i] + list2[i]; + list1[i].addAll(list2[i]); } } else { list1 ??= list2; diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 94ab702d2..9ed4800e0 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -48,7 +48,7 @@ abstract final class PiliScheme { Map? parameters, int? businessId, int? oid, - }) async { + }) { try { if (url.startsWith('//')) { url = 'https:$url'; @@ -64,7 +64,7 @@ abstract final class PiliScheme { oid: oid, ); } catch (_) { - return false; + return Future.syncValue(false); } } diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 7a0cc616b..7f6ec8272 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -278,7 +278,12 @@ abstract class PageUtils { ); } - static Future pushDynFromId({id, rid, bool off = false}) async { + static Future pushDynFromId({ + String? id, + Object? rid, + bool off = false, + }) async { + assert(id != null || rid != null); SmartDialog.showLoading(); final res = await DynamicsHttp.dynamicDetail( id: id, @@ -292,7 +297,7 @@ abstract class PageUtils { toDupNamed( '/articlePage', parameters: { - 'id': id, + 'id': id!, 'type': 'opus', }, off: off,