From 967093328fa5f55f633b1e4f415a2f24f64d8f7f Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 16 Nov 2019 20:15:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E8=8A=82=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/App.vue | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 4787b0b3..f70ea133 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -23,6 +23,7 @@ import { mapMutations, mapGetters, mapActions } from 'vuex' import { rendererOn, rendererSend } from '../common/ipc' import { isLinux } from '../common/utils' import music from './utils/music' +import { throttle } from './utils' window.ELECTRON_DISABLE_SECURITY_WARNINGS = process.env.ELECTRON_DISABLE_SECURITY_WARNINGS dnscache({ enable: true, @@ -50,6 +51,20 @@ export default { downloadStatus: 'downloadStatus', }), }, + created() { + this.saveSetting = throttle(n => { + this.electronStore.set('setting', n) + }) + this.saveDefaultList = throttle(n => { + this.electronStore.set('list.defaultList', n) + }, 500) + this.saveLoveList = throttle(n => { + this.electronStore.set('list.loveList', n) + }, 500) + this.saveDownloadList = throttle(n => { + this.electronStore.set('download.list', n) + }, 1000) + }, mounted() { document.body.classList.add(this.isLinux ? 'noTransparent' : 'transparent') this.init() @@ -57,27 +72,25 @@ export default { watch: { setting: { handler(n) { - this.electronStore.set('setting', n) + this.saveSetting(n) }, deep: true, }, defaultList: { handler(n) { - // console.log(n) - this.electronStore.set('list.defaultList', n) + this.saveDefaultList(n) }, deep: true, }, loveList: { handler(n) { - // console.log(n) - this.electronStore.set('list.loveList', n) + this.saveLoveList(n) }, deep: true, }, downloadList: { handler(n) { - this.electronStore.set('download.list', n) + this.saveDownloadList(n) }, deep: true, },