mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: better url pattern
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -26,6 +26,9 @@ class Constants {
|
|||||||
'%7B%22appId%22%3A5%2C%22platform%22%3A3%2C%22version%22%3A%221.46.2%22%2C%22abtest%22%3A%22%22%7D';
|
'%7B%22appId%22%3A5%2C%22platform%22%3A3%2C%22version%22%3A%221.46.2%22%2C%22abtest%22%3A%22%22%7D';
|
||||||
//Uri.encodeComponent('{"appId": 5,"platform": 3,"version": "1.46.2","abtest": ""}');
|
//Uri.encodeComponent('{"appId": 5,"platform": 3,"version": "1.46.2","abtest": ""}');
|
||||||
|
|
||||||
|
static const urlPattern =
|
||||||
|
r'https?://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]';
|
||||||
|
|
||||||
// 超分辨率滤镜
|
// 超分辨率滤镜
|
||||||
static const List<String> mpvAnime4KShaders = [
|
static const List<String> mpvAnime4KShaders = [
|
||||||
'Anime4K_Clamp_Highlights.glsl',
|
'Anime4K_Clamp_Highlights.glsl',
|
||||||
|
|||||||
@@ -1002,8 +1002,10 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
|
|||||||
switch (currentDesc.type) {
|
switch (currentDesc.type) {
|
||||||
case 1:
|
case 1:
|
||||||
final List<InlineSpan> spanChildren = <InlineSpan>[];
|
final List<InlineSpan> spanChildren = <InlineSpan>[];
|
||||||
final RegExp urlRegExp =
|
final RegExp urlRegExp = RegExp(
|
||||||
RegExp(r'https?://\S+\b|av\d+|bv\S+\b', caseSensitive: false);
|
'${Constants.urlPattern}|av\\d+|bv\\S+\\b',
|
||||||
|
caseSensitive: false,
|
||||||
|
);
|
||||||
|
|
||||||
(currentDesc.rawText as String).splitMapJoin(
|
(currentDesc.rawText as String).splitMapJoin(
|
||||||
urlRegExp,
|
urlRegExp,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
import 'package:PiliPlus/pages/search/widgets/search_text.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -147,7 +148,7 @@ class IntroDetail extends StatelessWidget {
|
|||||||
switch (currentDesc.type) {
|
switch (currentDesc.type) {
|
||||||
case 1:
|
case 1:
|
||||||
final List<InlineSpan> spanChildren = <InlineSpan>[];
|
final List<InlineSpan> spanChildren = <InlineSpan>[];
|
||||||
final RegExp urlRegExp = RegExp(r'https?://\S+\b');
|
final RegExp urlRegExp = RegExp(Constants.urlPattern);
|
||||||
final Iterable<Match> matches =
|
final Iterable<Match> matches =
|
||||||
urlRegExp.allMatches(currentDesc.rawText);
|
urlRegExp.allMatches(currentDesc.rawText);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/widgets/imageview.dart';
|
import 'package:PiliPlus/common/widgets/imageview.dart';
|
||||||
import 'package:PiliPlus/http/video.dart';
|
import 'package:PiliPlus/http/video.dart';
|
||||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||||
@@ -704,7 +705,7 @@ class ReplyItem extends StatelessWidget {
|
|||||||
if (jumpUrlKeysList.isNotEmpty) {
|
if (jumpUrlKeysList.isNotEmpty) {
|
||||||
patternStr += '|${jumpUrlKeysList.map(RegExp.escape).join('|')}';
|
patternStr += '|${jumpUrlKeysList.map(RegExp.escape).join('|')}';
|
||||||
}
|
}
|
||||||
patternStr += r'|https?://\S+\b';
|
patternStr += '|${Constants.urlPattern}';
|
||||||
final RegExp pattern = RegExp(patternStr);
|
final RegExp pattern = RegExp(patternStr);
|
||||||
List<String> matchedStrs = [];
|
List<String> matchedStrs = [];
|
||||||
void addPlainTextSpan(str) {
|
void addPlainTextSpan(str) {
|
||||||
@@ -896,10 +897,10 @@ class ReplyItem extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (RegExp(r'https?://\S+\b').hasMatch(matchStr)) {
|
} else if (RegExp(Constants.urlPattern).hasMatch(matchStr)) {
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' $matchStr ',
|
text: matchStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:PiliPlus/common/widgets/badge.dart';
|
import 'package:PiliPlus/common/widgets/badge.dart';
|
||||||
import 'package:PiliPlus/common/widgets/imageview.dart';
|
import 'package:PiliPlus/common/widgets/imageview.dart';
|
||||||
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
import 'package:PiliPlus/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||||
@@ -101,7 +102,6 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildContent(context) {
|
Widget _buildContent(context) {
|
||||||
print(replyItem.member.garbCardImage);
|
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
if (ModuleAuthorModel.showDynDecorate &&
|
if (ModuleAuthorModel.showDynDecorate &&
|
||||||
@@ -745,7 +745,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
if (jumpUrlKeysList.isNotEmpty) {
|
if (jumpUrlKeysList.isNotEmpty) {
|
||||||
patternStr += '|${jumpUrlKeysList.map(RegExp.escape).join('|')}';
|
patternStr += '|${jumpUrlKeysList.map(RegExp.escape).join('|')}';
|
||||||
}
|
}
|
||||||
patternStr += r'|https?://\S+\b';
|
patternStr += '|${Constants.urlPattern}';
|
||||||
final RegExp pattern = RegExp(patternStr);
|
final RegExp pattern = RegExp(patternStr);
|
||||||
List<String> matchedStrs = [];
|
List<String> matchedStrs = [];
|
||||||
void addPlainTextSpan(str) {
|
void addPlainTextSpan(str) {
|
||||||
@@ -934,10 +934,10 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (RegExp(r'https?://\S+\b').hasMatch(matchStr)) {
|
} else if (RegExp(Constants.urlPattern).hasMatch(matchStr)) {
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' $matchStr ',
|
text: matchStr,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:PiliPlus/common/constants.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -171,7 +172,7 @@ class AiDetail extends StatelessWidget {
|
|||||||
switch (currentDesc.type) {
|
switch (currentDesc.type) {
|
||||||
case 1:
|
case 1:
|
||||||
List<InlineSpan> spanChildren = [];
|
List<InlineSpan> spanChildren = [];
|
||||||
RegExp urlRegExp = RegExp(r'https?://\S+\b');
|
RegExp urlRegExp = RegExp(Constants.urlPattern);
|
||||||
Iterable<Match> matches = urlRegExp.allMatches(currentDesc.rawText);
|
Iterable<Match> matches = urlRegExp.allMatches(currentDesc.rawText);
|
||||||
|
|
||||||
int previousEndIndex = 0;
|
int previousEndIndex = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user