mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-11 10:39:56 +08:00
✨ Feature(custom): support open and edit config file in software
This commit is contained in:
@@ -42,6 +42,24 @@ export default [
|
||||
shell.openPath(abFilePath)
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.READ_FILE_CONTENT,
|
||||
handler: async (_: IIPCEvent, args: [fileName: string]) => {
|
||||
const abFilePath = path.join(STORE_PATH, args[0])
|
||||
if (!fs.existsSync(abFilePath)) {
|
||||
fs.writeFileSync(abFilePath, '')
|
||||
}
|
||||
return fs.readFileSync(abFilePath, 'utf-8')
|
||||
},
|
||||
type: IRPCType.INVOKE,
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.WRITE_FILE_CONTENT,
|
||||
handler: async (_: IIPCEvent, args: [fileName: string, content: string]) => {
|
||||
const abFilePath = path.join(STORE_PATH, args[0])
|
||||
fs.writeFileSync(abFilePath, args[1], 'utf-8')
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.PICLIST_OPEN_DIRECTORY,
|
||||
handler: async (_: IIPCEvent, args: [dirPath?: string, inStorePath?: boolean]) => {
|
||||
|
||||
@@ -138,4 +138,11 @@ export default [
|
||||
})
|
||||
},
|
||||
},
|
||||
{
|
||||
action: IRPCActionType.RELOAD_WINDOW,
|
||||
handler: async () => {
|
||||
const window = BrowserWindow.getFocusedWindow()
|
||||
window?.webContents.reload()
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
@@ -123,6 +123,9 @@ export const IRPCActionType = {
|
||||
PICLIST_OPEN_DIRECTORY: 'PICLIST_OPEN_DIRECTORY',
|
||||
PICLIST_AUTO_START: 'PICLIST_AUTO_START',
|
||||
PICLIST_AUTO_START_STATUS: 'PICLIST_AUTO_START_STATUS',
|
||||
READ_FILE_CONTENT: 'READ_FILE_CONTENT',
|
||||
WRITE_FILE_CONTENT: 'WRITE_FILE_CONTENT',
|
||||
RELOAD_WINDOW: 'RELOAD_WINDOW',
|
||||
|
||||
// shortkey setting rpc
|
||||
SHORTKEY_UPDATE: 'SHORTKEY_UPDATE',
|
||||
|
||||
Reference in New Issue
Block a user