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'