mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: reply item
Closes #95 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -19,6 +19,7 @@ import 'package:PiliPalaX/utils/url_utils.dart';
|
|||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import '../../../../../utils/app_scheme.dart';
|
import '../../../../../utils/app_scheme.dart';
|
||||||
import 'zan.dart';
|
import 'zan.dart';
|
||||||
|
import 'package:html/parser.dart' show parse;
|
||||||
|
|
||||||
class ReplyItem extends StatelessWidget {
|
class ReplyItem extends StatelessWidget {
|
||||||
const ReplyItem({
|
const ReplyItem({
|
||||||
@@ -614,13 +615,13 @@ class ReplyItem extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
message = message.replaceAll(RegExp(r"\{vote:\d+?\}"), "");
|
message = message.replaceAll(RegExp(r"\{vote:\d+?\}"), "");
|
||||||
}
|
}
|
||||||
message = message
|
message = parse(message).body?.text ?? message;
|
||||||
.replaceAll('&', '&')
|
// .replaceAll('&', '&')
|
||||||
.replaceAll('<', '<')
|
// .replaceAll('<', '<')
|
||||||
.replaceAll('>', '>')
|
// .replaceAll('>', '>')
|
||||||
.replaceAll('"', '"')
|
// .replaceAll('"', '"')
|
||||||
.replaceAll(''', "'")
|
// .replaceAll(''', "'")
|
||||||
.replaceAll(' ', ' ');
|
// .replaceAll(' ', ' ');
|
||||||
// 构建正则表达式
|
// 构建正则表达式
|
||||||
final List<String> specialTokens = [
|
final List<String> specialTokens = [
|
||||||
...content.emote.keys,
|
...content.emote.keys,
|
||||||
@@ -640,6 +641,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';
|
||||||
final RegExp pattern = RegExp(patternStr);
|
final RegExp pattern = RegExp(patternStr);
|
||||||
List<String> matchedStrs = [];
|
List<String> matchedStrs = [];
|
||||||
void addPlainTextSpan(str) {
|
void addPlainTextSpan(str) {
|
||||||
@@ -882,6 +884,20 @@ class ReplyItem extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
} else if (RegExp(r'https?://\S+\b').hasMatch(matchStr)) {
|
||||||
|
spanChildren.add(
|
||||||
|
TextSpan(
|
||||||
|
text: ' $matchStr ',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () => Get.toNamed(
|
||||||
|
'/webview',
|
||||||
|
parameters: {'url': matchStr},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
addPlainTextSpan(matchStr);
|
addPlainTextSpan(matchStr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import 'package:PiliPalaX/utils/storage.dart';
|
|||||||
import 'package:PiliPalaX/utils/url_utils.dart';
|
import 'package:PiliPalaX/utils/url_utils.dart';
|
||||||
import 'package:PiliPalaX/utils/utils.dart';
|
import 'package:PiliPalaX/utils/utils.dart';
|
||||||
import '../../../../../utils/app_scheme.dart';
|
import '../../../../../utils/app_scheme.dart';
|
||||||
|
import 'package:html/parser.dart' show parse;
|
||||||
|
|
||||||
class ReplyItemGrpc extends StatelessWidget {
|
class ReplyItemGrpc extends StatelessWidget {
|
||||||
const ReplyItemGrpc({
|
const ReplyItemGrpc({
|
||||||
@@ -640,13 +641,13 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
});
|
});
|
||||||
message = message.replaceAll(RegExp(r"\{vote:\d+?\}"), "");
|
message = message.replaceAll(RegExp(r"\{vote:\d+?\}"), "");
|
||||||
}
|
}
|
||||||
message = message
|
message = parse(message).body?.text ?? message;
|
||||||
.replaceAll('&', '&')
|
// .replaceAll('&', '&')
|
||||||
.replaceAll('<', '<')
|
// .replaceAll('<', '<')
|
||||||
.replaceAll('>', '>')
|
// .replaceAll('>', '>')
|
||||||
.replaceAll('"', '"')
|
// .replaceAll('"', '"')
|
||||||
.replaceAll(''', "'")
|
// .replaceAll(''', "'")
|
||||||
.replaceAll(' ', ' ');
|
// .replaceAll(' ', ' ');
|
||||||
// 构建正则表达式
|
// 构建正则表达式
|
||||||
final List<String> specialTokens = [
|
final List<String> specialTokens = [
|
||||||
...content.emote.keys,
|
...content.emote.keys,
|
||||||
@@ -666,7 +667,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://b23\.tv/[a-zA-Z0-9]{7}';
|
patternStr += r'|https?://\S+\b';
|
||||||
final RegExp pattern = RegExp(patternStr);
|
final RegExp pattern = RegExp(patternStr);
|
||||||
List<String> matchedStrs = [];
|
List<String> matchedStrs = [];
|
||||||
void addPlainTextSpan(str) {
|
void addPlainTextSpan(str) {
|
||||||
@@ -908,7 +909,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (matchStr.startsWith('https://b23.tv/')) {
|
} else if (RegExp(r'https?://\S+\b').hasMatch(matchStr)) {
|
||||||
spanChildren.add(
|
spanChildren.add(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text: ' $matchStr ',
|
text: ' $matchStr ',
|
||||||
|
|||||||
Reference in New Issue
Block a user