Refactor PWA state management to simplify and streamline implementation

Co-authored-by: jxxghp <jxxghp@163.com>
This commit is contained in:
Cursor Agent
2025-07-06 23:24:31 +00:00
parent 304b990994
commit a81071a50a
4 changed files with 41 additions and 192 deletions

View File

@@ -146,14 +146,9 @@ if (pwaStateController) {
}
// 6. 初始化后台优化工具
console.log('初始化后台优化工具...')
// 将后台管理器绑定到全局对象(便于调试)
if (import.meta.env.MODE === 'development') {
;(window as any).backgroundManager = backgroundManager
;(window as any).sseManagerSingleton = sseManagerSingleton
// 添加全局调试函数
;(window as any).debugBackground = () => {
console.table(backgroundManager.getTimersInfo())
console.log('Background Status:', backgroundManager.getStatus())
@@ -162,11 +157,9 @@ if (import.meta.env.MODE === 'development') {
// 页面卸载时清理后台管理器
window.addEventListener('beforeunload', () => {
console.log('应用卸载,清理后台资源...')
backgroundManager.destroy()
sseManagerSingleton.closeAllManagers()
// 清理PWA状态管理器
if (pwaStateController) {
pwaStateController.destroy()
}