mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-14 05:03:57 +08:00
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/widgets/dialog/dialog.dart';
|
||||
@@ -26,6 +25,7 @@ import 'package:PiliPlus/pages/fav_detail/controller.dart'
|
||||
show BaseFavController;
|
||||
import 'package:PiliPlus/pages/group_panel/view.dart';
|
||||
import 'package:PiliPlus/pages/login/geetest/geetest_webview_dialog.dart';
|
||||
import 'package:PiliPlus/pages/webview/view.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/extension/context_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
@@ -34,7 +34,6 @@ import 'package:PiliPlus/utils/extension/theme_ext.dart';
|
||||
import 'package:PiliPlus/utils/platform_utils.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/theme_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
@@ -42,7 +41,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart' show LengthLimitingTextInputFormatter;
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:gt3_flutter_plugin/gt3_flutter_plugin.dart';
|
||||
|
||||
abstract final class RequestUtils {
|
||||
static Future<void> syncHistoryStatus() async {
|
||||
@@ -333,58 +331,52 @@ abstract final class RequestUtils {
|
||||
String? dynText,
|
||||
bool isManual = false,
|
||||
}) async {
|
||||
if (isManual || Pref.enableCreateDynAntifraud) {
|
||||
try {
|
||||
if (id != null) {
|
||||
if (!isManual) {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
}
|
||||
final res = await DynamicsHttp.dynamicDetail(
|
||||
id: id,
|
||||
clearCookie: true,
|
||||
);
|
||||
final isSuccess = res.isSuccess;
|
||||
final theme = ThemeUtils.theme;
|
||||
final actions = [
|
||||
if (!isSuccess)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Utils.copyText('https://www.bilibili.com/opus/$id');
|
||||
Get.toNamed(
|
||||
'/webview',
|
||||
parameters: {
|
||||
'url':
|
||||
'https://www.bilibili.com/h5/comment/appeal?${ThemeUtils.themeUrl(theme.isDark)}',
|
||||
},
|
||||
);
|
||||
},
|
||||
child: const Text('申诉'),
|
||||
),
|
||||
if (!isManual)
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'关闭',
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
];
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
barrierDismissible: isManual,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
'${isSuccess ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}',
|
||||
),
|
||||
actions: actions.isEmpty ? null : actions,
|
||||
),
|
||||
);
|
||||
try {
|
||||
if (id != null) {
|
||||
if (!isManual) {
|
||||
await Future.delayed(const Duration(seconds: 5));
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) debugPrint('check dyn error: $e');
|
||||
final res = await DynamicsHttp.dynamicDetail(
|
||||
id: id,
|
||||
clearCookie: true,
|
||||
);
|
||||
final isSuccess = res.isSuccess;
|
||||
final theme = ThemeUtils.theme;
|
||||
final actions = [
|
||||
if (!isSuccess)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
Utils.copyText('https://www.bilibili.com/opus/$id');
|
||||
WebViewPage.toWebView(
|
||||
'https://www.bilibili.com/h5/comment/appeal?${ThemeUtils.themeUrl(theme.isDark)}',
|
||||
);
|
||||
},
|
||||
child: const Text('申诉'),
|
||||
),
|
||||
if (!isManual)
|
||||
TextButton(
|
||||
onPressed: Get.back,
|
||||
child: Text(
|
||||
'关闭',
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
];
|
||||
showDialog(
|
||||
context: Get.context!,
|
||||
barrierDismissible: isManual,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('动态检查结果'),
|
||||
content: SelectableText(
|
||||
'${isSuccess ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban(仅自己可见)!'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}',
|
||||
),
|
||||
actions: actions.isEmpty ? null : actions,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
if (kDebugMode) debugPrint('check dyn error: $e');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,118 +562,20 @@ abstract final class RequestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (PlatformUtils.isDesktop) {
|
||||
final json = await showDialog<Map<String, dynamic>>(
|
||||
context: Get.context!,
|
||||
builder: (context) => GeetestWebviewDialog(gt!, challenge!),
|
||||
);
|
||||
if (json != null) {
|
||||
captchaData
|
||||
..validate = json['geetest_validate']
|
||||
..seccode = json['geetest_seccode']
|
||||
..geetest = GeetestData(
|
||||
challenge: json['geetest_challenge'],
|
||||
gt: gt!,
|
||||
);
|
||||
gaiaVgateValidate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final registerData = Gt3RegisterData(
|
||||
challenge: challenge,
|
||||
gt: gt,
|
||||
success: true,
|
||||
final json = await showDialog<Map<String, dynamic>>(
|
||||
context: Get.context!,
|
||||
builder: (context) => GeetestWebviewDialog(gt!, challenge!),
|
||||
);
|
||||
|
||||
Gt3FlutterPlugin()
|
||||
..addEventHandler(
|
||||
onClose: (Map<String, dynamic> message) {
|
||||
SmartDialog.showToast('关闭验证');
|
||||
},
|
||||
onResult: (Map<String, dynamic> message) {
|
||||
if (kDebugMode) debugPrint("Captcha result: $message");
|
||||
String code = message["code"];
|
||||
if (code == "1") {
|
||||
// 发送 message["result"] 中的数据向 B 端的业务服务接口进行查询
|
||||
SmartDialog.showToast('验证成功');
|
||||
final result = message['result'];
|
||||
captchaData
|
||||
..validate = result?['geetest_validate']
|
||||
..seccode = result?['geetest_seccode']
|
||||
..geetest = GeetestData(
|
||||
challenge: result?['geetest_challenge'],
|
||||
gt: gt!,
|
||||
);
|
||||
gaiaVgateValidate();
|
||||
} else {
|
||||
// 终端用户完成验证失败,自动重试 If the verification fails, it will be automatically retried.
|
||||
if (kDebugMode) debugPrint("Captcha result code : $code");
|
||||
}
|
||||
},
|
||||
onError: (Map<String, dynamic> message) {
|
||||
SmartDialog.showToast("Captcha onError: $message");
|
||||
String code = message["code"];
|
||||
// 处理验证中返回的错误 Handling errors returned in verification
|
||||
if (Platform.isAndroid) {
|
||||
// Android 平台
|
||||
if (code == "-2") {
|
||||
// Dart 调用异常 Call exception
|
||||
} else if (code == "-1") {
|
||||
// Gt3RegisterData 参数不合法 Parameter is invalid
|
||||
} else if (code == "201") {
|
||||
// 网络无法访问 Network inaccessible
|
||||
} else if (code == "202") {
|
||||
// Json 解析错误 Analysis error
|
||||
} else if (code == "204") {
|
||||
// WebView 加载超时,请检查是否混淆极验 SDK Load timed out
|
||||
} else if (code == "204_1") {
|
||||
// WebView 加载前端页面错误,请查看日志 Error loading front-end page, please check the log
|
||||
} else if (code == "204_2") {
|
||||
// WebView 加载 SSLError
|
||||
} else if (code == "206") {
|
||||
// gettype 接口错误或返回为 null API error or return null
|
||||
} else if (code == "207") {
|
||||
// getphp 接口错误或返回为 null API error or return null
|
||||
} else if (code == "208") {
|
||||
// ajax 接口错误或返回为 null API error or return null
|
||||
} else {
|
||||
// 更多错误码参考开发文档 More error codes refer to the development document
|
||||
// https://docs.geetest.com/sensebot/apirefer/errorcode/android
|
||||
}
|
||||
}
|
||||
|
||||
if (Platform.isIOS) {
|
||||
// iOS 平台
|
||||
if (code == "-1009") {
|
||||
// 网络无法访问 Network inaccessible
|
||||
} else if (code == "-1004") {
|
||||
// 无法查找到 HOST Unable to find HOST
|
||||
} else if (code == "-1002") {
|
||||
// 非法的 URL Illegal URL
|
||||
} else if (code == "-1001") {
|
||||
// 网络超时 Network timeout
|
||||
} else if (code == "-999") {
|
||||
// 请求被意外中断, 一般由用户进行取消操作导致 The interrupted request was usually caused by the user cancelling the operation
|
||||
} else if (code == "-21") {
|
||||
// 使用了重复的 challenge Duplicate challenges are used
|
||||
// 检查获取 challenge 是否进行了缓存 Check if the fetch challenge is cached
|
||||
} else if (code == "-20") {
|
||||
// 尝试过多, 重新引导用户触发验证即可 Try too many times, lead the user to request verification again
|
||||
} else if (code == "-10") {
|
||||
// 预判断时被封禁, 不会再进行图形验证 Banned during pre-judgment, and no more image captcha verification
|
||||
} else if (code == "-2") {
|
||||
// Dart 调用异常 Call exception
|
||||
} else if (code == "-1") {
|
||||
// Gt3RegisterData 参数不合法 Parameter is invalid
|
||||
} else {
|
||||
// 更多错误码参考开发文档 More error codes refer to the development document
|
||||
// https://docs.geetest.com/sensebot/apirefer/errorcode/ios
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
..startCaptcha(registerData);
|
||||
if (json != null) {
|
||||
captchaData
|
||||
..validate = json['geetest_validate']
|
||||
..seccode = json['geetest_seccode']
|
||||
..geetest = GeetestData(
|
||||
challenge: json['geetest_challenge'],
|
||||
gt: gt!,
|
||||
);
|
||||
gaiaVgateValidate();
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> showUserRealName(String mid) async {
|
||||
|
||||
Reference in New Issue
Block a user