diff --git a/components.d.ts b/components.d.ts
index 216d078..d60b6d3 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -38,7 +38,6 @@ declare module '@vue/runtime-core' {
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']
- ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTransfer: typeof import('element-plus/es')['ElTransfer']
ElTree: typeof import('element-plus/es')['ElTree']
ElUpload: typeof import('element-plus/es')['ElUpload']
diff --git a/src/model/api/music.ts b/src/model/api/music.ts
index df48824..1bd1e74 100644
--- a/src/model/api/music.ts
+++ b/src/model/api/music.ts
@@ -28,8 +28,8 @@ export interface MusicLyricModel {
export interface MusicPlayerItem {
id: number
title: string
- artist: string | undefined
- album?: string | undefined
+ artist?: string
+ album?: string
src: string
pic: string
lrc?: string
diff --git a/src/views/api/Music.vue b/src/views/api/Music.vue
index 78e3a16..e2db1c0 100644
--- a/src/views/api/Music.vue
+++ b/src/views/api/Music.vue
@@ -142,7 +142,7 @@
-
+
@@ -221,6 +221,7 @@ export default class Music extends BaseList {
id: index,
title: item.title || item.name,
artist: item.artist,
+ album: item.album,
src: `/api/v2/common/music/load/${item._id}`,
pic: `/api/v2/common/music/album/${item._id}`,
}
@@ -310,33 +311,31 @@ export default class Music extends BaseList {
musicPlay() {
if(!('mediaSession' in window.navigator) || !this.currentMusic) return;
const player = this.$refs.player
- const mediaSession: any = navigator.mediaSession
const currentId = this.currentMusic.id
- mediaSession.metadata = new MediaMetadata({
+ navigator.mediaSession.metadata = new MediaMetadata({
title: this.currentMusic.title,
artist: this.currentMusic.artist,
album: this.currentMusic.album,
- artwork: [{src: this.currentMusic.pic}]
+ artwork: [{src: location.origin + this.currentMusic.pic}]
})
- const currentIndex = this.musicList.findIndex(item => item.id === currentId)
- mediaSession.setActionHandler('play', () => { // 播放
+ navigator.mediaSession.setActionHandler('play', () => { // 播放
player.play()
})
- mediaSession.setActionHandler('pause', () => { // 暂停
+ navigator.mediaSession.setActionHandler('pause', () => { // 暂停
player.pause()
})
- mediaSession.setActionHandler('previoustrack', () => { // 上一首
- if (currentIndex === 0) { // 已经是第一首
+ navigator.mediaSession.setActionHandler('previoustrack', () => { // 上一首
+ if (currentId === 0) { // 已经是第一首
player.switch(this.musicList.length - 1)
} else {
- player.switch(currentIndex - 1)
+ player.switch(currentId - 1)
}
})
- mediaSession.setActionHandler('nexttrack', () => { // 下一首
- if (currentIndex === this.musicList.length - 1) { // 已经是最后一首
+ navigator.mediaSession.setActionHandler('nexttrack', () => { // 下一首
+ if (currentId === this.musicList.length - 1) { // 已经是最后一首
player.switch(0)
} else {
- player.switch(currentIndex + 1)
+ player.switch(currentId + 1)
}
})
}
diff --git a/src/views/api/aplayer/utils.ts b/src/views/api/aplayer/utils.ts
index fdb6c78..e17358e 100644
--- a/src/views/api/aplayer/utils.ts
+++ b/src/views/api/aplayer/utils.ts
@@ -1,6 +1,6 @@
/**
* Parse lrc, suppose multiple time tag
- * @param {string} lrc_s - Format:
+ * @param {string} lrcRaw - Format:
* [mm:ss]lyric
* [mm:ss.xx]lyric
* [mm:ss.xxx]lyric
@@ -9,10 +9,10 @@
*
* @return {Array} [[time, text], [time, text], [time, text], ...]
*/
-export function parseLrc (lrc_s: string): Array<[number, string]> {
- if (!lrc_s) return []
- lrc_s = lrc_s.replace(/([^\]^\n])\[/g, (match, p1) => p1 + '\n[')
- const lyric = lrc_s.split('\n')
+export function parseLrc (lrcRaw: string): Array<[number, string]> {
+ if (!lrcRaw) return []
+ lrcRaw = lrcRaw.replace(/([^\]^\n])\[/g, (match, p1) => p1 + '\n[')
+ const lyric = lrcRaw.split('\n')
const lrc: Array<[number, string]> = []
const lyricLen = lyric.length
for (let i = 0; i < lyricLen; i++) {
@@ -36,8 +36,7 @@ export function parseLrc (lrc_s: string): Array<[number, string]> {
}
}
// sort by time
- lrc.sort((item1, item2) => item1[0] - item2[0])
- return lrc
+ return lrc.sort((item1, item2) => item1[0] - item2[0])
}
export function warn (message: string) {
diff --git a/src/views/api/aplayer/vue-aplayer.vue b/src/views/api/aplayer/vue-aplayer.vue
index bc9e3b4..37347b1 100644
--- a/src/views/api/aplayer/vue-aplayer.vue
+++ b/src/views/api/aplayer/vue-aplayer.vue
@@ -190,7 +190,7 @@
*/
volume: {
type: Number,
- default: 0.8,
+ default: 0.5,
validator (value) {
return value >= 0 && value <= 1
},