mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-18 11:37:31 +08:00
✨ feat: 添加每日推荐 样式, 请求等大量优化
This commit is contained in:
Vendored
+1
@@ -23,6 +23,7 @@ declare module 'vue' {
|
|||||||
NPopover: typeof import('naive-ui')['NPopover']
|
NPopover: typeof import('naive-ui')['NPopover']
|
||||||
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
NScrollbar: typeof import('naive-ui')['NScrollbar']
|
||||||
NSlider: typeof import('naive-ui')['NSlider']
|
NSlider: typeof import('naive-ui')['NSlider']
|
||||||
|
NSpin: typeof import('naive-ui')['NSpin']
|
||||||
NSwitch: typeof import('naive-ui')['NSwitch']
|
NSwitch: typeof import('naive-ui')['NSwitch']
|
||||||
NTooltip: typeof import('naive-ui')['NTooltip']
|
NTooltip: typeof import('naive-ui')['NTooltip']
|
||||||
PlayBottom: typeof import('./src/components/common/PlayBottom.vue')['default']
|
PlayBottom: typeof import('./src/components/common/PlayBottom.vue')['default']
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@
|
|||||||
"eslint-plugin-vue": "^9.21.1",
|
"eslint-plugin-vue": "^9.21.1",
|
||||||
"eslint-plugin-vue-scoped-css": "^2.7.2",
|
"eslint-plugin-vue-scoped-css": "^2.7.2",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"naive-ui": "^2.34.4",
|
"naive-ui": "^2.38.2",
|
||||||
"postcss": "^7.0.36",
|
"postcss": "^7.0.36",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.2.5",
|
||||||
"remixicon": "^4.2.0",
|
"remixicon": "^4.2.0",
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
<audio id="MusicAudio" ref="audioRef" :src="playMusicUrl" :autoplay="play"></audio>
|
<audio id="MusicAudio" ref="audioRef" :src="playMusicUrl" :autoplay="play"></audio>
|
||||||
<n-config-provider :theme="darkTheme">
|
<n-config-provider :theme="darkTheme">
|
||||||
<n-dialog-provider>
|
<n-dialog-provider>
|
||||||
|
<keep-alive>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
</keep-alive>
|
||||||
</n-dialog-provider>
|
</n-dialog-provider>
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import { IData } from '@/type';
|
||||||
import { IAlbumNew } from '@/type/album';
|
import { IAlbumNew } from '@/type/album';
|
||||||
|
import { IDayRecommend } from '@/type/day_recommend';
|
||||||
import { IRecommendMusic } from '@/type/music';
|
import { IRecommendMusic } from '@/type/music';
|
||||||
import { IPlayListSort } from '@/type/playlist';
|
import { IPlayListSort } from '@/type/playlist';
|
||||||
import { IHotSearch, ISearchKeyword } from '@/type/search';
|
import { IHotSearch, ISearchKeyword } from '@/type/search';
|
||||||
@@ -39,6 +41,11 @@ export const getRecommendMusic = (params: IRecommendMusicParams) => {
|
|||||||
return request.get<IRecommendMusic>('/personalized/newsong', { params });
|
return request.get<IRecommendMusic>('/personalized/newsong', { params });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取每日推荐
|
||||||
|
export const getDayRecommend = () => {
|
||||||
|
return request.get<IData<IDayRecommend>>('/recommend/songs');
|
||||||
|
};
|
||||||
|
|
||||||
// 获取最新专辑推荐
|
// 获取最新专辑推荐
|
||||||
export const getNewAlbum = () => {
|
export const getNewAlbum = () => {
|
||||||
return request.get<IAlbumNew>('/album/newest');
|
return request.get<IAlbumNew>('/album/newest');
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
v-for="(item, index) in songList"
|
v-for="(item, index) in songList"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:class="setAnimationClass('animate__bounceInUp')"
|
:class="setAnimationClass('animate__bounceInUp')"
|
||||||
:style="setAnimationDelay(index, 100)"
|
:style="setAnimationDelay(index, 50)"
|
||||||
>
|
>
|
||||||
<song-item :item="formatDetail(item)" @play="handlePlay" />
|
<song-item :item="formatDetail(item)" @play="handlePlay" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,11 +3,34 @@
|
|||||||
<div class="recommend-singer">
|
<div class="recommend-singer">
|
||||||
<div class="recommend-singer-list">
|
<div class="recommend-singer-list">
|
||||||
<div
|
<div
|
||||||
v-for="(item, index) in hotSingerData?.artists"
|
class="recommend-singer-item relative"
|
||||||
|
:class="setAnimationClass('animate__backInRight')"
|
||||||
|
:style="setAnimationDelay(0, 100)"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:style="setBackgroundImg(getImgUrl(dayRecommendData?.dailySongs[0].al.picUrl, '300y300'))"
|
||||||
|
class="recommend-singer-item-bg"
|
||||||
|
></div>
|
||||||
|
<div
|
||||||
|
class="recommend-singer-item-count p-2 text-base text-gray-200 z-10 cursor-pointer"
|
||||||
|
@click="showMusic = true"
|
||||||
|
>
|
||||||
|
<div class="font-bold text-xl">每日推荐列表</div>
|
||||||
|
|
||||||
|
<div class="mt-2">
|
||||||
|
<p v-for="item in dayRecommendData?.dailySongs.slice(0, 8)" :key="item.id" class="text-el">
|
||||||
|
{{ item.name }}
|
||||||
|
<br />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in hotSingerData?.artists.slice(0, 4)"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="recommend-singer-item relative"
|
class="recommend-singer-item relative"
|
||||||
:class="setAnimationClass('animate__backInRight')"
|
:class="setAnimationClass('animate__backInRight')"
|
||||||
:style="setAnimationDelay(index, 100)"
|
:style="setAnimationDelay(index + 1, 100)"
|
||||||
>
|
>
|
||||||
<div :style="setBackgroundImg(getImgUrl(item.picUrl, '300y300'))" class="recommend-singer-item-bg"></div>
|
<div :style="setBackgroundImg(getImgUrl(item.picUrl, '300y300'))" class="recommend-singer-item-bg"></div>
|
||||||
<div class="recommend-singer-item-count p-2 text-base text-gray-200 z-10">{{ item.musicSize }}首</div>
|
<div class="recommend-singer-item-count p-2 text-base text-gray-200 z-10">{{ item.musicSize }}首</div>
|
||||||
@@ -16,34 +39,58 @@
|
|||||||
<i class="iconfont icon-playfill text-xl"></i>
|
<i class="iconfont icon-playfill text-xl"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-4">
|
<div class="ml-4">
|
||||||
<div class="recommend-singer-item-info-name">{{ item.name }}</div>
|
<div class="recommend-singer-item-info-name text-el">{{ item.name }}</div>
|
||||||
<div class="recommend-singer-item-info-name">{{ item.name }}</div>
|
<div class="recommend-singer-item-info-name text-el">{{ item.name }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<music-list
|
||||||
|
v-if="dayRecommendData?.dailySongs.length"
|
||||||
|
v-model:show="showMusic"
|
||||||
|
name="每日推荐列表"
|
||||||
|
:song-list="dayRecommendData?.dailySongs"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
|
|
||||||
import { getHotSinger } from '@/api/home';
|
import { getDayRecommend, getHotSinger } from '@/api/home';
|
||||||
import router from '@/router';
|
import router from '@/router';
|
||||||
|
import { IDayRecommend } from '@/type/day_recommend';
|
||||||
import type { IHotSinger } from '@/type/singer';
|
import type { IHotSinger } from '@/type/singer';
|
||||||
import { getImgUrl, setAnimationClass, setAnimationDelay, setBackgroundImg } from '@/utils';
|
import { getImgUrl, setAnimationClass, setAnimationDelay, setBackgroundImg } from '@/utils';
|
||||||
|
|
||||||
// 歌手信息
|
// 歌手信息
|
||||||
const hotSingerData = ref<IHotSinger>();
|
const hotSingerData = ref<IHotSinger>();
|
||||||
|
const dayRecommendData = ref<IDayRecommend>();
|
||||||
|
const showMusic = ref(false);
|
||||||
|
// // 加载推荐歌手
|
||||||
|
// const loadSingerList = async () => {
|
||||||
|
// const { data } = await getHotSinger({ offset: 0, limit: 5 });
|
||||||
|
// hotSingerData.value = data;
|
||||||
|
// };
|
||||||
|
|
||||||
// 加载推荐歌手
|
// const loadDayRecommend = async () => {
|
||||||
const loadSingerList = async () => {
|
// const { data } = await getDayRecommend();
|
||||||
const { data } = await getHotSinger({ offset: 0, limit: 5 });
|
// dayRecommendData.value = data.data;
|
||||||
hotSingerData.value = data;
|
// };
|
||||||
};
|
|
||||||
// 页面初始化
|
// 页面初始化
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
loadSingerList();
|
try {
|
||||||
|
const [{ data: singerData }, { data: dayRecommend }] = await Promise.all([
|
||||||
|
getHotSinger({ offset: 0, limit: 5 }),
|
||||||
|
getDayRecommend(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
hotSingerData.value = singerData;
|
||||||
|
dayRecommendData.value = dayRecommend.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('error', error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const toSearchSinger = (keyword: string) => {
|
const toSearchSinger = (keyword: string) => {
|
||||||
@@ -66,7 +113,7 @@ const toSearchSinger = (keyword: string) => {
|
|||||||
@apply flex-1 h-full rounded-3xl p-5 mr-5 flex flex-col justify-between;
|
@apply flex-1 h-full rounded-3xl p-5 mr-5 flex flex-col justify-between;
|
||||||
&-bg {
|
&-bg {
|
||||||
@apply bg-gray-900 bg-no-repeat bg-cover bg-center rounded-3xl absolute w-full h-full top-0 left-0 z-0;
|
@apply bg-gray-900 bg-no-repeat bg-cover bg-center rounded-3xl absolute w-full h-full top-0 left-0 z-0;
|
||||||
filter: brightness(80%);
|
filter: brightness(60%);
|
||||||
}
|
}
|
||||||
&-info {
|
&-info {
|
||||||
@apply flex items-center p-2;
|
@apply flex items-center p-2;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="isPlay" class="bottom"></div>
|
<div v-if="isPlay" class="bottom" :style="{ height }"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -7,6 +7,12 @@ import { useStore } from 'vuex';
|
|||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const isPlay = computed(() => store.state.isPlay as boolean);
|
const isPlay = computed(() => store.state.isPlay as boolean);
|
||||||
|
defineProps({
|
||||||
|
height: {
|
||||||
|
type: String,
|
||||||
|
default: undefined,
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -9,3 +9,7 @@
|
|||||||
background-color: #111111;
|
background-color: #111111;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-el {
|
||||||
|
@apply overflow-ellipsis overflow-hidden whitespace-nowrap;
|
||||||
|
}
|
||||||
|
|||||||
+18
-13
@@ -9,26 +9,16 @@
|
|||||||
<!-- 搜索栏 -->
|
<!-- 搜索栏 -->
|
||||||
<search-bar />
|
<search-bar />
|
||||||
<!-- 主页面路由 -->
|
<!-- 主页面路由 -->
|
||||||
<div class="main-content bg-black pb-" :native-scrollbar="false" :class="isPlay ? 'pb-20' : ''">
|
<div class="main-content bg-black" :native-scrollbar="false">
|
||||||
<n-message-provider>
|
<n-message-provider>
|
||||||
<router-view v-slot="{ Component }" class="main-page" :class="route.meta.noScroll ? 'pr-3' : ''">
|
<router-view v-slot="{ Component }" class="main-page" :class="route.meta.noScroll ? 'pr-3' : ''">
|
||||||
<template v-if="route.meta.noScroll">
|
<keep-alive :include="keepAliveInclude">
|
||||||
<keep-alive v-if="!route.meta.noKeepAlive">
|
|
||||||
<component :is="Component" />
|
<component :is="Component" />
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
<component :is="Component" v-else />
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<n-scrollbar>
|
|
||||||
<keep-alive v-if="!route.meta.noKeepAlive">
|
|
||||||
<component :is="Component" />
|
|
||||||
</keep-alive>
|
|
||||||
<component :is="Component" v-else />
|
|
||||||
</n-scrollbar>
|
|
||||||
</template>
|
|
||||||
</router-view>
|
</router-view>
|
||||||
</n-message-provider>
|
</n-message-provider>
|
||||||
</div>
|
</div>
|
||||||
|
<play-bottom height="5rem" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- 底部音乐播放 -->
|
<!-- 底部音乐播放 -->
|
||||||
@@ -41,6 +31,21 @@
|
|||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useStore } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
|
|
||||||
|
import PlayBottom from '@/components/common/PlayBottom.vue';
|
||||||
|
import homeRouter from '@/router/home';
|
||||||
|
|
||||||
|
const keepAliveInclude = computed(() =>
|
||||||
|
homeRouter
|
||||||
|
.filter((item) => {
|
||||||
|
return item.meta.keepAlive;
|
||||||
|
})
|
||||||
|
.map((item) => {
|
||||||
|
// return item.name;
|
||||||
|
// 首字母大写
|
||||||
|
return item.name.charAt(0).toUpperCase() + item.name.slice(1);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
const AppMenu = defineAsyncComponent(() => import('./components/AppMenu.vue'));
|
const AppMenu = defineAsyncComponent(() => import('./components/AppMenu.vue'));
|
||||||
const PlayBar = defineAsyncComponent(() => import('./components/PlayBar.vue'));
|
const PlayBar = defineAsyncComponent(() => import('./components/PlayBar.vue'));
|
||||||
const SearchBar = defineAsyncComponent(() => import('./components/SearchBar.vue'));
|
const SearchBar = defineAsyncComponent(() => import('./components/SearchBar.vue'));
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ const loadPage = async () => {
|
|||||||
localStorage.setItem('user', JSON.stringify(data.profile));
|
localStorage.setItem('user', JSON.stringify(data.profile));
|
||||||
};
|
};
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
loadPage();
|
loadPage();
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
if (store.state.user) {
|
if (store.state.user) {
|
||||||
userSetOptions.value = USER_SET_OPTIONS;
|
userSetOptions.value = USER_SET_OPTIONS;
|
||||||
} else {
|
} else {
|
||||||
@@ -118,6 +119,7 @@ const selectItem = async (key: string) => {
|
|||||||
logout().then(() => {
|
logout().then(() => {
|
||||||
store.state.user = null;
|
store.state.user = null;
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
router.push('/login');
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'login':
|
case 'login':
|
||||||
|
|||||||
+6
-2
@@ -5,6 +5,7 @@ const layoutRouter = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: '首页',
|
title: '首页',
|
||||||
icon: 'icon-Home',
|
icon: 'icon-Home',
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
component: () => import('@/views/home/index.vue'),
|
component: () => import('@/views/home/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -14,8 +15,8 @@ const layoutRouter = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: '搜索',
|
title: '搜索',
|
||||||
noScroll: true,
|
noScroll: true,
|
||||||
noKeepAlive: true,
|
|
||||||
icon: 'icon-Search',
|
icon: 'icon-Search',
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
component: () => import('@/views/search/index.vue'),
|
component: () => import('@/views/search/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -25,6 +26,7 @@ const layoutRouter = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: '歌单',
|
title: '歌单',
|
||||||
icon: 'icon-Paper',
|
icon: 'icon-Paper',
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
component: () => import('@/views/list/index.vue'),
|
component: () => import('@/views/list/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -34,6 +36,7 @@ const layoutRouter = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: 'MV',
|
title: 'MV',
|
||||||
icon: 'icon-recordfill',
|
icon: 'icon-recordfill',
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
component: () => import('@/views/mv/index.vue'),
|
component: () => import('@/views/mv/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -43,6 +46,7 @@ const layoutRouter = [
|
|||||||
meta: {
|
meta: {
|
||||||
title: '历史',
|
title: '历史',
|
||||||
icon: 'icon-a-TicketStar',
|
icon: 'icon-a-TicketStar',
|
||||||
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
component: () => import('@/views/history/index.vue'),
|
component: () => import('@/views/history/index.vue'),
|
||||||
},
|
},
|
||||||
@@ -51,8 +55,8 @@ const layoutRouter = [
|
|||||||
name: 'user',
|
name: 'user',
|
||||||
meta: {
|
meta: {
|
||||||
title: '用户',
|
title: '用户',
|
||||||
noKeepAlive: true,
|
|
||||||
icon: 'icon-Profile',
|
icon: 'icon-Profile',
|
||||||
|
keepAlive: true,
|
||||||
noScroll: true,
|
noScroll: true,
|
||||||
},
|
},
|
||||||
component: () => import('@/views/user/index.vue'),
|
component: () => import('@/views/user/index.vue'),
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
export interface IDayRecommend {
|
||||||
|
dailySongs: DailySong[];
|
||||||
|
orderSongs: any[];
|
||||||
|
recommendReasons: RecommendReason[];
|
||||||
|
mvResourceInfos: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RecommendReason {
|
||||||
|
songId: number;
|
||||||
|
reason: string;
|
||||||
|
reasonId: string;
|
||||||
|
targetUrl: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DailySong {
|
||||||
|
name: string;
|
||||||
|
id: number;
|
||||||
|
pst: number;
|
||||||
|
t: number;
|
||||||
|
ar: Ar[];
|
||||||
|
alia: string[];
|
||||||
|
pop: number;
|
||||||
|
st: number;
|
||||||
|
rt: null | string;
|
||||||
|
fee: number;
|
||||||
|
v: number;
|
||||||
|
crbt: null;
|
||||||
|
cf: string;
|
||||||
|
al: Al;
|
||||||
|
dt: number;
|
||||||
|
h: H;
|
||||||
|
m: H;
|
||||||
|
l: H;
|
||||||
|
sq: H | null;
|
||||||
|
hr: H | null;
|
||||||
|
a: null;
|
||||||
|
cd: string;
|
||||||
|
no: number;
|
||||||
|
rtUrl: null;
|
||||||
|
ftype: number;
|
||||||
|
rtUrls: any[];
|
||||||
|
djId: number;
|
||||||
|
copyright: number;
|
||||||
|
s_id: number;
|
||||||
|
mark: number;
|
||||||
|
originCoverType: number;
|
||||||
|
originSongSimpleData: OriginSongSimpleDatum | null;
|
||||||
|
tagPicList: null;
|
||||||
|
resourceState: boolean;
|
||||||
|
version: number;
|
||||||
|
songJumpInfo: null;
|
||||||
|
entertainmentTags: null;
|
||||||
|
single: number;
|
||||||
|
noCopyrightRcmd: null;
|
||||||
|
rtype: number;
|
||||||
|
rurl: null;
|
||||||
|
mst: number;
|
||||||
|
cp: number;
|
||||||
|
mv: number;
|
||||||
|
publishTime: number;
|
||||||
|
reason: null | string;
|
||||||
|
videoInfo: VideoInfo;
|
||||||
|
recommendReason: null | string;
|
||||||
|
privilege: Privilege;
|
||||||
|
alg: string;
|
||||||
|
tns?: string[];
|
||||||
|
s_ctrp?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Privilege {
|
||||||
|
id: number;
|
||||||
|
fee: number;
|
||||||
|
payed: number;
|
||||||
|
realPayed: number;
|
||||||
|
st: number;
|
||||||
|
pl: number;
|
||||||
|
dl: number;
|
||||||
|
sp: number;
|
||||||
|
cp: number;
|
||||||
|
subp: number;
|
||||||
|
cs: boolean;
|
||||||
|
maxbr: number;
|
||||||
|
fl: number;
|
||||||
|
pc: null;
|
||||||
|
toast: boolean;
|
||||||
|
flag: number;
|
||||||
|
paidBigBang: boolean;
|
||||||
|
preSell: boolean;
|
||||||
|
playMaxbr: number;
|
||||||
|
downloadMaxbr: number;
|
||||||
|
maxBrLevel: string;
|
||||||
|
playMaxBrLevel: string;
|
||||||
|
downloadMaxBrLevel: string;
|
||||||
|
plLevel: string;
|
||||||
|
dlLevel: string;
|
||||||
|
flLevel: string;
|
||||||
|
rscl: null;
|
||||||
|
freeTrialPrivilege: FreeTrialPrivilege;
|
||||||
|
rightSource: number;
|
||||||
|
chargeInfoList: ChargeInfoList[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ChargeInfoList {
|
||||||
|
rate: number;
|
||||||
|
chargeUrl: null;
|
||||||
|
chargeMessage: null;
|
||||||
|
chargeType: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FreeTrialPrivilege {
|
||||||
|
resConsumable: boolean;
|
||||||
|
userConsumable: boolean;
|
||||||
|
listenType: number;
|
||||||
|
cannotListenReason: number;
|
||||||
|
playReason: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VideoInfo {
|
||||||
|
moreThanOne: boolean;
|
||||||
|
video: Video | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Video {
|
||||||
|
vid: string;
|
||||||
|
type: number;
|
||||||
|
title: string;
|
||||||
|
playTime: number;
|
||||||
|
coverUrl: string;
|
||||||
|
publishTime: number;
|
||||||
|
artists: null;
|
||||||
|
alias: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OriginSongSimpleDatum {
|
||||||
|
songId: number;
|
||||||
|
name: string;
|
||||||
|
artists: Artist[];
|
||||||
|
albumMeta: Artist;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Artist {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface H {
|
||||||
|
br: number;
|
||||||
|
fid: number;
|
||||||
|
size: number;
|
||||||
|
vd: number;
|
||||||
|
sr: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Al {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
picUrl: string;
|
||||||
|
tns: string[];
|
||||||
|
pic_str?: string;
|
||||||
|
pic: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Ar {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
tns: any[];
|
||||||
|
alias: any[];
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export interface IData<T> {
|
export interface IData<T> {
|
||||||
code: number;
|
code: number;
|
||||||
data: T;
|
data: T;
|
||||||
|
result: T;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ export const getMusicProxyUrl = (url: string) => {
|
|||||||
return `${ProxyUrl}/mc?url=${PUrl}`;
|
return `${ProxyUrl}/mc?url=${PUrl}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getImgUrl = computed(() => (url: string, size: string = '') => {
|
export const getImgUrl = computed(() => (url: string | undefined, size: string = '') => {
|
||||||
const bdUrl = 'https://image.baidu.com/search/down?url=';
|
const bdUrl = 'https://image.baidu.com/search/down?url=';
|
||||||
const imgUrl = encodeURIComponent(`${url}?param=${size}`);
|
const imgUrl = encodeURIComponent(`${url}?param=${size}`);
|
||||||
return `${bdUrl}${imgUrl}`;
|
return `${bdUrl}${imgUrl}`;
|
||||||
|
|||||||
@@ -27,6 +27,10 @@
|
|||||||
import { useMusicHistory } from '@/hooks/MusicHistoryHook';
|
import { useMusicHistory } from '@/hooks/MusicHistoryHook';
|
||||||
import { setAnimationClass, setAnimationDelay } from '@/utils';
|
import { setAnimationClass, setAnimationDelay } from '@/utils';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'History',
|
||||||
|
});
|
||||||
|
|
||||||
const { delMusic, musicList } = useMusicHistory();
|
const { delMusic, musicList } = useMusicHistory();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -38,7 +42,7 @@ const { delMusic, musicList } = useMusicHistory();
|
|||||||
}
|
}
|
||||||
|
|
||||||
.history-list-content {
|
.history-list-content {
|
||||||
@apply px-4 mt-2;
|
@apply px-4 mt-2 pb-28;
|
||||||
.history-item {
|
.history-item {
|
||||||
@apply flex items-center justify-between;
|
@apply flex items-center justify-between;
|
||||||
&-content {
|
&-content {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<n-scrollbar :size="100">
|
||||||
<div class="main-page">
|
<div class="main-page">
|
||||||
<!-- 推荐歌手 -->
|
<!-- 推荐歌手 -->
|
||||||
<recommend-singer />
|
<recommend-singer />
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
<recommend-album />
|
<recommend-album />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</n-scrollbar>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@@ -18,6 +20,9 @@ const RecommendSinger = defineAsyncComponent(() => import('@/components/Recommen
|
|||||||
const PlaylistType = defineAsyncComponent(() => import('@/components/PlaylistType.vue'));
|
const PlaylistType = defineAsyncComponent(() => import('@/components/PlaylistType.vue'));
|
||||||
const RecommendSonglist = defineAsyncComponent(() => import('@/components/RecommendSonglist.vue'));
|
const RecommendSonglist = defineAsyncComponent(() => import('@/components/RecommendSonglist.vue'));
|
||||||
const RecommendAlbum = defineAsyncComponent(() => import('@/components/RecommendAlbum.vue'));
|
const RecommendAlbum = defineAsyncComponent(() => import('@/components/RecommendAlbum.vue'));
|
||||||
|
defineOptions({
|
||||||
|
name: 'Home',
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@@ -25,6 +30,6 @@ const RecommendAlbum = defineAsyncComponent(() => import('@/components/Recommend
|
|||||||
@apply h-full w-full;
|
@apply h-full w-full;
|
||||||
}
|
}
|
||||||
.main-content {
|
.main-content {
|
||||||
@apply mt-6 flex pb-28;
|
@apply mt-6 flex mb-28;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import { getListByCat, getListDetail, getRecommendList } from '@/api/list';
|
import { getListByCat, getListDetail, getRecommendList } from '@/api/list';
|
||||||
import PlayBottom from '@/components/common/PlayBottom.vue';
|
|
||||||
import MusicList from '@/components/MusicList.vue';
|
import MusicList from '@/components/MusicList.vue';
|
||||||
import type { IRecommendItem } from '@/type/list';
|
import type { IRecommendItem } from '@/type/list';
|
||||||
import type { IListDetail } from '@/type/listDetail';
|
import type { IListDetail } from '@/type/listDetail';
|
||||||
import { formatNumber, getImgUrl, setAnimationClass, setAnimationDelay } from '@/utils';
|
import { formatNumber, getImgUrl, setAnimationClass, setAnimationDelay } from '@/utils';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'List',
|
||||||
|
});
|
||||||
|
|
||||||
const recommendList = ref();
|
const recommendList = ref();
|
||||||
const showMusic = ref(false);
|
const showMusic = ref(false);
|
||||||
|
|
||||||
@@ -82,7 +85,6 @@ watch(
|
|||||||
<div class="recommend-item-title">{{ item.name }}</div>
|
<div class="recommend-item-title">{{ item.name }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<play-bottom />
|
|
||||||
</n-scrollbar>
|
</n-scrollbar>
|
||||||
<music-list
|
<music-list
|
||||||
v-if="listDetail?.playlist"
|
v-if="listDetail?.playlist"
|
||||||
|
|||||||
@@ -4,9 +4,13 @@ import { onMounted } from 'vue';
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useStore } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
|
|
||||||
import { checkQr, createQr, getLoginStatus, getQrKey, getUserDetail, loginByCellphone } from '@/api/login';
|
import { checkQr, createQr, getQrKey, getUserDetail, loginByCellphone } from '@/api/login';
|
||||||
import { setAnimationClass } from '@/utils';
|
import { setAnimationClass } from '@/utils';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'Login',
|
||||||
|
});
|
||||||
|
|
||||||
const message = useMessage();
|
const message = useMessage();
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -16,37 +20,53 @@ onMounted(() => {
|
|||||||
loadLogin();
|
loadLogin();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const timerRef = ref(null);
|
||||||
|
|
||||||
const loadLogin = async () => {
|
const loadLogin = async () => {
|
||||||
|
try {
|
||||||
const qrKey = await getQrKey();
|
const qrKey = await getQrKey();
|
||||||
const key = qrKey.data.data.unikey;
|
const key = qrKey.data.data.unikey;
|
||||||
const { data } = await createQr(key);
|
const { data } = await createQr(key);
|
||||||
qrUrl.value = data.data.qrimg;
|
qrUrl.value = data.data.qrimg;
|
||||||
timerIsQr(key);
|
|
||||||
|
const timer = timerIsQr(key);
|
||||||
|
// 添加对定时器的引用,以便在出现错误时可以清除
|
||||||
|
timerRef.value = timer as any;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('加载登录信息时出错:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 使用 ref 来保存定时器,便于在任何地方清除它
|
||||||
|
|
||||||
const timerIsQr = (key: string) => {
|
const timerIsQr = (key: string) => {
|
||||||
const timer = setInterval(async () => {
|
const timer = setInterval(async () => {
|
||||||
|
try {
|
||||||
const { data } = await checkQr(key);
|
const { data } = await checkQr(key);
|
||||||
|
|
||||||
if (data.code === 800) {
|
if (data.code === 800) {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
|
timerRef.value = null;
|
||||||
}
|
}
|
||||||
if (data.code === 803) {
|
if (data.code === 803) {
|
||||||
// 将token存入localStorage
|
|
||||||
localStorage.setItem('token', data.cookie);
|
localStorage.setItem('token', data.cookie);
|
||||||
const user = await getUserDetail();
|
const user = await getUserDetail();
|
||||||
store.state.user = user.data.profile;
|
store.state.user = user.data.profile;
|
||||||
message.success('登录成功');
|
message.success('登录成功');
|
||||||
|
|
||||||
await getLoginStatus().then((res) => {
|
|
||||||
console.log(res);
|
|
||||||
});
|
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
setTimeout(() => {
|
timerRef.value = null;
|
||||||
router.push('/user');
|
router.push('/user');
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
}, 5000);
|
} catch (error) {
|
||||||
|
console.error('检查二维码状态时出错:', error);
|
||||||
|
// 在出现错误时清除定时器
|
||||||
|
clearInterval(timer);
|
||||||
|
timerRef.value = null;
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
return timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 是否扫码登陆
|
// 是否扫码登陆
|
||||||
|
|||||||
@@ -48,6 +48,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useIpcRenderer } from '@vueuse/electron';
|
import { useIpcRenderer } from '@vueuse/electron';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'Lyric',
|
||||||
|
});
|
||||||
|
|
||||||
const ipcRenderer = useIpcRenderer();
|
const ipcRenderer = useIpcRenderer();
|
||||||
|
|
||||||
const lyricData = ref({
|
const lyricData = ref({
|
||||||
@@ -74,7 +78,7 @@ const lyricSetting = ref({
|
|||||||
? JSON.parse(localStorage.getItem('lyricData') || '')
|
? JSON.parse(localStorage.getItem('lyricData') || '')
|
||||||
: {
|
: {
|
||||||
isTop: false,
|
isTop: false,
|
||||||
theme: 'light',
|
theme: 'dark',
|
||||||
isLock: false,
|
isLock: false,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ import { getMvUrl, getTopMv } from '@/api/mv';
|
|||||||
import { IMvItem } from '@/type/mv';
|
import { IMvItem } from '@/type/mv';
|
||||||
import { formatNumber, getImgUrl, setAnimationClass, setAnimationDelay } from '@/utils';
|
import { formatNumber, getImgUrl, setAnimationClass, setAnimationDelay } from '@/utils';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'Mv',
|
||||||
|
});
|
||||||
|
|
||||||
const showMv = ref(false);
|
const showMv = ref(false);
|
||||||
const mvList = ref<Array<IMvItem>>([]);
|
const mvList = ref<Array<IMvItem>>([]);
|
||||||
const playMvItem = ref<IMvItem>();
|
const playMvItem = ref<IMvItem>();
|
||||||
@@ -91,7 +95,7 @@ const close = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-content {
|
&-content {
|
||||||
@apply grid gap-6 pb-4 mt-2;
|
@apply grid gap-6 pb-28 mt-2;
|
||||||
grid-template-columns: repeat(auto-fill, minmax(14%, 1fr));
|
grid-template-columns: repeat(auto-fill, minmax(14%, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<!-- 搜索到的歌曲列表 -->
|
<!-- 搜索到的歌曲列表 -->
|
||||||
<n-layout class="search-list" :class="setAnimationClass('animate__fadeInUp')" :native-scrollbar="false">
|
<n-layout class="search-list" :class="setAnimationClass('animate__fadeInUp')" :native-scrollbar="false">
|
||||||
<div class="title">{{ hotKeyword }}</div>
|
<div class="title">{{ hotKeyword }}</div>
|
||||||
|
<n-spin :show="searchDetailLoading">
|
||||||
<div class="search-list-box">
|
<div class="search-list-box">
|
||||||
<template v-if="searchDetail">
|
<template v-if="searchDetail">
|
||||||
<div
|
<div
|
||||||
@@ -43,6 +44,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
</n-spin>
|
||||||
</n-layout>
|
</n-layout>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -59,10 +61,15 @@ import SongItem from '@/components/common/SongItem.vue';
|
|||||||
import type { IHotSearch } from '@/type/search';
|
import type { IHotSearch } from '@/type/search';
|
||||||
import { setAnimationClass, setAnimationDelay } from '@/utils';
|
import { setAnimationClass, setAnimationDelay } from '@/utils';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'Search',
|
||||||
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const searchDetail = ref<any>();
|
const searchDetail = ref<any>();
|
||||||
const searchType = ref(Number(route.query.type) || 1);
|
const searchType = ref(Number(route.query.type) || 1);
|
||||||
|
const searchDetailLoading = ref(false);
|
||||||
|
|
||||||
// 热搜列表
|
// 热搜列表
|
||||||
const hotSearchData = ref<IHotSearch>();
|
const hotSearchData = ref<IHotSearch>();
|
||||||
@@ -93,6 +100,8 @@ const loadSearch = async (keywords: any) => {
|
|||||||
hotKeyword.value = keywords;
|
hotKeyword.value = keywords;
|
||||||
searchDetail.value = undefined;
|
searchDetail.value = undefined;
|
||||||
if (!keywords) return;
|
if (!keywords) return;
|
||||||
|
|
||||||
|
searchDetailLoading.value = true;
|
||||||
const { data } = await getSearch({ keywords, type: searchType.value });
|
const { data } = await getSearch({ keywords, type: searchType.value });
|
||||||
|
|
||||||
const songs = data.result.songs || [];
|
const songs = data.result.songs || [];
|
||||||
@@ -111,6 +120,8 @@ const loadSearch = async (keywords: any) => {
|
|||||||
songs,
|
songs,
|
||||||
albums,
|
albums,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
searchDetailLoading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
loadSearch(route.query.keyword);
|
loadSearch(route.query.keyword);
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ import { useRouter } from 'vue-router';
|
|||||||
|
|
||||||
import store from '@/store';
|
import store from '@/store';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'Setting',
|
||||||
|
});
|
||||||
|
|
||||||
const setData = ref(store.state.setData);
|
const setData = ref(store.state.setData);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { onBeforeRouteUpdate, useRouter } from 'vue-router';
|
||||||
import { useStore } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
|
|
||||||
import { getListDetail } from '@/api/list';
|
import { getListDetail } from '@/api/list';
|
||||||
@@ -12,6 +12,10 @@ import type { Playlist } from '@/type/listDetail';
|
|||||||
import type { IUserDetail } from '@/type/user';
|
import type { IUserDetail } from '@/type/user';
|
||||||
import { getImgUrl, setAnimationClass, setAnimationDelay } from '@/utils';
|
import { getImgUrl, setAnimationClass, setAnimationDelay } from '@/utils';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'User',
|
||||||
|
});
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userDetail = ref<IUserDetail>();
|
const userDetail = ref<IUserDetail>();
|
||||||
@@ -35,7 +39,7 @@ const loadPage = async () => {
|
|||||||
recordList.value = recordData.allData;
|
recordList.value = recordData.allData;
|
||||||
};
|
};
|
||||||
|
|
||||||
watchEffect(() => {
|
onMounted(() => {
|
||||||
const localUser = localStorage.getItem('user');
|
const localUser = localStorage.getItem('user');
|
||||||
store.state.user = localUser ? JSON.parse(localUser) : null;
|
store.state.user = localUser ? JSON.parse(localUser) : null;
|
||||||
user = store.state.user;
|
user = store.state.user;
|
||||||
@@ -100,7 +104,7 @@ const handlePlay = () => {
|
|||||||
<div class="uesr-signature">{{ userDetail.profile.signature }}</div>
|
<div class="uesr-signature">{{ userDetail.profile.signature }}</div>
|
||||||
|
|
||||||
<div class="play-list" :class="setAnimationClass('animate__fadeInLeft')">
|
<div class="play-list" :class="setAnimationClass('animate__fadeInLeft')">
|
||||||
<div class="play-list-title">创建的歌单</div>
|
<div class=" ">创建的歌单</div>
|
||||||
<n-scrollbar>
|
<n-scrollbar>
|
||||||
<div v-for="(item, index) in playList" :key="index" class="play-list-item" @click="showPlaylist(item.id)">
|
<div v-for="(item, index) in playList" :key="index" class="play-list-item" @click="showPlaylist(item.id)">
|
||||||
<n-image :src="getImgUrl(item.coverImgUrl, '50y50')" class="play-list-item-img" lazy preview-disabled />
|
<n-image :src="getImgUrl(item.coverImgUrl, '50y50')" class="play-list-item-img" lazy preview-disabled />
|
||||||
@@ -167,10 +171,11 @@ const handlePlay = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.right {
|
.right {
|
||||||
@apply flex-1 ml-4;
|
@apply flex-1 ml-4 overflow-hidden h-full;
|
||||||
.record-list {
|
.record-list {
|
||||||
background-color: #0d0d0d;
|
background-color: #0d0d0d;
|
||||||
@apply rounded-2xl h-full;
|
@apply rounded-2xl;
|
||||||
|
height: calc(100% - 3.75rem);
|
||||||
.record-item {
|
.record-item {
|
||||||
@apply flex items-center px-4;
|
@apply flex items-center px-4;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user