From 03b14a0fb57c4dceb49bc0e22ebe70a4d4f0e18d Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Mon, 2 Sep 2024 20:04:40 +0800 Subject: [PATCH] fix(build): wrap top-level await in async function for browser compatibility --- src/main.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 6e08386e..1c56d316 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,12 +33,14 @@ import { fetchGlobalSettings } from './api' // 创建Vue实例 const app = createApp(App) -try { - const globalSettings = await fetchGlobalSettings() - // 使用 provide 传递全局设置 - app.provide('globalSettings', globalSettings) -} catch (error) { - console.error('Failed to initialize app', error) +async function initializeApp() { + try { + const globalSettings = await fetchGlobalSettings() + // 使用 provide 传递全局设置 + app.provide('globalSettings', globalSettings) + } catch (error) { + console.error('Failed to initialize app', error) + } } // 注册全局组件