From 59f9772e821e0862223683da7678dd9884b91fc8 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Fri, 19 Feb 2021 23:50:42 +0100 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E9=BB=98=E8=AE=A4Gi?= =?UTF-8?q?thub=E6=BA=90=E6=88=96=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E6=BA=90=E7=AB=99=E6=96=87=E4=BB=B6=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/EditSites.vue | 23 ++++++++++++++++------- src/components/Setting.vue | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/components/EditSites.vue b/src/components/EditSites.vue index 47bd514..829ca15 100644 --- a/src/components/EditSites.vue +++ b/src/components/EditSites.vue @@ -119,7 +119,6 @@ import { mapMutations } from 'vuex' import { sites, setting } from '../lib/dexie' import zy from '../lib/site/tools' import { remote } from 'electron' -import { sites as defaultSites } from '../lib/dexie/initData' import fs from 'fs' import Sortable from 'sortablejs' @@ -410,13 +409,23 @@ export default { }) }, resetSitesEvent () { - this.stopFlag = true - if (this.checkAllSitesLoading) { - this.$message.info('部分检测还未完全终止, 请稍等...') - return + let url = this.setting.sitesDataURL + if (!url) { + // 如果没有设置源站文件链接,使用默认的github源 + url = 'https://raw.githubusercontent.com/cuiocean/ZY-Player-Resources/main/Sites/Sites.json' } - sites.clear().then(sites.bulkAdd(defaultSites).then(this.getSites())) - this.$message.success('重置源成功') + const axios = require('axios') + axios.get(url).then(res => { + if (res.status === 200) { + if (res.data.length > 0) { + sites.clear().then(sites.bulkAdd(res.data)) + this.$message.success('重置源成功') + this.getSites() + } + } + }).catch(error => { + this.$message.error('导入云端源站失败. ' + error) + }) }, moveToTopEvent (i) { if (this.checkAllSitesLoading) { diff --git a/src/components/Setting.vue b/src/components/Setting.vue index 2469944..43947b1 100644 --- a/src/components/Setting.vue +++ b/src/components/Setting.vue @@ -90,6 +90,9 @@
设置默认解析接口
+
+
设置源站接口文件
+
屏蔽主分类
@@ -158,7 +161,7 @@
- + @@ -169,6 +172,20 @@
+
+ + + + + + + + 取消 + 重置 + 确定 + + +
@@ -260,7 +277,8 @@ export default { changePasswordDialog: false, proxy: false, proxyDialog: false, - configDefaultParseUrlDialog: false + configDefaultParseUrlDialog: false, + configSitesDataUrlDialog: false }, d: { }, latestVersion: pkg.version, @@ -310,6 +328,7 @@ export default { this.d = res this.setting = this.d if (!this.setting.defaultParseURL) this.configDefaultParseURL() + if (!this.setting.sitesDataURL) this.getDefaultdeSitesDataURL() }) }, getSites () { @@ -360,6 +379,15 @@ export default { this.show.configDefaultParseUrlDialog = false this.updateSettingEvent() }, + getDefaultdeSitesDataURL () { + this.setting.sitesDataURL = 'https://raw.githubusercontent.com/cuiocean/ZY-Player-Resources/main/Sites/Sites.json' + }, + configSitesDataURL () { + if (!this.setting.sitesDataURL) this.getDefaultdeSitesDataURL() + this.d.sitesDataURL = this.setting.sitesDataURL + this.show.configSitesDataUrlDialog = false + this.updateSettingEvent() + }, selectLocalPlayer () { const options = { filters: [ @@ -403,6 +431,7 @@ export default { this.show.checkPasswordDialog = false this.show.changePasswordDialog = false this.show.configDefaultParseUrlDialog = false + this.show.configSitesDataUrlDialog = false if (this.show.proxyDialog) { this.show.proxyDialog = false this.setting.proxy.type = 'none'