mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-02 08:09:44 +08:00
🔨 Refactor(custom): refactored manage page ipc
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user