test: log调试请求头获取功能

This commit is contained in:
hzj 2025-09-23 10:11:53 +08:00
parent 308c08ebac
commit 62e75d0061

View File

@ -681,10 +681,12 @@ const headerInfo = ref({})
const connectToApp = async () => {
console.group('🔗 APP Connection Process')
console.debug('🚀 Starting APP connection...')
console.log('connectToApp()')
try {
// APP
if (!isInApp()) {
console.log('!isInApp()')
console.debug('🌐 Browser environment detected')
appConnected.value = true
console.groupEnd()
@ -699,12 +701,15 @@ const connectToApp = async () => {
//
if (isAppConnected()) {
console.log('isAppConnected()')
console.debug('✅ APP already connected and valid')
appConnected.value = true
// 使
const cachedHeaderInfo = getAppHeaderInfo()
if (cachedHeaderInfo) {
console.log('cachedHeaderInfo')
headerInfo.value = cachedHeaderInfo
console.debug('🔧 Using cached HTTP headers')
}
@ -721,6 +726,8 @@ const connectToApp = async () => {
//
if (appConnectionManager.isConnecting()) {
console.log('appConnectionManager.isConnecting()')
console.debug('⏳ Connection already in progress, waiting...')
await appConnectionManager.getConnectionPromise()
appConnected.value = true
@ -737,14 +744,18 @@ const connectToApp = async () => {
// APP
console.debug('📱 Establishing new APP connection...')
console.log('📱 Establishing new APP connection...')
const connectionResult = await new Promise((resolve, reject) => {
const connectionPromise = new Promise((connectResolve, connectReject) => {
connectApplication(async (access) => {
try {
const result = parseAccessOrigin(access)
console.log('获取请求头信息:', result)
if (result.success) {
console.log('result.success')
//
headerInfo.value = parseHeader(result.data)
@ -760,11 +771,15 @@ const connectToApp = async () => {
connectResolve({ success: true, environment: 'app', fromCache: false })
} else {
console.error('❌ Failed to parse access origin:', result.error)
console.log('获取请求头信息失败:', result.error)
appConnectionManager.reset()
connectReject(new Error(result.error))
}
} catch (error) {
console.error('❌ Connection process failed:', error)
console.log('连接失败:', error)
appConnectionManager.reset()
connectReject(error)
}
@ -776,6 +791,7 @@ const connectToApp = async () => {
connectionPromise.then(resolve).catch(reject)
})
console.log('连接成功')
console.debug('✅ Connection completed successfully')
console.groupEnd()
@ -787,6 +803,8 @@ const connectToApp = async () => {
return connectionResult
} catch (error) {
console.log('连接失败:', error)
console.error('❌ Connection failed:', error)
appConnected.value = false
console.groupEnd()