mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: 专栏排版优化
This commit is contained in:
@@ -57,6 +57,7 @@ class HtmlRender extends StatelessWidget {
|
|||||||
width: isEmote ? 22 : Get.size.width - 24,
|
width: isEmote ? 22 : Get.size.width - 24,
|
||||||
height: isEmote ? 22 : 200,
|
height: isEmote ? 22 : 200,
|
||||||
src: imgUrl,
|
src: imgUrl,
|
||||||
|
ignoreHeight: !isEmote,
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
@@ -66,20 +67,26 @@ class HtmlRender extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
style: {
|
style: {
|
||||||
'html': Style(
|
'html': Style(
|
||||||
fontSize: FontSize.medium,
|
fontSize: FontSize.large,
|
||||||
lineHeight: LineHeight.percent(140),
|
lineHeight: LineHeight.percent(160),
|
||||||
|
letterSpacing: 0.3,
|
||||||
),
|
),
|
||||||
|
// 'br': Style(margin: Margins.zero, padding: HtmlPaddings.zero),
|
||||||
'body': Style(margin: Margins.zero, padding: HtmlPaddings.zero),
|
'body': Style(margin: Margins.zero, padding: HtmlPaddings.zero),
|
||||||
'a': Style(
|
'a': Style(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
textDecoration: TextDecoration.none,
|
textDecoration: TextDecoration.none,
|
||||||
),
|
),
|
||||||
|
'br': Style(
|
||||||
|
lineHeight: LineHeight.percent(-1),
|
||||||
|
),
|
||||||
'p': Style(
|
'p': Style(
|
||||||
margin: Margins.only(bottom: 10),
|
margin: Margins.only(bottom: 4),
|
||||||
|
// margin: Margins.zero,
|
||||||
),
|
),
|
||||||
'span': Style(
|
'span': Style(
|
||||||
fontSize: FontSize.medium,
|
fontSize: FontSize.medium,
|
||||||
height: Height(1.65),
|
height: Height(1.8),
|
||||||
),
|
),
|
||||||
'div': Style(height: Height.auto()),
|
'div': Style(height: Height.auto()),
|
||||||
'li > p': Style(
|
'li > p': Style(
|
||||||
@@ -90,6 +97,25 @@ class HtmlRender extends StatelessWidget {
|
|||||||
textAlign: TextAlign.justify,
|
textAlign: TextAlign.justify,
|
||||||
),
|
),
|
||||||
'img': Style(margin: Margins.only(top: 4, bottom: 4)),
|
'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,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
this.quality,
|
this.quality,
|
||||||
this.origAspectRatio,
|
this.origAspectRatio,
|
||||||
this.semanticsLabel,
|
this.semanticsLabel,
|
||||||
|
this.ignoreHeight,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String? src;
|
final String? src;
|
||||||
@@ -33,6 +34,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
final int? quality;
|
final int? quality;
|
||||||
final double? origAspectRatio;
|
final double? origAspectRatio;
|
||||||
final String? semanticsLabel;
|
final String? semanticsLabel;
|
||||||
|
final bool? ignoreHeight;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -65,7 +67,7 @@ class NetworkImgLayer extends StatelessWidget {
|
|||||||
child: CachedNetworkImage(
|
child: CachedNetworkImage(
|
||||||
imageUrl: imageUrl,
|
imageUrl: imageUrl,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: ignoreHeight == null || ignoreHeight == false? height:null,
|
||||||
memCacheWidth: memCacheWidth,
|
memCacheWidth: memCacheWidth,
|
||||||
memCacheHeight: memCacheHeight,
|
memCacheHeight: memCacheHeight,
|
||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class WebviewController extends GetxController {
|
|||||||
controller
|
controller
|
||||||
..setUserAgent(Request().headerUa(type: uaType))
|
..setUserAgent(Request().headerUa(type: uaType))
|
||||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||||
|
..enableZoom(true)
|
||||||
..setNavigationDelegate(
|
..setNavigationDelegate(
|
||||||
NavigationDelegate(
|
NavigationDelegate(
|
||||||
// 页面加载
|
// 页面加载
|
||||||
@@ -52,7 +53,9 @@ class WebviewController extends GetxController {
|
|||||||
loadProgress.value = progress;
|
loadProgress.value = progress;
|
||||||
},
|
},
|
||||||
onPageStarted: (String url) {
|
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 Map matchRes = IdUtils.matchAvorBv(input: str);
|
||||||
final List matchKeys = matchRes.keys.toList();
|
final List matchKeys = matchRes.keys.toList();
|
||||||
if (matchKeys.isNotEmpty) {
|
if (matchKeys.isNotEmpty) {
|
||||||
@@ -70,7 +73,13 @@ class WebviewController extends GetxController {
|
|||||||
//注入js
|
//注入js
|
||||||
controller.runJavaScriptReturningResult('''
|
controller.runJavaScriptReturningResult('''
|
||||||
document.styleSheets[0].insertRule('div.open-app-btn.bili-btn-warp {display:none;}', 0);
|
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));
|
''').then((value) => print(value));
|
||||||
|
} else if (type.value == 'whisper') {
|
||||||
|
controller.runJavaScriptReturningResult('''
|
||||||
|
document.querySelector('#internationalHeader').remove();
|
||||||
|
document.querySelector('#message-navbar').remove();
|
||||||
|
''').then((value) => print(value));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 加载完成
|
// 加载完成
|
||||||
|
|||||||
Reference in New Issue
Block a user