Skip to content

Commit

Permalink
一些布局与性能优化,修复状态栏bug、倍速/弹幕设置,弹幕带重试
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jan 1, 2025
1 parent b56e03c commit f7189b1
Show file tree
Hide file tree
Showing 24 changed files with 817 additions and 1,030 deletions.
6 changes: 6 additions & 0 deletions lib/common/skeleton/video_card_v.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class VideoCardVSkeleton extends StatelessWidget {
margin: const EdgeInsets.only(bottom: 12),
color: Theme.of(context).colorScheme.onInverseSurface,
),
Container(
width: 150,
height: 13,
margin: const EdgeInsets.only(bottom: 12),
color: Theme.of(context).colorScheme.onInverseSurface,
),
],
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/common/widgets/custom_toast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CustomToast extends StatelessWidget {
@override
Widget build(BuildContext context) {
final double toastOpacity =
setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0) as double;
setting.get(SettingBoxKey.defaultToastOp, defaultValue: 1.0).toDouble();
return Container(
margin:
EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom + 30),
Expand Down
32 changes: 22 additions & 10 deletions lib/http/danmaku.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,37 @@ import 'index.dart';

class DanmakaHttp {
// 获取视频弹幕
static Future queryDanmaku({
static Future<DmSegMobileReply> queryDanmaku({
required int cid,
required int segmentIndex,
int maxRetries = 3, // 最大重试次数
}) async {
// 构建参数对象
Map<String, int> params = {
'type': 1,
'oid': cid,
'segment_index': segmentIndex,
};
var response = await Request().get(
Api.webDanmaku,
data: params,
extra: {'resType': ResponseType.bytes},
);
if (response.statusCode != 200 || response.data == null) {
return DmSegMobileReply();

int retryCount = 0;
while (retryCount < maxRetries) {
var response = await Request().get(
Api.webDanmaku,
data: params,
extra: {'resType': ResponseType.bytes},
);

if (response.statusCode == 200) {
return response.data != null
? DmSegMobileReply.fromBuffer(response.data)
: DmSegMobileReply();
}
print('第${retryCount + 1}次重试失败, 状态码:${response.statusCode}');
retryCount++;
await Future.delayed(const Duration(seconds: 1)); // 重试间隔时间
}
return DmSegMobileReply.fromBuffer(response.data);

print('所有重试失败,返回默认值');
return DmSegMobileReply();
}

static Future shootDanmaku({
Expand Down
117 changes: 56 additions & 61 deletions lib/pages/about/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:hive/hive.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:PiliPalaX/http/index.dart';
import 'package:PiliPalaX/models/github/latest.dart';
Expand Down Expand Up @@ -50,41 +51,29 @@ class _AboutPageState extends State<AboutPage> {
),
body: ListView(
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 150),
child: ExcludeSemantics(
child: Image.asset(
Column(children: [
Image.asset(
excludeFromSemantics: true,
height: 150,
'assets/images/logo/logo_android_2.png',
)),
),
ListTile(
title: Text('PiliPalaX',
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.titleMedium!
.copyWith(height: 2)),
subtitle: Row(children: [
const Spacer(),
Text(
'使用Flutter开发的B站第三方客户端',
textAlign: TextAlign.center,
style: TextStyle(color: Theme.of(context).colorScheme.outline),
semanticsLabel: '与你一起,发现不一样的世界',
),
const Icon(
Icons.accessibility_new,
semanticLabel: "无障碍适配",
size: 18,
),
const Spacer(),
]),
),
),
Text('PiliPalaX',
textAlign: TextAlign.left,
style: Theme.of(context).textTheme.titleMedium,
semanticsLabel: 'PiliPalaX 与你一起,发现不一样的世界'),
Text(
'使用Flutter开发的B站第三方客户端⁺',
textAlign: TextAlign.left,
style: TextStyle(
color: Theme.of(context).colorScheme.outline, height: 3),
semanticsLabel: '使用Flutter开发的B站第三方客户端(带无障碍适配)',
),
]),
Obx(
() => ListTile(
onTap: () => _aboutController.tapOnVersion(),
title: const Text('当前版本'),
leading: const Icon(Icons.commit_outlined),
leading: Icon(MdiIcons.sourceCommitLocal),
trailing: Text(_aboutController.currentVersion.value,
style: subTitleStyle),
),
Expand All @@ -93,7 +82,7 @@ class _AboutPageState extends State<AboutPage> {
() => ListTile(
onTap: () => _aboutController.onUpdate(),
title: const Text('最新版本'),
leading: const Icon(Icons.flag_outlined),
leading: Icon(MdiIcons.newBox),
trailing: Text(
_aboutController.isLoading.value
? '正在获取'
Expand All @@ -119,26 +108,16 @@ class _AboutPageState extends State<AboutPage> {
),
ListTile(
onTap: () => _aboutController.githubUrl(),
leading: const Icon(Icons.star_outline_outlined),
title: const Text('Github开源仓库'),
leading: Icon(MdiIcons.github),
title: const Text('开源仓库⭐'),
trailing: Text(
'github.com/orz12/PiliPalaX',
'Github.com/orz12/PiliPalaX',
style: subTitleStyle,
),
),
ListTile(
onTap: () => _aboutController.feedback(context),
leading: const Icon(Icons.feedback_outlined),
title: const Text('问题反馈'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 16,
color: outline,
),
),
ListTile(
onTap: () => _aboutController.qqGroup(),
leading: const Icon(Icons.group_add_outlined),
leading: Icon(MdiIcons.qqchat),
title: const Text('QQ群'),
trailing: Text(
'392176105',
Expand All @@ -147,19 +126,29 @@ class _AboutPageState extends State<AboutPage> {
),
ListTile(
onTap: () => _aboutController.tgChannel(),
leading: const Icon(Icons.group_add_outlined),
title: const Text('TG频道'),
leading: Icon(MdiIcons.sendCircle),
title: const Text('TG群'),
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
),
ListTile(
onTap: () => _aboutController.aPay(),
leading: const Icon(Icons.wallet_giftcard_outlined),
title: const Text('赞赏'),
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
onTap: () => _aboutController.feedback(context),
leading: Icon(MdiIcons.chatAlert),
title: const Text('问题反馈'),
trailing: Icon(
Icons.arrow_forward_ios,
size: 16,
color: outline,
),
),
// ListTile(
// onTap: () => _aboutController.aPay(),
// leading: const Icon(Icons.wallet_giftcard_outlined),
// title: const Text('赞赏'),
// trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
// ),
ListTile(
onTap: () => _aboutController.logs(),
leading: const Icon(Icons.bug_report_outlined),
leading: const Icon(Icons.bug_report),
title: const Text('错误日志'),
trailing: Icon(Icons.arrow_forward_ios, size: 16, color: outline),
),
Expand All @@ -168,14 +157,14 @@ class _AboutPageState extends State<AboutPage> {
await CacheManage().clearCacheAll(context);
getCacheSize();
},
leading: const Icon(Icons.delete_outline),
leading: const Icon(Icons.delete),
title: const Text('清除缓存'),
subtitle: Text('图片及网络缓存 $cacheSize', style: subTitleStyle),
trailing: Text('图片及网络缓存 $cacheSize', style: subTitleStyle),
),
ListTile(
title: const Text('导入/导出设置'),
dense: false,
leading: const Icon(Icons.import_export_outlined),
leading: const Icon(Icons.import_export),
onTap: () async {
await showDialog(
context: context,
Expand Down Expand Up @@ -244,7 +233,7 @@ class _AboutPageState extends State<AboutPage> {
}),
ListTile(
title: const Text('重置所有设置'),
leading: const Icon(Icons.settings_backup_restore_outlined),
leading: const Icon(Icons.settings_backup_restore),
onTap: () async {
await showDialog(
context: context,
Expand Down Expand Up @@ -301,7 +290,7 @@ class AboutController extends GetxController {
late LatestDataModel remoteAppInfo;
RxBool isUpdate = true.obs;
RxBool isLoading = true.obs;
late LatestDataModel data;
LatestDataModel? data;
RxInt count = 0.obs;

@override
Expand Down Expand Up @@ -348,15 +337,21 @@ class AboutController extends GetxController {
return false;
}
data = LatestDataModel.fromJson(result.data[0]);
remoteAppInfo = data;
remoteVersion.value = data.tagName!;
remoteAppInfo = data!;
remoteVersion.value = data!.tagName!;
isUpdate.value =
Utils.needUpdate(currentVersion.value, remoteVersion.value);
isLoading.value = false;
}

// 跳转下载/本地更新
Future onUpdate() async {
if (data == null) {
SmartDialog.showLoading(msg: '正在尝试从Github获取最新版本');
await getRemoteApp();
SmartDialog.dismiss();
return;
}
Utils.matchVersion(data);
}

Expand Down Expand Up @@ -397,7 +392,7 @@ class AboutController extends GetxController {
context: context,
builder: (context) {
return SimpleDialog(
title: const Text('问题反馈(建议直接加群反馈)'),
title: const Text('问题反馈\n(建议直接加群)'),
children: [
ListTile(
title: const Text('GitHub Issue'),
Expand Down Expand Up @@ -438,7 +433,7 @@ class AboutController extends GetxController {
}
}

// tg频道
// tg群
tgChannel() {
Clipboard.setData(
const ClipboardData(text: 'https://t.me/+162zlPtZlT9hNWVl'),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/danmaku/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PlDanmakuController {
final int cid;
static int danmakuWeight = 0;
static List<Map<String, dynamic>> danmakuFilter = [];
PlDanmakuController(this.cid){
PlDanmakuController(this.cid) {
refresh();
}

Expand Down
Loading

0 comments on commit f7189b1

Please sign in to comment.