fix: bugs

This commit is contained in:
qier222 2022-06-06 12:56:24 +08:00
parent 0e58bb6e80
commit d09c5fd171
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
6 changed files with 12 additions and 13 deletions

View file

@ -10,7 +10,7 @@ export interface FetchTracksParams {
}
export interface FetchTracksResponse {
code: number
songs: Track[]
songs?: Track[]
privileges: {
[key: string]: unknown
}

View file

@ -93,7 +93,7 @@ export interface FetchPersonalFMResponse {
}
export function fetchPersonalFM(): Promise<FetchPersonalFMResponse> {
return request({
url: '/personal/fm',
url: window.ipcRenderer ? '/personal/fm' : '/personal_fm',
method: 'get',
params: {
timestamp: Date.now(),

View file

@ -79,7 +79,7 @@ const PlayingNext = ({ className }: { className?: string }) => {
</motion.div>
))}
{(tracks?.songs.length || 0) >= 4 && (
{(tracks?.songs?.length || 0) >= 4 && (
<div className='pointer-events-none sticky bottom-0 h-8 w-full bg-gradient-to-t from-black'></div>
)}
</AnimatePresence>

View file

@ -4,8 +4,8 @@ import {
fetchPlaylistWithReactQuery,
fetchFromCache,
} from '@/web/api/hooks/usePlaylist'
import useTracks, { fetchTracksWithReactQuery } from '@/web/api/hooks/useTracks'
import { useEffect, useMemo, useState } from 'react'
import { fetchTracksWithReactQuery } from '@/web/api/hooks/useTracks'
import { useEffect, useState } from 'react'
import { sampleSize } from 'lodash-es'
import { FetchPlaylistResponse } from '@/shared/api/Playlists'
@ -39,7 +39,7 @@ const getAlbumsFromAPI = async () => {
resolve(cache)
return
}
return fetchPlaylistWithReactQuery({ id })
resolve(fetchPlaylistWithReactQuery({ id }))
})
)
)) as FetchPlaylistResponse[]
@ -90,7 +90,7 @@ const Discover = () => {
localStorage.getItem('discoverAlbumsTime')
if (
!albumsInLocalStorageTime ||
Date.now() - Number(albumsInLocalStorageTime) > 1000 * 60 * 60 * 2
Date.now() - Number(albumsInLocalStorageTime) > 1000 * 60 * 60 * 2 // 2小时刷新一次
) {
setAlbums(await getAlbumsFromAPI())
} else {

View file

@ -250,9 +250,7 @@ export class Player {
}
if (this.trackID !== id) return
Howler.unload()
const url = audio.includes('?')
? `${audio}&ypm-id=${id}`
: `${audio}?ypm-id=${id}`
const url = audio.includes('?') ? `${audio}&id=${id}` : `${audio}?id=${id}`
const howler = new Howl({
src: [url],
format: ['mp3', 'flac', 'webm'],
@ -286,8 +284,8 @@ export class Player {
}
private _cacheAudio(audio: string) {
if (audio.includes('yesplaymusic')) return
const id = Number(new URL(audio).searchParams.get('ypm-id'))
if (audio.includes('yesplaymusic') || !window.ipcRenderer) return
const id = Number(new URL(audio).searchParams.get('id'))
if (isNaN(id) || !id) return
cacheAudio(id, audio)
}

View file

@ -6,6 +6,7 @@
{
"source": "/netease/:match*",
"destination": "http://168.138.40.199:12835/:match*"
}
},
{"source": "/(.*)", "destination": "/"}
]
}