mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-08 01:06:41 +08:00
优化 App.vue 中的背景图片加载逻辑,调整异步加载方式并简化图片地址获取逻辑。
This commit is contained in:
+7
-10
@@ -142,8 +142,7 @@ function preloadImage(url: string): Promise<boolean> {
|
|||||||
function getImgUrl(url: string) {
|
function getImgUrl(url: string) {
|
||||||
// 使用图片缓存
|
// 使用图片缓存
|
||||||
if (globalSettings.GLOBAL_IMAGE_CACHE && isLogin.value) {
|
if (globalSettings.GLOBAL_IMAGE_CACHE && isLogin.value) {
|
||||||
const cacheUrl = `${import.meta.env.VITE_API_BASE_URL}system/cache/image?url=${encodeURIComponent(url)}`
|
return `${import.meta.env.VITE_API_BASE_URL}system/cache/image?url=${encodeURIComponent(url)}`
|
||||||
return cacheUrl
|
|
||||||
}
|
}
|
||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
@@ -167,8 +166,8 @@ function animateAndRemoveLoader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 加载背景图片
|
// 加载背景图片
|
||||||
function loadBackgroundImages() {
|
async function loadBackgroundImages() {
|
||||||
fetchBackgroundImages()
|
await fetchBackgroundImages()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
startBackgroundRotation()
|
startBackgroundRotation()
|
||||||
})
|
})
|
||||||
@@ -180,7 +179,7 @@ function loadBackgroundImages() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
// 初始化data-theme属性
|
// 初始化data-theme属性
|
||||||
updateHtmlThemeAttribute(globalTheme.name.value)
|
updateHtmlThemeAttribute(globalTheme.name.value)
|
||||||
|
|
||||||
@@ -188,7 +187,7 @@ onMounted(() => {
|
|||||||
show.value = false
|
show.value = false
|
||||||
|
|
||||||
// 加载背景图片
|
// 加载背景图片
|
||||||
loadBackgroundImages()
|
await loadBackgroundImages()
|
||||||
|
|
||||||
// 移除加载动画
|
// 移除加载动画
|
||||||
ensureRenderComplete(() => {
|
ensureRenderComplete(() => {
|
||||||
@@ -233,8 +232,7 @@ onUnmounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-wrapper">
|
<div class="app-wrapper">
|
||||||
<!-- 透明主题背景 -->
|
<!-- 透明主题背景 -->
|
||||||
<template v-if="backgroundImages.length > 0 && (isTransparentTheme || !isLogin)">
|
<div v-if="backgroundImages.length > 0 && (isTransparentTheme || !isLogin)" class="background-container">
|
||||||
<div class="background-container">
|
|
||||||
<div
|
<div
|
||||||
v-for="(imageUrl, index) in backgroundImages"
|
v-for="(imageUrl, index) in backgroundImages"
|
||||||
:key="`bg-${index}-${loginStateKey}`"
|
:key="`bg-${index}-${loginStateKey}`"
|
||||||
@@ -245,8 +243,7 @@ onUnmounted(() => {
|
|||||||
<!-- 全局磨砂层 -->
|
<!-- 全局磨砂层 -->
|
||||||
<div v-if="isLogin && isTransparentTheme" class="global-blur-layer"></div>
|
<div v-if="isLogin && isTransparentTheme" class="global-blur-layer"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
<!-- 页面内容 -->
|
||||||
|
|
||||||
<VApp v-show="show" :class="{ 'transparent-app': isTransparentTheme }">
|
<VApp v-show="show" :class="{ 'transparent-app': isTransparentTheme }">
|
||||||
<RouterView />
|
<RouterView />
|
||||||
</VApp>
|
</VApp>
|
||||||
|
|||||||
Reference in New Issue
Block a user