mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-16 13:17:46 +00:00
fix: bugs (#1464)
* fix: nextFMTrack 执行顺序 * fix: 当前歌曲无法播放时,播放下一首 * fix: windows下无法创建部分文件 * fix: windows下无法加载sqlite3
This commit is contained in:
parent
530581ba82
commit
24798a0bf3
4 changed files with 13 additions and 5 deletions
|
|
@ -10,7 +10,7 @@
|
||||||
"repository": "github:qier222/YesPlayMusic",
|
"repository": "github:qier222/YesPlayMusic",
|
||||||
"main": "dist/main/index.js",
|
"main": "dist/main/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "node scripts/build.sqlite3.mjs",
|
"install": "node scripts/build.sqlite3.mjs --x64",
|
||||||
"dev": "concurrently -n=vite,main -c=#646cff,#74b1be \"npm run dev:renderer\" \"node scripts/build.main.mjs --watch\"",
|
"dev": "concurrently -n=vite,main -c=#646cff,#74b1be \"npm run dev:renderer\" \"node scripts/build.main.mjs --watch\"",
|
||||||
"dev:renderer": "vite dev",
|
"dev:renderer": "vite dev",
|
||||||
"build:main": "node scripts/build.main.mjs",
|
"build:main": "node scripts/build.main.mjs",
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@ const build = async arch => {
|
||||||
'./node_modules/better-sqlite3/build/Release/better_sqlite3.node',
|
'./node_modules/better-sqlite3/build/Release/better_sqlite3.node',
|
||||||
`./dist/main/better_sqlite3_${arch}.node`
|
`./dist/main/better_sqlite3_${arch}.node`
|
||||||
)
|
)
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
fs.copyFileSync(
|
||||||
|
'./node_modules/better-sqlite3/build/Release/sqlite3.dll',
|
||||||
|
'./dist/main/sqlite3.dll'
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.error(pc.red('Rebuild failed!'))
|
console.error(pc.red('Rebuild failed!'))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
|
import path from 'path'
|
||||||
|
|
||||||
export const createDirIfNotExist = (dir: string) => {
|
export const createDirIfNotExist = (dir: string) => {
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
|
|
@ -7,7 +8,7 @@ export const createDirIfNotExist = (dir: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createFileIfNotExist = (file: string) => {
|
export const createFileIfNotExist = (file: string) => {
|
||||||
createDirIfNotExist(file.split('/').slice(0, -1).join('/'))
|
createDirIfNotExist(path.dirname(file))
|
||||||
if (!fs.existsSync(file)) {
|
if (!fs.existsSync(file)) {
|
||||||
fs.writeFileSync(file, '')
|
fs.writeFileSync(file, '')
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ export class Player {
|
||||||
*/
|
*/
|
||||||
private async _fetchTrack(trackID: TrackID) {
|
private async _fetchTrack(trackID: TrackID) {
|
||||||
const response = await fetchTracksWithReactQuery({ ids: [trackID] })
|
const response = await fetchTracksWithReactQuery({ ids: [trackID] })
|
||||||
return response?.songs.length ? response.songs[0] : null
|
return response?.songs?.length ? response.songs[0] : null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -211,6 +211,7 @@ export class Player {
|
||||||
const { audio, id } = await this._fetchAudioSource(this.trackID)
|
const { audio, id } = await this._fetchAudioSource(this.trackID)
|
||||||
if (!audio) {
|
if (!audio) {
|
||||||
toast('无法播放此歌曲')
|
toast('无法播放此歌曲')
|
||||||
|
this.nextTrack()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.trackID !== id) return
|
if (this.trackID !== id) return
|
||||||
|
|
@ -269,11 +270,11 @@ export class Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fmTrackList.length === 0) await loadMoreTracks()
|
|
||||||
this.fmTrackList.shift()
|
this.fmTrackList.shift()
|
||||||
|
if (this.fmTrackList.length === 0) await loadMoreTracks()
|
||||||
this._playTrack()
|
this._playTrack()
|
||||||
|
|
||||||
this.fmTrackList.length === 0 ? await loadMoreTracks() : loadMoreTracks()
|
this.fmTrackList.length <= 1 ? await loadMoreTracks() : loadMoreTracks()
|
||||||
prefetchNextTrack()
|
prefetchNextTrack()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue