* opt: live extra

* opt: remove addPointer

* opt: use ssd

* opt: cache svg

* opt: localToGlobal

* opt: disabled icon

* opt: onVideoDetailChange switch

* fix

---------

Co-authored-by: dom <githubaccount56556@proton.me>
This commit is contained in:
My-Responsitories
2026-02-25 18:01:43 +08:00
committed by GitHub
parent 4a3d827f7a
commit e707764f84
19 changed files with 159 additions and 238 deletions

View File

@@ -182,12 +182,12 @@ class LiveRoomController extends GetxController {
void onInit() {
super.onInit();
scrollController = ScrollController()..addListener(listener);
final account = Accounts.heartbeat;
final account = Accounts.main;
isLogin = account.isLogin;
mid = account.mid;
queryLiveUrl();
queryLiveInfoH5();
if (isLogin && !Pref.historyPause) {
if (Accounts.heartbeat.isLogin && !Pref.historyPause) {
VideoHttp.roomEntryAction(roomId: roomId);
}
if (showSuperChat) {
@@ -428,7 +428,7 @@ class LiveRoomController extends GetxController {
LiveMessageStream(
streamToken: info.token!,
roomId: roomId,
uid: mid,
uid: Accounts.heartbeat.mid,
servers: info.hostList!
.map((host) => 'wss://${host.host}:${host.wssPort}/sub')
.toList(),
@@ -488,7 +488,6 @@ class LiveRoomController extends GetxController {
addDm(
DanmakuMsg(
name: name,
uid: uid,
text: msg,
emots: (extra['emots'] as Map<String, dynamic>?)?.map(
(k, v) => MapEntry(k, BaseEmote.fromJson(v)),
@@ -574,7 +573,7 @@ class LiveRoomController extends GetxController {
}
Future<void> onLike() async {
if (!Accounts.main.isLogin) {
if (!isLogin) {
likeClickTime.value = 0;
return;
}
@@ -593,7 +592,7 @@ class LiveRoomController extends GetxController {
}
void onSendDanmaku([bool fromEmote = false]) {
if (!Accounts.main.isLogin) {
if (!isLogin) {
SmartDialog.showToast('账号未登录');
return;
}
@@ -623,7 +622,7 @@ class LiveRoomController extends GetxController {
}
void reportSC(SuperChatItem item) {
if (!Accounts.main.isLogin) {
if (!isLogin) {
SmartDialog.showToast('账号未登录');
return;
}

View File

@@ -714,7 +714,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
..savedDanmaku = [
RichTextItem.fromStart(
'@${item.name} ',
rawText: item.uid.toString(),
rawText: item.extra.mid.toString(),
type: .at,
id: item.extra.id.toString(),
),

View File

@@ -8,7 +8,6 @@ import 'package:PiliPlus/models_new/live/live_superchat/item.dart';
import 'package:PiliPlus/pages/live_room/controller.dart';
import 'package:PiliPlus/pages/live_room/superchat/superchat_card.dart';
import 'package:PiliPlus/pages/video/widgets/header_control.dart';
import 'package:PiliPlus/utils/accounts.dart';
import 'package:PiliPlus/utils/extension/theme_ext.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/foundation.dart' show kDebugMode;
@@ -82,7 +81,7 @@ class LiveRoomChatPanel extends StatelessWidget {
color: nameColor,
fontSize: 14,
),
recognizer: item.uid == 0
recognizer: item.extra.mid == 0
? null
: (NoDeadlineTapGestureRecognizer()
..onTapUp = (e) => _showMsgMenu(
@@ -292,7 +291,11 @@ class LiveRoomChatPanel extends StatelessWidget {
) {
final dx = details.globalPosition.dx;
final renderBox = itemContext.findRenderObject() as RenderBox;
final dy = renderBox.localToGlobal(renderBox.size.bottomLeft(.zero)).dy;
final dy =
details.globalPosition.dy -
details.localPosition.dy +
renderBox.size.height -
4; // padding
final autoScroll =
liveRoomController.autoScroll &&
!liveRoomController.disableAutoScroll.value;
@@ -321,7 +324,7 @@ class LiveRoomChatPanel extends StatelessWidget {
),
PopupMenuItem(
height: 38,
onTap: () => Get.toNamed('/member?mid=${item.uid}'),
onTap: () => Get.toNamed('/member?mid=${item.extra.mid}'),
child: const Text(
'去TA的个人空间',
style: TextStyle(fontSize: 13),
@@ -338,9 +341,9 @@ class LiveRoomChatPanel extends StatelessWidget {
PopupMenuItem(
height: 38,
onTap: () async {
if (!Accounts.main.isLogin) return;
if (!liveRoomController.isLogin) return;
final res = await LiveHttp.liveShieldUser(
uid: item.uid,
uid: item.extra.mid,
roomid: roomId,
type: 1,
);

View File

@@ -25,9 +25,11 @@ import 'package:PiliPlus/pages/setting/widgets/multi_select_dialog.dart';
import 'package:PiliPlus/pages/setting/widgets/select_dialog.dart';
import 'package:PiliPlus/pages/setting/widgets/slider_dialog.dart';
import 'package:PiliPlus/plugin/pl_player/utils/fullscreen.dart';
import 'package:PiliPlus/utils/extension/file_ext.dart';
import 'package:PiliPlus/utils/extension/num_ext.dart';
import 'package:PiliPlus/utils/extension/theme_ext.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:PiliPlus/utils/path_utils.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:PiliPlus/utils/storage.dart';
import 'package:PiliPlus/utils/storage_key.dart';
@@ -38,6 +40,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:path/path.dart' as path;
List<SettingsModel> get styleSettings => [
if (PlatformUtils.isDesktop) ...[
@@ -56,16 +59,7 @@ List<SettingsModel> get styleSettings => [
needReboot: true,
),
],
if (Platform.isLinux)
const SwitchModel(
title: '使用SSDServer-Side Decoration',
subtitle: 'Linux强制使用Server-Side Decoration',
leading: Icon(Icons.web_asset),
setKey: SettingBoxKey.useSSD,
defaultVal: false,
needReboot: true,
onChanged: GStorage.syncToDisk,
),
if (Platform.isLinux) _useSSDModel(),
SwitchModel(
title: '横屏适配',
subtitle: '启用横屏布局与逻辑,平板、折叠屏等可开启;建议全屏方向设为【不改变当前方向】',
@@ -920,3 +914,31 @@ Future<void> _showBarHideTypeDialog(
setState();
}
}
NormalModel _useSSDModel() {
final file = File(path.join(appSupportDirPath, 'use_ssd'));
void onChanged(BuildContext context, VoidCallback setState) {
(file.existsSync() ? file.tryDel() : file.create()).whenComplete(() {
if (context.mounted) {
setState();
}
});
}
return NormalModel(
title: '使用SSDServer-Side Decoration',
leading: const Icon(Icons.web_asset),
onTap: onChanged,
getTrailing: (theme) => Builder(
builder: (context) => Transform.scale(
scale: 0.8,
alignment: .centerRight,
child: Switch(
value: file.existsSync(),
onChanged: (_) =>
onChanged(context, (context as Element).markNeedsBuild),
),
),
),
);
}

View File

@@ -45,19 +45,19 @@ class _PopupListTileState<T> extends State<PopupListTile<T>> {
final _key = PlatformUtils.isDesktop ? null : GlobalKey();
void _showButtonMenu(TapUpDetails details, T value) {
final box = context.findRenderObject() as RenderBox;
final offset = box.localToGlobal(box.size.topLeft(.zero));
final thisOffset = details.globalPosition - details.localPosition;
final double dx;
if (PlatformUtils.isDesktop) {
dx = details.globalPosition.dx + 1;
} else {
final box = _key!.currentContext!.findRenderObject() as RenderBox;
final offset = box.localToGlobal(box.size.topLeft(.zero));
dx = offset.dx;
final thisBox = context.findRenderObject() as RenderBox;
final titleBox = _key!.currentContext!.findRenderObject() as RenderBox;
final titleOffset = titleBox.localToGlobal(.zero, ancestor: thisBox);
dx = thisOffset.dx + titleOffset.dx;
}
showMenu<T?>(
context: context,
position: RelativeRect.fromLTRB(dx, offset.dy + 5, dx, 0),
position: RelativeRect.fromLTRB(dx, thisOffset.dy + 5, dx, 0),
items: widget.itemBuilder(context),
initialValue: value,
requestFocus: false,