From c37ad07f9398792f5a406becb2b64543da2eeb93 Mon Sep 17 00:00:00 2001 From: alger Date: Tue, 21 May 2024 11:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20style:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 2 +- src/components/PlaylistType.vue | 2 +- src/components/common/SongItem.vue | 2 +- src/hooks/MusicHistoryHook.ts | 2 +- src/hooks/MusicHook.ts | 8 ++++---- src/layout/components/AppMenu.vue | 2 +- src/layout/components/PlayBar.vue | 2 +- src/utils/index.ts | 4 ++-- src/views/list/index.vue | 6 +++--- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/api/login.ts b/src/api/login.ts index d4c09de..16f775d 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -38,7 +38,7 @@ export function logout() { // 手机号登录 // /login/cellphone -export function loginByCellphone(phone: any, password: any) { +export function loginByCellphone(phone: string, password: string) { return request.post('/login/cellphone', { phone, password, diff --git a/src/components/PlaylistType.vue b/src/components/PlaylistType.vue index d01cefe..97059f7 100644 --- a/src/components/PlaylistType.vue +++ b/src/components/PlaylistType.vue @@ -44,7 +44,7 @@ const loadPlaylistCategory = async () => { }; const router = useRouter(); -const handleClickPlaylistType = (type: any) => { +const handleClickPlaylistType = (type: string) => { router.push({ path: '/list', query: { diff --git a/src/components/common/SongItem.vue b/src/components/common/SongItem.vue index 7ac07f5..c77ad77 100644 --- a/src/components/common/SongItem.vue +++ b/src/components/common/SongItem.vue @@ -61,7 +61,7 @@ const isPlaying = computed(() => { const emits = defineEmits(['play']); // 播放音乐 设置音乐详情 打开音乐底栏 -const playMusicEvent = async (item: any) => { +const playMusicEvent = async (item: SongResult) => { if (playMusic.value.id === item.id) { return; } diff --git a/src/hooks/MusicHistoryHook.ts b/src/hooks/MusicHistoryHook.ts index 8e81067..3572284 100644 --- a/src/hooks/MusicHistoryHook.ts +++ b/src/hooks/MusicHistoryHook.ts @@ -16,7 +16,7 @@ export const useMusicHistory = () => { } }; - const delMusic = (music: any) => { + const delMusic = (music: SongResult) => { const index = musicHistory.value.findIndex((item) => item.id === music.id); if (index !== -1) { musicHistory.value.splice(index, 1); diff --git a/src/hooks/MusicHook.ts b/src/hooks/MusicHook.ts index 5cc4f99..f8311c5 100644 --- a/src/hooks/MusicHook.ts +++ b/src/hooks/MusicHook.ts @@ -82,7 +82,7 @@ export const reduceCorrectionTime = (time: number) => { correctionTime.value -= time; }; -export const isCurrentLrc = (index: any, time: number) => { +export const isCurrentLrc = (index: number, time: number) => { const currentTime = Number(lrcTimeArray.value[index]); const nextTime = Number(lrcTimeArray.value[index + 1]); const nowTime = time + correctionTime.value; @@ -108,13 +108,13 @@ export const getLrcIndex = (time: number) => { }; // 设置当前播放时间 -export const setAudioTime = (index: any, audio: HTMLAudioElement) => { +export const setAudioTime = (index: number, audio: HTMLAudioElement) => { audio.currentTime = lrcTimeArray.value[index] as number; audio.play(); }; // 计算这个歌词的播放时间 -const getLrcTime = (index: any) => { +const getLrcTime = (index: number) => { return Number(lrcTimeArray.value[index]); }; @@ -127,7 +127,7 @@ export const getCurrentLrc = () => { }; // 获取一句歌词播放时间是 几秒到几秒 -export const getLrcTimeRange = (index: any) => { +export const getLrcTimeRange = (index: number) => { const currentTime = Number(lrcTimeArray.value[index]); const nextTime = Number(lrcTimeArray.value[index + 1]); return { currentTime, nextTime }; diff --git a/src/layout/components/AppMenu.vue b/src/layout/components/AppMenu.vue index 89cbaf2..cb95e63 100644 --- a/src/layout/components/AppMenu.vue +++ b/src/layout/components/AppMenu.vue @@ -54,7 +54,7 @@ watch( }, ); -const iconStyle = (index: any) => { +const iconStyle = (index: number) => { const style = { fontSize: props.size, color: path.value === props.menus[index].path ? props.selectColor : props.color, diff --git a/src/layout/components/PlayBar.vue b/src/layout/components/PlayBar.vue index b532902..f68c163 100644 --- a/src/layout/components/PlayBar.vue +++ b/src/layout/components/PlayBar.vue @@ -184,7 +184,7 @@ function handlePrev() { const MusicFullRef = ref(null); -function handleGetAudioTime(this: any) { +function handleGetAudioTime(this: HTMLAudioElement) { // 监听音频播放的实时时间事件 const audio = this as HTMLAudioElement; // 获取当前播放时间 diff --git a/src/utils/index.ts b/src/utils/index.ts index 8e94002..6708a9c 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -24,8 +24,8 @@ export const secondToMinute = (s: number) => { }; // 格式化数字 千,万, 百万, 千万,亿 -export const formatNumber = (num: any) => { - num *= 1; +export const formatNumber = (num: string | number) => { + num = Number(num); if (num < 10000) { return num; } diff --git a/src/views/list/index.vue b/src/views/list/index.vue index ea56f14..2c36675 100644 --- a/src/views/list/index.vue +++ b/src/views/list/index.vue @@ -23,7 +23,7 @@ const selectRecommendItem = async (item: IRecommendItem) => { const route = useRoute(); const listTitle = ref(route.query.type || '歌单列表'); -const loadList = async (type: any) => { +const loadList = async (type: string) => { const params = { cat: type || '', limit: 30, @@ -34,7 +34,7 @@ const loadList = async (type: any) => { }; if (route.query.type) { - loadList(route.query.type); + loadList(route.query.type as string); } else { getRecommendList().then((res: { data: { result: any } }) => { recommendList.value = res.data.result; @@ -45,7 +45,7 @@ watch( () => route.query, async (newParams) => { if (newParams.type) { - loadList(newParams.type); + loadList(newParams.type as string); } }, );