diff --git a/src/main/index.js b/src/main/index.js index 04301ae..e8f2a90 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -423,6 +423,12 @@ ipcMain.on('updteDefaultPicBed', (evt) => { }) }) +ipcMain.on('autoStart', (evt, val) => { + app.setLoginItemSettings({ + openAtLogin: val + }) +}) + const shortKeyHash = { upload: uploadClipboardFiles } diff --git a/src/renderer/components/SettingView/PicGoSetting.vue b/src/renderer/components/SettingView/PicGoSetting.vue index f58f167..1887a4e 100644 --- a/src/renderer/components/SettingView/PicGoSetting.vue +++ b/src/renderer/components/SettingView/PicGoSetting.vue @@ -211,7 +211,11 @@ export default { }, handleAutoStartChange (val) { this.$db.read().set('picBed.autoStart', val).write() + this.$electron.ipcRenderer.send('autoStart', val) } + }, + beforeDestroy () { + this.$electron.ipcRenderer.removeAllListeners('autoStart') } }