opt: post redirect (#788)

* opt: cookie

* opt: post redirect
This commit is contained in:
My-Responsitories
2025-05-01 10:08:48 +08:00
committed by GitHub
parent a46bde68f5
commit c090cae1a1
5 changed files with 68 additions and 67 deletions

View File

@@ -535,8 +535,8 @@ class _PostPanelState extends CommonCollapseSlidePageState<PostPanel> {
];
}
void _onPost({String? url}) async {
Request().post(
Future _onPost({String? url}) {
return Request().post(
url ?? '${GStorage.blockServer}/api/skipSegments',
data: {
'videoID': videoDetailController.bvid,
@@ -557,14 +557,9 @@ class _PostPanelState extends CommonCollapseSlidePageState<PostPanel> {
)
.toList(),
},
options: Options(
validateStatus: (int? status) {
return status != null &&
((status >= 200 && status < 300) ||
const [400, 403, 429, 409].contains(status));
},
),
).then(
options: Options(followRedirects: true),
)
.then(
(res) {
if (res.statusCode == 200) {
Get.back();
@@ -578,12 +573,13 @@ class _PostPanelState extends CommonCollapseSlidePageState<PostPanel> {
}
} else {
SmartDialog.showToast(
'提交失败: ${const {
400: '参数错误',
403: '被自动审核机制拒绝',
429: '重复提交太快',
409: '重复提交'
}[res.statusCode] ?? res.statusCode}',
'提交失败: ${switch (res.statusCode) {
400 => '参数错误',
403 => '被自动审核机制拒绝',
429 => '重复提交太快',
409 => '重复提交',
_ => res.statusCode.toString()
}}',
);
}
},