From 8d7ac2245a6eff325b85d91cb9ab4680e47cf6f6 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Thu, 11 Dec 2025 16:41:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=88=B7=E6=96=B0=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=B4=E5=B7=A5=E5=85=B7):=20=E8=A7=A3=E5=86=B3=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84bug=EF=BC=8C=E5=9C=A8=E8=8E=B7=E5=8F=96=E5=88=B0?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=A4=B4=E5=90=8E=E7=9B=B4=E6=8E=A5=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/appConnector.js | 42 +++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/utils/appConnector.js b/src/utils/appConnector.js index facd0e8..71c7603 100644 --- a/src/utils/appConnector.js +++ b/src/utils/appConnector.js @@ -11,6 +11,8 @@ import { isAppConnected, getAppHeaderInfo, } from '@/utils/appConnectionManager.js' +import { getUserId, setUserInfo } from '@/utils/userStore.js' +import { getUserIdentity, getMemberProfile } from '@/api/wallet.js' import { useRouter } from 'vue-router' const router = useRouter() @@ -24,6 +26,30 @@ const defaultOnFailed = (error) => { } } +/** + * APP连接成功后获取用户信息 + * @private + */ +const fetchUserInfoAfterConnection = async () => { + try { + console.debug('👤 Fetching user info after connection...') + + const response = await getMemberProfile() + + if (response && response.status && response.body) { + // 缓存用户信息 + console.debug('✅ User info cached successfully') + setUserInfo(response.body, null) + } else { + console.warn('⚠️ Failed to get team entry or invalid response') + } + } catch (error) { + // 这里不抛出错误,因为APP连接已经成功 + // 用户信息获取失败可以在后续的身份检查中处理 + console.warn('⚠️ Failed to fetch user info after connection:', error) + } +} + /** * 统一的APP连接工具函数 * @param {Function} onConnected - 连接成功回调 @@ -40,8 +66,8 @@ export const connectToApp = async (onConnected, onFailed = defaultOnFailed) => { console.debug('🌐 Browser environment detected') console.groupEnd() - // 触发连接成功回调 - if (onConnected) onConnected() + await fetchUserInfoAfterConnection() //获取用户信息 + if (onConnected) onConnected() // 触发连接成功回调 return { success: true, environment: 'browser' } } @@ -58,8 +84,8 @@ export const connectToApp = async (onConnected, onFailed = defaultOnFailed) => { console.groupEnd() - // 触发连接成功回调 - if (onConnected) onConnected() + await fetchUserInfoAfterConnection() //获取用户信息 + if (onConnected) onConnected() // 触发连接成功回调 return { success: true, environment: 'app', fromCache: true } } @@ -71,8 +97,8 @@ export const connectToApp = async (onConnected, onFailed = defaultOnFailed) => { console.debug('✅ Connected via existing process') console.groupEnd() - // 触发连接成功回调 - if (onConnected) onConnected() + await fetchUserInfoAfterConnection() //获取用户信息 + if (onConnected) onConnected() // 触发连接成功回调 return { success: true, environment: 'app', fromCache: true } } @@ -121,8 +147,8 @@ export const connectToApp = async (onConnected, onFailed = defaultOnFailed) => { console.debug('✅ Connection completed successfully') console.groupEnd() - // 触发连接成功回调 - if (onConnected) onConnected() + await fetchUserInfoAfterConnection() //获取用户信息 + if (onConnected) onConnected() // 触发连接成功回调 return connectionResult } catch (error) {