Fixed: sync upload img to gallery

This commit is contained in:
Molunerfinn 2018-08-08 14:39:40 +08:00
parent e0bb8480a2
commit cf504a0173
3 changed files with 14 additions and 6 deletions

View File

@ -352,6 +352,9 @@ const uploadClipboardFiles = async () => {
icon: img[0].imgUrl
})
notification.show()
img.forEach(item => {
db.read().get('uploaded').insert(item).write()
})
window.webContents.send('clipboardFiles', [])
window.webContents.send('uploadFiles', img)
if (settingWindow) {
@ -397,8 +400,11 @@ ipcMain.on('uploadClipboardFiles', async (evt, file) => {
icon: img[0].imgUrl
})
notification.show()
img.forEach(item => {
db.read().get('uploaded').insert(item).write()
})
window.webContents.send('clipboardFiles', [])
window.webContents.send('uploadFiles', img)
window.webContents.send('uploadFiles')
if (settingWindow) {
settingWindow.webContents.send('updateGallery')
}
@ -428,6 +434,9 @@ ipcMain.on('uploadChoosedFiles', async (evt, files) => {
}, i * 100)
}
clipboard.writeText(pasteText)
imgs.forEach(item => {
db.read().get('uploaded').insert(item).write()
})
window.webContents.send('uploadFiles', imgs)
if (settingWindow) {
settingWindow.webContents.send('updateGallery')

View File

@ -104,7 +104,9 @@ export default {
created () {
this.getGallery()
this.$electron.ipcRenderer.on('updateGallery', (event) => {
this.filterList = this.getGallery()
this.$nextTick(() => {
this.filterList = this.getGallery()
})
})
},
computed: {

View File

@ -54,10 +54,7 @@
this.$electron.ipcRenderer.on('clipboardFiles', (event, files) => {
this.clipboardFiles = files
})
this.$electron.ipcRenderer.on('uploadFiles', (event, files) => {
files.forEach(item => {
this.$db.read().get('uploaded').insert(item).write()
})
this.$electron.ipcRenderer.on('uploadFiles', (event) => {
this.files = this.$db.read().get('uploaded').slice().reverse().slice(0, 5).value()
})
this.$electron.ipcRenderer.on('updateFiles', (event) => {