Преглед на файлове

fix: 修复照片重复问题

Destiny преди 9 месеца
родител
ревизия
38bfa8c410
променени са 2 файла, в които са добавени 15 реда и са изтрити 2 реда
  1. 14 1
      lib/base/base_photo_controller.dart
  2. 1 1
      pubspec.yaml

+ 14 - 1
lib/base/base_photo_controller.dart

@@ -180,8 +180,21 @@ abstract class BasePhotoController extends BaseController {
                 .where((asset) => selectedPhotosIds.contains(asset.id)))
             .toList();
 
+        // 检查是否有重复资产
+        final uniqueAssetIds = <String>{};
+        final uniqueAssets = <AssetEntity>[];
+
+        for (var asset in assetsToDelete) {
+          if (!uniqueAssetIds.contains(asset.id)) {
+            uniqueAssetIds.add(asset.id);
+            uniqueAssets.add(asset);
+          }
+        }
+
+        print('删除前检查: selectedPhotosIds数量=${selectedPhotosIds.length}, 原始assetsToDelete数量=${assetsToDelete.length}, 去重后数量=${uniqueAssets.length}');
+
         final List<String> result = await PhotoManager.editor.deleteWithIds(
-          assetsToDelete.map((e) => e.id).toList(),
+          uniqueAssets.map((e) => e.id).toList(),
         );
 
         if (result.length == selectedPhotosIds.length) {

+ 1 - 1
pubspec.yaml

@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
 # In Windows, build-name is used as the major, minor, and patch parts
 # of the product and file versions while build-number is used as the build suffix.
-version: 1.4.0+33
+version: 1.4.0+36
 
 environment:
   sdk: ^3.6.0