修复tx歌单无法显示的问题,添加歌单更新时间显示(如果有)
parent
c6087f577d
commit
b3600bef34
|
@ -16,21 +16,45 @@ export const sizeFormate = (size: number): string => {
|
|||
return `${(size / Math.pow(1024, Math.floor(number))).toFixed(2)} ${units[number]}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 将字符串、时间戳等格式转成时间对象
|
||||
* @param date 时间
|
||||
* @returns 时间对象或空字符串
|
||||
*/
|
||||
export const toDateObj = (date: any): Date | '' => {
|
||||
// console.log(date)
|
||||
if (!date) return ''
|
||||
switch (typeof date) {
|
||||
case 'string':
|
||||
if (!date.includes('T')) date = date.split('.')[0].replace(/-/g, '/')
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
case 'number':
|
||||
date = new Date(date)
|
||||
// eslint-disable-next-line no-fallthrough
|
||||
case 'object':
|
||||
break
|
||||
default: return ''
|
||||
}
|
||||
return date
|
||||
}
|
||||
|
||||
const numFix = (n: number): string => n < 10 ? (`0${n}`) : n.toString()
|
||||
/**
|
||||
* 日期格式化
|
||||
* @param {*} date 时间
|
||||
* @param {String} format 时间格式,默认YYYY-MM-DD hh:mm:ss
|
||||
*/
|
||||
export const dateFormat = (date: string | number | Date, format = 'YYYY-MM-DD hh:mm:ss') => {
|
||||
if (typeof date != 'object') date = new Date(date)
|
||||
* 时间格式化
|
||||
* @param _date 时间
|
||||
* @param format Y-M-D h:m:s Y年 M月 D日 h时 m分 s秒
|
||||
*/
|
||||
export const dateFormat = (_date: any, format = 'Y-M-D h:m:s') => {
|
||||
// console.log(date)
|
||||
const date = toDateObj(_date)
|
||||
if (!date) return ''
|
||||
return format
|
||||
.replace('YYYY', date.getFullYear().toString())
|
||||
.replace('MM', numFix(date.getMonth() + 1).toString())
|
||||
.replace('DD', numFix(date.getDate()))
|
||||
.replace('hh', numFix(date.getHours()))
|
||||
.replace('mm', numFix(date.getMinutes()))
|
||||
.replace('ss', numFix(date.getSeconds()))
|
||||
.replace('Y', date.getFullYear().toString())
|
||||
.replace('M', numFix(date.getMonth() + 1))
|
||||
.replace('D', numFix(date.getDate()))
|
||||
.replace('h', numFix(date.getHours()))
|
||||
.replace('m', numFix(date.getMinutes()))
|
||||
.replace('s', numFix(date.getSeconds()))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ export declare interface ListInfoItem {
|
|||
id: string
|
||||
author: string
|
||||
name: string
|
||||
// time: basic.publish_time,
|
||||
time?: string
|
||||
img: string
|
||||
// grade: basic.favorcnt / 10,
|
||||
desc: string | null
|
||||
|
@ -110,7 +110,7 @@ export const selectListInfo = markRaw<ListInfoItem>({
|
|||
id: '',
|
||||
author: '',
|
||||
name: '',
|
||||
// time: basic.publish_time,
|
||||
time: '',
|
||||
img: '',
|
||||
// grade: basic.favorcnt / 10,
|
||||
desc: '',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { httpFetch } from '../../request'
|
||||
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||
import { decodeName, formatPlayTime, sizeFormate, dateFormat } from '../../index'
|
||||
import { toMD5 } from '../utils'
|
||||
import infSign from './vendors/infSign.min'
|
||||
|
||||
|
@ -149,7 +149,7 @@ export default {
|
|||
id: 'id_' + item.specialid,
|
||||
author: item.nickname,
|
||||
name: item.specialname,
|
||||
time: item.publish_time || item.publishtime,
|
||||
time: dateFormat(item.publish_time || item.publishtime, 'Y-M-D'),
|
||||
img: item.img || item.imgurl,
|
||||
total: item.songcount,
|
||||
grade: item.grade,
|
||||
|
@ -739,7 +739,7 @@ export default {
|
|||
id: 'id_' + item.specialid,
|
||||
author: item.nickname,
|
||||
name: item.specialname,
|
||||
time: item.publishtime,
|
||||
time: dateFormat(item.publishtime, 'Y-M-D'),
|
||||
img: item.imgurl,
|
||||
grade: item.grade,
|
||||
desc: item.intro,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
import { httpFetch } from '../../request'
|
||||
import { decodeName, formatPlayTime, sizeFormate } from '../../index'
|
||||
import { decodeName, formatPlayTime, sizeFormate, dateFormat } from '../../index'
|
||||
|
||||
export default {
|
||||
_requestObj_tags: null,
|
||||
|
@ -30,23 +30,25 @@ export default {
|
|||
tagsUrl: 'https://u.y.qq.com/cgi-bin/musicu.fcg?loginUin=0&hostUin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=wk_v15.json&needNewCode=0&data=%7B%22tags%22%3A%7B%22method%22%3A%22get_all_categories%22%2C%22param%22%3A%7B%22qq%22%3A%22%22%7D%2C%22module%22%3A%22playlist.PlaylistAllCategoriesServer%22%7D%7D',
|
||||
hotTagUrl: 'https://c.y.qq.com/node/pc/wk_v15/category_playlist.html',
|
||||
getListUrl(sortId, id, page) {
|
||||
return id
|
||||
? `https://u.y.qq.com/cgi-bin/musicu.fcg?loginUin=0&hostUin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=wk_v15.json&needNewCode=0&data=${encodeURIComponent(JSON.stringify({
|
||||
comm: { cv: 1602, ct: 20 },
|
||||
playlist: {
|
||||
method: 'get_category_content',
|
||||
param: {
|
||||
titleid: id,
|
||||
caller: '0',
|
||||
category_id: id,
|
||||
size: this.limit_list,
|
||||
page: page - 1,
|
||||
use_page: 1,
|
||||
},
|
||||
module: 'playlist.PlayListCategoryServer',
|
||||
if (id) {
|
||||
id = parseInt(id)
|
||||
return `https://u.y.qq.com/cgi-bin/musicu.fcg?loginUin=0&hostUin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=wk_v15.json&needNewCode=0&data=${encodeURIComponent(JSON.stringify({
|
||||
comm: { cv: 1602, ct: 20 },
|
||||
playlist: {
|
||||
method: 'get_category_content',
|
||||
param: {
|
||||
titleid: id,
|
||||
caller: '0',
|
||||
category_id: id,
|
||||
size: this.limit_list,
|
||||
page: page - 1,
|
||||
use_page: 1,
|
||||
},
|
||||
}))}`
|
||||
: `https://u.y.qq.com/cgi-bin/musicu.fcg?loginUin=0&hostUin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=wk_v15.json&needNewCode=0&data=${encodeURIComponent(JSON.stringify({
|
||||
module: 'playlist.PlayListCategoryServer',
|
||||
},
|
||||
}))}`
|
||||
}
|
||||
return `https://u.y.qq.com/cgi-bin/musicu.fcg?loginUin=0&hostUin=0&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=wk_v15.json&needNewCode=0&data=${encodeURIComponent(JSON.stringify({
|
||||
comm: { cv: 1602, ct: 20 },
|
||||
playlist: {
|
||||
method: 'get_playlist_by_tag',
|
||||
|
@ -116,6 +118,7 @@ export default {
|
|||
this._requestObj_list = httpFetch(
|
||||
this.getListUrl(sortId, tagId, page),
|
||||
)
|
||||
console.log(this.getListUrl(sortId, tagId, page))
|
||||
return this._requestObj_list.promise.then(({ body }) => {
|
||||
if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
|
||||
return tagId ? this.filterList2(body.playlist.data, page) : this.filterList(body.playlist.data, page)
|
||||
|
@ -139,7 +142,7 @@ export default {
|
|||
id: item.tid,
|
||||
author: item.creator_info.nick,
|
||||
name: item.title,
|
||||
// time: item.publish_time,
|
||||
time: item.modify_time ? dateFormat(item.modify_time * 1000, 'Y-M-D') : '',
|
||||
img: item.cover_url_medium,
|
||||
// grade: item.favorcnt / 10,
|
||||
total: item.song_ids?.length,
|
||||
|
@ -317,7 +320,7 @@ export default {
|
|||
id: item.dissid,
|
||||
author: item.creator.name,
|
||||
name: item.dissname,
|
||||
time: item.createtime,
|
||||
time: dateFormat(item.createtime, 'Y-M-D'),
|
||||
img: item.imgurl,
|
||||
// grade: item.favorcnt / 10,
|
||||
total: item.song_count,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { weapi, linuxapi } from './utils/crypto'
|
||||
import { httpFetch } from '../../request'
|
||||
import { formatPlayTime, sizeFormate } from '../../index'
|
||||
import { formatPlayTime, sizeFormate, dateFormat } from '../../index'
|
||||
import musicDetailApi from './musicDetail'
|
||||
import { eapiRequest } from './utils/index'
|
||||
|
||||
|
@ -225,7 +225,7 @@ export default {
|
|||
}),
|
||||
})
|
||||
return this._requestObj_list.promise.then(({ body }) => {
|
||||
// console.log(body)
|
||||
console.log(body)
|
||||
if (body.code !== this.successCode) return this.getList(sortId, tagId, page, ++tryNum)
|
||||
return {
|
||||
list: this.filterList(body.playlists),
|
||||
|
@ -243,7 +243,7 @@ export default {
|
|||
id: item.id,
|
||||
author: item.creator.nickname,
|
||||
name: item.name,
|
||||
time: item.createTime,
|
||||
time: item.createTime ? dateFormat(item.createTime, 'Y-M-D') : '',
|
||||
img: item.coverImgUrl,
|
||||
grade: item.grade,
|
||||
total: item.trackCount,
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<h4>{{ item.name }}</h4>
|
||||
<div>
|
||||
<p :class="$style.author">{{ item.author }}</p>
|
||||
<p v-if="item.time" :class="$style.time">{{ item.time }}</p>
|
||||
<div :class="$style.songlist_info">
|
||||
<span v-if="item.total != null"><svg-icon name="music" />{{ item.total }}</span>
|
||||
<span v-if="item.play_count != null"><svg-icon name="headphones" />{{ item.play_count }}</span>
|
||||
|
@ -183,6 +184,15 @@ defineExpose({
|
|||
// text-indent: 24px;
|
||||
color: var(--color-font-label);
|
||||
}
|
||||
.time {
|
||||
margin-top: 3px;
|
||||
font-size: 12px;
|
||||
.mixin-ellipsis-1;
|
||||
text-align: justify;
|
||||
line-height: 1.3;
|
||||
// text-indent: 24px;
|
||||
color: var(--color-font-label);
|
||||
}
|
||||
.pagination {
|
||||
text-align: center;
|
||||
padding: 15px 0;
|
||||
|
|
Loading…
Reference in New Issue