mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 15:36:49 +08:00
Refactor PluginCard.vue and login.vue components
This commit is contained in:
@@ -61,6 +61,9 @@ const pluginInfoDialog = ref(false)
|
|||||||
// 进度框文本
|
// 进度框文本
|
||||||
const progressText = ref('正在更新插件...')
|
const progressText = ref('正在更新插件...')
|
||||||
|
|
||||||
|
// 用户头像是否加载完成
|
||||||
|
const isAvatarLoaded = ref(false)
|
||||||
|
|
||||||
// 插件数据页面配置项
|
// 插件数据页面配置项
|
||||||
let pluginPageItems = ref([])
|
let pluginPageItems = ref([])
|
||||||
|
|
||||||
@@ -218,7 +221,9 @@ const iconPath: Ref<string> = computed(() => {
|
|||||||
// 插件作者头像路径
|
// 插件作者头像路径
|
||||||
const authorPath: Ref<string> = computed(() => {
|
const authorPath: Ref<string> = computed(() => {
|
||||||
// 网络图片则使用代理后返回
|
// 网络图片则使用代理后返回
|
||||||
return `${import.meta.env.VITE_API_BASE_URL}system/img/1?imgurl=${encodeURIComponent(props.plugin?.author_url + '.png')}`
|
return `${import.meta.env.VITE_API_BASE_URL}system/img/1?imgurl=${encodeURIComponent(
|
||||||
|
props.plugin?.author_url + '.png',
|
||||||
|
)}`
|
||||||
})
|
})
|
||||||
|
|
||||||
// 重置插件
|
// 重置插件
|
||||||
@@ -443,7 +448,9 @@ watch(
|
|||||||
</div>
|
</div>
|
||||||
<VCardText class="flex flex-none align-self-baseline py-3 w-full align-end">
|
<VCardText class="flex flex-none align-self-baseline py-3 w-full align-end">
|
||||||
<span class="author-info">
|
<span class="author-info">
|
||||||
<VImg :src="authorPath" class="author-avatar" />
|
<VImg :src="authorPath" class="author-avatar" @load="isAvatarLoaded = true">
|
||||||
|
<VIcon v-if="!isAvatarLoaded" icon="mdi-github" class="me-1" />
|
||||||
|
</VImg>
|
||||||
<a :href="props.plugin?.author_url" target="_blank" @click.stop>
|
<a :href="props.plugin?.author_url" target="_blank" @click.stop>
|
||||||
{{ props.plugin?.plugin_author }}
|
{{ props.plugin?.plugin_author }}
|
||||||
</a>
|
</a>
|
||||||
@@ -519,15 +526,17 @@ watch(
|
|||||||
content: '';
|
content: '';
|
||||||
inset: 0;
|
inset: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.author-info {
|
.author-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.author-avatar {
|
.author-avatar {
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
margin-right: 8px;
|
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
block-size: 24px;
|
||||||
|
inline-size: 24px;
|
||||||
|
margin-inline-end: 8px;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+46
-27
@@ -31,13 +31,9 @@ const isPasswordVisible = ref(false)
|
|||||||
// 错误信息
|
// 错误信息
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
|
|
||||||
// 背景图片
|
// 背景图片 URL 和预加载 URL
|
||||||
const backgroundImageUrl = ref('')
|
const backgroundImageUrl = ref('')
|
||||||
|
|
||||||
// 所有的背景图片
|
|
||||||
const backgroundImages = ref<string[]>([])
|
const backgroundImages = ref<string[]>([])
|
||||||
|
|
||||||
// 背景图片加载状态
|
|
||||||
const isImageLoaded = ref(false)
|
const isImageLoaded = ref(false)
|
||||||
|
|
||||||
// 是否开启双重验证
|
// 是否开启双重验证
|
||||||
@@ -54,7 +50,6 @@ async function fetchBackgroundImage() {
|
|||||||
try {
|
try {
|
||||||
backgroundImages.value = await api.get('/login/wallpapers')
|
backgroundImages.value = await api.get('/login/wallpapers')
|
||||||
if (backgroundImages.value && backgroundImages.value.length > 0) {
|
if (backgroundImages.value && backgroundImages.value.length > 0) {
|
||||||
// 随机打乱排序
|
|
||||||
backgroundImages.value.sort(() => Math.random() - 0.5)
|
backgroundImages.value.sort(() => Math.random() - 0.5)
|
||||||
backgroundImageUrl.value = backgroundImages.value[0]
|
backgroundImageUrl.value = backgroundImages.value[0]
|
||||||
}
|
}
|
||||||
@@ -63,6 +58,34 @@ async function fetchBackgroundImage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 切换背景图片函数
|
||||||
|
function startBackgroundImageRotation() {
|
||||||
|
let currentIndex = 0
|
||||||
|
|
||||||
|
intervalTimer = setInterval(() => {
|
||||||
|
if (backgroundImages.value.length > 1) {
|
||||||
|
// 更新下一张图片索引
|
||||||
|
const nextIndex = (currentIndex + 1) % backgroundImages.value.length
|
||||||
|
const nextImageUrl = backgroundImages.value[nextIndex]
|
||||||
|
// 使用预加载机制确保下一张图片已加载完成
|
||||||
|
const img = new Image()
|
||||||
|
img.src = nextImageUrl
|
||||||
|
img.onload = () => {
|
||||||
|
// 开始淡入过渡
|
||||||
|
isImageLoaded.value = false
|
||||||
|
// 延迟一小段时间触发淡入效果
|
||||||
|
setTimeout(() => {
|
||||||
|
// 更新当前索引并切换背景图片 URL
|
||||||
|
currentIndex = nextIndex
|
||||||
|
backgroundImageUrl.value = nextImageUrl
|
||||||
|
// 切换完成后显示图片
|
||||||
|
isImageLoaded.value = true
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
|
|
||||||
// 查询是否开启双重验证
|
// 查询是否开启双重验证
|
||||||
const fetchOTP = debounce(async () => {
|
const fetchOTP = debounce(async () => {
|
||||||
const userid = usernameInput.value?.value
|
const userid = usernameInput.value?.value
|
||||||
@@ -205,14 +228,8 @@ onMounted(async () => {
|
|||||||
} else {
|
} else {
|
||||||
// 获取背景图片
|
// 获取背景图片
|
||||||
await fetchBackgroundImage()
|
await fetchBackgroundImage()
|
||||||
|
// 开始背景图片定时切换
|
||||||
// 每隔5秒更换一次背景图片
|
startBackgroundImageRotation()
|
||||||
intervalTimer = setInterval(() => {
|
|
||||||
if (backgroundImages.value.length > 0) {
|
|
||||||
const index = Math.floor(Math.random() * backgroundImages.value.length)
|
|
||||||
backgroundImageUrl.value = backgroundImages.value[index]
|
|
||||||
}
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -222,19 +239,21 @@ onUnmounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<template v-for="image in backgroundImages">
|
<!-- 当前背景图片 -->
|
||||||
<div v-if="backgroundImageUrl == image" class="absolute inset-0">
|
<div class="absolute inset-0 w-full h-full overflow-hidden">
|
||||||
<VImg :src="image" class="w-full h-full" cover position="center top" @load="isImageLoaded = true">
|
<VImg
|
||||||
<template #placeholder>
|
:src="backgroundImageUrl"
|
||||||
<VSkeletonLoader v-if="!isImageLoaded" class="object-cover" />
|
:class="{ 'opacity-0': !isImageLoaded, 'opacity-100': isImageLoaded }"
|
||||||
</template>
|
class="absolute inset-0 transition-opacity duration-1000"
|
||||||
<div
|
cover
|
||||||
class="absolute inset-0"
|
position="center top"
|
||||||
style="background-image: linear-gradient(rgba(45, 55, 72, 33%) 0%, rgb(26, 32, 46) 100%)"
|
/>
|
||||||
/>
|
<div
|
||||||
</VImg>
|
class="absolute inset-0"
|
||||||
</div>
|
style="background-image: linear-gradient(rgba(45, 55, 72, 33%) 0%, rgb(26, 32, 46) 100%)"
|
||||||
</template>
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="auth-wrapper d-flex align-center justify-center pa-4">
|
<div class="auth-wrapper d-flex align-center justify-center pa-4">
|
||||||
<VCard
|
<VCard
|
||||||
class="auth-card px-7 py-3 w-full h-full rounded-lg"
|
class="auth-card px-7 py-3 w-full h-full rounded-lg"
|
||||||
|
|||||||
Reference in New Issue
Block a user