完善同步
This commit is contained in:
@@ -69,16 +69,16 @@ export const buildLyricInfo = async(lyricInfo: MakeOptional<LX.Player.LyricInfo,
|
||||
|
||||
if (appSetting['player.isS2t']) {
|
||||
const tasks = [
|
||||
lyricInfo.lyric ? window.lx.worker.main.langS2t(lyricInfo.lyric) : Promise.resolve(''),
|
||||
lyricInfo.lyric ? langS2T(lyricInfo.lyric) : Promise.resolve(''),
|
||||
lyricInfo.tlyric ? langS2T(lyricInfo.tlyric) : Promise.resolve(''),
|
||||
lyricInfo.rlyric ? langS2T(lyricInfo.rlyric) : Promise.resolve(''),
|
||||
lyricInfo.lxlyric ? langS2T(lyricInfo.lxlyric) : Promise.resolve(''),
|
||||
]
|
||||
if (lyricInfo.rawlrcInfo) {
|
||||
tasks.push(lyricInfo.lyric ? window.lx.worker.main.langS2t(lyricInfo.lyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.tlyric ? window.lx.worker.main.langS2t(lyricInfo.tlyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.rlyric ? window.lx.worker.main.langS2t(lyricInfo.rlyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.lxlyric ? window.lx.worker.main.langS2t(lyricInfo.lxlyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.lyric ? langS2T(lyricInfo.lyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.tlyric ? langS2T(lyricInfo.tlyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.rlyric ? langS2T(lyricInfo.rlyric) : Promise.resolve(''))
|
||||
tasks.push(lyricInfo.lxlyric ? langS2T(lyricInfo.lxlyric) : Promise.resolve(''))
|
||||
}
|
||||
return await Promise.all(tasks).then(([lyric, tlyric, rlyric, lxlyric, lyric_raw, tlyric_raw, rlyric_raw, lxlyric_raw]) => {
|
||||
const rawlrcInfo = lyric_raw ? {
|
||||
|
||||
@@ -202,6 +202,17 @@ export const listMusicOverwrite = (listId: string, musicInfos: LX.Music.MusicInf
|
||||
return isExist || listId == loveList.id ? [listId] : []
|
||||
}
|
||||
|
||||
export const listMusicClear = (ids: string[]): string[] => {
|
||||
const changedIds: string[] = []
|
||||
for (const id of ids) {
|
||||
const list = allMusicList.get(id)
|
||||
if (!list?.length) continue
|
||||
overwriteMusicList(id, [])
|
||||
changedIds.push(id)
|
||||
}
|
||||
return changedIds
|
||||
}
|
||||
|
||||
export const listMusicAdd = (id: string, musicInfos: LX.Music.MusicInfo[], addMusicLocationType: LX.AddMusicLocationType): string[] => {
|
||||
const targetList = allMusicList.get(id)
|
||||
if (!targetList) return id == loveList.id ? [id] : []
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
listMusicUpdatePosition,
|
||||
setMusicList,
|
||||
setUserLists,
|
||||
listMusicClear,
|
||||
} from './action'
|
||||
import { allMusicList } from './state'
|
||||
|
||||
@@ -122,10 +123,10 @@ export const overwriteListMusics = async(data: LX.List.ListActionMusicOverwrite)
|
||||
|
||||
/**
|
||||
* 清空列表内的歌曲
|
||||
* @param listId
|
||||
* @param ids
|
||||
*/
|
||||
export const clearListMusics = async(listId: LX.List.ListActionMusicClear) => {
|
||||
await rendererInvoke<LX.List.ListActionMusicClear>(PLAYER_EVENT_NAME.list_music_clear, listId)
|
||||
export const clearListMusics = async(ids: LX.List.ListActionMusicClear) => {
|
||||
await rendererInvoke<LX.List.ListActionMusicClear>(PLAYER_EVENT_NAME.list_music_clear, ids)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,6 +219,10 @@ export const registerListAction = (appSetting: LX.AppSetting, onListChanged: (li
|
||||
const updatedListIds = listMusicOverwrite(listId, musicInfos)
|
||||
if (updatedListIds.length) onListChanged(updatedListIds)
|
||||
}
|
||||
const list_music_clear = ({ params: ids }: LX.IpcRendererEventParams<LX.List.ListActionMusicClear>) => {
|
||||
const updatedListIds = listMusicClear(ids)
|
||||
if (updatedListIds.length) onListChanged(updatedListIds)
|
||||
}
|
||||
|
||||
rendererOn(PLAYER_EVENT_NAME.list_data_overwire, list_data_overwrite)
|
||||
rendererOn(PLAYER_EVENT_NAME.list_add, list_create)
|
||||
@@ -230,7 +235,7 @@ export const registerListAction = (appSetting: LX.AppSetting, onListChanged: (li
|
||||
rendererOn(PLAYER_EVENT_NAME.list_music_update, list_music_update)
|
||||
rendererOn(PLAYER_EVENT_NAME.list_music_update_position, list_music_update_position)
|
||||
rendererOn(PLAYER_EVENT_NAME.list_music_overwrite, list_music_overwrite)
|
||||
// rendererOn(PLAYER_EVENT_NAME.list_data_overwire, list_music_clear)
|
||||
rendererOn(PLAYER_EVENT_NAME.list_data_overwire, list_music_clear)
|
||||
|
||||
return () => {
|
||||
rendererOff(PLAYER_EVENT_NAME.list_data_overwire, list_data_overwrite)
|
||||
@@ -244,6 +249,6 @@ export const registerListAction = (appSetting: LX.AppSetting, onListChanged: (li
|
||||
rendererOff(PLAYER_EVENT_NAME.list_music_update, list_music_update)
|
||||
rendererOff(PLAYER_EVENT_NAME.list_music_update_position, list_music_update_position)
|
||||
rendererOff(PLAYER_EVENT_NAME.list_music_overwrite, list_music_overwrite)
|
||||
// rendererOff(PLAYER_EVENT_NAME.list_data_overwire, list_music_clear)
|
||||
rendererOff(PLAYER_EVENT_NAME.list_data_overwire, list_music_clear)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user