From cf504a0173f63c94f6b2e7da77cb9554128d2eab Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Wed, 8 Aug 2018 14:39:40 +0800 Subject: [PATCH] Fixed: sync upload img to gallery --- src/main/index.js | 11 ++++++++++- src/renderer/components/SettingView/Gallery.vue | 4 +++- src/renderer/components/TrayPage.vue | 5 +---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index b0d430b..ccacadc 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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') diff --git a/src/renderer/components/SettingView/Gallery.vue b/src/renderer/components/SettingView/Gallery.vue index 7f2c392..d4d5d27 100644 --- a/src/renderer/components/SettingView/Gallery.vue +++ b/src/renderer/components/SettingView/Gallery.vue @@ -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: { diff --git a/src/renderer/components/TrayPage.vue b/src/renderer/components/TrayPage.vue index d30be07..3198b11 100644 --- a/src/renderer/components/TrayPage.vue +++ b/src/renderer/components/TrayPage.vue @@ -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) => {