From 7a494a54c01b7e32cb56d9d5e01a888385206ce6 Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Sat, 29 Aug 2020 10:11:53 +0200 Subject: [PATCH] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E6=B7=BB=E5=8A=A0"?= =?UTF-8?q?=E8=B1=86=E7=93=A3"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Detail.vue | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/components/Detail.vue b/src/components/Detail.vue index ca791e2..b6e7577 100644 --- a/src/components/Detail.vue +++ b/src/components/Detail.vue @@ -32,6 +32,7 @@ 收藏 下载 分享 + 豆瓣
{{info.des}}
@@ -189,6 +190,26 @@ export default { info: this.detail.info } }, + doubanLinkEvent () { + const open = require('open') + const axios = require('axios') + const cheerio = require('cheerio') + const name = this.detail.info.name.trim() + // 豆瓣搜索链接 + var doubanSearchLink = 'https://www.douban.com/search?q=' + name + axios.get(doubanSearchLink).then(res => { + const $ = cheerio.load(res.data) + // 得到豆瓣搜索的第一条结果 + var nameInDouban = $('div.result').first().find('div>div>h3>a').first() + // 如果第一条结果就是该影片,打开该链接,否则打开搜索页面 + if (name === nameInDouban.text().trim()) { + var link = nameInDouban.attr('href') + open(link) + } else { + open(doubanSearchLink) + } + }) + }, getDetailInfo () { const id = this.detail.info.ids || this.detail.info.id zy.detail(this.detail.key, id).then(res => {