mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-10 10:16:44 +08:00
perf(glass): preload optical modules during wallpaper preparation
This commit is contained in:
@@ -47,17 +47,6 @@
|
|||||||
"count": 3
|
"count": 3
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"src/App.vue": {
|
|
||||||
"@typescript-eslint/no-explicit-any": {
|
|
||||||
"count": 2
|
|
||||||
},
|
|
||||||
"@typescript-eslint/no-unused-vars": {
|
|
||||||
"count": 1
|
|
||||||
},
|
|
||||||
"sonarjs/no-ignored-exceptions": {
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"src/ace-config.ts": {
|
"src/ace-config.ts": {
|
||||||
"@typescript-eslint/no-explicit-any": {
|
"@typescript-eslint/no-explicit-any": {
|
||||||
"count": 24
|
"count": 24
|
||||||
|
|||||||
+28
-10
@@ -286,7 +286,20 @@ const shouldRenderGlassOpticalLayer = computed(
|
|||||||
isInitialRouteReady.value &&
|
isInitialRouteReady.value &&
|
||||||
Boolean(activeBackgroundImage.value),
|
Boolean(activeBackgroundImage.value),
|
||||||
)
|
)
|
||||||
const GlassOpticalLayer = defineAsyncComponent(() => import('@/components/theme/GlassOpticalLayer.vue'))
|
const loadGlassOpticalLayer = () => import('@/components/theme/GlassOpticalLayer.vue')
|
||||||
|
const GlassOpticalLayer = defineAsyncComponent(loadGlassOpticalLayer)
|
||||||
|
|
||||||
|
// 模块下载与壁纸准备并行;实际挂载仍等待路由和壁纸,CSS 档不请求光学组件。
|
||||||
|
watch(
|
||||||
|
() => isGlassTheme.value && opticalQuality.value !== 'css',
|
||||||
|
enabled => {
|
||||||
|
if (!enabled) return
|
||||||
|
void loadGlassOpticalLayer().catch(error => {
|
||||||
|
console.warn('[Glass] Optical component preload failed', error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
const transparentBackgroundBlur = ref(16)
|
const transparentBackgroundBlur = ref(16)
|
||||||
const transparencyGlassQuality = ref<TransparencyGlassQuality>(
|
const transparencyGlassQuality = ref<TransparencyGlassQuality>(
|
||||||
localStorage.getItem('transparency-glass-quality') === 'realtime' ? 'realtime' : 'lightweight',
|
localStorage.getItem('transparency-glass-quality') === 'realtime' ? 'realtime' : 'lightweight',
|
||||||
@@ -864,13 +877,15 @@ async function removeLoadingWithStateCheck() {
|
|||||||
globalLoadingStateManager.setLoadingState('pwa-state', true)
|
globalLoadingStateManager.setLoadingState('pwa-state', true)
|
||||||
|
|
||||||
// 静默检查PWA状态恢复,但不能让恢复异常或慢请求挡住应用外壳。
|
// 静默检查PWA状态恢复,但不能让恢复异常或慢请求挡住应用外壳。
|
||||||
const pwaController = (window as any).pwaStateController
|
const pwaController = (
|
||||||
|
window as Window & {
|
||||||
|
/** 宿主可选的状态恢复钩子;启动预算到期后不阻塞外壳。 */
|
||||||
|
pwaStateController?: { waitForStateRestore?: () => unknown }
|
||||||
|
}
|
||||||
|
).pwaStateController
|
||||||
if (pwaController?.waitForStateRestore) {
|
if (pwaController?.waitForStateRestore) {
|
||||||
await waitForLaunchTask(
|
const restoreState = pwaController.waitForStateRestore.bind(pwaController)
|
||||||
Promise.resolve().then(() => pwaController.waitForStateRestore()),
|
await waitForLaunchTask(Promise.resolve().then(restoreState), getRemainingLaunchBudget(), 'PWA state restore')
|
||||||
getRemainingLaunchBudget(),
|
|
||||||
'PWA state restore',
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
globalLoadingStateManager.setLoadingState('pwa-state', false)
|
globalLoadingStateManager.setLoadingState('pwa-state', false)
|
||||||
|
|
||||||
@@ -893,7 +908,7 @@ async function removeLoadingWithStateCheck() {
|
|||||||
checkAndEmitUnreadMessages()
|
checkAndEmitUnreadMessages()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 即使出错也要移除加载界面
|
console.warn('[Launch] State checks failed; revealing the application shell', error)
|
||||||
globalLoadingStateManager.reset()
|
globalLoadingStateManager.reset()
|
||||||
await animateAndRemoveLoader()
|
await animateAndRemoveLoader()
|
||||||
}
|
}
|
||||||
@@ -927,9 +942,12 @@ async function loadBackgroundImages(loadVersion: number, retryCount = 0) {
|
|||||||
resetBackgroundCrossfade()
|
resetBackgroundCrossfade()
|
||||||
recordGlassLaunchTiming('wallpaper-committed', activeBackgroundImage.value)
|
recordGlassLaunchTiming('wallpaper-committed', activeBackgroundImage.value)
|
||||||
startBackgroundRotation()
|
startBackgroundRotation()
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
if (loadVersion !== backgroundLoadVersion) return
|
if (loadVersion !== backgroundLoadVersion) return
|
||||||
const isAbortError = error.name === 'AbortError' || error.code === 'ERR_CANCELED'
|
const isAbortError =
|
||||||
|
typeof error === 'object' &&
|
||||||
|
error !== null &&
|
||||||
|
(('name' in error && error.name === 'AbortError') || ('code' in error && error.code === 'ERR_CANCELED'))
|
||||||
if (retryCount < maxRetries) {
|
if (retryCount < maxRetries) {
|
||||||
const baseDelay = isAbortError ? 1000 : 3000
|
const baseDelay = isAbortError ? 1000 : 3000
|
||||||
const retryDelay = Math.min(baseDelay * Math.pow(2, retryCount), 10000)
|
const retryDelay = Math.min(baseDelay * Math.pow(2, retryCount), 10000)
|
||||||
|
|||||||
Reference in New Issue
Block a user