From 506be03e3e679fae4a2cb75d07c7f2c33fe3b258 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sun, 23 Aug 2020 17:45:19 +0200 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E6=96=87=E4=BB=B6=E4=B8=AD=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=94=B6=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Setting.vue | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/components/Setting.vue b/src/components/Setting.vue index 4135387..7df7d37 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -245,11 +245,27 @@ export default { }) }, importFavorites () { - const str = clipboard.readText() - const json = JSON.parse(str) - star.bulkAdd(json).then(e => { - this.$message.success('已添加成功') - this.getFavorites() + const options = { + filters: [ + { name: 'JSON file', extensions: ['json'] }, + { name: 'Normal text file', extensions: ['txt'] }, + { name: 'All types', extensions: ['*'] } + ], + properties: ['openFile', 'multiSelections'] + } + remote.dialog.showOpenDialog(options).then(result => { + if (!result.canceled) { + result.filePaths.forEach(file => { + var str = fs.readFileSync(file) + const json = JSON.parse(str) + star.bulkAdd(json).then(e => { + this.getFavorites() + }) + }) + this.$message.success('导入收藏成功') + } + }).catch(err => { + this.$message.error(err) }) }, expSites () {