mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
fix: bugs
This commit is contained in:
parent
0e58bb6e80
commit
d09c5fd171
6 changed files with 12 additions and 13 deletions
|
|
@ -10,7 +10,7 @@ export interface FetchTracksParams {
|
||||||
}
|
}
|
||||||
export interface FetchTracksResponse {
|
export interface FetchTracksResponse {
|
||||||
code: number
|
code: number
|
||||||
songs: Track[]
|
songs?: Track[]
|
||||||
privileges: {
|
privileges: {
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ export interface FetchPersonalFMResponse {
|
||||||
}
|
}
|
||||||
export function fetchPersonalFM(): Promise<FetchPersonalFMResponse> {
|
export function fetchPersonalFM(): Promise<FetchPersonalFMResponse> {
|
||||||
return request({
|
return request({
|
||||||
url: '/personal/fm',
|
url: window.ipcRenderer ? '/personal/fm' : '/personal_fm',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ const PlayingNext = ({ className }: { className?: string }) => {
|
||||||
</motion.div>
|
</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>
|
<div className='pointer-events-none sticky bottom-0 h-8 w-full bg-gradient-to-t from-black'></div>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ import {
|
||||||
fetchPlaylistWithReactQuery,
|
fetchPlaylistWithReactQuery,
|
||||||
fetchFromCache,
|
fetchFromCache,
|
||||||
} from '@/web/api/hooks/usePlaylist'
|
} from '@/web/api/hooks/usePlaylist'
|
||||||
import useTracks, { fetchTracksWithReactQuery } from '@/web/api/hooks/useTracks'
|
import { fetchTracksWithReactQuery } from '@/web/api/hooks/useTracks'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { sampleSize } from 'lodash-es'
|
import { sampleSize } from 'lodash-es'
|
||||||
import { FetchPlaylistResponse } from '@/shared/api/Playlists'
|
import { FetchPlaylistResponse } from '@/shared/api/Playlists'
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ const getAlbumsFromAPI = async () => {
|
||||||
resolve(cache)
|
resolve(cache)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return fetchPlaylistWithReactQuery({ id })
|
resolve(fetchPlaylistWithReactQuery({ id }))
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)) as FetchPlaylistResponse[]
|
)) as FetchPlaylistResponse[]
|
||||||
|
|
@ -90,7 +90,7 @@ const Discover = () => {
|
||||||
localStorage.getItem('discoverAlbumsTime')
|
localStorage.getItem('discoverAlbumsTime')
|
||||||
if (
|
if (
|
||||||
!albumsInLocalStorageTime ||
|
!albumsInLocalStorageTime ||
|
||||||
Date.now() - Number(albumsInLocalStorageTime) > 1000 * 60 * 60 * 2
|
Date.now() - Number(albumsInLocalStorageTime) > 1000 * 60 * 60 * 2 // 2小时刷新一次
|
||||||
) {
|
) {
|
||||||
setAlbums(await getAlbumsFromAPI())
|
setAlbums(await getAlbumsFromAPI())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -250,9 +250,7 @@ export class Player {
|
||||||
}
|
}
|
||||||
if (this.trackID !== id) return
|
if (this.trackID !== id) return
|
||||||
Howler.unload()
|
Howler.unload()
|
||||||
const url = audio.includes('?')
|
const url = audio.includes('?') ? `${audio}&id=${id}` : `${audio}?id=${id}`
|
||||||
? `${audio}&ypm-id=${id}`
|
|
||||||
: `${audio}?ypm-id=${id}`
|
|
||||||
const howler = new Howl({
|
const howler = new Howl({
|
||||||
src: [url],
|
src: [url],
|
||||||
format: ['mp3', 'flac', 'webm'],
|
format: ['mp3', 'flac', 'webm'],
|
||||||
|
|
@ -286,8 +284,8 @@ export class Player {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _cacheAudio(audio: string) {
|
private _cacheAudio(audio: string) {
|
||||||
if (audio.includes('yesplaymusic')) return
|
if (audio.includes('yesplaymusic') || !window.ipcRenderer) return
|
||||||
const id = Number(new URL(audio).searchParams.get('ypm-id'))
|
const id = Number(new URL(audio).searchParams.get('id'))
|
||||||
if (isNaN(id) || !id) return
|
if (isNaN(id) || !id) return
|
||||||
cacheAudio(id, audio)
|
cacheAudio(id, audio)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
{
|
{
|
||||||
"source": "/netease/:match*",
|
"source": "/netease/:match*",
|
||||||
"destination": "http://168.138.40.199:12835/:match*"
|
"destination": "http://168.138.40.199:12835/:match*"
|
||||||
}
|
},
|
||||||
|
{"source": "/(.*)", "destination": "/"}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue