mod: 直播样式&组件

This commit is contained in:
guozhigq
2023-06-23 15:45:10 +08:00
parent fccd21e8b6
commit 4b1ddae3d7
8 changed files with 340 additions and 38 deletions

29
lib/utils/em.dart Normal file
View File

@ -0,0 +1,29 @@
class Em {
static regCate(String origin) {
String str = origin;
RegExp exp = RegExp('<[^>]*>([^<]*)</[^>]*>');
Iterable<Match> matches = exp.allMatches(origin);
for (Match match in matches) {
str = match.group(1)!;
}
return str;
}
static regTitle(String origin) {
RegExp exp = RegExp('<[^>]*>([^<]*)</[^>]*>');
List res = [];
origin.splitMapJoin(exp, onMatch: (Match match) {
String matchStr = match[0]!;
Map map = {'type': 'em', 'text': regCate(matchStr)};
res.add(map);
return regCate(matchStr);
}, onNonMatch: (String str) {
if (str != '') {
Map map = {'type': 'text', 'text': str};
res.add(map);
}
return str;
});
return res;
}
}