Merge branch 'fix-replyReqError'

This commit is contained in:
guozhigq
2024-01-31 22:44:14 +08:00
11 changed files with 56 additions and 57 deletions

View File

@ -4,7 +4,7 @@ import 'init.dart';
class ReplyHttp { class ReplyHttp {
static Future replyList({ static Future replyList({
required dynamic oid, required int oid,
required int pageNum, required int pageNum,
required int type, required int type,
int? ps, int? ps,
@ -76,7 +76,7 @@ class ReplyHttp {
// 评论点赞 // 评论点赞
static Future likeReply({ static Future likeReply({
required int type, required int type,
required dynamic oid, required int oid,
required int rpid, required int rpid,
required int action, required int action,
}) async { }) async {

View File

@ -331,7 +331,7 @@ class VideoHttp {
// plat num 发送平台标识 非必要 1web端 2安卓客户端 3ios客户端 4wp客户端 // plat num 发送平台标识 非必要 1web端 2安卓客户端 3ios客户端 4wp客户端
static Future replyAdd({ static Future replyAdd({
required ReplyType type, required ReplyType type,
required dynamic oid, required int oid,
required String message, required String message,
int? root, int? root,
int? parent, int? parent,

View File

@ -266,7 +266,7 @@ class BangumiIntroController extends GetxController {
/// 未渲染回复组件时可能异常 /// 未渲染回复组件时可能异常
VideoReplyController videoReplyCtr = VideoReplyController videoReplyCtr =
Get.find<VideoReplyController>(tag: Get.arguments['heroTag']); Get.find<VideoReplyController>(tag: Get.arguments['heroTag']);
videoReplyCtr.oid = bvid; videoReplyCtr.aid = aid;
videoReplyCtr.queryReplyList(type: 'init'); videoReplyCtr.queryReplyList(type: 'init');
} catch (_) {} } catch (_) {}
} }

View File

@ -385,8 +385,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
isScrollControlled: true, isScrollControlled: true,
builder: (BuildContext context) { builder: (BuildContext context) {
return VideoReplyNewDialog( return VideoReplyNewDialog(
oid: _dynamicDetailController.oid?.toString() ?? oid: _dynamicDetailController.oid ??
Get.parameters['bvid'], IdUtils.bv2av(Get.parameters['bvid']!),
root: 0, root: 0,
parent: 0, parent: 0,
replyType: ReplyType.values[replyType], replyType: ReplyType.values[replyType],

View File

@ -13,7 +13,6 @@ import 'package:pilipala/pages/video/detail/reply/widgets/reply_item.dart';
import 'package:pilipala/pages/video/detail/reply_new/index.dart'; import 'package:pilipala/pages/video/detail/reply_new/index.dart';
import 'package:pilipala/pages/video/detail/reply_reply/index.dart'; import 'package:pilipala/pages/video/detail/reply_reply/index.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'controller.dart'; import 'controller.dart';
@ -428,7 +427,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
isScrollControlled: true, isScrollControlled: true,
builder: (BuildContext context) { builder: (BuildContext context) {
return VideoReplyNewDialog( return VideoReplyNewDialog(
oid: IdUtils.av2bv(_htmlRenderCtr.oid.value), oid: _htmlRenderCtr.oid.value,
root: 0, root: 0,
parent: 0, parent: 0,
replyType: ReplyType.values[type], replyType: ReplyType.values[type],

View File

@ -478,7 +478,7 @@ class VideoIntroController extends GetxController {
/// 未渲染回复组件时可能异常 /// 未渲染回复组件时可能异常
final VideoReplyController videoReplyCtr = final VideoReplyController videoReplyCtr =
Get.find<VideoReplyController>(tag: heroTag); Get.find<VideoReplyController>(tag: heroTag);
videoReplyCtr.oid = bvid; videoReplyCtr.aid = aid;
videoReplyCtr.queryReplyList(type: 'init'); videoReplyCtr.queryReplyList(type: 'init');
} catch (_) {} } catch (_) {}
this.bvid = bvid; this.bvid = bvid;

View File

@ -11,13 +11,13 @@ import 'package:pilipala/utils/storage.dart';
class VideoReplyController extends GetxController { class VideoReplyController extends GetxController {
VideoReplyController( VideoReplyController(
this.oid, this.aid,
this.rpid, this.rpid,
this.replyLevel, this.replyLevel,
); );
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
// 视频aid 请求时使用的oid // 视频aid 请求时使用的oid
String? oid; int? aid;
// 层级 2为楼中楼 // 层级 2为楼中楼
String? replyLevel; String? replyLevel;
// rpid 请求楼中楼回复 // rpid 请求楼中楼回复
@ -57,7 +57,7 @@ class VideoReplyController extends GetxController {
return; return;
} }
final res = await ReplyHttp.replyList( final res = await ReplyHttp.replyList(
oid: oid!, oid: aid!,
pageNum: currentPage + 1, pageNum: currentPage + 1,
ps: ps, ps: ps,
type: ReplyType.video.index, type: ReplyType.video.index,

View File

@ -40,7 +40,6 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
bool _isFabVisible = true; bool _isFabVisible = true;
String replyLevel = '1'; String replyLevel = '1';
late String heroTag; late String heroTag;
late String oid;
// 添加页面缓存 // 添加页面缓存
@override @override
@ -49,7 +48,7 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
oid = widget.bvid != null ? widget.bvid! : '0'; int oid = widget.bvid != null ? IdUtils.bv2av(widget.bvid!) : 0;
heroTag = Get.arguments['heroTag']; heroTag = Get.arguments['heroTag'];
replyLevel = widget.replyLevel ?? '1'; replyLevel = widget.replyLevel ?? '1';
if (replyLevel == '2') { if (replyLevel == '2') {
@ -298,8 +297,8 @@ class _VideoReplyPanelState extends State<VideoReplyPanel>
isScrollControlled: true, isScrollControlled: true,
builder: (BuildContext context) { builder: (BuildContext context) {
return VideoReplyNewDialog( return VideoReplyNewDialog(
oid: oid: _videoReplyController.aid ??
_videoReplyController.oid ?? Get.parameters['bvid'], IdUtils.bv2av(Get.parameters['bvid']!),
root: 0, root: 0,
parent: 0, parent: 0,
replyType: ReplyType.video, replyType: ReplyType.video,

View File

@ -353,7 +353,7 @@ class ReplyItem extends StatelessWidget {
isScrollControlled: true, isScrollControlled: true,
builder: (builder) { builder: (builder) {
return VideoReplyNewDialog( return VideoReplyNewDialog(
oid: IdUtils.av2bv(replyItem!.oid!), oid: replyItem!.oid,
root: replyItem!.rpid, root: replyItem!.rpid,
parent: replyItem!.rpid, parent: replyItem!.rpid,
replyType: replyType, replyType: replyType,

View File

@ -8,7 +8,7 @@ import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/utils/feed_back.dart'; import 'package:pilipala/utils/feed_back.dart';
class VideoReplyNewDialog extends StatefulWidget { class VideoReplyNewDialog extends StatefulWidget {
final String? oid; final int? oid;
final int? root; final int? root;
final int? parent; final int? parent;
final ReplyType? replyType; final ReplyType? replyType;

View File

@ -1,51 +1,52 @@
// ignore_for_file: constant_identifier_names // ignore_for_file: constant_identifier_names, non_constant_identifier_names
import 'dart:convert'; import 'dart:convert';
import 'dart:math';
import 'package:flutter/material.dart';
class IdUtils { class IdUtils {
static const String TABLE = static final XOR_CODE = BigInt.parse('23442827791579');
'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'; static final MASK_CODE = BigInt.parse('2251799813685247');
static const List<int> S = [11, 10, 3, 8, 4, 6]; // 位置编码表 static final MAX_AID = BigInt.one << (BigInt.from(51)).toInt();
static const int XOR = 177451812; // 固定异或值 static final BASE = BigInt.from(58);
static const int ADD = 8728348608; // 固定加法值
static const List<String> r = [ static const data =
'B', 'FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf';
'V',
'1',
'',
'',
'4',
'',
'1',
'',
'7',
'',
''
];
/// av转bv /// av转bv
static String av2bv(int av) { static String av2bv(int aid) {
int x_ = (av ^ XOR) + ADD; List<String> bytes = List.filled(12, '0', growable: false);
List<String> newR = []; int bvIndex = bytes.length - 1;
newR.addAll(r); BigInt tmp = (MAX_AID | BigInt.from(aid)) ^ XOR_CODE;
for (int i = 0; i < S.length; i++) { while (tmp > BigInt.zero) {
newR[S[i]] = bytes[bvIndex] = data[(tmp % BASE).toInt()];
TABLE.characters.elementAt((x_ / pow(58, i).toInt() % 58).toInt()); tmp = tmp ~/ BASE;
bvIndex -= 1;
} }
return newR.join(); final tmpValue = bytes[3];
bytes[3] = bytes[9];
bytes[9] = tmpValue;
final tmpValue2 = bytes[4];
bytes[4] = bytes[7];
bytes[7] = tmpValue2;
return bytes.join();
} }
/// bv转bv /// bv转av
static int bv2av(String bv) { static int bv2av(String bvid) {
int r = 0; List<String> bvidArr = bvid.split('');
for (int i = 0; i < S.length; i++) { final tmpValue = bvidArr[3];
r += (TABLE.indexOf(bv.characters.elementAt(S[i])).toInt()) * bvidArr[3] = bvidArr[9];
pow(58, i).toInt(); bvidArr[9] = tmpValue;
}
return (r - ADD) ^ XOR; final tmpValue2 = bvidArr[4];
bvidArr[4] = bvidArr[7];
bvidArr[7] = tmpValue2;
bvidArr.removeRange(0, 3);
BigInt tmp = bvidArr.fold(BigInt.zero,
(pre, bvidChar) => pre * BASE + BigInt.from(data.indexOf(bvidChar)));
return ((tmp & MASK_CODE) ^ XOR_CODE).toInt();
} }
// 匹配 // 匹配