From a3bc8f1f31939bb1fca5fbea11118b1ed514b7fc Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sun, 21 Feb 2021 21:32:58 +0100 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E9=87=8D=E7=BD=AE=E6=88=96=E6=BA=90?= =?UTF-8?q?=E7=AB=99=E5=88=97=E8=A1=A8=E4=B8=BA=E7=A9=BA=E6=97=B6,?= =?UTF-8?q?=E4=BB=8E=E4=BA=91=E7=AB=AF=E8=8E=B7=E5=8F=96=E6=BA=90=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Setting.vue | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/Setting.vue b/src/components/Setting.vue index 27c89da..c7c379a 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -258,7 +258,7 @@ import { mapMutations } from 'vuex' import pkg from '../../package.json' import { setting, sites, shortcut } from '../lib/dexie' -import { sites as defaultSites, localKey as defaultShortcuts } from '../lib/dexie/initData' +import { localKey as defaultShortcuts } from '../lib/dexie/initData' import { shell, clipboard, remote, ipcRenderer } from 'electron' import db from '../lib/dexie/dexie' import zy from '../lib/site/tools' @@ -331,11 +331,24 @@ export default { if (!this.setting.sitesDataURL) this.getDefaultdeSitesDataURL() }) }, + getDefaultSites () { + this.getDefaultdeSitesDataURL() + const axios = require('axios') + axios.get(this.setting.sitesDataURL).then(res => { + if (res.status === 200) { + if (res.data.length > 0) { + sites.clear().then(sites.bulkAdd(res.data)) + } + } + }).catch(error => { + this.$message.error('获取云端源站失败. ' + error) + }) + }, getSites () { sites.all().then(res => { if (res.length <= 0) { this.$message.warning('检测到视频源未能正常加载, 即将重置源.') - sites.clear().then(sites.bulkAdd(defaultSites).then(this.getSites())) + this.getDefaultSites() } }) }, @@ -588,7 +601,7 @@ export default { } }, created () { - // this.getSites() + this.getSites() this.getSetting() this.getShortcut() this.checkUpdate()