修复 tx 歌单搜索名字、描述出现乱码的问题(#2250)

pull/2266/head
lyswhut 2025-02-04 23:20:51 +08:00
parent 68b32a20a4
commit 3ac6d0ff5f
6 changed files with 12 additions and 19 deletions

View File

@ -1,3 +1,4 @@
### 修复
- 修复 Windows 下桌面歌词最小高度设置问题(#2244
- 修复 tx 歌单搜索名字、描述出现乱码的问题(#2250

View File

@ -71,19 +71,6 @@ export const formatPlayTime2 = (time: number) => {
}
const encodeNames = {
' ': ' ',
'&': '&',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
'&apos;': "'",
'&#039;': "'",
} as const
export const decodeName = (str: string | null = '') => {
return str?.replace(/(?:&amp;|&lt;|&gt;|&quot;|&apos;|&#039;|&nbsp;)/gm, (s: string) => encodeNames[s as keyof typeof encodeNames]) ?? ''
}
export const isUrl = (path: string) => /https?:\/\//.test(path)
// 解析URL参数为对象

View File

@ -1,6 +1,6 @@
import { markRaw } from '@common/utils/vueTools'
import { useRouter } from '@common/utils/vueRouter'
import { decodeName } from '@common/utils/common'
import { decodeName } from '@renderer/utils'
// import { allList, defaultList, loveList, userLists } from '@renderer/store/list'
import { playMusicInfo, isShowPlayerDetail } from '@renderer/store/player/state'
import { setShowPlayerDetail, addTempPlayList } from '@renderer/store/player/action'

View File

@ -75,3 +75,8 @@ export const deduplicationList = <T extends LX.Music.MusicInfo>(list: T[]): T[]
export const langS2T = async(str: string) => {
return window.lx.worker.main.langS2t(Buffer.from(str).toString('base64')).then(b64 => Buffer.from(b64, 'base64').toString())
}
export const decodeName = (str: string | null = '') => {
if (!str) return ''
return new window.DOMParser().parseFromString(str, 'text/html').body.textContent
}

View File

@ -137,7 +137,7 @@ export default {
img: item.cover_url_medium,
// grade: item.favorcnt / 10,
total: item.song_ids?.length,
desc: item.desc,
desc: decodeName(item.desc).replace(/<br>/g, '\n'),
source: 'tx',
})),
total: data.total,
@ -305,13 +305,13 @@ export default {
return {
play_count: formatPlayCount(item.listennum),
id: String(item.dissid),
author: item.creator.name,
name: item.dissname,
author: decodeName(item.creator.name),
name: decodeName(item.dissname),
time: dateFormat(item.createtime, 'Y-M-D'),
img: item.imgurl,
// grade: item.favorcnt / 10,
total: item.song_count,
desc: item.introduction,
desc: decodeName(decodeName(item.introduction)).replace(/<br>/g, '\n'),
source: 'tx',
}
}),

View File

@ -1,6 +1,6 @@
import crypto from 'crypto'
import dns from 'dns'
import { decodeName } from '@common/utils/common'
import { decodeName } from '@renderer/utils'
export const toMD5 = str => crypto.createHash('md5').update(str).digest('hex')