mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-05 19:31:21 +08:00
新增更多资源网站, 优化显示结果.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "zy-player",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
|
||||
@@ -43,13 +43,7 @@
|
||||
}
|
||||
}
|
||||
.search-bottom{
|
||||
border-top: 1px solid #dcdee2;
|
||||
.ivu-progress-bg{
|
||||
background-color: #dcdee2;
|
||||
}
|
||||
span{
|
||||
color: #808695;
|
||||
}
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
}
|
||||
.collection{
|
||||
|
||||
29
src/lib/sites.js
Normal file
29
src/lib/sites.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const sites = [
|
||||
{
|
||||
id: 'okzy',
|
||||
name: 'OK资源网',
|
||||
url: 'https://www.okzy.co'
|
||||
},
|
||||
{
|
||||
id: 'zuidazy',
|
||||
name: '最大资源网',
|
||||
url: 'http://www.zuidazy1.com'
|
||||
},
|
||||
{
|
||||
id: 'subo',
|
||||
name: '速播资源站',
|
||||
url: 'https://www.subo988.com'
|
||||
},
|
||||
{
|
||||
id: 'zuixinzy',
|
||||
name: '最新资源网',
|
||||
url: 'http://www.zuixinzy.cc'
|
||||
},
|
||||
{
|
||||
id: '123ku',
|
||||
name: '123资源网',
|
||||
url: 'https://www.123ku.com'
|
||||
}
|
||||
]
|
||||
|
||||
export default sites
|
||||
63
src/lib/util.zy.js
Normal file
63
src/lib/util.zy.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import axios from 'axios'
|
||||
import sites from './sites'
|
||||
const zy = {
|
||||
num: 0,
|
||||
page: 1,
|
||||
key: '',
|
||||
site: {},
|
||||
list: [],
|
||||
getInfoRequire () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const key = encodeURI(this.key)
|
||||
const params = `${this.site.url}/index.php?m=vod-search-pg-${this.page}-wd-${key}.html`
|
||||
axios.get(params).then(res => {
|
||||
this.getInfoHtml(res.data).then(res => {
|
||||
resolve(res)
|
||||
})
|
||||
}).catch(err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
getInfoHtml (txt) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const parser = new DOMParser()
|
||||
const html = parser.parseFromString(txt, 'text/html')
|
||||
const list = html.querySelectorAll('.xing_vb li')
|
||||
let d = {
|
||||
list: [],
|
||||
num: 0
|
||||
}
|
||||
for (let i = 1; i < list.length - 1; i++) {
|
||||
let info = {
|
||||
name: list[i].childNodes[1].innerText,
|
||||
detail: this.site.url + list[i].childNodes[1].childNodes[0].getAttribute('href'),
|
||||
category: list[i].childNodes[3].innerText,
|
||||
time: list[i].childNodes[5].innerText,
|
||||
index: 0,
|
||||
urls: [],
|
||||
check: false
|
||||
}
|
||||
d.list.push(info)
|
||||
}
|
||||
let num = html.querySelectorAll('.nvc dd span')[1].innerText
|
||||
num = parseInt(num)
|
||||
d.num = num
|
||||
resolve(d)
|
||||
})
|
||||
},
|
||||
info (n = 0, p = 1, k = null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.page = p
|
||||
this.key = k
|
||||
this.num = n
|
||||
this.site = sites[this.num]
|
||||
this.getInfoRequire().then(res => {
|
||||
resolve(res)
|
||||
})
|
||||
})
|
||||
},
|
||||
detail () {}
|
||||
}
|
||||
|
||||
export default zy
|
||||
@@ -2,8 +2,8 @@ import Vue from 'vue'
|
||||
import 'view-design/dist/styles/iview.css'
|
||||
import {
|
||||
Layout, Sider, Header, Content, Row, Col,
|
||||
Icon, Button, Input, Progress, Table,
|
||||
Message, Notice
|
||||
Icon, Button, Input, Select, Option, Table,
|
||||
Message, Notice, Page
|
||||
} from 'view-design'
|
||||
|
||||
Vue.component('Layout', Layout)
|
||||
@@ -15,8 +15,10 @@ Vue.component('Col', Col)
|
||||
Vue.component('Icon', Icon)
|
||||
Vue.component('Button', Button)
|
||||
Vue.component('Input', Input)
|
||||
Vue.component('Progress', Progress)
|
||||
Vue.component('Select', Select)
|
||||
Vue.component('Option', Option)
|
||||
Vue.component('Table', Table)
|
||||
Vue.component('Page', Page)
|
||||
|
||||
Vue.prototype.$Message = Message
|
||||
Vue.prototype.$Notice = Notice
|
||||
|
||||
12
src/store.js
12
src/store.js
@@ -6,6 +6,7 @@ Vue.use(Vuex)
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
site: 0,
|
||||
theme: {
|
||||
id: '',
|
||||
color: 'light'
|
||||
@@ -14,6 +15,9 @@ export default new Vuex.Store({
|
||||
video: {}
|
||||
},
|
||||
getters: {
|
||||
getSite: state => {
|
||||
return state.site
|
||||
},
|
||||
getTheme: state => {
|
||||
return state.theme
|
||||
},
|
||||
@@ -25,6 +29,9 @@ export default new Vuex.Store({
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
SET_SITE: (state, payload) => {
|
||||
state.site = payload
|
||||
},
|
||||
SET_THEME: (state, payload) => {
|
||||
state.theme = payload
|
||||
},
|
||||
@@ -40,6 +47,11 @@ export default new Vuex.Store({
|
||||
setting.update(payload.id, { theme: payload.color }).then(res => {
|
||||
commit('SET_THEME', payload)
|
||||
})
|
||||
},
|
||||
changeSite: ({ commit }, payload) => {
|
||||
setting.update(payload.id, { site: payload.site }).then(res => {
|
||||
commit('SET_SITE', payload)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import haku from '@/util/util.666zy'
|
||||
import haku from '@/lib/util.666zy'
|
||||
import { mapMutations } from 'vuex'
|
||||
export default {
|
||||
name: 'detail',
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<script>
|
||||
import 'xgplayer'
|
||||
import Hls from 'xgplayer-hls.js'
|
||||
import haku from '@/util/util.666zy'
|
||||
import haku from '@/lib/util.666zy'
|
||||
export default {
|
||||
name: 'player',
|
||||
data () {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
<template>
|
||||
<div class="search">
|
||||
<div :class="active ? 'search-top haveList': 'search-top'" >
|
||||
<Input class="search-input" v-model.trim="txt" size="large" search placeholder="输入需要搜索的资源名称..." @on-search="searchEvent" @on-focus="searchFocus" />
|
||||
<Input class="search-input" v-model.trim="txt" size="large" search placeholder="输入需要搜索的资源名称..." @on-search="searchEvent" clearable @on-clear="searchClear">
|
||||
<Select slot="prepend" v-model="site" style="width: 120px;">
|
||||
<Option v-for="(i, j) in sites" :key="j" :value="j">{{i.name}}</Option>
|
||||
</Select>
|
||||
<!-- eslint-disable-next-line -->
|
||||
</Input>
|
||||
</div>
|
||||
<div class="search-middle" v-if="active">
|
||||
<Table stripe :columns="columns" :data="data" :loading="loading">
|
||||
@@ -13,23 +18,22 @@
|
||||
</Table>
|
||||
</div>
|
||||
<div class="search-bottom" v-if="active">
|
||||
<Progress class="progress" :percent="percent" status="active" :stroke-width="10">
|
||||
<span class="progress-txt">搜索中</span>
|
||||
</Progress>
|
||||
<Page :total="num" :current.sync="page" :page-size="50" show-total @on-change="onChange" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import db from '@/plugin/nedb/video'
|
||||
import haku from '@/util/util.666zy'
|
||||
import { mapGetters } from 'vuex'
|
||||
import zy from '@/lib/util.zy'
|
||||
import sites from '@/lib/sites'
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
export default {
|
||||
name: 'search',
|
||||
data () {
|
||||
return {
|
||||
sites: sites,
|
||||
txt: '',
|
||||
active: false,
|
||||
percent: 0,
|
||||
columns: [
|
||||
{
|
||||
title: 'Name',
|
||||
@@ -55,24 +59,47 @@ export default {
|
||||
}
|
||||
],
|
||||
data: [],
|
||||
page: 1,
|
||||
num: 0,
|
||||
loading: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['getVideo'])
|
||||
...mapGetters(['getVideo']),
|
||||
...mapGetters({
|
||||
getSite: 'getSite'
|
||||
}),
|
||||
site: {
|
||||
get () {
|
||||
return this.getSite
|
||||
},
|
||||
set (val) {
|
||||
this.SET_SITE(val)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['SET_SITE']),
|
||||
async searchEvent () {
|
||||
if (this.txt !== '') {
|
||||
this.data = await haku.getHtml(this.txt)
|
||||
this.active = true
|
||||
this.loading = true
|
||||
this.page = 1
|
||||
let z = await zy.info(this.site, this.page, this.txt)
|
||||
this.data = z.list
|
||||
this.num = z.num
|
||||
this.loading = false
|
||||
this.percent = 20
|
||||
}
|
||||
},
|
||||
searchFocus () {
|
||||
searchClear () {
|
||||
this.txt = ''
|
||||
this.active = false
|
||||
this.loading = true
|
||||
},
|
||||
async onChange () {
|
||||
let z = await zy.info(this.site, this.page, this.txt)
|
||||
this.data = z.list
|
||||
this.num = z.num
|
||||
},
|
||||
play (e) {
|
||||
if (this.getVideo.detail !== e.detail) {
|
||||
@@ -82,41 +109,46 @@ export default {
|
||||
this.$router.push({ name: 'play' })
|
||||
},
|
||||
async collection (e) {
|
||||
let d = await haku.getDetail(e.detail)
|
||||
let data = {
|
||||
category: e.category,
|
||||
detail: e.detail,
|
||||
name: e.name,
|
||||
time: e.time,
|
||||
type: 'single',
|
||||
index: 0,
|
||||
urls: [],
|
||||
check: false
|
||||
}
|
||||
data.urls = d.urls
|
||||
data.check = true
|
||||
this.$store.commit('SET_VIDEO', data)
|
||||
db.find({ detail: data.detail }).then(res => {
|
||||
if (res.length >= 1) {
|
||||
this.$Notice.warning({
|
||||
title: '资源已存在',
|
||||
backgroud: true
|
||||
})
|
||||
} else {
|
||||
db.add(data).then(res => {
|
||||
this.$Notice.success({
|
||||
title: '收藏成功',
|
||||
backgroud: true
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
console.log(e)
|
||||
// let d = await haku.getDetail(e.detail)
|
||||
// let d = {}
|
||||
// let data = {
|
||||
// category: e.category,
|
||||
// detail: e.detail,
|
||||
// name: e.name,
|
||||
// time: e.time,
|
||||
// type: 'single',
|
||||
// index: 0,
|
||||
// urls: [],
|
||||
// check: false
|
||||
// }
|
||||
// data.urls = d.urls
|
||||
// data.check = true
|
||||
// this.$store.commit('SET_VIDEO', data)
|
||||
// db.find({ detail: data.detail }).then(res => {
|
||||
// if (res.length >= 1) {
|
||||
// this.$Notice.warning({
|
||||
// title: '资源已存在',
|
||||
// backgroud: true
|
||||
// })
|
||||
// } else {
|
||||
// db.add(data).then(res => {
|
||||
// this.$Notice.success({
|
||||
// title: '收藏成功',
|
||||
// backgroud: true
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
},
|
||||
detail (e) {
|
||||
this.$store.commit('SET_VIDEO', e)
|
||||
this.$store.commit('SET_ICON_ACTIVE', 'detail')
|
||||
this.$router.push({ name: 'detail' })
|
||||
}
|
||||
},
|
||||
created () {
|
||||
// this.sites = sites
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -161,7 +193,7 @@ export default {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
width: 100%;
|
||||
height: calc(100% - 80px);
|
||||
height: calc(100% - 120px);
|
||||
padding: 10px;
|
||||
overflow: scroll;
|
||||
&::-webkit-scrollbar { display: none }
|
||||
@@ -180,18 +212,11 @@ export default {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
padding: 0 10px;
|
||||
.progress-txt{
|
||||
font-size: 10px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
.progress{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user