首页异步问题修复,调试控制台增加token输出

This commit is contained in:
tianfeng 2025-08-19 18:05:51 +08:00
parent 1b36e63f5d
commit a607ec008f
3 changed files with 8 additions and 7 deletions

View File

@ -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)

View File

@ -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)

View File

@ -176,7 +176,7 @@ const connectToApp = async () => {
// HTTP
console.debug('🔧 Setting HTTP headers...')
setHttpHeaders(headerInfo.value)
await setHttpHeaders(headerInfo.value)
//
appConnected.value = true