Feature: add remote file delete , picBed management

First version of PicList.
In album, you can delete remote file now.
Add picBed management
function.
This commit is contained in:
萌萌哒赫萝
2023-02-15 23:36:47 +08:00
parent 7421322475
commit efeadb8fb8
355 changed files with 12428 additions and 883 deletions

View File

@@ -0,0 +1,44 @@
import { ipcRenderer, IpcRendererEvent } from 'electron'
import { PICLIST_MANAGE_GET_CONFIG, PICLIST_MANAGE_SAVE_CONFIG, PICLIST_MANAGE_REMOVE_CONFIG } from '~/main/manage/events/constants'
import { v4 as uuid } from 'uuid'
import { getRawData } from '~/renderer/utils/common'
export function getConfig<T> (key?: string): Promise<T | undefined> {
return new Promise((resolve) => {
const callbackId = uuid()
const callback = (event: IpcRendererEvent, config: T | undefined, returnCallbackId: string) => {
if (returnCallbackId === callbackId) {
resolve(config)
ipcRenderer.removeListener(PICLIST_MANAGE_GET_CONFIG, callback)
}
}
ipcRenderer.on(PICLIST_MANAGE_GET_CONFIG, callback)
ipcRenderer.send(PICLIST_MANAGE_GET_CONFIG, key, callbackId)
})
}
export function saveConfig (_config: IObj | string, value?: any) {
let config
if (typeof _config === 'string') {
config = {
[_config]: value
}
} else {
config = getRawData(_config)
}
ipcRenderer.send(PICLIST_MANAGE_SAVE_CONFIG, config)
}
export function removeConfig (key: string, propName: string) {
ipcRenderer.send(PICLIST_MANAGE_REMOVE_CONFIG, key, propName)
}
export function sendToMain (channel: string, ...args: any[]) {
const data = getRawData(args)
ipcRenderer.send(channel, ...data)
}
export function invokeToMain (channel: string, ...args: any[]) {
const data = getRawData(args)
return ipcRenderer.invoke(channel, ...data)
}