From a607ec008f188493679943eb2098d51ec0f4ff68 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 19 Aug 2025 18:05:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=BC=82=E6=AD=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D=EF=BC=8C=E8=B0=83=E8=AF=95=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=8F=B0=E5=A2=9E=E5=8A=A0token=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/appBridge.js | 11 ++++++----- src/utils/http.js | 2 +- src/views/HostCenterView.vue | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/utils/appBridge.js b/src/utils/appBridge.js index e9e02d3..c1cf56f 100644 --- a/src/utils/appBridge.js +++ b/src/utils/appBridge.js @@ -270,15 +270,16 @@ export function parseHeader(head) { * 设置HTTP请求的默认头部信息 * @param {Object} headerInfo 解析后的头部信息 */ -export function setHttpHeaders(headerInfo) { - // 动态导入http.js中的函数来避免循环依赖 - import('../utils/http.js').then(httpModule => { +export async function setHttpHeaders(headerInfo) { + + try { + const httpModule = await import('../utils/http.js') if (httpModule.setHeadersFromApp) { httpModule.setHeadersFromApp(headerInfo) } - }).catch(error => { + } catch(error) { console.error('Failed to update HTTP headers:', error) - }) + } console.debug('🔑 Authorization token set:', headerInfo.authorization) console.debug('🌍 Language set:', headerInfo.reqLang) diff --git a/src/utils/http.js b/src/utils/http.js index e7f537b..8f6e9c3 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -118,7 +118,7 @@ export async function request(url, options = {}) { try { if (DEBUG_MODE) { - console.log('🚀 API Request:', fullUrl, config) + console.log('🚀 API Request:', fullUrl, JSON.stringify(config.headers)) } const response = await fetch(fullUrl, config) diff --git a/src/views/HostCenterView.vue b/src/views/HostCenterView.vue index b7a9583..c9111eb 100644 --- a/src/views/HostCenterView.vue +++ b/src/views/HostCenterView.vue @@ -176,7 +176,7 @@ const connectToApp = async () => { // 设置HTTP请求头 console.debug('🔧 Setting HTTP headers...') - setHttpHeaders(headerInfo.value) + await setHttpHeaders(headerInfo.value) // 标记连接成功 appConnected.value = true