mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-02-09 21:47:34 +08:00
添加recommandation数据库,支持更新推荐
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
"mousetrap": "^1.6.5",
|
||||
"qrcode.vue": "^1.7.0",
|
||||
"randomstring": "^1.1.5",
|
||||
"request": "^2.88.2",
|
||||
"v-fit-columns": "^0.2.0",
|
||||
"vue": "^2.6.12",
|
||||
"vue-infinite-loading": "^2.4.5",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="listpage-content">
|
||||
<div class="listpage-header">
|
||||
<el-switch v-model="viewMode" active-text="海报" active-value="picture" inactive-text="列表" inactive-value="list"></el-switch>
|
||||
<el-button icon="el-icon-refresh">更新推荐</el-button>
|
||||
<el-button @click.stop="updateEvent" icon="el-icon-refresh">更新推荐</el-button>
|
||||
</div>
|
||||
<div class="listpage-body" id="recommandataions-table" v-show="viewMode === 'list'">
|
||||
<el-table size="mini" fit height="100%" row-key="id"
|
||||
@@ -11,8 +11,6 @@
|
||||
:data="recommandations"
|
||||
@row-click="detailEvent">
|
||||
<el-table-column
|
||||
sortable
|
||||
:sort-method="sortByName"
|
||||
prop="name"
|
||||
label="片名">
|
||||
</el-table-column>
|
||||
@@ -32,14 +30,6 @@
|
||||
width="100"
|
||||
align="center">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="site.name"
|
||||
width="120"
|
||||
label="源站">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getSiteName(scope.row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="recommandations.some(e => e.detail.note)"
|
||||
prop="detail.note"
|
||||
width="120"
|
||||
@@ -58,6 +48,7 @@
|
||||
<el-button @click.stop="playEvent(scope.row)" type="text">播放</el-button>
|
||||
<el-button @click.stop="shareEvent(scope.row)" type="text">分享</el-button>
|
||||
<el-button @click.stop="downloadEvent(scope.row)" type="text">下载</el-button>
|
||||
<el-button @click.stop="deleteEvent(scope.row)" type="text">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -100,10 +91,10 @@
|
||||
</template>
|
||||
<script>
|
||||
import { mapMutations } from 'vuex'
|
||||
import { history, sites } from '../lib/dexie'
|
||||
import { history, recommandation } from '../lib/dexie'
|
||||
import zy from '../lib/site/tools'
|
||||
import Waterfall from 'vue-waterfall-plugin'
|
||||
import { recommandations as buildInRecommandations } from '../lib/dexie/initData'
|
||||
// import { recommandations as buildInRecommandations } from '../lib/dexie/initData'
|
||||
const { clipboard } = require('electron')
|
||||
export default {
|
||||
name: 'recommandations',
|
||||
@@ -153,17 +144,13 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
view () {
|
||||
this.getAllsites()
|
||||
this.getRecommandations()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
|
||||
sortByName (a, b) {
|
||||
return a.name.localeCompare(b.name, 'zh')
|
||||
},
|
||||
sortByType (a, b) {
|
||||
return a.type.localeCompare(b.type)
|
||||
return a.detail.type.localeCompare(b.detail.type)
|
||||
},
|
||||
detailEvent (e) {
|
||||
this.detail = {
|
||||
@@ -175,6 +162,24 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
updateEvent () {
|
||||
const url = 'https://raw.githubusercontent.com/Hunlongyu/ZY-Player/master/src/lib/dexie/iniData/Recommandations.json'
|
||||
const request = require('request')
|
||||
const options = { json: true }
|
||||
request(url, options, (error, res, body) => {
|
||||
if (!error && res.statusCode === 200) {
|
||||
// do something with JSON, using the 'body' variable
|
||||
if (body.length > 0) {
|
||||
this.recommandations = body
|
||||
this.recommandations.sort(function (a, b) {
|
||||
return b.detail.year - a.detail.year
|
||||
})
|
||||
recommandation.clear().then(recommandation.bulkAdd(this.recommandations))
|
||||
this.$message.success('更新推荐成功')
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
async playEvent (e) {
|
||||
const db = await history.find({ site: e.key, ids: e.ids })
|
||||
if (db) {
|
||||
@@ -184,6 +189,16 @@ export default {
|
||||
}
|
||||
this.view = 'Play'
|
||||
},
|
||||
deleteEvent (e) {
|
||||
recommandation.remove(e.id).then(res => {
|
||||
if (res) {
|
||||
this.$message.warning('删除失败')
|
||||
} else {
|
||||
this.$message.success('删除成功')
|
||||
}
|
||||
this.getRecommandations()
|
||||
})
|
||||
},
|
||||
shareEvent (e) {
|
||||
this.share = {
|
||||
show: true,
|
||||
@@ -233,24 +248,12 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
getSiteName (row) {
|
||||
if (row.site) {
|
||||
return row.site.name
|
||||
} else {
|
||||
var site = this.sites.find(e => e.key === row.key)
|
||||
if (site) {
|
||||
return site.name
|
||||
}
|
||||
}
|
||||
},
|
||||
getRecommandations () {
|
||||
this.recommandations = buildInRecommandations.sort(function (a, b) {
|
||||
return b.detail.year - a.detail.year
|
||||
})
|
||||
},
|
||||
getAllsites () {
|
||||
sites.all().then(res => {
|
||||
this.sites = res
|
||||
recommandation.all().then(res => {
|
||||
this.recommandations = res
|
||||
this.recommandations.sort(function (a, b) {
|
||||
return b.detail.year - a.detail.year
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Dexie from 'dexie'
|
||||
import { setting, sites, localKey, iptv } from './initData'
|
||||
import { setting, sites, localKey, iptv, recommandations } from './initData'
|
||||
|
||||
const db = new Dexie('zy')
|
||||
|
||||
@@ -9,6 +9,7 @@ db.version(4).stores({
|
||||
setting: 'id, theme, site, shortcut, view, externalPlayer, searchAllSites, excludeRootClasses, excludeR18Films, forwardTimeInSec, starViewMode',
|
||||
shortcut: 'name, key, desc',
|
||||
star: '++id, [key+ids], site, name, detail, index, rate, hasUpdate',
|
||||
recommandation: '++id, [key+ids], site, name, detail, index, rate, hasUpdate',
|
||||
sites: '++id, key, name, api, download, isActive, group',
|
||||
history: '++id, [site+ids], name, type, year, index, time',
|
||||
mini: 'id, site, ids, name, index, time',
|
||||
@@ -20,6 +21,7 @@ db.on('populate', () => {
|
||||
db.sites.bulkAdd(sites)
|
||||
db.shortcut.bulkAdd(localKey)
|
||||
db.iptv.bulkAdd(iptv)
|
||||
db.recommandation.bulkAdd(recommandations)
|
||||
})
|
||||
|
||||
db.open()
|
||||
|
||||
@@ -7,6 +7,7 @@ import sites from './sites'
|
||||
import search from './search'
|
||||
import iptvSearch from './iptvSearch'
|
||||
import iptv from './iptv'
|
||||
import recommandation from './recommandation'
|
||||
|
||||
export {
|
||||
history,
|
||||
@@ -17,5 +18,6 @@ export {
|
||||
sites,
|
||||
iptv,
|
||||
search,
|
||||
iptvSearch
|
||||
iptvSearch,
|
||||
recommandation
|
||||
}
|
||||
|
||||
28
src/lib/dexie/recommandation.js
Normal file
28
src/lib/dexie/recommandation.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import db from './dexie'
|
||||
const { recommandation } = db
|
||||
export default {
|
||||
async add (doc) {
|
||||
return await recommandation.add(doc)
|
||||
},
|
||||
async bulkAdd (doc) {
|
||||
return await recommandation.bulkAdd(doc)
|
||||
},
|
||||
async find (doc) {
|
||||
return await recommandation.where(doc).first()
|
||||
},
|
||||
async update (id, docs) {
|
||||
return await recommandation.update(id, docs)
|
||||
},
|
||||
async all () {
|
||||
return await recommandation.toArray()
|
||||
},
|
||||
async remove (id) {
|
||||
return await recommandation.delete(id)
|
||||
},
|
||||
async get (id) {
|
||||
return await recommandation.get(id)
|
||||
},
|
||||
async clear () {
|
||||
return await recommandation.clear()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user