mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-02-04 19:03:15 +08:00
过滤搜索结果,只返回名字中包含搜索关键词的结果
This commit is contained in:
@@ -819,7 +819,7 @@ export default {
|
||||
zy.detail(site.key, element.id).then(detailRes => {
|
||||
if (id !== this.searchID || !this.searchRunning) return
|
||||
detailRes.site = site
|
||||
if (detailRes.dl.dd && (detailRes.dl.dd._t || (Object.prototype.toString.call(detailRes.dl.dd) === '[object Array]' && detailRes.dl.dd.some(i => i._t)))) {
|
||||
if (this.isValidSearchResult(detailRes, wd)) {
|
||||
this.searchContents.push(detailRes)
|
||||
this.searchContents.sort(function (a, b) {
|
||||
return a.site.id - b.site.id
|
||||
@@ -831,7 +831,7 @@ export default {
|
||||
zy.detail(site.key, res.id).then(detailRes => {
|
||||
if (id !== this.searchID || !this.searchRunning) return
|
||||
detailRes.site = site
|
||||
if (detailRes.dl.dd && (detailRes.dl.dd._t || (Object.prototype.toString.call(detailRes.dl.dd) === '[object Array]' && detailRes.dl.dd.some(i => i._t)))) {
|
||||
if (this.isValidSearchResult(detailRes, wd)) {
|
||||
this.searchContents.push(detailRes)
|
||||
this.searchContents.sort(function (a, b) {
|
||||
return a.site.id - b.site.id
|
||||
@@ -846,6 +846,10 @@ export default {
|
||||
}).catch(() => { this.siteSearchCount++; if (this.searchGroup === '站内') this.$message.error('本次查询状态异常,未获取到数据!') })
|
||||
})
|
||||
},
|
||||
isValidSearchResult (detailRes, searchKeyword) {
|
||||
return detailRes.dl.dd && (detailRes.dl.dd._t || (Object.prototype.toString.call(detailRes.dl.dd) === '[object Array]' &&
|
||||
detailRes.dl.dd.some(i => i._t))) && detailRes.name.includes(searchKeyword)
|
||||
},
|
||||
searchAndRecord () {
|
||||
this.addSearchRecord()
|
||||
this.searchEvent()
|
||||
|
||||
Reference in New Issue
Block a user