🔨 Refactor(custom): refactored manage page ipc

This commit is contained in:
Kuingsmile
2024-06-26 18:57:40 +08:00
parent 09bf847459
commit a11ae31359
18 changed files with 332 additions and 259 deletions

View File

@@ -1,22 +1,16 @@
import { ipcRenderer } from 'electron'
import { sendRPC, triggerRPC } from '@/utils/common'
import { getRawData } from '@/utils/common'
import {
PICLIST_MANAGE_GET_CONFIG,
PICLIST_MANAGE_SAVE_CONFIG,
PICLIST_MANAGE_REMOVE_CONFIG
} from '~/manage/events/constants'
import { IRPCActionType } from '#/types/enum'
export function saveConfig(config: IObj | string, value?: any) {
const configObj = typeof config === 'string' ? { [config]: value } : getRawData(config)
ipcRenderer.send(PICLIST_MANAGE_SAVE_CONFIG, configObj)
const configObj = typeof config === 'string' ? { [config]: value } : config
sendRPC(IRPCActionType.MANAGE_SAVE_CONFIG, configObj)
}
export async function getConfig<T>(key?: string): Promise<T | undefined> {
return await ipcRenderer.invoke(PICLIST_MANAGE_GET_CONFIG, key)
return await triggerRPC<T>(IRPCActionType.MANAGE_GET_CONFIG, key)
}
export function removeConfig(key: string, propName: string) {
ipcRenderer.send(PICLIST_MANAGE_REMOVE_CONFIG, key, propName)
sendRPC(IRPCActionType.MANAGE_REMOVE_CONFIG, key, propName)
}