mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-30 22:30:13 +08:00
@@ -1,26 +1,17 @@
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
|
||||
class GlobalData {
|
||||
int imgQuality = Pref.picQuality;
|
||||
abstract final class GlobalData {
|
||||
static int imgQuality = Pref.picQuality;
|
||||
|
||||
num? coins;
|
||||
static num? coins;
|
||||
|
||||
void afterCoin(num coin) {
|
||||
static void afterCoin(num coin) {
|
||||
if (coins != null) {
|
||||
coins = coins! - coin;
|
||||
}
|
||||
}
|
||||
|
||||
Set<int> blackMids = Pref.blackMids;
|
||||
static Set<int> blackMids = Pref.blackMids;
|
||||
|
||||
bool dynamicsWaterfallFlow = Pref.dynamicsWaterfallFlow;
|
||||
|
||||
// 私有构造函数
|
||||
GlobalData._();
|
||||
|
||||
// 单例实例
|
||||
static final GlobalData _instance = GlobalData._();
|
||||
|
||||
// 获取全局实例
|
||||
factory GlobalData() => _instance;
|
||||
static bool dynamicsWaterfallFlow = Pref.dynamicsWaterfallFlow;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract final class ImageUtils {
|
||||
try {
|
||||
SmartDialog.showLoading();
|
||||
final path = '$tmpDirPath/${Utils.getFileName(url)}';
|
||||
final res = await Request().downloadFile(url.http2https, path);
|
||||
final res = await Request.downloadFile(url.http2https, path);
|
||||
SmartDialog.dismiss();
|
||||
if (res.statusCode == 200) {
|
||||
await SharePlus.instance
|
||||
@@ -106,11 +106,11 @@ abstract final class ImageUtils {
|
||||
String videoName = "video_${Utils.getFileName(liveUrl)}";
|
||||
String videoPath = '$tmpDirPath/$videoName';
|
||||
|
||||
final res = await Request().downloadFile(liveUrl.http2https, videoPath);
|
||||
final res = await Request.downloadFile(liveUrl.http2https, videoPath);
|
||||
if (res.statusCode != 200) throw '${res.statusCode}';
|
||||
|
||||
if (Platform.isIOS) {
|
||||
final res1 = await Request().downloadFile(url.http2https, imagePath);
|
||||
final res1 = await Request.downloadFile(url.http2https, imagePath);
|
||||
if (res1.statusCode != 200) throw '${res1.statusCode}';
|
||||
SmartDialog.showLoading(msg: '正在保存');
|
||||
bool success =
|
||||
@@ -174,7 +174,7 @@ abstract final class ImageUtils {
|
||||
|
||||
if (file == null) {
|
||||
final String filePath = '$tmpDirPath/$name';
|
||||
final response = await Request().downloadFile(
|
||||
final response = await Request.downloadFile(
|
||||
url.http2https,
|
||||
filePath,
|
||||
cancelToken: cancelToken,
|
||||
@@ -275,7 +275,7 @@ abstract final class ImageUtils {
|
||||
String suffix = kSuffixWEBP,
|
||||
}) {
|
||||
if (src != null && maxQuality != 100) {
|
||||
maxQuality = math.max(maxQuality, GlobalData().imgQuality);
|
||||
maxQuality = math.max(maxQuality, GlobalData.imgQuality);
|
||||
bool hasMatch = false;
|
||||
src = src.splitMapJoin(
|
||||
_thumbRegex,
|
||||
|
||||
@@ -53,7 +53,7 @@ abstract final class PageUtils {
|
||||
pageBuilder: (context, animation, secondaryAnimation) => GalleryViewer(
|
||||
sources: imgList,
|
||||
initIndex: initialPage,
|
||||
quality: quality ?? GlobalData().imgQuality,
|
||||
quality: quality ?? GlobalData.imgQuality,
|
||||
onPageChanged: onPageChanged,
|
||||
tag: tag,
|
||||
),
|
||||
@@ -399,7 +399,7 @@ abstract final class PageUtils {
|
||||
(context) => GalleryViewer(
|
||||
sources: imgList,
|
||||
initIndex: index,
|
||||
quality: GlobalData().imgQuality,
|
||||
quality: GlobalData.imgQuality,
|
||||
),
|
||||
enableDrag: false,
|
||||
elevation: 0.0,
|
||||
|
||||
@@ -62,12 +62,12 @@ abstract final class Pref {
|
||||
|
||||
static void setBlackMid(int mid) => _localCache.put(
|
||||
LocalCacheKey.blackMids,
|
||||
GlobalData().blackMids..add(mid),
|
||||
GlobalData.blackMids..add(mid),
|
||||
);
|
||||
|
||||
static void removeBlackMid(int mid) => _localCache.put(
|
||||
LocalCacheKey.blackMids,
|
||||
GlobalData().blackMids..remove(mid),
|
||||
GlobalData.blackMids..remove(mid),
|
||||
);
|
||||
|
||||
static int get _themeTypeInt => _setting.get(
|
||||
|
||||
@@ -16,7 +16,7 @@ mixin DynMixin {
|
||||
);
|
||||
|
||||
Widget buildPage(Widget child) {
|
||||
if (GlobalData().dynamicsWaterfallFlow) {
|
||||
if (GlobalData.dynamicsWaterfallFlow) {
|
||||
return child;
|
||||
}
|
||||
return SliverLayoutBuilder(
|
||||
@@ -43,7 +43,7 @@ mixin DynMixin {
|
||||
);
|
||||
|
||||
Widget get dynSkeleton {
|
||||
if (GlobalData().dynamicsWaterfallFlow) {
|
||||
if (GlobalData.dynamicsWaterfallFlow) {
|
||||
return SliverGrid.builder(
|
||||
gridDelegate: skeDelegate,
|
||||
itemBuilder: (_, _) => const DynamicCardSkeleton(),
|
||||
|
||||
@@ -76,7 +76,7 @@ abstract final class WbiSign {
|
||||
}
|
||||
|
||||
static Future<String> _getWbiKeys() async {
|
||||
final resp = await Request().get(Api.userInfo);
|
||||
final resp = await Request.get(Api.userInfo);
|
||||
try {
|
||||
final wbiUrls = resp.data['data']['wbi_img'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user