Skip to content

Commit

Permalink
剔除一次性的'数据整理'功能
Browse files Browse the repository at this point in the history
  • Loading branch information
FirstJavaMaster committed Dec 24, 2021
1 parent bb73ea8 commit db876b5
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions lib/page/account/main_drawer.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:my_password_flutter/dbconfig/database_utils.dart';
import 'package:my_password_flutter/entity/old_password.dart';
import 'package:my_password_flutter/utils/import_export_utils.dart';
import 'package:my_password_flutter/utils/version_checker.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -80,39 +78,6 @@ class MainDrawer extends StatelessWidget {
title: Text('检查更新'),
onTap: () => VersionChecker.check(mainContext),
),
ListTile(
leading: Icon(Icons.build_circle_outlined),
title: Text('数据整理'),
onTap: () {
DatabaseUtils.getDatabase().then((db) {
db.accountDao.findAll().then((accountList) {
int finishNum = 0;
accountList.forEach((account) {
db.oldPasswordDao.findByAccountId(account.id!).then((oldPasswordList) {
List<OldPassword> deleteList = [];
for (int i = 0; i < oldPasswordList.length - 1; i++) {
var oldPassword = oldPasswordList[i];
var nextOldPassword = oldPasswordList[i + 1];
if (oldPassword.password == nextOldPassword.password) {
deleteList.add(oldPassword);
}
}
// 删除冗余密码
deleteList.forEach((oldPassword) {
db.oldPasswordDao.deleteByEntity(oldPassword);
});
// 进度+1
finishNum++;
Fluttertoast.showToast(msg: '进度: $finishNum/${accountList.length}');
if (finishNum == accountList.length) {
Fluttertoast.showToast(msg: '整理完成');
}
});
});
});
});
},
),
ListTile(
leading: Icon(Icons.help_outline),
title: Text('关于'),
Expand Down

0 comments on commit db876b5

Please sign in to comment.