Merge pull request #343 from Hunlongyu/buvta

增加代理及直播源检测功能
This commit is contained in:
buvta
2020-11-08 18:03:52 +08:00
committed by GitHub
6 changed files with 104 additions and 82 deletions

View File

@@ -6,21 +6,22 @@
<el-button @click="addSite" icon="el-icon-document-add">新增</el-button>
<el-button @click="exportSites" icon="el-icon-upload2" >导出</el-button>
<el-button @click="importSites" icon="el-icon-download">导入</el-button>
<el-button @click="checkAllSite" icon="el-icon-refresh" :loading="checkAllSiteLoading">检测</el-button>
<el-button @click="removeAllSites" icon="el-icon-delete-solid">清空</el-button>
<el-button @click="checkAllSite" icon="el-icon-refresh" :loading="checkAllSitesLoading">检测{{ this.checkAllSitesLoading ? this.checkProgress + '/' + this.sites.length : '' }}</el-button>
<el-button @click="resetSitesEvent" icon="el-icon-refresh-left">重置</el-button>
</div>
<div class="listpage-header" v-show="enableBatchEdit">
<el-switch v-model="enableBatchEdit" active-text="批处理分组"></el-switch>
<el-input placeholder="新组名" v-model="batchGroupName"></el-input>
<el-switch v-model="batchIsActive" :active-value="1" :inactive-value="0" active-text="启用"></el-switch>
<el-switch v-model="batchIsActive" active-text="启用"></el-switch>
<el-button type="primary" icon="el-icon-edit" @click.stop="saveBatchEdit">保存</el-button>
<el-button @click="removeSelectedSites" icon="el-icon-delete-solid">删除</el-button>
</div>
<div class="listpage-body" id="sites-body">
<div class="show-table" id="sites-table">
<el-table size="mini" fit height="100%" row-key="id"
ref="editSitesTable"
:data="sites"
@select="selectionCellClick"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange">
<el-table-column
@@ -33,13 +34,14 @@
</el-table-column>
<el-table-column
prop="isActive"
width="120"
:filters = "[{text:'启用', value: true}, {text:'停用', value: false}]"
:filter-method="(value, row) => value === row.isActive"
label="启用">
<template slot-scope="scope">
<el-switch
v-model="scope.row.isActive"
:active-value="1"
:inactive-value="0"
@change='isActiveChangeEvent(scope.row)'>
@click.native.stop='isActiveChangeEvent(scope.row)'>
</el-switch>
</template>
</el-table-column>
@@ -47,7 +49,7 @@
prop="group"
label="分组"
:filters="getFilters"
:filter-method="filterHandle"
:filter-method="(value, row) => value === row.group"
filter-placement="bottom-end">
</el-table-column>
<el-table-column
@@ -71,7 +73,7 @@
<el-button size="mini" @click.stop="moveToTopEvent(scope.row)" type="text">置顶</el-button>
<el-button size="mini" @click.stop="editSite(scope.row)" type="text">编辑</el-button>
<!-- 检测时先强制批量检测一遍,如果不强制直接单个检测时第一次不会显示“检测中” -->
<el-button size="mini" v-if="sites.every(site => site.status)" v-show="!checkAllSiteLoading" @click.stop="checkSingleSite(scope.row)" type="text">检测</el-button>
<el-button size="mini" v-if="sites.every(site => site.status)" v-show="!checkAllSitesLoading" @click.stop="checkSingleSite(scope.row)" type="text">检测</el-button>
<el-button size="mini" @click.stop="removeEvent(scope.row)" type="text">删除</el-button>
</template>
</el-table-column>
@@ -131,7 +133,7 @@ export default {
api: '',
download: '',
group: '',
isActive: 1
isActive: true
},
siteGroup: [],
rules: {
@@ -144,9 +146,14 @@ export default {
},
enableBatchEdit: false,
batchGroupName: '',
batchIsActive: 1,
batchIsActive: true,
shiftDown: false,
selectionBegin: '',
selectionEnd: '',
multipleSelection: [],
checkAllSiteLoading: false,
checkAllSitesLoading: false,
checkProgress: 0,
stopFlag: false,
editOldkey: ''
}
},
@@ -159,14 +166,6 @@ export default {
this.SET_SETTING(val)
}
},
editSites: {
get () {
return this.$store.getters.getEditSites
},
set (val) {
this.SET_EDITSITES(val)
}
},
getFilters () {
const groups = [...new Set(this.sites.map(site => site.group))]
var filters = []
@@ -180,21 +179,48 @@ export default {
return filters
}
},
watch: {
enableBatchEdit () {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
this.enableBatchEdit = false
}
}
},
methods: {
...mapMutations(['SET_SETTING', 'SET_EDITSITES']),
...mapMutations(['SET_SETTING']),
excludeR18FilmsChangeEvent () {
setting.find().then(res => {
res.excludeR18Films = this.setting.excludeR18Films
setting.update(res)
})
},
filterHandle (value, row) {
return row.group === value
selectionCellClick (selection, row) {
if (this.shiftDown && this.selectionBegin !== '' && selection.includes(row)) {
this.selectionEnd = row.id
const start = Math.min(this.selectionBegin, this.selectionEnd) - 1
const end = Math.max(this.selectionBegin, this.selectionEnd)
const selections = this.sites.slice(start, end)
this.$nextTick(() => {
selections.forEach(e => this.$refs.editSitesTable.toggleRowSelection(e, true))
})
this.selectionBegin = this.selectionEnd = ''
return
}
if (selection.includes(row)) {
this.selectionBegin = row.id
} else {
this.selectionBegin = ''
}
},
handleSelectionChange (rows) {
this.multipleSelection = rows
},
handleSortChange (column, prop, order) {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
this.updateDatabase(this.sites)
},
saveBatchEdit () {
@@ -208,10 +234,12 @@ export default {
},
getSites () {
sites.all().then(res => {
res.forEach(ele => {
if (ele.isActive === undefined) {
ele.isActive = true
}
})
this.sites = res
this.editSites = {
sites: res
}
})
},
getSitesGroup () {
@@ -224,6 +252,10 @@ export default {
this.siteGroup = arr
},
addSite () {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
this.getSitesGroup()
this.dialogType = 'new'
this.dialogVisible = true
@@ -233,15 +265,15 @@ export default {
api: '',
download: '',
group: '',
isActive: 1
isActive: true
}
},
editSite (siteInfo) {
this.getSitesGroup()
if (this.checkAllSiteLoading) {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
this.getSitesGroup()
this.dialogType = 'edit'
this.dialogVisible = true
this.siteInfo = siteInfo
@@ -252,7 +284,7 @@ export default {
this.getSites()
},
removeEvent (e) {
if (this.checkAllSiteLoading) {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
@@ -329,6 +361,10 @@ export default {
})
},
importSites () {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
const options = {
filters: [
{ name: 'JSON file', extensions: ['json'] },
@@ -346,7 +382,7 @@ export default {
if (ele.api && this.sites.filter(x => x.key === ele.key).length === 0 && this.sites.filter(x => x.name === ele.name && x.api === ele.api).length === 0) {
// 不含该key 同时也不含名字和url一样的
if (ele.isActive === undefined) {
ele.isActive = 1
ele.isActive = true
}
if (ele.group === undefined) {
ele.group = '导入'
@@ -363,11 +399,16 @@ export default {
})
},
resetSitesEvent () {
this.stopFlag = true
if (this.checkAllSitesLoading) {
this.$message.info('部分检测还未完全终止, 请稍等...')
return
}
sites.clear().then(sites.bulkAdd(defaultSites).then(this.getSites()))
this.$message.success('重置源成功')
},
moveToTopEvent (i) {
if (this.checkAllSiteLoading) {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
@@ -375,7 +416,7 @@ export default {
this.updateDatabase()
},
syncTableData () {
if (this.$refs.editSitesTable.tableData && this.$refs.editSitesTable.tableData.length === this.sites.length) {
if (this.$refs.editSitesTable.tableData) {
this.sites = this.$refs.editSitesTable.tableData
}
},
@@ -402,10 +443,18 @@ export default {
sites.bulkAdd(this.sites).then(this.getSites())
})
},
removeAllSites () {
sites.clear().then(this.getSites())
removeSelectedSites () {
this.multipleSelection.forEach(e => sites.remove(e.id))
this.$refs.editSitesTable.clearFilter()
this.getSites()
this.updateDatabase()
this.enableBatchEdit = false
},
rowDrop () {
if (this.checkAllSitesLoading) {
this.$message.info('正在检测, 请勿操作.')
return false
}
const tbody = document.getElementById('sites-table').querySelector('.el-table__body-wrapper tbody')
var _this = this
Sortable.create(tbody, {
@@ -417,20 +466,30 @@ export default {
})
},
async checkAllSite () {
this.checkAllSiteLoading = true
Promise.all(this.sites.map(site => this.checkSingleSite(site))).then(res => {
this.checkAllSiteLoading = false
this.checkAllSitesLoading = true
this.stopFlag = false
this.checkProgress = 0
const uncheckedList = this.sites.filter(e => e.status === undefined || e.status === ' ') // 未检测过的优先
const other = this.sites.filter(e => !uncheckedList.includes(e))
await Promise.all(uncheckedList.map(site => this.checkSingleSite(site)))
await Promise.all(other.map(site => this.checkSingleSite(site))).then(res => {
this.checkAllSitesLoading = false
this.getSites()
})
},
async checkSingleSite (row) {
row.status = ' '
if (this.stopFlag) {
this.checkProgress += 1
return row.status
}
const flag = await zy.check(row.key)
this.checkProgress += 1
if (flag) {
row.status = '可用'
} else {
row.status = '失效'
row.isActive = 0
row.isActive = false
}
sites.remove(row.id)
sites.add(row)
@@ -439,6 +498,8 @@ export default {
},
mounted () {
this.rowDrop()
addEventListener('keydown', code => { if (code.keyCode === 16) this.shiftDown = true })
addEventListener('keyup', code => { if (code.keyCode === 16) this.shiftDown = false })
},
created () {
this.getSites()

View File

@@ -45,7 +45,7 @@
prop="isActive"
width="120"
align="center"
:filters = "[{text:'启用', value: 1}, {text:'停用', value: 0}]"
:filters = "[{text:'启用', value: true}, {text:'停用', value: false}]"
:filter-method="(value, row) => value === row.isActive"
label="启用">
<template slot-scope="scope">

View File

@@ -1051,7 +1051,7 @@ export default {
},
getIptvList () {
iptv.all().then(res => {
this.iptvList = res
this.iptvList = res.filter(e => e.isActive)
})
},
bindEvent () {

View File

@@ -174,7 +174,6 @@ export default {
data () {
return {
pkg: pkg,
sitesList: [],
shortcutList: [],
show: {
site: false,
@@ -206,18 +205,10 @@ export default {
set (val) {
this.SET_SETTING(val)
}
},
editSites: {
get () {
return this.$store.getters.getEditSites
},
set (val) {
this.SET_EDITSITES(val)
}
}
},
methods: {
...mapMutations(['SET_SETTING', 'SET_VIEW', 'SET_EDITSITES']),
...mapMutations(['SET_SETTING', 'SET_VIEW']),
linkOpen (e) {
shell.openExternal(e)
},
@@ -232,11 +223,6 @@ export default {
if (res.length <= 0) {
this.$message.warning('检测到视频源未能正常加载, 即将重置源.')
sites.clear().then(sites.bulkAdd(defaultSites).then(this.getSites()))
} else {
this.sitesList = res
this.editSites = {
sites: res
}
}
})
},

View File

@@ -1667,4 +1667,4 @@
"url": "https://www.fanmingming.cn/hls/fhzw.m3u8",
"group": "港澳台"
}
]
]

View File

@@ -5,7 +5,6 @@
"name": "麻花资源",
"api": "https://www.mhapi123.com/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -14,7 +13,6 @@
"name": "速播资源站",
"api": "https://www.subo988.com/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -32,7 +30,6 @@
"name": "1886 资源",
"api": "http://cj.1886zy.co/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -41,7 +38,6 @@
"name": "88 影视资源站",
"api": "http://www.88zyw.net/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -59,7 +55,6 @@
"name": "秒播资源",
"api": "http://caiji.mb77.vip/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -68,7 +63,6 @@
"name": "最大资源网",
"api": "http://www.zdziyuan.com/inc/api.php",
"download": "http://www.zdziyuan.com/inc/apidown.php",
"isActive": 1,
"group": "默认"
},
{
@@ -77,7 +71,6 @@
"name": "123 资源",
"api": "http://cj.123ku2.com:12315/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -86,7 +79,6 @@
"name": "OK 资源网",
"api": "http://cj.okzy.tv/inc/api.php",
"download": "http://cj.okzy.tv/inc/apidown.php",
"isActive": 1,
"group": "默认"
},
{
@@ -95,7 +87,6 @@
"name": "酷云资源",
"api": "http://caiji.kuyun98.com/inc/ldg_api.php",
"download": "http://caiji.kuyun98.com/inc/apidown.php",
"isActive": 1,
"group": "默认"
},
{
@@ -104,7 +95,6 @@
"name": "最新资源",
"api": "http://api.zuixinapi.com/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -113,7 +103,6 @@
"name": "酷播资源",
"api": "http://api.kbzyapi.com/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -122,7 +111,6 @@
"name": "永久资源",
"api": "http://cj.yongjiuzyw.com/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -131,7 +119,6 @@
"name": "人人资源",
"api": "https://www.rrzyw.cc/api.php/provide/vod/from/rrm3u8/at/xml/",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -140,7 +127,6 @@
"name": "步步高顶尖资源网",
"api": "http://api.bbkdj.com/api",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -149,7 +135,6 @@
"name": "搜乐资源网",
"api": "https://www.caijizy.vip/api.php/provide/vod/at/xml/",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -158,7 +143,6 @@
"name": "605资源",
"api": "http://www.605zy.net/inc/seacmsapi.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -167,7 +151,6 @@
"name": "豆瓣电影资源",
"api": "http://v.1988cj.com/inc/api.php",
"download": "http://v.1988cj.com/inc/apidown.php",
"isActive": 1,
"group": "默认"
},
{
@@ -176,7 +159,6 @@
"name": "135 资源网",
"api": "http://cj.zycjw1.com/inc/api.php",
"download": "http://cj.zycjw1.com/inc/apidown.php",
"isActive": 1,
"group": "默认"
},
{
@@ -185,7 +167,6 @@
"name": "芒果 TV 资源网",
"api": "https://api.shijiapi.com/api.php/provide/vod/at/xml/",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -194,7 +175,6 @@
"name": "209 资源",
"api": "http://cj.1156zy.com/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -203,7 +183,6 @@
"name": "快快资源",
"api": "https://api.kkzy.tv/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -212,7 +191,6 @@
"name": "卧龙资源",
"api": "http://cj.wlzy.tv/inc/api_mac.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -221,7 +199,6 @@
"name": "魔卡资源网",
"api": "https://cj.heiyap.com/api.php/provide/vod/at/xml/",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -230,7 +207,6 @@
"name": "壹伍捌资源网",
"api": "http://cj.158zyz.net:158/inc/api.php",
"download": "",
"isActive": 1,
"group": "默认"
},
{
@@ -239,7 +215,6 @@
"name": "快影资源站",
"api": "https://www.kyzy.tv/api.php/kyyun/vod/at/xml/",
"download": "",
"isActive": 1,
"group": "默认"
}
]
]