主界面修改及代理模块初始化

This commit is contained in:
zhongluofeng
2026-07-15 18:22:07 +08:00
parent 29a5f456cb
commit fb361aff9a
39 changed files with 4768 additions and 396 deletions
+35 -3
View File
@@ -3,6 +3,23 @@ import { createPinia } from 'pinia'
import App from './App.vue'
import './style.css'
// 导入模块注册入口 —— 副作用导入,注册所有模块到 moduleRegistry
import './modules'
import { createLogger } from './lib/logger'
const logger = createLogger('main')
// 全局未捕获异常日志
window.addEventListener('error', (event) => {
logger.error(`全局JS错误: ${event.message} @ ${event.filename}:${event.lineno}`)
})
window.addEventListener('unhandledrejection', (event) => {
logger.error(`未处理的Promise拒绝: ${event.reason}`)
})
logger.info('Thing 应用启动')
const app = createApp(App)
const pinia = createPinia()
@@ -10,7 +27,22 @@ app.use(pinia)
app.mount('#app')
// 应用挂载后初始化搜索索引不阻塞首屏渲染
// 应用挂载后初始化搜索索引和进程监听(不阻塞首屏渲染
void import('./stores/searchStore').then(({ useSearchStore }) => {
useSearchStore().initGlobalIndex()
})
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))
})