Feature(custom): support open and edit config file in software

This commit is contained in:
Kuingsmile
2026-01-25 18:25:52 +08:00
parent 9c78c54800
commit a10e701cc9
12 changed files with 387 additions and 3 deletions

View File

@@ -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]) => {

View File

@@ -138,4 +138,11 @@ export default [
})
},
},
{
action: IRPCActionType.RELOAD_WINDOW,
handler: async () => {
const window = BrowserWindow.getFocusedWindow()
window?.webContents.reload()
},
},
]

View File

@@ -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',