@@ -47,19 +47,19 @@ export const formatSongsList = (data: any[]): SongType[] => {
4747 typeof item . album === "string"
4848 ? item . album
4949 : {
50- id : ( item . album || item . al ) ?. id ,
51- name : ( item . album || item . al ) ?. name ,
52- cover : ( item . album || item . al ) ?. picUrl ,
53- } ,
50+ id : ( item . album || item . al ) ?. id ,
51+ name : ( item . album || item . al ) ?. name ,
52+ cover : ( item . album || item . al ) ?. picUrl ,
53+ } ,
5454 alia : isArray ( item . alia || item . alias || item . transNames || item . tns )
5555 ? item . alia ?. [ 0 ] || item . alias ?. [ 0 ] || item . transNames ?. [ 0 ] || item . tns ?. [ 0 ]
5656 : item . alia ,
5757 dj : item . dj
5858 ? {
59- id : item . mainTrackId || item . id ,
60- name : item . dj ?. brand ,
61- creator : item . dj ?. nickname ,
62- }
59+ id : item . mainTrackId || item . id ,
60+ name : item . dj ?. brand ,
61+ creator : item . dj ?. nickname ,
62+ }
6363 : undefined ,
6464 ...getCoverUrl ( item ) ,
6565 duration : Number ( item . duration || item . dt || 0 ) ,
@@ -175,13 +175,13 @@ export const formatCommentList = (data: any[]): CommentType[] => {
175175 beReplied :
176176 item . beReplied ?. length > 0
177177 ? {
178- content : item . beReplied [ 0 ] ?. content ,
179- user : {
180- id : item . beReplied [ 0 ] ?. user . userId ,
181- name : item . beReplied [ 0 ] ?. user . nickname ,
182- avatarUrl : item . beReplied [ 0 ] ?. user . avatarUrl ,
183- } ,
184- }
178+ content : item . beReplied [ 0 ] ?. content ,
179+ user : {
180+ id : item . beReplied [ 0 ] ?. user . userId ,
181+ name : item . beReplied [ 0 ] ?. user . nickname ,
182+ avatarUrl : item . beReplied [ 0 ] ?. user . avatarUrl ,
183+ } ,
184+ }
185185 : undefined ,
186186 time : item . time ,
187187 likedCount : item . likedCount ,
@@ -197,9 +197,9 @@ export const formatCommentList = (data: any[]): CommentType[] => {
197197 } ,
198198 ip : item ?. ip
199199 ? {
200- ip : item . ip ,
201- location : item . location ,
202- }
200+ ip : item . ip ,
201+ location : item . location ,
202+ }
203203 : undefined ,
204204 } ) ) ;
205205} ;
@@ -277,13 +277,14 @@ const getCoverSizeUrl = (url: string, size: number | null = null) => {
277277 * @param lyric 歌词内容
278278 * @returns 语言代码("ja" | "zh-CN" | "en")
279279 */
280- export const getLyricLanguage = ( lyric : string ) : string => {
280+ export const getLyricLanguage = ( lyric : string ) : "ja" | "ko" | "zh-CN" | "en" => {
281+ if ( ! lyric || typeof lyric !== "string" ) return "en" ;
281282 // 判断日语 根据平假名和片假名
282- if ( / [ \u3040 - \u309f \u30a0 - \u30ff ] / . test ( lyric ) ) return "ja" ;
283+ if ( / [ \u3040 - \u309F \u30A0 - \u30FF ] / . test ( lyric ) ) return "ja" ;
283284 // 判断韩语 根据韩文音节
284- if ( / [ \uac00 - \ud7af ] / . test ( lyric ) ) return "ko" ;
285+ if ( / [ \uAC00 - \uD7AF ] / . test ( lyric ) ) return "ko" ;
285286 // 判断简体中文 根据中日韩统一表意文字基本区
286- if ( / [ \u4e00 - \u9fa5 ] / . test ( lyric ) ) return "zh-CN" ;
287+ if ( / [ \u4E00 - \u9FFF ] / . test ( lyric ) ) return "zh-CN" ;
287288 // 默认英语
288289 return "en" ;
289290} ;
0 commit comments