mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 03:54:49 +08:00
@@ -44,18 +44,6 @@ abstract final class CacheManager {
|
||||
return total;
|
||||
}
|
||||
|
||||
// 缓存大小格式转换
|
||||
static String formatSize(num value) {
|
||||
const unitArr = ['B', 'K', 'M', 'G', 'T', 'P'];
|
||||
int index = 0;
|
||||
while (value >= 1024) {
|
||||
index++;
|
||||
value = value / 1024;
|
||||
}
|
||||
String size = value.toStringAsFixed(2);
|
||||
return size + (unitArr.elementAtOrNull(index) ?? '');
|
||||
}
|
||||
|
||||
// 清除 Library/Caches 目录及文件缓存
|
||||
static Future<void> clearLibraryCache() async {
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
import 'dart:math' show pow;
|
||||
|
||||
const unitArr = ['B', 'K', 'M', 'G', 'T', 'P'];
|
||||
|
||||
extension NumExt on num {
|
||||
String get formatSize {
|
||||
var value = this;
|
||||
int index = 0;
|
||||
while (value >= 1024) {
|
||||
index++;
|
||||
value = value / 1024;
|
||||
}
|
||||
String size = value.toStringAsFixed(2);
|
||||
return size + (unitArr.elementAtOrNull(index) ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
extension IntExt on int? {
|
||||
int? operator +(int other) => this == null ? null : this! + other;
|
||||
int? operator -(int other) => this == null ? null : this! - other;
|
||||
|
||||
Reference in New Issue
Block a user