fix close

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-09-30 15:01:37 +08:00
parent 698e11885a
commit d833f3651c
3 changed files with 23 additions and 26 deletions

View File

@@ -139,7 +139,9 @@ class _MainAppState extends State<MainApp>
} }
} }
void _onClose() { Future<void> _onClose() async {
await GStorage.compact();
await GStorage.close();
if (Platform.isWindows) { if (Platform.isWindows) {
const MethodChannel('window_control').invokeMethod('closeWindow'); const MethodChannel('window_control').invokeMethod('closeWindow');
} else { } else {

View File

@@ -92,12 +92,6 @@ abstract class Accounts {
Request.buvidActive(AnonymousAccount()); Request.buvidActive(AnonymousAccount());
} }
static void close() {
account
..compact()
..close();
}
static Future<void> deleteAll(Set<Account> accounts) async { static Future<void> deleteAll(Set<Account> accounts) async {
var isloginMain = Accounts.main.isLogin; var isloginMain = Accounts.main.isLogin;
for (int i = 0; i < AccountType.values.length; i++) { for (int i = 0; i < AccountType.values.length; i++) {

View File

@@ -86,24 +86,25 @@ abstract class GStorage {
..registerAdapter(RuleFilterAdapter()); ..registerAdapter(RuleFilterAdapter());
} }
static void close() { static Future<void> compact() async {
// user.compact(); await Future.wait([
// user.close(); userInfo.compact(),
userInfo historyWord.compact(),
..compact() localCache.compact(),
..close(); setting.compact(),
historyWord video.compact(),
..compact() Accounts.account.compact(),
..close(); ]);
localCache }
..compact()
..close(); static Future<void> close() async {
setting await Future.wait([
..compact() userInfo.close(),
..close(); historyWord.close(),
video localCache.close(),
..compact() setting.close(),
..close(); video.close(),
Accounts.close(); Accounts.account.close(),
]);
} }
} }