性能优化
This commit is contained in:
+23
-36
@@ -1,4 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createApp, type Component } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import './style.css'
|
||||
import 'vue-sonner/style.css'
|
||||
@@ -15,44 +15,31 @@ window.addEventListener('unhandledrejection', (event) => {
|
||||
logger.error(`未处理的Promise拒绝: ${event.reason}`)
|
||||
})
|
||||
|
||||
// ===== OSD 窗口模式检测 =====
|
||||
// ===== 独立窗口模式 =====
|
||||
// 通过 URL hash 识别独立窗口:#osd-overlay / #clipboard-popup / #quick-panel / #tray-menu / #screenshot-overlay / #screenshot-editor
|
||||
// 这些窗口是精简的独立 Vue 应用,不加载主应用的 store 和模块
|
||||
// 新增独立窗口只需在此表登记一行(hash → 组件)
|
||||
const standaloneWindowApps: Array<[hash: string, label: string, loader: () => Promise<{ default: Component }>]> = [
|
||||
['#osd-overlay', 'OSD', () => import('./modules/monitor/OsdWindow.vue')],
|
||||
['#clipboard-popup', '剪贴板弹窗', () => import('./modules/clipboard/ClipboardPopup.vue')],
|
||||
['#quick-panel', '快速面板弹窗', () => import('./modules/quickpanel/QuickPanel.vue')],
|
||||
['#tray-menu', '托盘菜单', () => import('./modules/tray/TrayMenu.vue')],
|
||||
['#screenshot-overlay', '截图覆盖层', () => import('./modules/screenshot/ScreenshotOverlay.vue')],
|
||||
['#screenshot-editor', '截图编辑器', () => import('./modules/screenshot/ScreenshotEditor.vue')],
|
||||
]
|
||||
|
||||
const winHash = window.location.hash
|
||||
if (winHash === '#osd-overlay') {
|
||||
logger.info(`OSD 窗口启动: ${winHash}`)
|
||||
void import('./modules/monitor/OsdWindow.vue').then(({ default: OsdWindow }) => {
|
||||
const app = createApp(OsdWindow)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else if (winHash === '#clipboard-popup') {
|
||||
logger.info(`剪贴板弹窗窗口启动: ${winHash}`)
|
||||
void import('./modules/clipboard/ClipboardPopup.vue').then(({ default: ClipboardPopup }) => {
|
||||
const app = createApp(ClipboardPopup)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else if (winHash === '#quick-panel') {
|
||||
logger.info(`快速面板弹窗窗口启动: ${winHash}`)
|
||||
void import('./modules/quickpanel/QuickPanel.vue').then(({ default: QuickPanel }) => {
|
||||
const app = createApp(QuickPanel)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else if (winHash === '#tray-menu') {
|
||||
logger.info(`托盘菜单窗口启动: ${winHash}`)
|
||||
void import('./modules/tray/TrayMenu.vue').then(({ default: TrayMenu }) => {
|
||||
const app = createApp(TrayMenu)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else if (winHash.startsWith('#screenshot-overlay')) {
|
||||
logger.info(`截图覆盖层窗口启动: ${winHash}`)
|
||||
void import('./modules/screenshot/ScreenshotOverlay.vue').then(({ default: ScreenshotOverlay }) => {
|
||||
const app = createApp(ScreenshotOverlay)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else if (winHash === '#screenshot-editor') {
|
||||
logger.info(`截图编辑器窗口启动: ${winHash}`)
|
||||
void import('./modules/screenshot/ScreenshotEditor.vue').then(({ default: ScreenshotEditor }) => {
|
||||
const app = createApp(ScreenshotEditor)
|
||||
|
||||
// #screenshot-overlay 带窗口号参数(多屏),按前缀匹配;其余精确匹配
|
||||
const matched = standaloneWindowApps.find(([hash]) =>
|
||||
hash === '#screenshot-overlay' ? winHash.startsWith(hash) : winHash === hash
|
||||
)
|
||||
|
||||
if (matched) {
|
||||
const [, label, loader] = matched
|
||||
logger.info(`${label}窗口启动: ${winHash}`)
|
||||
void loader().then(({ default: Comp }) => {
|
||||
const app = createApp(Comp)
|
||||
app.mount('#app')
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user