Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-12-16 14:22:47 +08:00
parent 13818533a7
commit 0baf3fcd36
283 changed files with 803 additions and 1550 deletions

View File

@@ -4,6 +4,7 @@ import 'dart:io';
import 'dart:math' show Random;
import 'package:PiliPlus/common/constants.dart';
import 'package:PiliPlus/utils/platform_utils.dart';
import 'package:catcher_2/catcher_2.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:device_info_plus/device_info_plus.dart';
@@ -18,13 +19,6 @@ abstract class Utils {
static const channel = MethodChannel(Constants.appName);
@pragma("vm:platform-const")
static final bool isMobile = Platform.isAndroid || Platform.isIOS;
@pragma("vm:platform-const")
static final bool isDesktop =
Platform.isWindows || Platform.isMacOS || Platform.isLinux;
static const jsonEncoder = JsonEncoder.withIndent(' ');
static Future<void> saveBytes2File({
@@ -38,13 +32,13 @@ abstract class Utils {
allowedExtensions: allowedExtensions,
type: type,
fileName: name,
bytes: Utils.isDesktop ? null : bytes,
bytes: PlatformUtils.isDesktop ? null : bytes,
);
if (path == null) {
SmartDialog.showToast("取消保存");
return;
}
if (Utils.isDesktop) {
if (PlatformUtils.isDesktop) {
await File(path).writeAsBytes(bytes);
}
SmartDialog.showToast("已保存");
@@ -62,7 +56,7 @@ abstract class Utils {
static Future<bool> get isWiFi async {
try {
return Utils.isMobile &&
return PlatformUtils.isMobile &&
(await Connectivity().checkConnectivity()).contains(
ConnectivityResult.wifi,
);
@@ -96,7 +90,7 @@ abstract class Utils {
}
static Future<void> shareText(String text) async {
if (Utils.isDesktop) {
if (PlatformUtils.isDesktop) {
copyText(text);
return;
}