监控、OSD
This commit is contained in:
+39
-24
@@ -1,12 +1,8 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import App from './App.vue'
|
||||
import './style.css'
|
||||
import 'vue-sonner/style.css'
|
||||
|
||||
// 导入模块注册入口 —— 副作用导入,注册所有模块到 moduleRegistry
|
||||
import './modules'
|
||||
|
||||
import { createLogger } from './lib/logger'
|
||||
const logger = createLogger('main')
|
||||
|
||||
@@ -19,31 +15,50 @@ window.addEventListener('unhandledrejection', (event) => {
|
||||
logger.error(`未处理的Promise拒绝: ${event.reason}`)
|
||||
})
|
||||
|
||||
logger.info('Thing 应用启动')
|
||||
// ===== OSD 窗口模式检测 =====
|
||||
// 通过 URL hash 识别:#osd-overlay(悬浮窗)
|
||||
// OSD 窗口是精简的独立 Vue 应用,不加载主应用的 store 和模块
|
||||
const osdHash = window.location.hash
|
||||
if (osdHash === '#osd-overlay') {
|
||||
logger.info(`OSD 窗口启动: ${osdHash}`)
|
||||
void import('./modules/monitor/OsdWindow.vue').then(({ default: OsdWindow }) => {
|
||||
const app = createApp(OsdWindow)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else {
|
||||
// ===== 主应用模式 =====
|
||||
void import('./App.vue').then(async ({ default: App }) => {
|
||||
// 导入模块注册入口 —— 副作用导入,注册所有模块到 moduleRegistry
|
||||
await import('./modules')
|
||||
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
logger.info('Thing 应用启动')
|
||||
|
||||
app.use(pinia)
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
|
||||
app.mount('#app')
|
||||
app.use(pinia)
|
||||
|
||||
// 应用挂载后初始化搜索索引和进程监听(不阻塞首屏渲染)
|
||||
void import('./stores/searchStore').then(({ useSearchStore }) => {
|
||||
const searchStore = useSearchStore()
|
||||
searchStore.initGlobalIndex()
|
||||
app.mount('#app')
|
||||
|
||||
// 移除已禁用模块的搜索项
|
||||
void import('./stores/appStore').then(({ useAppStore }) => {
|
||||
const appStore = useAppStore()
|
||||
appStore.modules.forEach(m => {
|
||||
if (!m.enabled) {
|
||||
searchStore.unregisterModule(m.id)
|
||||
}
|
||||
// 应用挂载后初始化搜索索引和进程监听(不阻塞首屏渲染)
|
||||
void import('./stores/searchStore').then(({ useSearchStore }) => {
|
||||
const searchStore = useSearchStore()
|
||||
searchStore.initGlobalIndex()
|
||||
|
||||
// 移除已禁用模块的搜索项
|
||||
void import('./stores/appStore').then(({ useAppStore }) => {
|
||||
const appStore = useAppStore()
|
||||
appStore.modules.forEach(m => {
|
||||
if (!m.enabled) {
|
||||
searchStore.unregisterModule(m.id)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
void import('./stores/processStore').then(({ useProcessStore }) => {
|
||||
useProcessStore().initListener().catch(e => console.error('Process listener init error:', e))
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
void import('./stores/processStore').then(({ useProcessStore }) => {
|
||||
useProcessStore().initListener().catch(e => console.error('Process listener init error:', e))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user