* tweak

* opt: async

* tweak

* opt: PopularSeries tile

* tweak

* opt: sc

* mod: more account type

* tweak

* opt: qrcode

* tweak

* partial revert: opt: sc

* fix

* fix

* mod: window enqueue
This commit is contained in:
My-Responsitories
2025-09-26 00:02:55 +08:00
committed by GitHub
parent 67c25bd130
commit 4ae3bd2845
29 changed files with 520 additions and 554 deletions

View File

@@ -105,6 +105,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
List<DanmakuElem>? currentDanmakuList = _plDanmakuController
.getCurrentDanmaku(currentPosition);
if (currentDanmakuList != null) {
final blockColorful = playerController.blockColorful;
for (DanmakuElem e in currentDanmakuList) {
if (e.mode == 7) {
try {
@@ -120,7 +121,7 @@ class _PlDanmakuState extends State<PlDanmaku> {
_controller!.addDanmaku(
DanmakuContentItem(
e.content,
color: playerController.blockColorful
color: blockColorful
? Colors.white
: DmUtils.decimalToColor(e.color),
type: DmUtils.getPosition(e.mode),

View File

@@ -30,8 +30,8 @@ class _LaterPageState extends State<LaterPage>
LaterController currCtr([int? index]) {
final type = LaterViewType.values[index ?? _tabController.index];
return Get.put(
LaterController(type),
return Get.putOrFind(
() => LaterController(type),
tag: type.type.toString(),
);
}

View File

@@ -241,7 +241,7 @@ class LiveRoomController extends GetxController {
Future<void> getSuperChatMsg() async {
final res = await LiveHttp.superChatMsg(roomId);
if (res.dataOrNull?.list case List<SuperChatItem> list) {
if (res.dataOrNull?.list case final list?) {
superChatMsg.addAll(list);
}
}
@@ -377,7 +377,7 @@ class LiveRoomController extends GetxController {
}
}
break;
case 'SUPER_CHAT_MESSAGE' when (showSuperChat):
case 'SUPER_CHAT_MESSAGE' when showSuperChat:
final item = SuperChatItem.fromJson(obj['data']);
superChatMsg.insert(0, item);
if (isFullScreen || plPlayerController.isDesktopPip) {
@@ -385,10 +385,8 @@ class LiveRoomController extends GetxController {
}
break;
}
} catch (e) {
if (kDebugMode) {
debugPrint('$e,,$obj');
}
} catch (_) {
if (kDebugMode) rethrow;
}
})
..init();

View File

@@ -43,9 +43,7 @@ class _SuperChatCardState extends State<SuperChatCard> {
}
void _remove() {
WidgetsBinding.instance.addPostFrameCallback(
(_) => Future.delayed(const Duration(seconds: 1), _onRemove),
);
Future.delayed(const Duration(seconds: 1), _onRemove);
}
void _onRemove() {

View File

@@ -30,10 +30,16 @@ class _SuperChatPanelState extends DebounceStreamState<SuperChatPanel, bool>
padding: const EdgeInsets.symmetric(horizontal: 12),
physics: const ClampingScrollPhysics(),
itemCount: widget.controller.superChatMsg.length,
findChildIndexCallback: (key) {
final index = widget.controller.superChatMsg.indexWhere(
(i) => i.id == (key as ValueKey<int>).value,
);
return index == -1 ? null : index;
},
itemBuilder: (context, index) {
final item = widget.controller.superChatMsg[index];
return SuperChatCard(
key: Key(item.id.toString()),
key: ValueKey(item.id),
item: item,
onRemove: () => ctr?.add(true),
);

View File

@@ -265,7 +265,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
child: TextButton(
onPressed: () {
_liveRoomController.fsSC.value = SuperChatItem.fromJson({
"id": Utils.generateRandomString(8),
"id": Utils.random.nextInt(2147483647),
"price": 66,
"end_time":
DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5,
@@ -300,7 +300,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
}
try {
return SizedBox(
key: Key(item.id.toString()),
key: ValueKey(item.id),
width: 255,
child: Stack(
clipBehavior: Clip.none,
@@ -330,6 +330,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
),
);
} catch (_) {
if (kDebugMode) rethrow;
return const SizedBox.shrink();
}
}),
@@ -740,7 +741,7 @@ class _LiveRoomPageState extends State<LiveRoomPage>
liveRoomController: _liveRoomController,
);
return Padding(
padding: EdgeInsets.only(bottom: 12, top: !isPortrait ? 0 : 12),
padding: EdgeInsets.only(bottom: 12, top: isPortrait ? 12 : 0),
child: _liveRoomController.showSuperChat
? PageView(
key: pageKey,

View File

@@ -87,7 +87,7 @@ class LiveRoomChatPanel extends StatelessWidget {
liveRoomController.superChatMsg.insert(
0,
SuperChatItem.fromJson({
"id": Utils.generateRandomString(8),
"id": Utils.random.nextInt(2147483647),
"price": 66,
"end_time":
DateTime.now().millisecondsSinceEpoch ~/ 1000 + 5,

View File

@@ -5,6 +5,7 @@ import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/button/icon_button.dart';
import 'package:PiliPlus/common/widgets/radio_widget.dart';
import 'package:PiliPlus/http/init.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/login.dart';
import 'package:PiliPlus/models/common/account_type.dart';
import 'package:PiliPlus/models/login/model.dart';
@@ -26,7 +27,8 @@ class LoginPageController extends GetxController
final TextEditingController smsCodeTextController = TextEditingController();
final TextEditingController cookieTextController = TextEditingController();
late final RxMap<String, dynamic> codeInfo = RxMap<String, dynamic>({});
late final codeInfo =
LoadingState<({String authCode, String url})>.loading().obs;
late final TabController tabController;
@@ -36,10 +38,7 @@ class LoginPageController extends GetxController
late final RxInt qrCodeLeftTime = 180.obs;
late final RxString statusQRCode = ''.obs;
late final List<Map<String, dynamic>> internationalDialingPrefix =
Constants.internationalDialingPrefix;
late Map<String, dynamic> selectedCountryCodeId =
internationalDialingPrefix.first;
late var selectedCountryCodeId = Constants.internationalDialingPrefix.first;
late String captchaKey = '';
late final RxInt smsSendCooldown = 0.obs;
late int smsSendTimestamp = 0;
@@ -48,6 +47,8 @@ class LoginPageController extends GetxController
Timer? qrCodeTimer;
Timer? smsSendCooldownTimer;
bool _isReq = false;
@override
void onInit() {
super.onInit();
@@ -70,46 +71,47 @@ class LoginPageController extends GetxController
super.onClose();
}
void refreshQRCode() {
LoginHttp.getHDcode().then((res) {
if (res['status']) {
qrCodeTimer?.cancel();
codeInfo.addAll(res);
qrCodeTimer = Timer.periodic(const Duration(milliseconds: 1000), (t) {
qrCodeLeftTime.value = 180 - t.tick;
if (qrCodeLeftTime <= 0) {
t.cancel();
statusQRCode.value = '二维码已过期,请刷新';
qrCodeLeftTime.value = 0;
return;
}
Future<void> refreshQRCode() async {
final res = await LoginHttp.getHDcode();
if (res.isSuccess) {
qrCodeTimer?.cancel();
codeInfo.value = res;
qrCodeTimer = Timer.periodic(const Duration(milliseconds: 1000), (t) {
final left = 180 - t.tick;
if (left <= 0) {
t.cancel();
statusQRCode.value = '二维码已过期,请刷新';
qrCodeLeftTime.value = 0;
return;
}
qrCodeLeftTime.value = left;
if (_isReq || tabController.index != 2) return;
LoginHttp.codePoll(codeInfo['data']['auth_code']).then((value) async {
if (value['status']) {
t.cancel();
statusQRCode.value = '扫码成功';
await setAccount(
value['data'],
value['data']['cookie_info']['cookies'],
);
Get.back();
} else if (value['code'] == 86038) {
t.cancel();
qrCodeLeftTime.value = 0;
} else {
statusQRCode.value = value['msg'];
}
});
_isReq = true;
LoginHttp.codePoll(res.data.authCode).then((value) async {
_isReq = false;
if (value['status']) {
t.cancel();
statusQRCode.value = '扫码成功';
await setAccount(
value['data'],
value['data']['cookie_info']['cookies'],
);
Get.back();
} else if (value['code'] == 86038) {
t.cancel();
qrCodeLeftTime.value = 0;
} else {
statusQRCode.value = value['msg'];
}
});
} else {
SmartDialog.showToast(res['msg']);
}
});
});
}
}
void _handleTabChange() {
if (tabController.index == 2) {
if (qrCodeTimer == null || qrCodeTimer!.isActive == false) {
if (qrCodeTimer == null || !qrCodeTimer!.isActive) {
refreshQRCode();
}
}
@@ -545,7 +547,7 @@ class LoginPageController extends GetxController
tel: telTextController.text,
code: smsCodeTextController.text,
captchaKey: captchaKey,
cid: selectedCountryCodeId['country_id'],
cid: selectedCountryCodeId.countryId,
key: key,
);
if (res['status']) {
@@ -608,7 +610,7 @@ class LoginPageController extends GetxController
var res = await LoginHttp.sendSmsCode(
tel: telTextController.text,
cid: selectedCountryCodeId['country_id'],
cid: selectedCountryCodeId.countryId,
// deviceTouristId: guestId,
geeValidate: captchaData.validate,
geeSeccode: captchaData.seccode,

View File

@@ -1,17 +1,21 @@
import 'dart:ui';
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/common/widgets/loading_widget/loading_widget.dart';
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/pages/login/controller.dart';
import 'package:PiliPlus/utils/extension.dart';
import 'package:PiliPlus/utils/image_utils.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart' hide ContextExtensionss;
import 'package:pretty_qr_code/pretty_qr_code.dart';
import 'package:url_launcher/url_launcher.dart';
class LoginPage extends StatefulWidget {
const LoginPage({super.key});
@@ -25,7 +29,7 @@ class _LoginPageState extends State<LoginPage> {
// 二维码生成时间
bool showPassword = false;
GlobalKey globalKey = GlobalKey();
final isMobile = Utils.isMobile;
bool get isMobile => kDebugMode || Utils.isMobile;
Widget loginByQRCode(ThemeData theme) {
return Column(
@@ -70,35 +74,48 @@ class _LoginPageState extends State<LoginPage> {
icon: const Icon(Icons.save),
label: const Text('保存至相册'),
),
if (isMobile)
TextButton.icon(
onPressed: () => launchUrl(
Uri.parse(_loginPageCtr.codeInfo.value.data.url),
mode: LaunchMode.externalNonBrowserApplication,
),
icon: const Icon(Icons.open_in_browser_outlined),
label: const Text('其他应用打开'),
),
],
),
RepaintBoundary(
key: globalKey,
child: Obx(() {
if (_loginPageCtr.codeInfo['data']?['url'] == null) {
return Container(
return switch (_loginPageCtr.codeInfo.value) {
Loading() => Container(
height: 200,
width: 200,
alignment: Alignment.center,
child: const CircularProgressIndicator(
semanticsLabel: '二维码加载中',
),
);
}
return Container(
width: 200,
height: 200,
color: Colors.white,
padding: const EdgeInsets.all(8),
child: PrettyQrView.data(
data: _loginPageCtr.codeInfo['data']!['url']!,
decoration: const PrettyQrDecoration(
shape: PrettyQrSquaresSymbol(
color: Colors.black87,
),
Success(:var response) => Container(
width: 200,
height: 200,
color: Colors.white,
padding: const EdgeInsets.all(8),
child: PrettyQrView.data(
data: response.url,
decoration: const PrettyQrDecoration(
shape: PrettyQrSquaresSymbol(
color: Colors.black87,
),
),
),
),
);
Error(:var errMsg) => errorWidget(
errMsg: errMsg,
onReload: _loginPageCtr.refreshQRCode,
),
};
}),
),
const SizedBox(height: 10),
@@ -109,21 +126,27 @@ class _LoginPageState extends State<LoginPage> {
),
),
Obx(
() => GestureDetector(
onTap: () => Utils.copyText(
_loginPageCtr.codeInfo['data']?['url'] ?? '',
toastText: '已复制到剪贴板可粘贴至已登录的app私信处发送然后点击已发送的链接打开',
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
child: Text(
_loginPageCtr.codeInfo['data']?['url'] ?? "",
style: theme.textTheme.labelSmall!.copyWith(
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
() {
final url = _loginPageCtr.codeInfo.value.dataOrNull?.url ?? '';
return GestureDetector(
onTap: () => Utils.copyText(
url,
toastText: '已复制到剪贴板可粘贴至已登录的app私信处发送然后点击已发送的链接打开',
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 20,
vertical: 20,
),
child: Text(
url,
style: theme.textTheme.labelSmall!.copyWith(
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
),
),
),
),
),
);
},
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
@@ -349,34 +372,31 @@ class _LoginPageState extends State<LoginPage> {
const SizedBox(width: 12),
Builder(
builder: (context) {
return PopupMenuButton<Map<String, dynamic>>(
return PopupMenuButton(
enabled: isMobile,
padding: EdgeInsets.zero,
tooltip:
'选择国际冠码,'
'当前为${_loginPageCtr.selectedCountryCodeId['cname']}'
'+${_loginPageCtr.selectedCountryCodeId['country_id']}',
onSelected: (Map<String, dynamic> type) {},
'当前为${_loginPageCtr.selectedCountryCodeId.cname}'
'+${_loginPageCtr.selectedCountryCodeId.countryId}',
onSelected: (item) {
_loginPageCtr.selectedCountryCodeId = item;
(context as Element).markNeedsBuild();
},
initialValue: _loginPageCtr.selectedCountryCodeId,
itemBuilder: (_) => _loginPageCtr
.internationalDialingPrefix
.map((Map<String, dynamic> item) {
return PopupMenuItem<Map<String, dynamic>>(
onTap: () {
_loginPageCtr.selectedCountryCodeId = item;
(context as Element).markNeedsBuild();
},
itemBuilder: (_) =>
Constants.internationalDialingPrefix.map((item) {
return PopupMenuItem(
value: item,
child: Row(
children: [
Text(item['cname']),
Text(item.cname),
const Spacer(),
Text("+${item['country_id']}"),
Text("+${item.countryId}"),
],
),
);
})
.toList(),
}).toList(),
child: Row(
children: [
Icon(
@@ -385,7 +405,7 @@ class _LoginPageState extends State<LoginPage> {
),
const SizedBox(width: 12),
Text(
"+${_loginPageCtr.selectedCountryCodeId['country_id']}",
"+${_loginPageCtr.selectedCountryCodeId.countryId}",
),
],
),

View File

@@ -57,10 +57,10 @@ class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
return gridSkeleton;
case Success<List<HotVideoItemModel>?>(:var response):
Widget sliver;
if (response?.isNotEmpty == true) {
if (response != null && response.isNotEmpty == true) {
sliver = SliverGrid.builder(
gridDelegate: gridDelegate,
itemCount: response!.length,
itemCount: response.length,
itemBuilder: (context, index) {
final item = response[index];
return VideoCardH(
@@ -126,7 +126,6 @@ class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
showDialog(
context: context,
builder: (context) {
final theme = Theme.of(context);
return Dialog(
clipBehavior: Clip.hardEdge,
child: SizedBox(
@@ -140,39 +139,27 @@ class _PopularSeriesPageState extends State<PopularSeriesPage> with GridMixin {
itemBuilder: (context, index) {
final item = seriesList[index];
final isCurr = index == currIndex;
Widget child = Text(
item.name!,
style: const TextStyle(fontSize: 14),
);
if (isCurr) {
child = Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
child,
const Icon(Icons.check, size: 18),
],
);
}
return Material(
color: isCurr ? theme.highlightColor : null,
child: InkWell(
onTap: () {
Get.back();
if (!isCurr) {
_controller
..number = item.number!
..onReload();
}
},
child: Padding(
padding: const EdgeInsetsGeometry.symmetric(
horizontal: 16,
),
child: Align(
alignment: Alignment.centerLeft,
child: child,
),
),
return ListTile(
dense: true,
minTileHeight: 44,
selected: isCurr,
onTap: () {
Get.back();
if (!isCurr) {
_controller
..number = item.number!
..onReload();
}
},
title: Text(
item.name!,
style: const TextStyle(fontSize: 14),
),
trailing: isCurr
? const Icon(Icons.check, size: 18)
: null,
contentPadding: const EdgeInsetsGeometry.symmetric(
horizontal: 16,
),
);
},

View File

@@ -7,9 +7,8 @@ import 'package:get/get.dart';
class NoteListPageCtr
extends CommonListController<VideoNoteData, VideoNoteItemModel> {
NoteListPageCtr({this.oid, this.upperMid});
final dynamic oid;
final dynamic upperMid;
NoteListPageCtr({required this.oid});
final int oid;
RxInt count = (-1).obs;
@@ -37,7 +36,6 @@ class NoteListPageCtr
Future<LoadingState<VideoNoteData>> customGetData() =>
VideoHttp.getVideoNoteList(
oid: oid,
uperMid: upperMid,
page: page,
);
}

View File

@@ -20,17 +20,15 @@ class NoteListPage extends CommonSlidePage {
super.key,
super.enableSlide,
required this.heroTag,
this.oid,
this.upperMid,
required this.oid,
required this.isStein,
required this.title,
});
final dynamic heroTag;
final dynamic oid;
final dynamic upperMid;
final String? heroTag;
final int oid;
final bool isStein;
final dynamic title;
final String? title;
@override
State<NoteListPage> createState() => _NoteListPageState();
@@ -39,7 +37,7 @@ class NoteListPage extends CommonSlidePage {
class _NoteListPageState extends State<NoteListPage>
with SingleTickerProviderStateMixin, CommonSlideMixin {
late final _controller = Get.put(
NoteListPageCtr(oid: widget.oid, upperMid: widget.upperMid),
NoteListPageCtr(oid: widget.oid),
tag: widget.heroTag,
);