From e1e8344764ded159f4c9a3175db232b671d88e8a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 10 Mar 2025 08:08:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B3=A8=E5=86=8C=20Pinia=20=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=AE=A1=E7=90=86=E5=B9=B6=E6=8F=90=E4=BE=9B=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index c66de80a..4aebab47 100644 --- a/src/main.ts +++ b/src/main.ts @@ -50,11 +50,19 @@ import '@styles/styles.scss' // 创建Vue实例 const app = createApp(App) +// 注册pinia +app.use(pinia) + +// 初始化配置 async function initializeApp() { try { // 是否为PWA const pwaMode = await isPWA() app.provide('pwaMode', pwaMode) + + // 全局设置 + const globalSettings = await fetchGlobalSettings() + app.provide('globalSettings', globalSettings) } catch (error) { console.error('Failed to initialize app', error) } @@ -65,13 +73,10 @@ initializeApp().then(() => { // 1. 注册 UI 框架 app.use(vuetify) - // 2. 注册状态管理与路由 - app.use(pinia).use(router) + // 2. 注册路由 + app.use(router) - // 3. 全局设置 - app.provide('globalSettings', fetchGlobalSettings()) - - // 4. 注册全局组件 + // 3. 注册全局组件 app .component('VAceEditor', VAceEditor) .component('VApexChart', VueApexCharts)