🐞 fix(img): 修复图片展示慢的问题

This commit is contained in:
algerkc@qq.com
2023-12-18 15:24:57 +08:00
parent b4a692a09c
commit f893de62cd
5 changed files with 16 additions and 18 deletions

View File

@@ -52,13 +52,13 @@ onMounted(() => {
&-item { &-item {
@apply rounded-xl overflow-hidden relative; @apply rounded-xl overflow-hidden relative;
&-img { &-img {
@apply rounded-xl transition; @apply rounded-xl transition w-full h-full;
} }
&:hover img { &:hover img {
filter: brightness(50%); filter: brightness(50%);
} }
&-content { &-content {
@apply w-full h-full opacity-0 transition absolute z-10 top-0 left-0 p-4 text-xl; @apply w-full h-full opacity-0 transition absolute z-10 top-0 left-0 p-4 text-xl bg-opacity-60 bg-black;
} }
&-content:hover { &-content:hover {
opacity: 1; opacity: 1;

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="recommend-music-list-item"> <div class="recommend-music-list-item">
<n-image <n-image
:src="getImgUrl( item.picUrl, '200y200')" :src="getImgUrl( item.picUrl, '40y40')"
class="recommend-music-list-item-img" class="recommend-music-list-item-img"
lazy lazy
preview-disabled preview-disabled

View File

@@ -1,8 +1,14 @@
<template> <template>
<n-drawer :show="musicFull" height="100vh" placement="bottom" :drawer-style="{backgroundColor:'transparent'}"> <n-drawer
:show="musicFull"
height="100vh"
placement="bottom"
:drawer-style="{ backgroundColor: 'transparent' }"
>
<div id="drawer-target"> <div id="drawer-target">
<div class="music-img"> <div class="music-img">
<n-image <n-image
ref="PicImgRef"
:src="getImgUrl(playMusic?.picUrl, '300y300')" :src="getImgUrl(playMusic?.picUrl, '300y300')"
class="img" class="img"
lazy lazy
@@ -29,7 +35,7 @@
<div <div
class="music-lrc-text" class="music-lrc-text"
:class="{ 'now-text': isCurrentLrc(index, nowTime) }" :class="{ 'now-text': isCurrentLrc(index, nowTime) }"
@click="setAudioTime(index,audio)" @click="setAudioTime(index, audio)"
> >
{{ item.text }} {{ item.text }}
</div> </div>
@@ -41,7 +47,7 @@
<n-button @click="addCorrectionTime(0.2)">+0.2</n-button> <n-button @click="addCorrectionTime(0.2)">+0.2</n-button>
</div> </div>
</div> </div>
</n-drawer> </n-drawer>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -57,7 +63,6 @@ import {
reduceCorrectionTime, reduceCorrectionTime,
setAudioTime, setAudioTime,
nowTime, nowTime,
allTime,
} from '@/hooks/MusicHook' } from '@/hooks/MusicHook'
const store = useStore() const store = useStore()
@@ -75,7 +80,6 @@ const props = defineProps({
const emit = defineEmits(['update:musicFull']) const emit = defineEmits(['update:musicFull'])
// 播放的音乐信息 // 播放的音乐信息
const playMusic = computed(() => store.state.playMusic as SongResult) const playMusic = computed(() => store.state.playMusic as SongResult)
// 获取歌词滚动dom // 获取歌词滚动dom
@@ -98,10 +102,8 @@ const mouseLeaveLayout = () => {
} }
defineExpose({ defineExpose({
lrcScroll lrcScroll,
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -153,4 +155,4 @@ defineExpose({
} }
} }
} }
</style> </style>

View File

@@ -33,5 +33,6 @@ export const getIsMc = () => {
export const getImgUrl = computed(() => (url: string, size: string) => { export const getImgUrl = computed(() => (url: string, size: string) => {
const bdUrl = 'https://image.baidu.com/search/down?url=' const bdUrl = 'https://image.baidu.com/search/down?url='
return getIsMc() ? `${bdUrl}${url}?param${size}` : `${url}?param${size}` const imgUrl = encodeURIComponent(`${url}?param=${size}`)
return getIsMc() ? `${bdUrl}${imgUrl}` : `${url}?param=${size}`
}) })

View File

@@ -28,7 +28,6 @@
class="search-list" class="search-list"
:class="setAnimationClass('animate__fadeInUp')" :class="setAnimationClass('animate__fadeInUp')"
:native-scrollbar="false" :native-scrollbar="false"
@scroll="searchScrolling"
> >
<div class="title">{{ hotKeyword }}</div> <div class="title">{{ hotKeyword }}</div>
<div class="search-list-box"> <div class="search-list-box">
@@ -69,10 +68,6 @@ const loadHotSearch = async () => {
hotSearchData.value = data; hotSearchData.value = data;
}; };
function searchScrolling(e: any) {
console.log(e);
}
onMounted(() => { onMounted(() => {
loadHotSearch(); loadHotSearch();