手动修正变量定义var

This commit is contained in:
buvta
2021-01-02 15:05:24 +08:00
parent 458144a6ea
commit 2b24ac7d0c
9 changed files with 69 additions and 69 deletions

View File

@@ -173,9 +173,9 @@ export default {
},
getFilters () {
const groups = [...new Set(this.sites.map(site => site.group))]
var filters = []
const filters = []
groups.forEach(g => {
var doc = {
const doc = {
text: g,
value: g
}
@@ -327,8 +327,8 @@ export default {
if (!this.checkSiteKey()) {
return false
}
var randomstring = require('randomstring')
var doc = {
const randomstring = require('randomstring')
const doc = {
key: this.dialogType === 'edit' ? this.siteInfo.key : this.siteInfo.key ? this.siteInfo.key : randomstring.generate(6),
id: this.dialogType === 'edit' ? this.siteInfo.id : this.sites.length ? this.sites[this.sites.length - 1].id + 1 : 1,
name: this.siteInfo.name,
@@ -387,7 +387,7 @@ export default {
remote.dialog.showOpenDialog(options).then(result => {
if (!result.canceled) {
result.filePaths.forEach(file => {
var str = fs.readFileSync(file)
const str = fs.readFileSync(file)
const json = JSON.parse(str)
json.forEach(ele => {
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) {
@@ -436,7 +436,7 @@ export default {
sites.add(row)
},
resetId (inArray) {
var id = 1
let id = 1
inArray.forEach(ele => {
ele.id = id
id += 1
@@ -446,7 +446,7 @@ export default {
// 因为el-table的数据是单向绑定,我们先同步el-table里的数据和其绑定的数据
this.syncTableData()
sites.clear().then(res => {
var id = 1
let id = 1
this.sites.forEach(ele => {
ele.id = id
id += 1
@@ -467,7 +467,7 @@ export default {
return false
}
const tbody = document.getElementById('sites-table').querySelector('.el-table__body-wrapper tbody')
var _this = this
const _this = this
Sortable.create(tbody, {
onEnd ({ newIndex, oldIndex }) {
const currRow = _this.sites.splice(oldIndex, 1)[0]

View File

@@ -544,7 +544,7 @@ export default {
return a.localeCompare(b, 'zh')
},
dateFormat (row, column) {
var date = row[column.property]
const date = row[column.property]
if (date === undefined) {
return ''
}
@@ -620,7 +620,7 @@ export default {
// 屏蔽主分类
const classToHide = ['电影', '电影片', '电视剧', '连续剧', '综艺', '动漫']
zy.class(key).then(res => {
var allClass = [{ name: '最新', tid: 0 }]
const allClass = [{ name: '最新', tid: 0 }]
res.class.forEach(element => {
if (!this.setting.excludeRootClasses || !classToHide.includes(element.name)) {
if (this.setting.excludeR18Films) {
@@ -640,7 +640,7 @@ export default {
})
},
containsR18Keywords (name) {
var containKeyWord = false
const containKeyWord = false
if (!name) {
return containKeyWord
}
@@ -656,7 +656,7 @@ export default {
infiniteHandler ($state) {
const key = this.site.key
const typeTid = this.type.tid
var page = this.pagecount
let page = this.pagecount
if (this.toFlipPagecount()) {
page = this.totalpagecount - this.pagecount + 1
}
@@ -759,8 +759,8 @@ export default {
})
},
querySearch (queryString, cb) {
var searchList = this.searchList.slice(0, -1)
var results = queryString ? searchList.filter(this.createFilter(queryString)) : this.searchList
const searchList = this.searchList.slice(0, -1)
const results = queryString ? searchList.filter(this.createFilter(queryString)) : this.searchList
// 调用 callback 返回建议列表的数据
cb(results)
},

View File

@@ -277,7 +277,7 @@ export default {
remote.dialog.showOpenDialog(options).then(result => {
if (!result.canceled) {
result.filePaths.forEach(file => {
var str = fs.readFileSync(file)
const str = fs.readFileSync(file)
const json = JSON.parse(str)
history.bulkAdd(json).then(res => {
this.$message.success('导入成功')
@@ -298,7 +298,7 @@ export default {
})
},
getSiteName (key) {
var site = this.sites.find(e => e.key === key)
const site = this.sites.find(e => e.key === key)
if (site) {
return site.name
}
@@ -312,7 +312,7 @@ export default {
},
updateDatabase () {
history.clear().then(res => {
var id = length
let id = length
this.history.forEach(ele => {
ele.id = id
id -= 1

View File

@@ -168,9 +168,9 @@ export default {
},
getFilters () {
const groups = [...new Set(this.channelList.map(iptv => iptv.group))]
var filters = []
const filters = []
groups.forEach(g => {
var doc = {
const doc = {
text: g,
value: g
}
@@ -257,7 +257,7 @@ export default {
},
mergeChannel () {
if (this.inputContent && this.multipleSelection.length) {
var channels = []
let channels = []
const id = this.multipleSelection[0].id
this.multipleSelection.forEach(ele => {
channels = channels.concat(ele.channels)
@@ -320,7 +320,7 @@ export default {
remote.dialog.showSaveDialog(options).then(result => {
if (!result.canceled) {
if (result.filePath.endsWith('m3u')) {
var writer = require('m3u').extendedWriter()
const writer = require('m3u').extendedWriter()
this.iptvList.forEach(e => {
writer.file(e.url, -1, e.name)
})
@@ -364,7 +364,7 @@ export default {
const urls = ele.url.split('#').filter(e => e.startsWith('http')) // 网址带#时自动分割
urls.forEach(url => {
if (ele.name && url && new URL.URL(url).pathname.endsWith('.m3u8')) { // 网址可能带参数
var doc = {
const doc = {
id: id,
name: ele.name,
url: url,
@@ -438,12 +438,12 @@ export default {
res = res.filter(o => !this.iptvList.find(e => o.url === e.url))
const resClone = JSON.parse(JSON.stringify(res))
const uniqueChannelName = {}
for (var i = 0; i < resClone.length; i++) {
var channelName = resClone[i].name.trim().replace(/[- ]?(1080p|蓝光|超清|高清|标清|hd|cq|4k)(\d{1,2})?$/i, '')
for (let i = 0; i < resClone.length; i++) {
let channelName = resClone[i].name.trim().replace(/[- ]?(1080p|蓝光|超清|高清|标清|hd|cq|4k)(\d{1,2})?$/i, '')
if (channelName.match(/cctv/i)) channelName = channelName.replace('-', '')
if (Object.keys(uniqueChannelName).some(name => channelName.match(new RegExp(`${name}(1080p|4k|(?!\\d))`, 'i')))) continue // 避免重复
const matchRule = new RegExp(`${channelName}(1080p|4k|(?!\\d))`, 'i')
for (var j = i; j < resClone.length; j++) {
for (let j = i; j < resClone.length; j++) {
if (resClone[j].name.match(/cctv/i)) {
resClone[j].name = resClone[j].name.replace('-', '')
}
@@ -513,7 +513,7 @@ export default {
})
},
resetId (channelList) {
var id = 1
let id = 1
channelList.forEach(ele => {
ele.id = id
id += 1
@@ -575,7 +575,7 @@ export default {
})
},
async checkChannelsBySite (channels) {
var siteList = {}
const siteList = {}
channels.forEach(channel => {
const site = channel.url.split('/')[2]
if (siteList[site]) {

View File

@@ -544,7 +544,7 @@ export default {
const index = this.video.info.index || 0
const db = await history.find({ site: this.video.key, ids: this.video.info.id })
const key = this.video.key + '@' + this.video.info.id
var time = this.video.info.time
let time = this.video.info.time
this.xg.removeAllProgressDot()
this.startPosition = { min: '00', sec: '00' }
this.endPosition = { min: '00', sec: '00' }
@@ -620,14 +620,14 @@ export default {
this.isLive = false
this.exportablePlaylist = false
this.fetchPlaylist().then(async (fullList) => {
var playlist = fullList[0].list // ZY支持的已移到首位
let playlist = fullList[0].list // ZY支持的已移到首位
// 如果设定了特定的video flag, 获取该flag下的视频列表
const videoFlag = this.video.info.videoFlag
if (videoFlag) {
playlist = fullList.find(x => x.flag === videoFlag).list
}
this.right.list = playlist
var url = playlist[index].split('$')[1]
const url = playlist[index].split('$')[1]
if (playlist.every(e => e.split('$')[1].endsWith('.m3u8'))) this.exportablePlaylist = true
if (!url.endsWith('.m3u8') && !url.endsWith('.mp4')) {
const currentSite = await sites.find({ key: this.video.key })
@@ -776,9 +776,9 @@ export default {
},
prevEvent () {
if (this.video.iptv) {
var index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID)
const index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID)
if (index >= 1) {
var channel = this.channelList[index - 1]
const channel = this.channelList[index - 1]
this.playChannel(channel)
} else {
this.$message.warning('这已经是第一个频道了。')
@@ -794,9 +794,9 @@ export default {
},
nextEvent () {
if (this.video.iptv) {
var index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID)
const index = this.channelList.findIndex(obj => obj.id === this.video.iptv.channelID)
if (index < (this.channelList.length - 1)) {
var channel = this.channelList[index + 1]
const channel = this.channelList[index + 1]
this.playChannel(channel)
} else {
this.$message.warning('这已经是最后一个频道了。')
@@ -945,7 +945,7 @@ export default {
this.$message.error('请设置第三方播放器路径')
// 在线播放该视频
if (playlistUrls[this.video.info.index].endsWith('.m3u8')) {
var link = 'https://www.m3u8play.com/?play=' + playlistUrls[this.video.info.index]
const link = 'https://www.m3u8play.com/?play=' + playlistUrls[this.video.info.index]
const open = require('open')
open(link)
}
@@ -968,11 +968,11 @@ export default {
const path = require('path')
const os = require('os')
const fs = require('fs')
var filePath = path.join(os.tmpdir(), fileName + '.m3u')
const filePath = path.join(os.tmpdir(), fileName + '.m3u')
if (fs.existsSync(filePath)) {
fs.unlinkSync(filePath)
}
var str = '#EXTM3U' + os.EOL
let str = '#EXTM3U' + os.EOL
for (let ind = startIndex; ind < m3u8Arr.length; ind++) {
str += `#EXTINF: -1, 第${ind + 1}` + os.EOL
str += m3u8Arr[ind] + os.EOL
@@ -1037,7 +1037,7 @@ export default {
},
listItemEvent (n) {
if (this.video.iptv) {
var channel = this.channelList[n]
const channel = this.channelList[n]
// 是直播源,直接播放
this.playChannel(channel)
} else {
@@ -1399,7 +1399,7 @@ export default {
this.channelTree = []
const groups = [...new Set(this.channelList.map(iptv => iptv.group))]
groups.forEach(g => {
var doc = {
const doc = {
label: g,
children: this.channelList.filter(x => x.group === g).map(i => { return { label: i.name, channel: i } })
}
@@ -1486,7 +1486,7 @@ export default {
this.videoStop()
return
}
var historyItem = this.right.history[0]
const historyItem = this.right.history[0]
this.video = { key: historyItem.site, info: { id: historyItem.ids, name: historyItem.name, index: historyItem.index } }
} else if (this.video.iptv && !this.isLive) {
this.playChannel(this.video.iptv)

View File

@@ -190,7 +190,7 @@ export default {
}
},
filteredRecommendations () {
var filteredData = this.recommendations.filter(x => (this.selectedAreas.length === 0) || this.selectedAreas.includes(x.detail.area))
let filteredData = this.recommendations.filter(x => (this.selectedAreas.length === 0) || this.selectedAreas.includes(x.detail.area))
filteredData = filteredData.filter(x => (this.selectedTypes.length === 0) || this.selectedTypes.includes(x.detail.type))
return filteredData
}

View File

@@ -333,7 +333,7 @@ export default {
}
remote.dialog.showOpenDialog(options).then(result => {
if (!result.canceled) {
var playerPath = result.filePaths[0].replace(/\\/g, '/')
const playerPath = result.filePaths[0].replace(/\\/g, '/')
this.$message.success('设定第三方播放器路径为:' + result.filePaths[0])
this.d.externalPlayer = playerPath
this.updateSettingEvent()

View File

@@ -331,7 +331,7 @@ export default {
star.get(e.id).then(resStar => {
if (!e.hasUpdate && e.detail.last !== doc.detail.last) {
doc.hasUpdate = true
var msg = `同步"${e.name}"成功, 检查到更新。`
const msg = `同步"${e.name}"成功, 检查到更新。`
this.$message.success(msg)
} else {
this.numNoUpdate += 1
@@ -340,7 +340,7 @@ export default {
this.getFavorites()
})
} catch (err) {
var msg = `同步"${e.name}"失败, 请重试`
const msg = `同步"${e.name}"失败, 请重试`
this.$message.warning(msg, err)
}
},
@@ -365,7 +365,7 @@ export default {
if (row.site) {
return row.site.name
} else {
var site = this.sites.find(e => e.key === row.key)
const site = this.sites.find(e => e.key === row.key)
if (site) {
return site.name
}
@@ -417,10 +417,10 @@ export default {
}
remote.dialog.showOpenDialog(options).then(result => {
if (!result.canceled) {
var starList = Array.from(this.list)
var id = this.list.length + 1
const starList = Array.from(this.list)
let id = this.list.length + 1
result.filePaths.forEach(file => {
var str = fs.readFileSync(file)
const str = fs.readFileSync(file)
const json = JSON.parse(str)
json.reverse().forEach(ele => {
const starExists = starList.some(x => x.key === ele.key && x.ids === ele.ids)
@@ -435,7 +435,7 @@ export default {
last: ele.last,
note: ele.note
}
var doc = {
const doc = {
id: id,
key: ele.key,
ids: ele.ids,
@@ -468,7 +468,7 @@ export default {
updateDatabase () {
this.syncTableData()
star.clear().then(res => {
var id = this.list.length
let id = this.list.length
this.list.forEach(ele => {
ele.id = id
id -= 1

View File

@@ -7,12 +7,12 @@ import { Parser as M3u8Parser } from 'm3u8-parser'
// axios使用系统代理 https://evandontje.com/2020/04/02/automatic-system-proxy-configuration-for-electron-applications/
// xgplayer使用chromium代理设置浏览器又默认使用系统代理 https://www.chromium.org/developers/design-documents/network-settings
// 要在设置中添加代理设置可参考https://stackoverflow.com/questions/37393248/how-connect-to-proxy-in-electron-webview
var http = require('http')
var https = require('http')
const http = require('http')
const https = require('http')
const { remote } = require('electron')
var win = remote.getCurrentWindow()
var session = win.webContents.session
var ElectronProxyAgent = require('electron-proxy-agent')
const win = remote.getCurrentWindow()
const session = win.webContents.session
const ElectronProxyAgent = require('electron-proxy-agent')
// 请求超时时限
// axios.defaults.timeout = 10000 // 可能使用代理,增长超时
@@ -42,7 +42,7 @@ axios.interceptors.response.use(function (response) {
}, function (err) { // 请求错误时做些事
// 请求超时的之后,抛出 err.code = ECONNABORTED的错误..错误信息是 timeout of xxx ms exceeded
if (err.code === 'ECONNABORTED' && err.message.indexOf('timeout') !== -1) {
var config = err.config
const config = err.config
config.__retryCount = config.__retryCount || 0
if (config.__retryCount >= config.retry) {
@@ -52,7 +52,7 @@ axios.interceptors.response.use(function (response) {
config.__retryCount += 1
var backoff = new Promise(function (resolve) {
const backoff = new Promise(function (resolve) {
setTimeout(function () {
resolve()
}, config.retryDelay || 1)
@@ -204,7 +204,7 @@ const zy = {
this.getSite(key).then(res => {
const site = res
wd = encodeURI(wd)
var url = `${site.api}?wd=${wd}`
const url = `${site.api}?wd=${wd}`
axios.post(url, { timeout: 3000 }).then(res => {
const data = res.data
const json = parser.parse(data, this.xmlConfig)
@@ -237,7 +237,7 @@ const zy = {
const jsondata = json.rss === undefined ? json : json.rss
const videoList = jsondata.list.video
// Parse video lists
var fullList = []
let fullList = []
let index = 0
const supportedFormats = ['m3u8', 'mp4']
const dd = videoList.dl.dd
@@ -370,10 +370,10 @@ const zy = {
return new Promise((resolve, reject) => {
axios.get(channel).then(res => {
const manifest = res.data
var parser = new M3u8Parser()
const parser = new M3u8Parser()
parser.push(manifest)
parser.end()
var parsedManifest = parser.manifest
const parsedManifest = parser.manifest
if (parsedManifest.segments.length) {
resolve(true)
} else {
@@ -393,16 +393,16 @@ const zy = {
doubanLink (name, year) {
return new Promise((resolve, reject) => {
// 豆瓣搜索链接
var nameToSearch = name.replace(/\s/g, '')
var doubanSearchLink = 'https://www.douban.com/search?q=' + nameToSearch
const nameToSearch = name.replace(/\s/g, '')
const doubanSearchLink = 'https://www.douban.com/search?q=' + nameToSearch
axios.get(doubanSearchLink).then(res => {
const $ = cheerio.load(res.data)
// 查询所有搜索结果, 看名字和年代是否相符
var link = ''
let link = ''
$('div.result').each(function () {
var linkInDouban = $(this).find('div>div>h3>a').first()
var nameInDouban = linkInDouban.text().replace(/\s/g, '')
var subjectCast = $(this).find('span.subject-cast').text()
const linkInDouban = $(this).find('div>div>h3>a').first()
const nameInDouban = linkInDouban.text().replace(/\s/g, '')
const subjectCast = $(this).find('span.subject-cast').text()
if (nameToSearch === nameInDouban && subjectCast && subjectCast.includes(year)) {
link = linkInDouban.attr('href')
}
@@ -426,14 +426,14 @@ const zy = {
*/
doubanRate (name, year) {
return new Promise((resolve, reject) => {
var nameToSearch = name.replace(/\s/g, '')
const nameToSearch = name.replace(/\s/g, '')
this.doubanLink(nameToSearch, year).then(link => {
if (link.includes('https://www.douban.com/search')) {
resolve('暂无评分')
} else {
axios.get(link).then(response => {
const parsedHtml = cheerio.load(response.data)
var rating = parsedHtml('body').find('#interest_sectl').first().find('strong').first()
const rating = parsedHtml('body').find('#interest_sectl').first().find('strong').first()
if (rating.text()) {
resolve(rating.text().replace(/\s/g, ''))
} else {