From 0d6e0d6e9ff2ac936a112fcf32ccd318ab76e61d Mon Sep 17 00:00:00 2001
From: buvta <12312540+buvta@users.noreply.github.com>
Date: Fri, 11 Dec 2020 23:07:13 +0800
Subject: [PATCH] =?UTF-8?q?film=E5=81=9C=E6=AD=A2=E6=90=9C=E7=B4=A2?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/Film.vue | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/components/Film.vue b/src/components/Film.vue
index 747ddc8..7e22120 100644
--- a/src/components/Film.vue
+++ b/src/components/Film.vue
@@ -50,8 +50,8 @@
-
-
+
+
@@ -344,7 +344,7 @@ export default {
sortKeyword: '',
sortKeywords: ['按片名', '按上映年份', '按更新时间'],
selectedYears: { start: 0, end: new Date().getFullYear() },
- keepSearching: false,
+ searchRunning: false,
infiniteHandlerCount: 0
}
},
@@ -765,7 +765,7 @@ export default {
})
},
stopSearchEvent () {
- this.keepSearching = false
+ this.searchRunning = false
},
searchEvent () {
const wd = this.searchTxt
@@ -785,29 +785,30 @@ export default {
this.showFind = true
this.statusText = ' '
if (wd) {
- this.keepSearching = true
+ this.searchRunning = true
+ let siteSearchCount = 0
searchSites.forEach(site => {
const id = this.searchID
zy.search(site.key, wd).then(res => {
- if (id !== this.searchID) return
+ 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 (!this.keepSearching) return
+ 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(() => { 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.keepSearching) return
+ if (!this.searchRunning) return
detailRes.site = site
if (id !== this.searchID) return
this.searchContents.push(detailRes)
@@ -815,9 +816,10 @@ export default {
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++ })
})
}
},