diff --git a/src/renderer/store/songList/action.ts b/src/renderer/store/songList/action.ts index b218a9d7..7181c8ce 100644 --- a/src/renderer/store/songList/action.ts +++ b/src/renderer/store/songList/action.ts @@ -62,7 +62,7 @@ export const setSelectListInfo = (info: ListInfoItem) => { selectListInfo.id = info.id selectListInfo.img = info.img selectListInfo.name = info.name - selectListInfo.play_count = info.play_count + selectListInfo.playCountInfo = info.playCountInfo selectListInfo.source = info.source } export const clearListDetail = () => { diff --git a/src/renderer/store/songList/state.ts b/src/renderer/store/songList/state.ts index 24d2d7d4..4f59943c 100644 --- a/src/renderer/store/songList/state.ts +++ b/src/renderer/store/songList/state.ts @@ -35,10 +35,15 @@ export declare interface TagInfo> +interface PlayCountInfo { + count: number, + language: string +} + export const tags = shallowReactive({}) export declare interface ListInfoItem { - playCountInfo: { count: number, language: string } + playCountInfo: PlayCountInfo id: string author: string name: string @@ -75,7 +80,7 @@ export declare interface ListDetailInfo { img?: string desc?: string author?: string - play_count?: string + playCountInfo?: PlayCountInfo } noItemLabel: string } diff --git a/src/renderer/utils/musicSdk/bd/songList.js b/src/renderer/utils/musicSdk/bd/songList.js index efe3fa03..d4144d65 100644 --- a/src/renderer/utils/musicSdk/bd/songList.js +++ b/src/renderer/utils/musicSdk/bd/songList.js @@ -1,5 +1,5 @@ import { httpFetch } from '../../request' -import { formatPlayTime, toMD5 } from '../../index' +import { formatPlayTime, toMD5, formatPlayCount } from '../../index' import CryptoJS from 'crypto-js' export default { @@ -161,19 +161,9 @@ export default { }) }, - - /** - * 格式化播放数量 - * @param {*} num - */ - formatPlayCount(num) { - if (num > 100000000) return parseInt(num / 10000000) / 10 + '亿' - if (num > 10000) return parseInt(num / 1000) / 10 + '万' - return num - }, filterList(rawData) { return rawData.map(item => ({ - play_count: this.formatPlayCount(item.listen_num), + playCountInfo: formatPlayCount(item.listen_num), id: item.list_id, author: item.username, name: item.title, @@ -206,7 +196,7 @@ export default { img: body.result.info.list_pic, desc: body.result.info.list_desc, author: body.result.info.userinfo.username, - play_count: this.formatPlayCount(body.result.listen_num), + playCountInfo: formatPlayCount(body.result.listen_num), }, } }) diff --git a/src/renderer/utils/musicSdk/kg/album.js b/src/renderer/utils/musicSdk/kg/album.js index 2250c08e..2bf52ebf 100644 --- a/src/renderer/utils/musicSdk/kg/album.js +++ b/src/renderer/utils/musicSdk/kg/album.js @@ -29,7 +29,7 @@ export default { image: albumInfo.sizable_cover.replace('{size}', 240), desc: albumInfo.intro, authorName: albumInfo.author_name, - // play_count: this.formatPlayCount(info.count), + // playCountInfo: this.formatPlayCount(info.count), } }, /** @@ -56,7 +56,7 @@ export default { img: info.image, desc: info.desc, author: info.authorName, - // play_count: this.formatPlayCount(info.count), + // playCountInfo: this.formatPlayCount(info.count), }, } }, diff --git a/src/renderer/utils/musicSdk/kw/album.js b/src/renderer/utils/musicSdk/kw/album.js index 79e641fc..0ccb2802 100644 --- a/src/renderer/utils/musicSdk/kw/album.js +++ b/src/renderer/utils/musicSdk/kw/album.js @@ -96,7 +96,7 @@ export default { img: body.img || body.hts_img, desc: decodeName(body.info), author: decodeName(body.artist), - // play_count: this.formatPlayCount(body.playnum), + // playCountInfo: this.formatPlayCount(body.playnum), }, } }) @@ -122,7 +122,7 @@ export default { // // img: data.pic, // // desc: data.albuminfo, // // author: data.artist, - // // play_count: this.formatPlayCount(data.playCnt), + // // playCountInfo: this.formatPlayCount(data.playCnt), // // }, // // } // })