mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-06-04 23:30:03 +08:00
feat: 注册 Pinia 状态管理并提供全局设置
This commit is contained in:
17
src/main.ts
17
src/main.ts
@@ -50,11 +50,19 @@ import '@styles/styles.scss'
|
|||||||
// 创建Vue实例
|
// 创建Vue实例
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
|
|
||||||
|
// 注册pinia
|
||||||
|
app.use(pinia)
|
||||||
|
|
||||||
|
// 初始化配置
|
||||||
async function initializeApp() {
|
async function initializeApp() {
|
||||||
try {
|
try {
|
||||||
// 是否为PWA
|
// 是否为PWA
|
||||||
const pwaMode = await isPWA()
|
const pwaMode = await isPWA()
|
||||||
app.provide('pwaMode', pwaMode)
|
app.provide('pwaMode', pwaMode)
|
||||||
|
|
||||||
|
// 全局设置
|
||||||
|
const globalSettings = await fetchGlobalSettings()
|
||||||
|
app.provide('globalSettings', globalSettings)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to initialize app', error)
|
console.error('Failed to initialize app', error)
|
||||||
}
|
}
|
||||||
@@ -65,13 +73,10 @@ initializeApp().then(() => {
|
|||||||
// 1. 注册 UI 框架
|
// 1. 注册 UI 框架
|
||||||
app.use(vuetify)
|
app.use(vuetify)
|
||||||
|
|
||||||
// 2. 注册状态管理与路由
|
// 2. 注册路由
|
||||||
app.use(pinia).use(router)
|
app.use(router)
|
||||||
|
|
||||||
// 3. 全局设置
|
// 3. 注册全局组件
|
||||||
app.provide('globalSettings', fetchGlobalSettings())
|
|
||||||
|
|
||||||
// 4. 注册全局组件
|
|
||||||
app
|
app
|
||||||
.component('VAceEditor', VAceEditor)
|
.component('VAceEditor', VAceEditor)
|
||||||
.component('VApexChart', VueApexCharts)
|
.component('VApexChart', VueApexCharts)
|
||||||
|
|||||||
Reference in New Issue
Block a user