v2.0.0
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
export { registerRendererEvents } from './winRendererEvent'
|
||||
|
||||
export { default } from './rendererEvent'
|
||||
@@ -0,0 +1,26 @@
|
||||
import { mainHandle, mainOn } from '@common/mainIpc'
|
||||
import { CMMON_EVENT_NAME } from '@common/ipcNames'
|
||||
import { getFonts } from '@main/utils/fontManage'
|
||||
|
||||
// 公共操作事件(公共,只注册一次)
|
||||
export default () => {
|
||||
mainHandle<LX.AppSetting>(CMMON_EVENT_NAME.get_app_setting, async() => {
|
||||
return global.lx.appSetting
|
||||
})
|
||||
mainHandle<Partial<LX.AppSetting>>(CMMON_EVENT_NAME.set_app_setting, async({ params: config }) => {
|
||||
global.lx.event_app.update_config(config)
|
||||
})
|
||||
|
||||
mainHandle<LX.EnvParams>(CMMON_EVENT_NAME.get_env_params, async() => {
|
||||
return global.envParams
|
||||
})
|
||||
|
||||
mainOn(CMMON_EVENT_NAME.clear_env_params_deeplink, () => {
|
||||
global.envParams.deeplink = null
|
||||
})
|
||||
|
||||
mainHandle<string[]>(CMMON_EVENT_NAME.get_system_fonts, async() => {
|
||||
return await getFonts()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { CMMON_EVENT_NAME } from '@common/ipcNames'
|
||||
|
||||
// 发送列表操作事件到渲染进程的注册方法
|
||||
// 哪个渲染进程需要接收则引入此方法注册
|
||||
export const registerRendererEvents = (sendEvent: <T = any>(name: string, params?: T | undefined) => void) => {
|
||||
const sendDeeplink = (link: string) => {
|
||||
sendEvent(CMMON_EVENT_NAME.deeplink, link)
|
||||
}
|
||||
const sendSystemThemeChange = () => {
|
||||
sendEvent(CMMON_EVENT_NAME.theme_change, global.lx.theme)
|
||||
}
|
||||
|
||||
global.lx.event_app.on('deeplink', sendDeeplink)
|
||||
global.lx.event_app.on('theme_change', sendSystemThemeChange)
|
||||
|
||||
return () => {
|
||||
global.lx.event_app.off('deeplink', sendDeeplink)
|
||||
global.lx.event_app.off('theme_change', sendSystemThemeChange)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import common from './common'
|
||||
import list from './list'
|
||||
|
||||
export default () => {
|
||||
common()
|
||||
list()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export { registerRendererEvents } from './winRendererEvent'
|
||||
|
||||
export { default } from './rendererEvent'
|
||||
@@ -0,0 +1,54 @@
|
||||
import { mainHandle } from '@common/mainIpc'
|
||||
import { PLAYER_EVENT_NAME } from '@common/ipcNames'
|
||||
|
||||
// 列表操作事件(公共,只注册一次)
|
||||
export default () => {
|
||||
mainHandle<LX.List.UserListInfo[]>(PLAYER_EVENT_NAME.list_get, async() => {
|
||||
return await global.lx.worker.dbService.getAllUserList()
|
||||
})
|
||||
mainHandle<LX.List.ListActionDataOverwrite>(PLAYER_EVENT_NAME.list_data_overwire, async({ params: listData }) => {
|
||||
await global.lx.event_list.list_data_overwrite(listData, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionAdd>(PLAYER_EVENT_NAME.list_add, async({ params: { position, listInfos } }) => {
|
||||
await global.lx.event_list.list_create(position, listInfos, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionRemove>(PLAYER_EVENT_NAME.list_remove, async({ params: ids }) => {
|
||||
await global.lx.event_list.list_remove(ids, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionUpdate>(PLAYER_EVENT_NAME.list_update, async({ params: listInfos }) => {
|
||||
await global.lx.event_list.list_update(listInfos, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionUpdatePosition>(PLAYER_EVENT_NAME.list_update_position, async({ params: { position, ids } }) => {
|
||||
await global.lx.event_list.list_update_position(position, ids, false)
|
||||
})
|
||||
mainHandle<string, LX.Music.MusicInfo[]>(PLAYER_EVENT_NAME.list_music_get, async({ params: listId }) => {
|
||||
return await global.lx.worker.dbService.getListMusics(listId)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicAdd>(PLAYER_EVENT_NAME.list_music_add, async({ params: { id, musicInfos, addMusicLocationType } }) => {
|
||||
await global.lx.event_list.list_music_add(id, musicInfos, addMusicLocationType, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicMove>(PLAYER_EVENT_NAME.list_music_move, async({ params: { fromId, toId, musicInfos, addMusicLocationType } }) => {
|
||||
await global.lx.event_list.list_music_move(fromId, toId, musicInfos, addMusicLocationType, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicRemove>(PLAYER_EVENT_NAME.list_music_remove, async({ params: { listId, ids } }) => {
|
||||
await global.lx.event_list.list_music_remove(listId, ids, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicUpdate>(PLAYER_EVENT_NAME.list_music_update, async({ params: musicInfos }) => {
|
||||
await global.lx.event_list.list_music_update(musicInfos, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicUpdatePosition>(PLAYER_EVENT_NAME.list_music_update_position, async({ params: { listId, position, ids } }) => {
|
||||
await global.lx.event_list.list_music_update_position(listId, position, ids, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicOverwrite>(PLAYER_EVENT_NAME.list_music_overwrite, async({ params: { listId, musicInfos } }) => {
|
||||
await global.lx.event_list.list_music_overwrite(listId, musicInfos, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionMusicClear>(PLAYER_EVENT_NAME.list_music_clear, async({ params: listId }) => {
|
||||
await global.lx.event_list.list_music_clear(listId, false)
|
||||
})
|
||||
mainHandle<LX.List.ListActionCheckMusicExistList, boolean>(PLAYER_EVENT_NAME.list_music_check_exist, async({ params: { listId, musicInfoId } }) => {
|
||||
return await global.lx.worker.dbService.checkListExistMusic(listId, musicInfoId)
|
||||
})
|
||||
mainHandle<string, string[]>(PLAYER_EVENT_NAME.list_music_get_list_ids, async({ params: musicInfoId }) => {
|
||||
return await global.lx.worker.dbService.getMusicExistListIds(musicInfoId)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
import { PLAYER_EVENT_NAME } from '@common/ipcNames'
|
||||
|
||||
// 发送列表操作事件到渲染进程的注册方法
|
||||
// 哪个渲染进程需要接收则引入此方法注册
|
||||
export const registerRendererEvents = (sendEvent: <T = any>(name: string, params?: T | undefined) => void) => {
|
||||
const list_data_overwrite = async(listData: LX.List.ListActionDataOverwrite) => {
|
||||
sendEvent<LX.List.ListActionDataOverwrite>(PLAYER_EVENT_NAME.list_data_overwire, listData)
|
||||
}
|
||||
const list_create = async(position: number, listInfos: LX.List.UserListInfo[]) => {
|
||||
sendEvent<LX.List.ListActionAdd>(PLAYER_EVENT_NAME.list_add, { position, listInfos })
|
||||
}
|
||||
const list_remove = async(ids: string[]) => {
|
||||
sendEvent<LX.List.ListActionRemove>(PLAYER_EVENT_NAME.list_remove, ids)
|
||||
}
|
||||
const list_update = async(lists: LX.List.UserListInfo[]) => {
|
||||
sendEvent<LX.List.ListActionUpdate>(PLAYER_EVENT_NAME.list_update, lists)
|
||||
}
|
||||
const list_update_position = async(position: number, ids: string[]) => {
|
||||
sendEvent<LX.List.ListActionUpdatePosition>(PLAYER_EVENT_NAME.list_update_position, { position, ids })
|
||||
}
|
||||
const list_music_add = async(id: string, musicInfos: LX.Music.MusicInfo[], addMusicLocationType: LX.AddMusicLocationType) => {
|
||||
sendEvent<LX.List.ListActionMusicAdd>(PLAYER_EVENT_NAME.list_music_add, { id, musicInfos, addMusicLocationType })
|
||||
}
|
||||
const list_music_move = async(fromId: string, toId: string, musicInfos: LX.Music.MusicInfo[], addMusicLocationType: LX.AddMusicLocationType) => {
|
||||
sendEvent<LX.List.ListActionMusicMove>(PLAYER_EVENT_NAME.list_music_move, { fromId, toId, musicInfos, addMusicLocationType })
|
||||
}
|
||||
const list_music_remove = async(listId: string, ids: string[]) => {
|
||||
sendEvent<LX.List.ListActionMusicRemove>(PLAYER_EVENT_NAME.list_music_remove, { listId, ids })
|
||||
}
|
||||
const list_music_update = async(musicInfos: LX.List.ListActionMusicUpdate) => {
|
||||
sendEvent<LX.List.ListActionMusicUpdate>(PLAYER_EVENT_NAME.list_music_update, musicInfos)
|
||||
}
|
||||
const list_music_update_position = async(listId: string, position: number, ids: string[]) => {
|
||||
sendEvent<LX.List.ListActionMusicUpdatePosition>(PLAYER_EVENT_NAME.list_music_update_position, { listId, position, ids })
|
||||
}
|
||||
const list_music_overwrite = async(listId: string, musicInfos: LX.Music.MusicInfo[]) => {
|
||||
sendEvent<LX.List.ListActionMusicOverwrite>(PLAYER_EVENT_NAME.list_music_overwrite, { listId, musicInfos })
|
||||
}
|
||||
const list_music_clear = async(listId: string) => {
|
||||
sendEvent<LX.List.ListActionMusicClear>(PLAYER_EVENT_NAME.list_data_overwire, listId)
|
||||
}
|
||||
global.lx.event_list.on('list_data_overwrite', list_data_overwrite)
|
||||
global.lx.event_list.on('list_create', list_create)
|
||||
global.lx.event_list.on('list_remove', list_remove)
|
||||
global.lx.event_list.on('list_update', list_update)
|
||||
global.lx.event_list.on('list_update_position', list_update_position)
|
||||
global.lx.event_list.on('list_music_add', list_music_add)
|
||||
global.lx.event_list.on('list_music_move', list_music_move)
|
||||
global.lx.event_list.on('list_music_remove', list_music_remove)
|
||||
global.lx.event_list.on('list_music_update', list_music_update)
|
||||
global.lx.event_list.on('list_music_update_position', list_music_update_position)
|
||||
global.lx.event_list.on('list_music_overwrite', list_music_overwrite)
|
||||
global.lx.event_list.on('list_music_clear', list_music_clear)
|
||||
|
||||
return () => {
|
||||
global.lx.event_list.off('list_data_overwrite', list_data_overwrite)
|
||||
global.lx.event_list.off('list_create', list_create)
|
||||
global.lx.event_list.off('list_remove', list_remove)
|
||||
global.lx.event_list.off('list_update', list_update)
|
||||
global.lx.event_list.off('list_update_position', list_update_position)
|
||||
global.lx.event_list.off('list_music_add', list_music_add)
|
||||
global.lx.event_list.off('list_music_move', list_music_move)
|
||||
global.lx.event_list.off('list_music_remove', list_music_remove)
|
||||
global.lx.event_list.off('list_music_update', list_music_update)
|
||||
global.lx.event_list.off('list_music_update_position', list_music_update_position)
|
||||
global.lx.event_list.off('list_music_overwrite', list_music_overwrite)
|
||||
global.lx.event_list.off('list_music_clear', list_music_clear)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user