音乐封面获取

This commit is contained in:
灌糖包子 2022-02-09 02:14:26 +08:00
parent d4c499827f
commit 90a0589741
4 changed files with 15 additions and 19 deletions

View File

@ -26,11 +26,11 @@ export interface MusicLyricModel {
}
export interface MusicPlayerItem {
id: number
id?: number
name: string
artist: string
album: string
artist: string | undefined
album: string | undefined
url: string
cover: string
lrc: string | undefined
lrc?: string
}

View File

@ -7,11 +7,3 @@ export interface SourceImageModel {
img: ArrayBuffer // 图片二进制数据
created_at: Date
}
/**
*
*/
export interface ImageLabel {
name: string // 标签名称
color: string // 标签颜色
}

View File

@ -212,13 +212,17 @@ export default class Music extends BaseList<MusicPage> {
try {
const data = await this.$http.get<any, any>('/api/v1/music/list/all', {params: selectedIds.length ? {ids: selectedIds} : this.search})
this.musicList = data.map((item: MusicModel) => {
return {
const musicItem: MusicPlayerItem = {
name: item.title || item.name,
artist: item.artist,
url: `/api/v2/getMusic/${item._id}`,
cover: `/api/v1/common/music/album/${item._id}`,
lrc: item.lyric_id ? `/api/v1/common/music/lyric/${item.lyric_id}` : undefined
album: item.album,
url: `/api/v2/common/music/load/${item._id}`,
cover: `/api/v2/common/music/album/${item._id}`,
}
if(item.lyric_id) {
musicItem.lrc = `/api/v1/common/music/lyric/${item.lyric_id}`
}
return musicItem
})
// ( )
this.musicPlaying = true

View File

@ -79,7 +79,7 @@ import { ElButton, ElTable, ElTableColumn, ElPagination, ElAlert, ElUpload, ElTa
import prettyBytes from 'pretty-bytes'
import { MsgResult, Page } from '../../model/common.dto'
import BaseList from '../../model/baselist'
import { SourceImageModel, ImageLabel } from '../../model/api/source-image'
import { SourceImageModel } from '../../model/api/source-image'
import { h } from 'vue'
let selectedData: string[] = []
@ -93,7 +93,7 @@ export default class SourceImage extends BaseList<Page> {
allowUploadExt = ['jpg','jpeg','png','svg','ico']
sourceImageData: SourceImageModel[] = []
curModifyLabels: string[] = []
labelList: ImageLabel[] = []
labelList: string[] = []
curId: string | null = null
modifyModal: boolean = false
isUploading: boolean = false
@ -102,7 +102,7 @@ export default class SourceImage extends BaseList<Page> {
}
get labels() {
return this.labelList.map(item => {
return { key: item.name, label: item.name }
return { key: item, label: item }
})
}
async loadData(): Promise<void> {