From a1458cf8bf3b90eb8bcd50d2d2f486b7c66ec29a Mon Sep 17 00:00:00 2001 From: haiyangcui Date: Mon, 7 Sep 2020 23:36:55 +0200 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E8=97=8F=E9=A1=B5=E9=9D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=A7=82=E7=9C=8B=E8=87=B3=E7=AC=AC=E5=87=A0=E9=9B=86?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Detail.vue | 22 ++++++++++------------ src/components/History.vue | 2 +- src/components/Play.vue | 35 ++++++++++++++++++++++++----------- src/components/Star.vue | 22 +++++++++------------- 4 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/components/Detail.vue b/src/components/Detail.vue index 0597989..b854bf0 100644 --- a/src/components/Detail.vue +++ b/src/components/Detail.vue @@ -134,20 +134,18 @@ export default { }, starEvent () { star.find({ key: this.detail.key, ids: this.info.id }).then(res => { - const docs = { - key: this.detail.key, - ids: this.info.id, - name: this.info.name, - type: this.info.type, - year: this.info.year, - last: this.info.last, - note: this.info.note - } if (res) { - star.update(res.id, docs).then(res => { - this.$message.success('已存在,更新成功') - }) + this.$message.info('该影片已被收藏') } else { + const docs = { + key: this.detail.key, + ids: this.info.id, + name: this.info.name, + type: this.info.type, + year: this.info.year, + last: this.info.last, + note: this.info.note + } star.add(docs).then(res => { this.$message.success('收藏成功') }) diff --git a/src/components/History.vue b/src/components/History.vue index aecf4d3..47c629b 100644 --- a/src/components/History.vue +++ b/src/components/History.vue @@ -11,7 +11,7 @@
  • 名字 片源 - 播放至 + 观看至 diff --git a/src/components/Play.vue b/src/components/Play.vue index f7bfaa7..c0f9bd1 100644 --- a/src/components/Play.vue +++ b/src/components/Play.vue @@ -407,6 +407,7 @@ export default { history.add(doc) } }) + this.updateStar() this.timerEvent() }, changeVideo () { @@ -465,21 +466,33 @@ export default { this.right.history = res.reverse() }) }, - starEvent () { + updateStar () { const info = this.video.info star.find({ key: this.video.key, ids: info.id }).then(res => { if (res) { - this.$message.info('已存在') + res.index = info.index + star.update(res.id, res) + } + }).catch(() => { + this.$message.warning('检查收藏失败') + }) + }, + starEvent () { + const info = this.video.info + star.find({ key: this.video.key, ids: info.id }).then(res => { + const doc = { + key: this.video.key, + ids: info.id, + name: info.name, + type: info.type, + year: info.year, + last: info.last, + note: info.note, + index: info.index + } + if (res) { + star.update(res.id, doc) } else { - const doc = { - key: this.video.key, - ids: info.id, - name: info.name, - type: info.type, - year: info.year, - last: info.last, - note: info.note - } star.add(doc).then(starRes => { this.$message.success('收藏成功') this.isStar = true diff --git a/src/components/Star.vue b/src/components/Star.vue index f063e00..0fe650c 100644 --- a/src/components/Star.vue +++ b/src/components/Star.vue @@ -13,6 +13,7 @@ 上映 片源 备注 + 观看至 @@ -29,6 +30,7 @@ {{i.year}} {{getSiteName(i.key)}} {{i.note}} + {{getHistoryNote(i.index)}} 播放 分享 @@ -96,19 +98,6 @@ export default { this.SET_SHARE(val) } } - // draggableList: { - // get () { - // return this.list - // }, - // set (value) { - // star.clear().then(res1 => { - // star.bulkAdd(value).then(res2 => { - // this.$message.success('排序成功') - // this.list = value - // }) - // }) - // } - // } }, watch: { view () { @@ -263,6 +252,13 @@ export default { return site.name } }, + getHistoryNote (index) { + if (index !== null && index !== undefined) { + return `第${index + 1}集` + } else { + return '' + } + }, getStarList () { star.all().then(res => { this.list = res.reverse()