From 4c92ff9e70aabea6ea802fed45ffe64ad710658c Mon Sep 17 00:00:00 2001 From: buvta <12312540+buvta@users.noreply.github.com> Date: Sat, 12 Dec 2020 12:25:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BC=98=E5=8C=96film=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=97=B6=E7=9A=84=E8=87=AA=E5=8A=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2searchRunning=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Film.vue | 78 +++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/src/components/Film.vue b/src/components/Film.vue index c27ad63..6dcd6ef 100644 --- a/src/components/Film.vue +++ b/src/components/Film.vue @@ -347,6 +347,7 @@ export default { sortKeywords: ['按片名', '按上映年份', '按更新时间'], selectedYears: { start: 0, end: new Date().getFullYear() }, searchRunning: false, + siteSearchCount: 0, infiniteHandlerCount: 0 } }, @@ -397,6 +398,11 @@ export default { }, filterSettings () { return this.$store.getters.getSetting.excludeR18Films // 需要监听的数据 + }, + searchSites () { + if (this.searchGroup === '站内') return [this.site] + if (this.searchGroup === '全站') return this.sites + return this.sites.filter(site => site.group === this.searchGroup) } }, filters: { @@ -426,6 +432,9 @@ export default { }, deep: true }, + siteSearchCount () { + if (this.siteSearchCount === this.searchSites.length) this.searchRunning = false + }, searchContents: { handler (list) { this.areas = [...new Set(list.map(ele => ele.area))].filter(x => x) @@ -786,53 +795,46 @@ export default { } if (!wd) return this.searchID += 1 - var searchSites = [] - if (this.searchGroup === '站内') searchSites.push(this.site) - if (this.searchGroup === '全站') searchSites = this.sites - if (!searchSites.length) { - searchSites = this.sites.filter(site => site.group === this.searchGroup) - } this.searchContents = [] this.showFind = true this.statusText = ' ' - if (wd) { - this.searchRunning = true - let siteSearchCount = 0 - searchSites.forEach(site => { - const id = this.searchID - zy.search(site.key, wd).then(res => { - if (id !== this.searchID || !this.searchRunning) return - const type = Object.prototype.toString.call(res) - if (type === '[object Array]') { - let count = 0 - res.forEach(element => { - zy.detail(site.key, element.id).then(detailRes => { - if (id !== this.searchID || !this.searchRunning) return - detailRes.site = site - this.searchContents.push(detailRes) - this.searchContents.sort(function (a, b) { - return a.site.id - b.site.id - }) - this.statusText = '暂无数据' - }).finally(() => { count++; if (siteSearchCount === searchSites.length && count === res.length) this.searchRunning = false }) - }) - } - if (type === '[object Object]') { - zy.detail(site.key, res.id).then(detailRes => { - if (!this.searchRunning) return + this.searchRunning = true + this.siteSearchCount = 0 + this.searchSites.forEach(site => { + const id = this.searchID + zy.search(site.key, wd).then(res => { + if (id !== this.searchID || !this.searchRunning) return + const type = Object.prototype.toString.call(res) + if (type === '[object Array]') { + let count = 0 + res.forEach(element => { + zy.detail(site.key, element.id).then(detailRes => { + if (id !== this.searchID || !this.searchRunning) return detailRes.site = site - if (id !== this.searchID) return this.searchContents.push(detailRes) this.searchContents.sort(function (a, b) { return a.site.id - b.site.id }) this.statusText = '暂无数据' - }).finally(() => { if (siteSearchCount === searchSites.length) this.searchRunning = false }) - } - }).catch(() => { const length = this.searchContents.length; setTimeout(() => { if (length === this.searchContents.length) this.searchRunning = false }) }, 2000) - .finally(() => { siteSearchCount++ }) - }) - } + }).finally(() => { count++; if (count === res.length) { this.siteSearchCount++ } }) + }) + } else if (type === '[object Object]') { + zy.detail(site.key, res.id).then(detailRes => { + if (id !== this.searchID || !this.searchRunning) return + detailRes.site = site + this.searchContents.push(detailRes) + this.searchContents.sort(function (a, b) { + return a.site.id - b.site.id + }) + this.statusText = '暂无数据' + }).finally(() => { this.siteSearchCount++ }) + } else if (res === undefined) { + this.siteSearchCount++ + this.statusText = '暂无数据' + if (this.searchGroup === '站内') this.$message.info('没有查询到数据!') + } + }).catch(() => { this.siteSearchCount++ }) + }) }, searchAndRecord () { this.addSearchRecord()