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 => {