转移getDefaultSites函数到tools.js

This commit is contained in:
haiyangcui
2021-02-23 22:51:40 +01:00
parent 289f3c3c2d
commit a3a26e0deb
3 changed files with 16 additions and 15 deletions

View File

@@ -414,14 +414,11 @@ export default {
// 如果没有设置源站文件链接,使用默认的gitee源
url = 'https://gitee.com/cuiocean/ZY-Player-Resources/raw/main/Sites/Sites.json'
}
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()
}
zy.getDefaultSites(url).then(res => {
if (res.length > 0) {
sites.clear().then(sites.bulkAdd(res))
this.$message.success('重置源成功')
this.getSites()
}
}).catch(error => {
this.$message.error('导入云端源站失败. ' + error)

View File

@@ -332,13 +332,9 @@ export default {
})
},
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))
}
zy.getDefaultSites(this.setting.sitesDataURL).then(res => {
if (res.length > 0) {
sites.clear().then(sites.bulkAdd(res))
}
}).catch(error => {
this.$message.error('获取云端源站失败. ' + error)

View File

@@ -500,6 +500,14 @@ const zy = {
}).catch(err => { reject(err) })
})
},
getDefaultSites () {
const url = 'https://gitee.com/cuiocean/ZY-Player-Resources/raw/main/Sites/Sites.json'
return new Promise((resolve, reject) => {
axios.get(url).then(res => {
resolve(res.data)
}).catch(err => { reject(err) })
})
},
proxy () {
return new Promise((resolve, reject) => {
setting.find().then(db => {