搜索的时候设置timeout,解决全局搜索结果无法打开的问题

This commit is contained in:
haiyangcui
2020-09-27 14:55:56 +02:00
parent 89d6183841
commit 00dab782e8
2 changed files with 9 additions and 5 deletions

View File

@@ -422,7 +422,7 @@ export default {
}
this.getAllSearch()
})
sites.forEach(site =>
sites.forEach(site => {
zy.search(site.key, wd).then(res => {
const type = Object.prototype.toString.call(res)
if (type === '[object Array]') {
@@ -436,7 +436,7 @@ export default {
this.searchContents.push(res)
}
})
)
})
} else {
this.show.find = false
this.getClass().then(res => {

View File

@@ -130,14 +130,18 @@ const zy = {
this.getSite(key).then(res => {
const site = res
wd = encodeURI(wd)
axios.post(`http://localhost:${this.ports}/api`, { url: site.api + '?wd=' + wd }).then(res => {
axios.post(`http://localhost:${this.ports}/api`, { url: site.api + '?wd=' + wd }, { timeout: 2000 }).then(res => {
const data = res.data.info
const json = parser.parse(data, this.xmlConfig)
const videoList = json.rss.list.video
resolve(videoList)
if (json && json.rss && json.rss.list) {
const videoList = json.rss.list.video
resolve(videoList)
}
}).catch(err => {
reject(err)
})
}).catch(err => {
reject(err)
})
})
},