Finished: dynamic sync default picbed in menu

This commit is contained in:
Molunerfinn
2018-12-25 16:11:10 +08:00
parent 51cea7cdf0
commit 60ccd10e1a
4 changed files with 12 additions and 42 deletions

View File

@@ -48,8 +48,7 @@ export default {
this.showError = true
}
})
this.$electron.ipcRenderer.send('getPicBeds')
this.$electron.ipcRenderer.on('getPicBeds', this.getPicBeds)
this.getPicBeds()
},
mounted () {
window.addEventListener('mousedown', this.handleMouseDown, false)
@@ -70,8 +69,8 @@ export default {
}
},
methods: {
getPicBeds (event, picBeds) {
this.picBed = picBeds
getPicBeds () {
this.picBed = this.$electron.ipcRenderer.sendSync('getPicBeds')
this.buildMenu()
},
onDrop (e) {
@@ -123,16 +122,7 @@ export default {
if (e.button === 0) { // left mouse
this.openUploadWindow()
} else {
let _this = this
const types = this.picBed.map(item => item.type)
let submenuItem = this.menu.items[1].submenu.items
submenuItem.forEach((item, index) => {
const result = _this.$db.read().get('picBed.current').value() === types[index]
if (result) {
item.click()
return true
}
})
this.getPicBeds()
this.openContextMenu()
}
}

View File

@@ -64,7 +64,6 @@ export default {
setDefaultPicBed (type) {
this.$db.read().set('picBed.current', type).write()
this.defaultPicBed = type
this.$electron.ipcRenderer.send('updateDefaultPicBed', type)
const successNotification = new window.Notification('设置默认图床', {
body: '设置成功'
})

View File

@@ -9,7 +9,6 @@ export default {
setDefaultPicBed (type) {
this.$db.read().set('picBed.current', type).write()
this.defaultPicBed = type
this.$electron.ipcRenderer.send('updateDefaultPicBed', type)
const successNotification = new window.Notification('设置默认图床', {
body: '设置成功'
})