From 1105c46f08fea4dcd433b71b388b61b284217d3b Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Fri, 14 Aug 2020 19:29:39 +0200 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E2=80=9C=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=89=80=E6=9C=89=E8=B5=84=E6=BA=90=E2=80=9Dcheckbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Film.vue | 55 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/components/Film.vue b/src/components/Film.vue index 7a3990f..a03cce1 100644 --- a/src/components/Film.vue +++ b/src/components/Film.vue @@ -26,6 +26,9 @@ +
+ 搜索所有资源 +
@@ -135,7 +138,8 @@ export default { infiniteId: +new Date(), searchList: [], searchTxt: '', - searchContents: [] + searchContents: [], + searchAllSites: false } }, components: { @@ -379,7 +383,7 @@ export default { this.searchList = res.reverse() }) }, - searchEvent (wd) { + searchSingleSiteEvent (wd) { this.searchTxt = wd this.searchContents = [] this.pagecount = 0 @@ -417,6 +421,53 @@ export default { }) } }, + searchAllSitesEvent (wd) { + this.searchTxt = wd + this.searchContents = [] + this.pagecount = 0 + this.show.search = false + this.show.find = true + if (wd) { + search.find({ keywords: wd }).then(res => { + if (!res) { + search.add({ keywords: wd }) + } + this.getAllSearch() + }) + this.sites.forEach(site => + zy.search(site.key, wd).then(res => { + const type = Object.prototype.toString.call(res) + if (type === '[object Undefined]') { + this.$message.info('无搜索结果') + } + if (type === '[object Array]') { + res.forEach(element => { + element.site = site.name + this.searchContents.push(element) + }) + } + if (type === '[object Object]') { + res.site = site.name + this.searchContents.push(res) + } + }) + ) + } else { + this.show.find = false + this.getClass().then(res => { + if (res) { + this.infiniteId += 1 + } + }) + } + }, + searchEvent (wd) { + if (this.searchAllSites) { + this.searchAllSitesEvent(wd) + } else { + this.searchSingleSiteEvent(wd) + } + }, clearSearch () { search.clear().then(res => { this.getAllSearch()