mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: updates
This commit is contained in:
parent
ffcc60b793
commit
dd5361b8c4
106 changed files with 11989 additions and 4143 deletions
|
|
@ -23,8 +23,8 @@ export function resizeImage(
|
|||
lg: '1024',
|
||||
}
|
||||
return `${url}?param=${sizeMap[size]}y${sizeMap[size]}`.replace(
|
||||
'http://',
|
||||
'https://'
|
||||
/http(s?):\/\/p\d.music.126.net/,
|
||||
'https://p1.music.126.net'
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
1
packages/web/utils/const.ts
Normal file
1
packages/web/utils/const.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export const ease: [number, number, number, number] = [0.4, 0, 0.2, 1]
|
||||
|
|
@ -2,17 +2,18 @@ import { Howl, Howler } from 'howler'
|
|||
import {
|
||||
fetchAudioSourceWithReactQuery,
|
||||
fetchTracksWithReactQuery,
|
||||
} from '@/web/hooks/useTracks'
|
||||
import { fetchPersonalFMWithReactQuery } from '@/web/hooks/usePersonalFM'
|
||||
} from '@/web/api/hooks/useTracks'
|
||||
import { fetchPersonalFMWithReactQuery } from '@/web/api/hooks/usePersonalFM'
|
||||
import { fmTrash } from '@/web/api/personalFM'
|
||||
import { cacheAudio } from '@/web/api/yesplaymusic'
|
||||
import { clamp } from 'lodash-es'
|
||||
import axios from 'axios'
|
||||
import { resizeImage } from './common'
|
||||
import { fetchPlaylistWithReactQuery } from '@/web/hooks/usePlaylist'
|
||||
import { fetchAlbumWithReactQuery } from '@/web/hooks/useAlbum'
|
||||
import { fetchPlaylistWithReactQuery } from '@/web/api/hooks/usePlaylist'
|
||||
import { fetchAlbumWithReactQuery } from '@/web/api/hooks/useAlbum'
|
||||
import { IpcChannels } from '@/shared/IpcChannels'
|
||||
import { RepeatMode } from '@/shared/playerDataTypes'
|
||||
import toast from 'react-hot-toast'
|
||||
|
||||
type TrackID = number
|
||||
export enum TrackListSourceType {
|
||||
|
|
@ -128,6 +129,10 @@ export class Player {
|
|||
return this.mode === Mode.FM ? this.fmTrack : this._track
|
||||
}
|
||||
|
||||
get trackIndex() {
|
||||
return this._trackIndex
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/Set progress of current track
|
||||
*/
|
||||
|
|
@ -168,6 +173,11 @@ export class Player {
|
|||
this._loadMoreFMTracks()
|
||||
}
|
||||
|
||||
private setStateToLoading() {
|
||||
this.state = State.Loading
|
||||
_howler.pause()
|
||||
}
|
||||
|
||||
private _setupProgressInterval() {
|
||||
this._progressInterval = setInterval(() => {
|
||||
if (this.state === State.Playing) this._progress = _howler.seek()
|
||||
|
|
@ -346,6 +356,7 @@ export class Player {
|
|||
* Play previous track
|
||||
*/
|
||||
prevTrack() {
|
||||
this.setStateToLoading()
|
||||
this._progress = 0
|
||||
if (this.mode === Mode.FM) {
|
||||
toast('Personal FM not support previous track')
|
||||
|
|
@ -363,6 +374,7 @@ export class Player {
|
|||
* Play next track
|
||||
*/
|
||||
nextTrack(forceFM: boolean = false) {
|
||||
this.setStateToLoading()
|
||||
this._progress = 0
|
||||
if (forceFM || this.mode === Mode.FM) {
|
||||
this.mode = Mode.FM
|
||||
|
|
@ -384,6 +396,7 @@ export class Player {
|
|||
* @param {null|number} autoPlayTrackID
|
||||
*/
|
||||
playAList(list: TrackID[], autoPlayTrackID?: null | number) {
|
||||
this.setStateToLoading()
|
||||
this.mode = Mode.TrackList
|
||||
this.trackList = list
|
||||
this._trackIndex = autoPlayTrackID
|
||||
|
|
@ -398,6 +411,7 @@ export class Player {
|
|||
* @param {null|number=} autoPlayTrackID
|
||||
*/
|
||||
async playPlaylist(playlistID: number, autoPlayTrackID?: null | number) {
|
||||
this.setStateToLoading()
|
||||
const playlist = await fetchPlaylistWithReactQuery({ id: playlistID })
|
||||
if (!playlist?.playlist?.trackIds?.length) return
|
||||
this.trackListSource = {
|
||||
|
|
@ -416,6 +430,7 @@ export class Player {
|
|||
* @param {null|number=} autoPlayTrackID
|
||||
*/
|
||||
async playAlbum(albumID: number, autoPlayTrackID?: null | number) {
|
||||
this.setStateToLoading()
|
||||
const album = await fetchAlbumWithReactQuery({ id: albumID })
|
||||
if (!album?.songs?.length) return
|
||||
this.trackListSource = {
|
||||
|
|
@ -433,6 +448,7 @@ export class Player {
|
|||
* Play personal fm
|
||||
*/
|
||||
async playFM() {
|
||||
this.setStateToLoading()
|
||||
this.mode = Mode.FM
|
||||
if (
|
||||
this.fmTrackList.length > 0 &&
|
||||
|
|
@ -459,6 +475,7 @@ export class Player {
|
|||
* Play track in trackList by id
|
||||
*/
|
||||
async playTrack(trackID: TrackID) {
|
||||
this.setStateToLoading()
|
||||
const index = this.trackList.findIndex(t => t === trackID)
|
||||
if (!index) toast('播放失败,歌曲不在列表内')
|
||||
this._trackIndex = index
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue