@@ -15,14 +15,15 @@ import { likeSong } from "@/api/song";
1515import { formatCoverList , formatArtistsList , formatSongsList } from "@/utils/format" ;
1616import { useDataStore , useMusicStore } from "@/stores" ;
1717import { logout , refreshLogin } from "@/api/login" ;
18- import { debounce , isFunction } from "lodash-es" ;
18+ import { debounce , isFunction , type DebouncedFunc } from "lodash-es" ;
1919import { isBeforeSixAM } from "./time" ;
2020import { dailyRecommend } from "@/api/rec" ;
2121import { isElectron } from "./env" ;
2222import { likePlaylist , playlistTracks } from "@/api/playlist" ;
2323import { likeArtist } from "@/api/artist" ;
2424import { likeAlbum } from "@/api/album" ;
2525import { radioSub } from "@/api/radio" ;
26+ import router from "@/router" ;
2627
2728/**
2829 * 用户是否登录
@@ -34,10 +35,8 @@ export const isLogin = (): 0 | 1 | 2 => {
3435 if ( dataStore . loginType === "uid" ) return 2 ;
3536 return getCookie ( "MUSIC_U" ) ? 1 : 0 ;
3637} ;
37-
3838// 退出登录
39- export const toLogout = async ( ) => {
40- const router = useRouter ( ) ;
39+ export const toLogout = async ( ) : Promise < void > => {
4140 const dataStore = useDataStore ( ) ;
4241 await logout ( ) ;
4342 // 去除 cookie
@@ -192,8 +191,8 @@ export const updateUserLikeMvs = async () => {
192191} ;
193192
194193// 喜欢歌曲
195- export const toLikeSong = debounce (
196- async ( song : SongType , like : boolean ) => {
194+ export const toLikeSong : DebouncedFunc < ( song : SongType , like : boolean ) => Promise < void > > = debounce (
195+ async ( song : SongType , like : boolean ) : Promise < void > => {
197196 try {
198197 if ( ! isLogin ( ) ) {
199198 window . $message . warning ( "请登录后使用" ) ;
@@ -239,9 +238,9 @@ const toLikeSomething = (
239238 thingName : string ,
240239 request : ( ) => ( id : number , t : 1 | 2 ) => Promise < { code : number } > ,
241240 update : ( ) => Promise < void > ,
242- ) =>
241+ ) : DebouncedFunc < ( id : number , like : boolean ) => Promise < void > > =>
243242 debounce (
244- async ( id : number , like : boolean ) => {
243+ async ( id : number , like : boolean ) : Promise < void > => {
245244 // 错误情况
246245 if ( ! id ) return ;
247246 if ( ! isLogin ( ) ) {
0 commit comments