|
|
@@ -23,6 +23,11 @@ class HomeController extends BaseController {
|
|
|
Rx<double> photoSpace = 100.0.obs;
|
|
|
Rx<double> freeSpace = 200.0.obs;
|
|
|
|
|
|
+ Rx<String> totalSpaceStr = "".obs;
|
|
|
+ Rx<String> usedSpaceStr = "".obs;
|
|
|
+ Rx<String> photoSpaceStr = "".obs;
|
|
|
+ Rx<String> freeSpaceStr = "".obs;
|
|
|
+
|
|
|
// 计算已用存储百分比
|
|
|
double get usedSpacePercentage => (usedSpace.value / totalSpace.value) * 100;
|
|
|
|
|
|
@@ -90,8 +95,8 @@ class HomeController extends BaseController {
|
|
|
print('Error loading photos: $e');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
Future<void> getStorageInfo() async {
|
|
|
|
|
|
final classifyPhoto = ClassifyPhoto();
|
|
|
@@ -105,15 +110,20 @@ class HomeController extends BaseController {
|
|
|
final usedSpaceGB = storageInfo['usedSpace']! / (1024 * 1024 * 1024);
|
|
|
final photoSpaceGB = storageInfo['photoSpace']! / (1024 * 1024 * 1024);
|
|
|
|
|
|
+ totalSpaceStr.value = ImagePickerUtil.formatFileSize(storageInfo['totalSpace']!, decimals: 1);
|
|
|
+ freeSpaceStr.value = ImagePickerUtil.formatFileSize(storageInfo['freeSpace']!, decimals: 1);
|
|
|
+ usedSpaceStr.value = ImagePickerUtil.formatFileSize(storageInfo['usedSpace']!, decimals: 1);
|
|
|
+ photoSpaceStr.value = ImagePickerUtil.formatFileSize(storageInfo['photoSpace']!, decimals: 1);
|
|
|
+
|
|
|
totalSpace.value = totalSpaceGB.round().toDouble();
|
|
|
freeSpace.value = freeSpaceGB;
|
|
|
usedSpace.value = usedSpaceGB;
|
|
|
photoSpace.value = photoSpaceGB;
|
|
|
|
|
|
- print('总容量: ${totalSpaceGB.toStringAsFixed(0)} GB');
|
|
|
- print('可用空间: ${freeSpaceGB.toStringAsFixed(2)} GB');
|
|
|
- print('已用空间: ${usedSpaceGB.toStringAsFixed(2)} GB');
|
|
|
- print('照片占用: ${photoSpaceGB.toStringAsFixed(2)} GB');
|
|
|
+ print('总容量: $totalSpaceStr');
|
|
|
+ print('可用空间: $freeSpaceStr');
|
|
|
+ print('已用空间: $usedSpaceStr');
|
|
|
+ print('照片占用: $photoSpaceStr');
|
|
|
|
|
|
} catch (e) {
|
|
|
print('获取存储信息失败: $e');
|