🦄 refactor(样式): 修改样式 修改图片加载方式

This commit is contained in:
algerkc@qq.com
2023-12-15 14:24:58 +08:00
parent 4f7d066376
commit 086bbb8958
13 changed files with 126 additions and 49 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
<!-- 歌单分类列表 --> <!-- 歌单分类列表 -->
<div class="play-list-type"> <div class="play-list-type">
<div class="title" :class="setAnimationClass('animate__fadeInLeft')">歌单分类</div> <div class="title" :class="setAnimationClass('animate__fadeInLeft')">歌单分类</div>
<n-layout class="bg-black"> <n-layout>
<template v-for="(item, index) in playlistCategory?.sub" :key="item.name"> <template v-for="(item, index) in playlistCategory?.sub" :key="item.name">
<span <span
class="play-list-type-item" class="play-list-type-item"
@@ -66,7 +66,7 @@ onMounted(() => {
} }
.play-list-type { .play-list-type {
width: 250px; width: 250px;
@apply mr-6; @apply mx-6;
&-item, &-item,
&-showall { &-showall {
@apply py-2 px-3 mr-3 mb-3 inline-block border border-gray-700 rounded-xl cursor-pointer hover:bg-green-600 transition; @apply py-2 px-3 mr-3 mb-3 inline-block border border-gray-700 rounded-xl cursor-pointer hover:bg-green-600 transition;
+5 -3
View File
@@ -9,9 +9,11 @@
:class="setAnimationClass('animate__backInUp')" :class="setAnimationClass('animate__backInUp')"
:style="setAnimationDelay(index, 100)" :style="setAnimationDelay(index, 100)"
> >
<img <n-image
class="recommend-album-list-item-img" class="recommend-album-list-item-img"
:src="item.blurPicUrl + '?param=200y200'" :src="getImgUrl( item.blurPicUrl, '200y200')"
lazy
preview-disabled
/> />
<div class="recommend-album-list-item-content">{{ item.name }}</div> <div class="recommend-album-list-item-content">{{ item.name }}</div>
</div> </div>
@@ -24,7 +26,7 @@
import { getNewAlbum } from "@/api/home" import { getNewAlbum } from "@/api/home"
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import type { IAlbumNew } from "@/type/album" import type { IAlbumNew } from "@/type/album"
import { setAnimationClass, setAnimationDelay } from "@/utils"; import { setAnimationClass, setAnimationDelay, getImgUrl } from "@/utils";
const albumData = ref<IAlbumNew>() const albumData = ref<IAlbumNew>()
+2 -2
View File
@@ -10,7 +10,7 @@
:key="item.id" :key="item.id"
> >
<div <div
:style="setBackgroundImg(item.picUrl + '?param=500y500')" :style="setBackgroundImg(getImgUrl(item.picUrl,'300y300'))"
class="recommend-singer-item-bg" class="recommend-singer-item-bg"
></div> ></div>
<div <div
@@ -31,7 +31,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { setBackgroundImg, setAnimationDelay, setAnimationClass } from "@/utils"; import { setBackgroundImg, setAnimationDelay, setAnimationClass,getImgUrl } from "@/utils";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { getHotSinger } from "@/api/home"; import { getHotSinger } from "@/api/home";
import type { IHotSinger } from "@/type/singer"; import type { IHotSinger } from "@/type/singer";
+5 -2
View File
@@ -1,8 +1,10 @@
<template> <template>
<div class="recommend-music-list-item"> <div class="recommend-music-list-item">
<img <n-image
:src="item.picUrl + '?param=200y200'" :src="getImgUrl( item.picUrl, '200y200')"
class="recommend-music-list-item-img" class="recommend-music-list-item-img"
lazy
preview-disabled
/> />
<div class="recommend-music-list-item-content"> <div class="recommend-music-list-item-content">
<div class="recommend-music-list-item-content-title"> <div class="recommend-music-list-item-content-title">
@@ -43,6 +45,7 @@
import { useStore } from 'vuex' import { useStore } from 'vuex'
import type { SongResult } from '@/type/music' import type { SongResult } from '@/type/music'
import { computed } from 'vue' import { computed } from 'vue'
import { getImgUrl } from '@/utils'
const props = defineProps({ const props = defineProps({
item: { item: {
+8
View File
@@ -4,3 +4,11 @@
@tailwind base; @tailwind base;
@tailwind components; @tailwind components;
@tailwind utilities; @tailwind utilities;
img{
@apply bg-gray-900;
}
.n-image img {
width: 100%;
}
+10 -3
View File
@@ -1,8 +1,13 @@
<template> <template>
<div id="drawer-target" v-show="isFull"> <div id="drawer-target" v-show="isFull" :style="{backgroundImage:`url(${getImgUrl( playMusic?.picUrl, '300y300')})`}">
<div class="music-img"> <div class="music-img">
<img class="img" :src="playMusic?.picUrl + '?param=300y300'" /> <n-image
:src="getImgUrl( playMusic?.picUrl, '300y300')"
class="img"
lazy
preview-disabled
/>
</div> </div>
<div class="music-content"> <div class="music-content">
<div class="music-content-name">{{ playMusic?.song.name }}</div> <div class="music-content-name">{{ playMusic?.song.name }}</div>
@@ -37,6 +42,7 @@ import type { SongResult } from "@/type/music";
import type { ILyric } from "@/type/lyric"; import type { ILyric } from "@/type/lyric";
import { getMusicLrc } from "@/api/music" import { getMusicLrc } from "@/api/music"
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { getImgUrl } from '@/utils'
const store = useStore(); const store = useStore();
const props = defineProps({ const props = defineProps({
@@ -150,7 +156,8 @@ const mouseLeaveLayout = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
#drawer-target { #drawer-target {
@apply top-0 left-0 absolute w-full h-full overflow-hidden rounded px-24 pt-24 pb-48 flex items-center; @apply top-0 left-0 absolute w-full h-full overflow-hidden rounded px-24 pt-24 pb-48 flex items-center;
background-color: #333333; // background-color: #333333;
backdrop-filter: saturate(180%) blur(20px);
animation-duration: 300ms; animation-duration: 300ms;
.music-img { .music-img {
@apply flex-1; @apply flex-1;
+32 -6
View File
@@ -2,8 +2,14 @@
<!-- 展开全屏 --> <!-- 展开全屏 -->
<transition name="musicPage"> <transition name="musicPage">
<div id="drawer-target" v-show="musicFull"> <div id="drawer-target" v-show="musicFull">
<div class="drawer-target-back" :style="{backgroundImage:`url(${getImgUrl( playMusic?.picUrl, '300y300')})`}"></div>
<div class="music-img"> <div class="music-img">
<img class="img" :src="playMusic.picUrl + '?param=300y300'" /> <n-image
:src="getImgUrl( playMusic?.picUrl, '300y300')"
class="img"
lazy
preview-disabled
/>
</div> </div>
<div class="music-content"> <div class="music-content">
<div class="music-content-name">{{ playMusic.song.name }}</div> <div class="music-content-name">{{ playMusic.song.name }}</div>
@@ -24,7 +30,13 @@
</transition> </transition>
<!-- 底部播放栏 --> <!-- 底部播放栏 -->
<div class="music-play-bar" :class="setAnimationClass('animate__bounceInUp')"> <div class="music-play-bar" :class="setAnimationClass('animate__bounceInUp')">
<img class="play-bar-img" :src="playMusic.picUrl + '?param=200y200'" @click="setMusicFull" /> <n-image
:src="getImgUrl( playMusic?.picUrl, '300y300')"
class="play-bar-img"
lazy
preview-disabled
@click="setMusicFull"
/>
<div class="music-content"> <div class="music-content">
<div class="music-content-title"> <div class="music-content-title">
<n-ellipsis class="text-ellipsis" line-clamp="1">{{ <n-ellipsis class="text-ellipsis" line-clamp="1">{{
@@ -88,7 +100,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { SongResult } from '@/type/music' import type { SongResult } from '@/type/music'
import type { ILyric } from '@/type/lyric' import type { ILyric } from '@/type/lyric'
import { secondToMinute } from '@/utils' import { secondToMinute, getImgUrl} from '@/utils'
import { computed, onMounted, ref, watch } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { useStore } from 'vuex' import { useStore } from 'vuex'
import { setAnimationClass } from '@/utils' import { setAnimationClass } from '@/utils'
@@ -363,15 +375,29 @@ const setAudioTime = (index: any) => {
animation: fadeOutDown 0.8s ease-in-out; animation: fadeOutDown 0.8s ease-in-out;
} }
.drawer-target-back{
position: absolute;
width: 100%;
height: 100%;
z-index: -1;
left: 0;
opacity: 0.8;
filter: blur(143px) brightness(80%);
background-size: 100%;
}
#drawer-target { #drawer-target {
@apply top-0 left-0 absolute w-full h-full overflow-hidden rounded px-24 pt-24 pb-48 flex items-center; @apply top-0 left-0 absolute w-full h-full overflow-hidden rounded px-24 pt-24 pb-48 flex items-center;
background-color: #333333; backdrop-filter: saturate(180%) blur(50px);
// background-color: #333333;
animation-duration: 300ms; animation-duration: 300ms;
.music-img { .music-img {
@apply flex-1; @apply flex-1 flex justify-center mr-24;
.img { .img {
width: 450px;
@apply rounded-xl; @apply rounded-xl;
} }
} }
@@ -389,7 +415,7 @@ const setAudioTime = (index: any) => {
} }
.music-lrc { .music-lrc {
background-color: #333333; background-color: inherit;
width: 800px; width: 800px;
height: 550px; height: 550px;
+1 -1
View File
@@ -23,5 +23,5 @@ const routes = [
export default createRouter({ export default createRouter({
routes: routes, routes: routes,
history: createMemoryHistory(), history: createWebHistory(),
}) })
+18 -7
View File
@@ -1,26 +1,37 @@
import { computed } from 'vue'
// 设置歌手背景图片 // 设置歌手背景图片
export const setBackgroundImg = (url: String) => { export const setBackgroundImg = (url: String) => {
return "background-image:" + "url(" + url + ")" return 'background-image:' + 'url(' + url + ')'
} }
// 设置动画类型 // 设置动画类型
export const setAnimationClass = (type: String) => { export const setAnimationClass = (type: String) => {
return "animate__animated " + type return 'animate__animated ' + type
} }
// 设置动画延时 // 设置动画延时
export const setAnimationDelay = (index: number = 6, time: number = 50) => { export const setAnimationDelay = (index: number = 6, time: number = 50) => {
return "animation-delay:" + index * time + "ms" return 'animation-delay:' + index * time + 'ms'
} }
//将秒转换为分钟和秒 //将秒转换为分钟和秒
export const secondToMinute = (s: number) => { export const secondToMinute = (s: number) => {
if (!s) { if (!s) {
return "00:00" return '00:00'
} }
let minute: number = Math.floor(s / 60) let minute: number = Math.floor(s / 60)
let second: number = Math.floor(s % 60) let second: number = Math.floor(s % 60)
let minuteStr: string = let minuteStr: string =
minute > 9 ? minute.toString() : "0" + minute.toString() minute > 9 ? minute.toString() : '0' + minute.toString()
let secondStr: string = let secondStr: string =
second > 9 ? second.toString() : "0" + second.toString() second > 9 ? second.toString() : '0' + second.toString()
return minuteStr + ":" + secondStr return minuteStr + ':' + secondStr
} }
export const getIsMc = () => {
return !!location.href.includes('mc.')
}
export const getImgUrl = computed(() => (url: string, size: string) => {
const bdUrl = 'https://image.baidu.com/search/down?url='
return getIsMc() ? `${bdUrl}${url}?param${size}` : `${url}?param${size}`
})
+5 -4
View File
@@ -1,5 +1,5 @@
<template> <template>
<div class="main-page"> <n-layout class="main-page" :native-scrollbar="false">
<!-- 推荐歌手 --> <!-- 推荐歌手 -->
<recommend-singer /> <recommend-singer />
<div class="main-content"> <div class="main-content">
@@ -10,11 +10,11 @@
<!-- 推荐最新专辑 --> <!-- 推荐最新专辑 -->
<recommend-album /> <recommend-album />
</div> </div>
</div> </n-layout>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {defineAsyncComponent} from 'vue'; import { defineAsyncComponent } from 'vue';
// import RecommendSinger from "@/components/RecommendSinger.vue"; // import RecommendSinger from "@/components/RecommendSinger.vue";
// import PlaylistType from "@/components/PlaylistType.vue"; // import PlaylistType from "@/components/PlaylistType.vue";
// import RecommendSonglist from "@/components/RecommendSonglist.vue"; // import RecommendSonglist from "@/components/RecommendSonglist.vue";
@@ -48,8 +48,9 @@ const RecommendAlbum = defineAsyncComponent(() => import("@/components/Recommend
<style lang="scss" scoped> <style lang="scss" scoped>
.main-page { .main-page {
@apply mt-4 pb-32; @apply mt-4 h-full;
} }
.main-content { .main-content {
@apply mt-6 flex; @apply mt-6 flex;
} }
+20 -16
View File
@@ -3,7 +3,7 @@ import { getRecommendList, getListDetail, getListByTag, getListByCat } from '@/a
import { computed, onMounted, ref, watch } from 'vue'; import { computed, onMounted, ref, watch } from 'vue';
import type { IRecommendList, IRecommendItem } from "@/type/list"; import type { IRecommendList, IRecommendItem } from "@/type/list";
import type { IListDetail } from "@/type/listDetail"; import type { IListDetail } from "@/type/listDetail";
import { setAnimationClass, setAnimationDelay } from "@/utils"; import { setAnimationClass, setAnimationDelay, getImgUrl } from "@/utils";
import SongItem from "@/components/common/SongItem.vue"; import SongItem from "@/components/common/SongItem.vue";
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
@@ -16,8 +16,8 @@ const showMusic = ref(false)
const recommendItem = ref<IRecommendItem>() const recommendItem = ref<IRecommendItem>()
const listDetail = ref<IListDetail>() const listDetail = ref<IListDetail>()
const selectRecommendItem = async (item: IRecommendItem) => { const selectRecommendItem = async (item: IRecommendItem) => {
const { data } = await getListDetail(item.id)
showMusic.value = true showMusic.value = true
const { data } = await getListDetail(item.id)
recommendItem.value = item recommendItem.value = item
listDetail.value = data listDetail.value = data
} }
@@ -119,7 +119,12 @@ const handlePlay = (item: any) => {
@click.stop="selectRecommendItem(item)" @click.stop="selectRecommendItem(item)"
> >
<div class="recommend-item-img"> <div class="recommend-item-img">
<img :src="(item.picUrl || item.coverImgUrl) + '?param=200y200'" /> <n-image
class="recommend-item-img-img"
:src="getImgUrl( (item.picUrl || item.coverImgUrl), '200y200')"
lazy
preview-disabled
/>
<div class="top"> <div class="top">
<div class="play-count">{{ formatNumber(item.playCount) }}</div> <div class="play-count">{{ formatNumber(item.playCount) }}</div>
<i class="iconfont icon-videofill"></i> <i class="iconfont icon-videofill"></i>
@@ -170,18 +175,16 @@ const handlePlay = (item: any) => {
} }
&-list { &-list {
@apply flex flex-wrap justify-between; @apply grid gap-6 pb-28;
padding-bottom: 100px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
} }
&-item { &-item {
width: 200px;
@apply mr-6 mb-4;
&-img { &-img {
@apply rounded-xl overflow-hidden relative; @apply rounded-xl overflow-hidden relative;
&:hover img { &:hover img {
@apply hover:scale-110 transition-all duration-300 ease-in-out; @apply hover:scale-110 transition-all duration-300 ease-in-out;
} }
img { &-img {
width: 200px; width: 200px;
height: 200px; height: 200px;
} }
@@ -217,14 +220,15 @@ const handlePlay = (item: any) => {
.music { .music {
&-page { &-page {
width: 100%; // width: 100%;
height: 70%; // height: 70%;
position: absolute; // position: absolute;
background-color: #000000f0; // background-color: #000000f0;
bottom: 0; // bottom: 0;
left: 0; // left: 0;
border-radius: 30px 30px 0 0; // border-radius: 30px 30px 0 0;
animation-duration: 300ms; // animation-duration: 300ms;
@apply w-full h-5/6 absolute bottom-0 left-0 bg-black rounded-t-3xl flex flex-col transition-all;
} }
&-title { &-title {
@apply text-lg font-bold text-white p-4; @apply text-lg font-bold text-white p-4;
+11 -1
View File
@@ -6,6 +6,7 @@
:native-scrollbar="false" :native-scrollbar="false"
> >
<div class="title">热搜列表</div> <div class="title">热搜列表</div>
<div class="hot-search-list">
<template v-for="(item, index) in hotSearchData?.data"> <template v-for="(item, index) in hotSearchData?.data">
<div <div
:class="setAnimationClass('animate__bounceInLeft')" :class="setAnimationClass('animate__bounceInLeft')"
@@ -20,6 +21,7 @@
{{ item.searchWord }} {{ item.searchWord }}
</div> </div>
</template> </template>
</div>
</n-layout> </n-layout>
<!-- 搜索到的歌曲列表 --> <!-- 搜索到的歌曲列表 -->
<n-layout <n-layout
@@ -29,7 +31,8 @@
@scroll="searchScrolling" @scroll="searchScrolling"
> >
<div class="title">{{ hotKeyword }}</div> <div class="title">{{ hotKeyword }}</div>
<template v-if="searchDetail"> <div class="search-list-box">
<template v-if="searchDetail">
<div <div
v-for="(item, index) in searchDetail?.result.songs" v-for="(item, index) in searchDetail?.result.songs"
:key="item.id" :key="item.id"
@@ -39,6 +42,7 @@
<SongItem :item="item" /> <SongItem :item="item" />
</div> </div>
</template> </template>
</div>
</n-layout> </n-layout>
</div> </div>
</template> </template>
@@ -125,6 +129,9 @@ watch(
animation-duration: 0.2s; animation-duration: 0.2s;
min-width: 400px; min-width: 400px;
height: 100%; height: 100%;
&-list{
@apply pb-28;
}
&-item { &-item {
@apply px-4 py-3 text-lg hover:bg-gray-700 rounded-xl cursor-pointer; @apply px-4 py-3 text-lg hover:bg-gray-700 rounded-xl cursor-pointer;
&-count { &-count {
@@ -140,6 +147,9 @@ watch(
@apply mt-3 flex-1 rounded-xl; @apply mt-3 flex-1 rounded-xl;
background-color: #0d0d0d; background-color: #0d0d0d;
height: 100%; height: 100%;
&-box{
@apply pb-28;
}
} }
.title { .title {
+7 -2
View File
@@ -4,7 +4,7 @@ import { useRouter } from "vue-router";
import { getUserDetail, getUserPlaylist, getUserRecord } from "@/api/user"; import { getUserDetail, getUserPlaylist, getUserRecord } from "@/api/user";
import type { IUserDetail } from "@/type/user"; import type { IUserDetail } from "@/type/user";
import { computed, ref } from "vue"; import { computed, ref } from "vue";
import { setAnimationClass, setAnimationDelay } from "@/utils"; import { setAnimationClass, setAnimationDelay, getImgUrl } from "@/utils";
import { getListDetail } from '@/api/list' import { getListDetail } from '@/api/list'
import SongItem from "@/components/common/SongItem.vue"; import SongItem from "@/components/common/SongItem.vue";
@@ -115,7 +115,12 @@ const handlePlay = (item: any) => {
:key="index" :key="index"
@click="showPlaylist(item.id)" @click="showPlaylist(item.id)"
> >
<img class="play-list-item-img" :src="item.coverImgUrl" /> <n-image
:src="getImgUrl( item.coverImgUrl, '')"
class="play-list-item-img"
lazy
preview-disabled
/>
<div class="play-list-item-info"> <div class="play-list-item-info">
<div class="play-list-item-name">{{ item.name }}</div> <div class="play-list-item-name">{{ item.name }}</div>
<div class="play-list-item-count">{{ item.trackCount }}播放{{ item.playCount }}</div> <div class="play-list-item-count">{{ item.trackCount }}播放{{ item.playCount }}</div>