mod: 专栏排版优化

This commit is contained in:
orz12
2024-04-04 10:33:18 +08:00
parent d700851c6c
commit e3fb4d4b28
3 changed files with 43 additions and 6 deletions

View File

@@ -57,6 +57,7 @@ class HtmlRender extends StatelessWidget {
width: isEmote ? 22 : Get.size.width - 24,
height: isEmote ? 22 : 200,
src: imgUrl,
ignoreHeight: !isEmote,
);
} catch (err) {
return const SizedBox();
@@ -66,20 +67,26 @@ class HtmlRender extends StatelessWidget {
],
style: {
'html': Style(
fontSize: FontSize.medium,
lineHeight: LineHeight.percent(140),
fontSize: FontSize.large,
lineHeight: LineHeight.percent(160),
letterSpacing: 0.3,
),
// 'br': Style(margin: Margins.zero, padding: HtmlPaddings.zero),
'body': Style(margin: Margins.zero, padding: HtmlPaddings.zero),
'a': Style(
color: Theme.of(context).colorScheme.primary,
textDecoration: TextDecoration.none,
),
'br': Style(
lineHeight: LineHeight.percent(-1),
),
'p': Style(
margin: Margins.only(bottom: 10),
margin: Margins.only(bottom: 4),
// margin: Margins.zero,
),
'span': Style(
fontSize: FontSize.medium,
height: Height(1.65),
height: Height(1.8),
),
'div': Style(height: Height.auto()),
'li > p': Style(
@@ -90,6 +97,25 @@ class HtmlRender extends StatelessWidget {
textAlign: TextAlign.justify,
),
'img': Style(margin: Margins.only(top: 4, bottom: 4)),
'h1,h2': Style(
fontSize: FontSize.xLarge,
fontWeight: FontWeight.bold,
margin: Margins.only(bottom: 8),
),
'h3,h4,h5': Style(
fontSize: FontSize.large,
fontWeight: FontWeight.bold,
margin: Margins.only(bottom: 4),
),
'figcaption': Style(
fontSize: FontSize.medium,
textAlign: TextAlign.center,
// margin: Margins.only(top: 4),
),
'strong': Style(fontWeight: FontWeight.bold),
'figure': Style(
margin: Margins.zero,
),
},
);
}

View File

@@ -22,6 +22,7 @@ class NetworkImgLayer extends StatelessWidget {
this.quality,
this.origAspectRatio,
this.semanticsLabel,
this.ignoreHeight,
});
final String? src;
@@ -33,6 +34,7 @@ class NetworkImgLayer extends StatelessWidget {
final int? quality;
final double? origAspectRatio;
final String? semanticsLabel;
final bool? ignoreHeight;
@override
Widget build(BuildContext context) {
@@ -65,7 +67,7 @@ class NetworkImgLayer extends StatelessWidget {
child: CachedNetworkImage(
imageUrl: imageUrl,
width: width,
height: height,
height: ignoreHeight == null || ignoreHeight == false? height:null,
memCacheWidth: memCacheWidth,
memCacheHeight: memCacheHeight,
fit: BoxFit.cover,

View File

@@ -44,6 +44,7 @@ class WebviewController extends GetxController {
controller
..setUserAgent(Request().headerUa(type: uaType))
..setJavaScriptMode(JavaScriptMode.unrestricted)
..enableZoom(true)
..setNavigationDelegate(
NavigationDelegate(
// 页面加载
@@ -52,7 +53,9 @@ class WebviewController extends GetxController {
loadProgress.value = progress;
},
onPageStarted: (String url) {
final String str = Uri.parse(url).pathSegments[0];
final parseUrl = Uri.parse(url);
if (parseUrl.pathSegments.isEmpty) return;
final String str = parseUrl.pathSegments[0];
final Map matchRes = IdUtils.matchAvorBv(input: str);
final List matchKeys = matchRes.keys.toList();
if (matchKeys.isNotEmpty) {
@@ -70,7 +73,13 @@ class WebviewController extends GetxController {
//注入js
controller.runJavaScriptReturningResult('''
document.styleSheets[0].insertRule('div.open-app-btn.bili-btn-warp {display:none;}', 0);
document.styleSheets[0].insertRule('#app__display-area > div.control-panel {display:none;}', 0);
''').then((value) => print(value));
} else if (type.value == 'whisper') {
controller.runJavaScriptReturningResult('''
document.querySelector('#internationalHeader').remove();
document.querySelector('#message-navbar').remove();
''').then((value) => print(value));
}
},
// 加载完成