mod: lint

mod: tweaks

opt: publish page

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-05-04 11:37:13 +08:00
parent 2cfad80214
commit caa58e9d7d
313 changed files with 2751 additions and 2789 deletions

View File

@@ -72,7 +72,7 @@ class LoginAccount implements Account {
LoginAccount(this.cookieJar, this.accessKey, this.refresh,
[Set<AccountType>? type])
: this.type = type ?? {};
: type = type ?? {};
LoginAccount.fromJson(Map json) {
cookieJar = BiliCookieJar.fromJson(json['cookies']);

View File

@@ -16,7 +16,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
final _setCookieReg = RegExp('(?<=)(,)(?=[^;]+?=)');
class AccountManager extends Interceptor {
static final Map<AccountType, Set<String>> apiTypeSet = {
static const Map<AccountType, Set<String>> apiTypeSet = {
AccountType.heartbeat: {
Api.videoIntro,
Api.replyList,
@@ -53,7 +53,7 @@ class AccountManager extends Interceptor {
AccountType.video: {Api.videoUrl, Api.bangumiVideoUrl}
};
static final loginApi = {
static const loginApi = {
Api.getTVCode,
Api.qrcodePoll,
Api.getCaptcha,

View File

@@ -1,7 +1,7 @@
import 'package:cookie_jar/cookie_jar.dart';
import 'package:hive/hive.dart';
import 'account.dart';
import 'package:PiliPlus/utils/accounts/account.dart';
class BiliCookieJarAdapter extends TypeAdapter<DefaultCookieJar> {
@override

View File

@@ -1,6 +1,6 @@
import 'package:PiliPlus/http/user.dart';
import 'storage.dart';
import 'package:PiliPlus/utils/storage.dart';
class Data {
static Future init() async {

View File

@@ -16,7 +16,7 @@ import 'package:share_plus/share_plus.dart';
class DownloadUtils {
// 图片分享
static void onShareImg(String imgUrl) async {
static Future<void> onShareImg(String imgUrl) async {
try {
SmartDialog.showLoading();
var response = await Request()

View File

@@ -145,8 +145,8 @@ extension RationalExt on Rational {
/// Android docs specified boundaries as inclusive.
bool get fitsInAndroidRequirements {
final aspectRatio = numerator / denominator;
final min = 1 / 2.39;
final max = 2.39;
const min = 1 / 2.39;
const max = 2.39;
return (min <= aspectRatio) && (aspectRatio <= max);
}
}

View File

@@ -1,11 +1,9 @@
import 'package:flutter/services.dart';
import 'storage.dart';
import 'package:PiliPlus/utils/storage.dart';
bool enableFeedback = GStorage.feedBackEnable;
void feedBack() {
// 设置中是否开启
final bool enable = GStorage.setting
.get(SettingBoxKey.feedBackEnable, defaultValue: false) as bool;
if (enable) {
if (enableFeedback) {
HapticFeedback.lightImpact();
}
}

View File

@@ -3,12 +3,13 @@ import 'dart:math';
import 'package:PiliPlus/common/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'storage.dart';
import 'package:PiliPlus/utils/storage.dart';
class Grid {
static double smallCardWidth = GStorage.smallCardWidth;
static videoCardHDelegate(context, {double minHeight = 90}) =>
static SliverGridDelegateWithExtentAndRatio videoCardHDelegate(context,
{double minHeight = 90}) =>
SliverGridDelegateWithExtentAndRatio(
mainAxisSpacing: 2,
maxCrossAxisExtent: Grid.smallCardWidth * 2,

View File

@@ -28,7 +28,8 @@ import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';
class PageUtils {
static void pmShare(BuildContext context, {required Map content}) async {
static Future<void> pmShare(BuildContext context,
{required Map content}) async {
// debugPrint(content.toString());
List<UserModel> userList = <UserModel>[];
@@ -155,7 +156,7 @@ class PageUtils {
.startShutdownTimer();
setState(() {});
},
child: Text('确定'),
child: const Text('确定'),
),
],
);
@@ -168,7 +169,7 @@ class PageUtils {
shutdownTimerService.startShutdownTimer();
}
},
contentPadding: const EdgeInsets.only(),
contentPadding: EdgeInsets.zero,
title: Text(choice == -1
? '自定义'
: choice == 0
@@ -199,7 +200,7 @@ class PageUtils {
!shutdownTimerService.waitForPlayingCompleted;
setState(() {});
},
contentPadding: const EdgeInsets.only(),
contentPadding: EdgeInsets.zero,
title: const Text("额外等待视频播放完毕", style: titleStyle),
trailing: Transform.scale(
alignment: Alignment.centerRight,
@@ -342,7 +343,7 @@ class PageUtils {
);
}
static void pushDynDetail(DynamicItemModel item, floor,
static Future<void> pushDynDetail(DynamicItemModel item, floor,
{action = 'all'}) async {
feedBack();
@@ -553,7 +554,7 @@ class PageUtils {
}
}
static launchURL(String url) async {
static Future<void> launchURL(String url) async {
try {
final Uri uri = Uri.parse(url);
if (!await launchUrl(
@@ -567,7 +568,7 @@ class PageUtils {
}
}
static void handleWebview(
static Future<void> handleWebview(
String url, {
bool off = false,
bool inApp = false,
@@ -629,8 +630,8 @@ class PageUtils {
transitionBuilder: (context, animation, secondaryAnimation, child) {
Offset begin =
MediaQuery.orientationOf(Get.context!) == Orientation.portrait
? Offset(0.0, 1.0)
: Offset(1.0, 0.0);
? const Offset(0.0, 1.0)
: const Offset(1.0, 0.0);
var tween = Tween(begin: begin, end: Offset.zero)
.chain(CurveTween(curve: Curves.easeInOut));
return SlideTransition(
@@ -683,7 +684,7 @@ class PageUtils {
return false;
}
static void viewBangumi(
static Future<void> viewBangumi(
{dynamic seasonId, dynamic epId, dynamic progress}) async {
try {
SmartDialog.showLoading(msg: '资源获取中');

View File

@@ -2,7 +2,7 @@ import 'dart:io';
import 'package:system_proxy/system_proxy.dart';
class CustomProxy {
init() async {
Future<void> init() async {
Map<String, String>? proxy = await SystemProxy.getProxySettings();
if (proxy != null) {
HttpOverrides.global =

View File

@@ -1,7 +1,7 @@
import 'package:PiliPlus/models/model_video.dart';
import 'package:hive/hive.dart';
import 'storage.dart';
import 'package:PiliPlus/utils/storage.dart';
class RecommendFilter {
static late int minDurationForRcmd;

View File

@@ -294,7 +294,7 @@ class RequestUtils {
showDialog(
context: Get.context!,
builder: (context) => AlertDialog(
title: Text('动态检查结果'),
title: const Text('动态检查结果'),
content: SelectableText(
'${res['status'] ? '无账号状态下找到了你的动态,动态正常!' : '你的动态被shadow ban仅自己可见'}${dynText != null ? ' \n\n动态内容: $dynText' : ''}'),
),
@@ -422,7 +422,7 @@ class RequestUtils {
});
}
},
child: Text('确认'),
child: const Text('确认'),
),
],
);
@@ -470,107 +470,106 @@ class RequestUtils {
success: true,
);
final Gt3FlutterPlugin captcha = Gt3FlutterPlugin();
captcha.addEventHandler(
onClose: (Map<String, dynamic> message) async {
SmartDialog.showToast('关闭验证');
},
onResult: (Map<String, dynamic> message) async {
debugPrint("Captcha result: $message");
String code = message["code"];
if (code == "1") {
// 发送 message["result"] 中的数据向 B 端的业务服务接口进行查询
SmartDialog.showToast('验证成功');
captchaData.validate = message['result']?['geetest_validate'];
captchaData.seccode = message['result']?['geetest_seccode'];
String? challenge = message['result']?['geetest_challenge'];
final res = await ValidateHttp.gaiaVgateValidate(
challenge: challenge,
seccode: captchaData.seccode,
token: captchaData.token,
validate: captchaData.validate,
);
if (res['status']) {
if (res['data']?['is_valid'] == 1) {
final griskId = res['data']?['grisk_id'];
if (griskId != null) {
onSuccess(griskId);
Gt3FlutterPlugin()
..addEventHandler(
onClose: (Map<String, dynamic> message) async {
SmartDialog.showToast('关闭验证');
},
onResult: (Map<String, dynamic> message) async {
debugPrint("Captcha result: $message");
String code = message["code"];
if (code == "1") {
// 发送 message["result"] 中的数据向 B 端的业务服务接口进行查询
SmartDialog.showToast('验证成功');
captchaData
..validate = message['result']?['geetest_validate']
..seccode = message['result']?['geetest_seccode'];
String? challenge = message['result']?['geetest_challenge'];
final res = await ValidateHttp.gaiaVgateValidate(
challenge: challenge,
seccode: captchaData.seccode,
token: captchaData.token,
validate: captchaData.validate,
);
if (res['status']) {
if (res['data']?['is_valid'] == 1) {
final griskId = res['data']?['grisk_id'];
if (griskId != null) {
onSuccess(griskId);
}
} else {
SmartDialog.showToast('invalid');
}
} else {
SmartDialog.showToast('invalid');
SmartDialog.showToast(res['msg']);
}
} else {
SmartDialog.showToast(res['msg']);
// 终端用户完成验证失败,自动重试 If the verification fails, it will be automatically retried.
debugPrint("Captcha result code : $code");
}
} else {
// 终端用户完成验证失败,自动重试 If the verification fails, it will be automatically retried.
debugPrint("Captcha result code : $code");
}
},
onError: (Map<String, dynamic> message) async {
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
},
onError: (Map<String, dynamic> message) async {
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
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
}
}
}
},
);
captcha.startCaptcha(registerData);
},
)
..startCaptcha(registerData);
}
}

View File

@@ -34,7 +34,7 @@ import 'package:hive_flutter/hive_flutter.dart';
import 'package:path_provider/path_provider.dart';
import 'package:PiliPlus/models/model_owner.dart';
import 'package:PiliPlus/models/user/info.dart';
import 'global_data.dart';
import 'package:PiliPlus/utils/global_data.dart';
import 'package:uuid/uuid.dart';
class GStorage {
@@ -47,7 +47,7 @@ class GStorage {
static List<double> get speedList => List<double>.from(
video.get(
VideoBoxKey.speedsList,
defaultValue: [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0],
defaultValue: const [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 3.0],
),
);
@@ -226,7 +226,7 @@ class GStorage {
String blockUserID =
setting.get(SettingBoxKey.blockUserID, defaultValue: '');
if (blockUserID.isEmpty) {
blockUserID = Uuid().v4().replaceAll('-', '');
blockUserID = const Uuid().v4().replaceAll('-', '');
setting.put(SettingBoxKey.blockUserID, blockUserID);
}
return blockUserID;
@@ -475,7 +475,7 @@ class GStorage {
GStorage.setting.get(SettingBoxKey.optTabletNav, defaultValue: true);
static List<double> get dynamicDetailRatio => List<double>.from(setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: const [60.0, 40.0]));
static Set<int> get blackMids =>
GStorage.localCache.get(LocalCacheKey.blackMids, defaultValue: <int>{});
@@ -583,29 +583,35 @@ class GStorage {
}
static void regAdapter() {
Hive.registerAdapter(OwnerAdapter());
Hive.registerAdapter(UserInfoDataAdapter());
Hive.registerAdapter(LevelInfoAdapter());
Hive.registerAdapter(BiliCookieJarAdapter());
Hive.registerAdapter(LoginAccountAdapter());
Hive.registerAdapter(AccountTypeAdapter());
Hive.registerAdapter(SetIntAdapter());
Hive.registerAdapter(RuleFilterAdapter());
Hive
..registerAdapter(OwnerAdapter())
..registerAdapter(UserInfoDataAdapter())
..registerAdapter(LevelInfoAdapter())
..registerAdapter(BiliCookieJarAdapter())
..registerAdapter(LoginAccountAdapter())
..registerAdapter(AccountTypeAdapter())
..registerAdapter(SetIntAdapter())
..registerAdapter(RuleFilterAdapter());
}
static Future<void> close() async {
// user.compact();
// user.close();
userInfo.compact();
userInfo.close();
historyWord.compact();
historyWord.close();
localCache.compact();
localCache.close();
setting.compact();
setting.close();
video.compact();
video.close();
userInfo
..compact()
..close();
historyWord
..compact()
..close();
localCache
..compact()
..close();
setting
..compact()
..close();
video
..compact()
..close();
Accounts.close();
}
}
@@ -877,7 +883,7 @@ class Accounts {
final Directory tempDir = await getApplicationSupportDirectory();
final String tempPath = "${tempDir.path}/.plpl/";
final Directory dir = Directory(tempPath);
if (await dir.exists()) {
if (dir.existsSync()) {
debugPrint('migrating...');
final cookieJar =
PersistCookieJar(ignoreExpires: true, storage: FileStorage(tempPath));
@@ -928,8 +934,9 @@ class Accounts {
}
static Future<void> close() async {
account.compact();
account.close();
account
..compact()
..close();
}
static Future<void> deleteAll(Set<Account> accounts) async {

View File

@@ -110,7 +110,7 @@ class ThemeUtils {
return themeData;
}
static darkenTheme(ThemeData themeData) {
static ThemeData darkenTheme(ThemeData themeData) {
Color color = themeData.colorScheme.surfaceContainerHighest.darken(0.7);
return themeData.copyWith(
scaffoldBackgroundColor: Colors.black,

View File

@@ -41,7 +41,7 @@ class UrlUtils {
}
// 匹配url路由跳转
static matchUrlPush(
static Future<void> matchUrlPush(
String pathSegment,
String redirectUrl,
) async {

View File

@@ -69,7 +69,7 @@ class Utils {
return _isIpad!;
}
static void shareText(String text) async {
static Future<void> shareText(String text) async {
try {
Rect? sharePositionOrigin;
if (await isIpad()) {
@@ -275,11 +275,12 @@ class Utils {
semanticsLabel.write(videoItem.title);
if (!emptyStatCheck(videoItem.stat.view)) {
semanticsLabel.write(',${Utils.numFormat(videoItem.stat.view)}');
semanticsLabel.write(
(videoItem is RecVideoItemAppModel && videoItem.goto == 'picture')
? '浏览'
: '播放');
semanticsLabel
..write(',${Utils.numFormat(videoItem.stat.view)}')
..write(
(videoItem is RecVideoItemAppModel && videoItem.goto == 'picture')
? '浏览'
: '播放');
}
if (!emptyStatCheck(videoItem.stat.danmu)) {
semanticsLabel.write(',${Utils.numFormat(videoItem.stat.danmu)}弹幕');
@@ -494,7 +495,7 @@ class Utils {
}
// 检查更新
static Future checkUpdate([bool isAuto = true]) async {
static Future<void> checkUpdate([bool isAuto = true]) async {
if (BuildConfig.isDebug) return;
SmartDialog.dismiss();
try {

View File

@@ -88,8 +88,9 @@ class WbiSign {
Utils.getFileName(wbiUrls['img_url'], fileExt: false) +
Utils.getFileName(wbiUrls['sub_url'], fileExt: false));
localCache.put(LocalCacheKey.mixinKey, mixinKey);
localCache.put(LocalCacheKey.timeStamp, nowDate.millisecondsSinceEpoch);
localCache
..put(LocalCacheKey.mixinKey, mixinKey)
..put(LocalCacheKey.timeStamp, nowDate.millisecondsSinceEpoch);
return mixinKey;
} catch (_) {