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 {
static Future replyList({
required dynamic oid,
required int oid,
required int pageNum,
required int type,
int? ps,
@ -76,7 +76,7 @@ class ReplyHttp {
// 评论点赞
static Future likeReply({
required int type,
required dynamic oid,
required int oid,
required int rpid,
required int action,
}) async {

View File

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

View File

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

View File

@ -385,8 +385,8 @@ class _DynamicDetailPageState extends State<DynamicDetailPage>
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: _dynamicDetailController.oid?.toString() ??
Get.parameters['bvid'],
oid: _dynamicDetailController.oid ??
IdUtils.bv2av(Get.parameters['bvid']!),
root: 0,
parent: 0,
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_reply/index.dart';
import 'package:pilipala/utils/feed_back.dart';
import 'package:pilipala/utils/id_utils.dart';
import 'controller.dart';
@ -428,7 +427,7 @@ class _HtmlRenderPageState extends State<HtmlRenderPage>
isScrollControlled: true,
builder: (BuildContext context) {
return VideoReplyNewDialog(
oid: IdUtils.av2bv(_htmlRenderCtr.oid.value),
oid: _htmlRenderCtr.oid.value,
root: 0,
parent: 0,
replyType: ReplyType.values[type],

View File

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

View File

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

View File

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

View File

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

View File

@ -8,7 +8,7 @@ import 'package:pilipala/models/video/reply/item.dart';
import 'package:pilipala/utils/feed_back.dart';
class VideoReplyNewDialog extends StatefulWidget {
final String? oid;
final int? oid;
final int? root;
final int? parent;
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:math';
import 'package:flutter/material.dart';
class IdUtils {
static const String TABLE =
'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF';
static const List<int> S = [11, 10, 3, 8, 4, 6]; // 位置编码表
static const int XOR = 177451812; // 固定异或值
static const int ADD = 8728348608; // 固定加法值
static const List<String> r = [
'B',
'V',
'1',
'',
'',
'4',
'',
'1',
'',
'7',
'',
''
];
static final XOR_CODE = BigInt.parse('23442827791579');
static final MASK_CODE = BigInt.parse('2251799813685247');
static final MAX_AID = BigInt.one << (BigInt.from(51)).toInt();
static final BASE = BigInt.from(58);
static const data =
'FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf';
/// av转bv
static String av2bv(int av) {
int x_ = (av ^ XOR) + ADD;
List<String> newR = [];
newR.addAll(r);
for (int i = 0; i < S.length; i++) {
newR[S[i]] =
TABLE.characters.elementAt((x_ / pow(58, i).toInt() % 58).toInt());
static String av2bv(int aid) {
List<String> bytes = List.filled(12, '0', growable: false);
int bvIndex = bytes.length - 1;
BigInt tmp = (MAX_AID | BigInt.from(aid)) ^ XOR_CODE;
while (tmp > BigInt.zero) {
bytes[bvIndex] = data[(tmp % BASE).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
static int bv2av(String bv) {
int r = 0;
for (int i = 0; i < S.length; i++) {
r += (TABLE.indexOf(bv.characters.elementAt(S[i])).toInt()) *
pow(58, i).toInt();
}
return (r - ADD) ^ XOR;
/// bv转av
static int bv2av(String bvid) {
List<String> bvidArr = bvid.split('');
final tmpValue = bvidArr[3];
bvidArr[3] = bvidArr[9];
bvidArr[9] = tmpValue;
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();
}
// 匹配