From 704553cd4e5d133014e17806033d0bb9b758c696 Mon Sep 17 00:00:00 2001 From: CodeST <694468528@qq.com> Date: Thu, 11 Dec 2025 21:00:43 +0800 Subject: [PATCH] 1 --- keyBoard/Class/Login/VM/KBLoginVM.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/keyBoard/Class/Login/VM/KBLoginVM.m b/keyBoard/Class/Login/VM/KBLoginVM.m index 61541b2..ab5e6b1 100644 --- a/keyBoard/Class/Login/VM/KBLoginVM.m +++ b/keyBoard/Class/Login/VM/KBLoginVM.m @@ -10,9 +10,11 @@ #import "IAPVerifyTransactionObj.h" #import "KBAPI.h" #import "KBUser.h" +#import "KBMyVM.h" @interface KBLoginVM () @property (atomic, strong, readwrite, nullable) KBUser *currentUser; +@property (nonatomic, strong) KBMyVM *myVM; @end @implementation KBLoginVM @@ -75,6 +77,7 @@ } [[KBUserSessionManager shared] handleLoginSuccessWithUser:user]; [KBLoginVM kb_configureIAPIfNeeded]; + [self kb_syncKeyboardCharactersAfterLogin]; if (completion) completion(YES, nil); // 保存登录态到共享钥匙串;供 App 与扩展共享 // BOOL ok = [[KBAuthManager shared] saveAccessToken:user.token @@ -111,6 +114,7 @@ } [[KBUserSessionManager shared] handleLoginSuccessWithUser:user]; [KBLoginVM kb_configureIAPIfNeeded]; + [self kb_syncKeyboardCharactersAfterLogin]; if (completion) completion(YES, nil); }]; } @@ -172,6 +176,21 @@ }]; } +#pragma mark - Private + +- (void)kb_syncKeyboardCharactersAfterLogin { + if (!self.myVM) { + self.myVM = [[KBMyVM alloc] init]; + } + [self.myVM fetchCharacterListByUserWithCompletion:^(NSArray * _Nonnull characterArray, NSError * _Nullable error) { + if (error) { + KBLOG(@"[Login] Failed to sync keyboard characters after login: %@", error); + } else { + KBLOG(@"[Login] Synced %tu keyboard characters after login", characterArray.count); + } + }]; +} + #pragma mark - Helpers // 宽松解析:token / access_token / accessToken,支持顶层或 data/user 层