🎎 新增全局监听

This commit is contained in:
hunlongyu
2020-05-20 11:39:46 +08:00
parent f94d00e36c
commit 8c0e35e766
11 changed files with 1960 additions and 1789 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "zy",
"version": "1.0.1",
"version": "1.0.4",
"private": true,
"author": {
"name": "Hunlongyu",

View File

@@ -93,7 +93,7 @@
width: 120px;
}
&.operate{
width: 120px;
width: 170px;
}
}
}
@@ -133,7 +133,7 @@
width: 120px;
}
&.operate{
width: 120px;
width: 170px;
}
}
}

View File

@@ -8,6 +8,7 @@ import {
import path from 'path'
import { autoUpdater } from 'electron-updater'
const isDevelopment = process.env.NODE_ENV !== 'production'
const globalShortcut = require('electron').globalShortcut
let win
let mini
@@ -20,7 +21,7 @@ function createWindow () {
width: 1080,
height: 720,
frame: false,
resizable: false,
resizable: true,
transparent: true,
webPreferences: {
webSecurity: false,
@@ -126,6 +127,32 @@ if (!gotTheLock) {
// 创建 win, 加载应用的其余部分, etc...
app.on('ready', () => {
globalShortcut.register('CommandOrControl+right', function () {
if (win) {
win.webContents.send('next', 0)
}
if (mini) {
mini.webContents.send('next', 0)
}
})
globalShortcut.register('CommandOrControl+left', function () {
if (win) {
win.webContents.send('prev', 0)
}
if (mini) {
mini.webContents.send('prev', 0)
}
})
globalShortcut.register('CommandOrControl+up', function () {
if (mini) {
mini.webContents.send('up', 0)
}
})
globalShortcut.register('CommandOrControl+down', function () {
if (mini) {
mini.webContents.send('down', 0)
}
})
if (!process.env.WEBPACK_DEV_SERVER_URL) {
createProtocol('app')
}

View File

@@ -59,6 +59,7 @@
<span class="btn" @click.stop="playEvent(i)">{{$t('play')}}</span>
<span class="btn" @click.stop="starEvent(i)">{{$t('star')}}</span>
<span class="btn" @click.stop="shareEvent(i)">{{$t('share')}}</span>
<span class="btn" @click.stop="downloadEvent(i)">{{$t('download')}}</span>
</span>
</li>
</ul>
@@ -80,6 +81,7 @@ import { sites, getSite } from '../lib/site/sites'
import tools from '../lib/site/tools'
import video from '../lib/dexie/video'
import setting from '../lib/dexie/setting'
const { clipboard } = require('electron')
export default {
name: 'film',
data () {
@@ -261,6 +263,33 @@ export default {
v: e
}
},
downloadEvent (e) {
tools.detail_get(e.site, e.detail).then(res => {
if (res.mp4_urls.length > 0) {
const urls = [...res.mp4_urls]
let txt = `${e.name}\n`
for (const i of urls) {
const name = i.split('$')[0]
const url = encodeURI(i.split('$')[1])
txt += (name + ': ' + url + '\n')
}
clipboard.writeText(txt)
this.$m.success('〖MP4〗: ' + this.$t('copy_success'))
return false
}
if (res.m3u8_urls.length > 0) {
const urls = [...res.m3u8_urls]
let txt = `${e.name}\n`
for (const i of urls) {
const name = i.split('$')[0]
const url = encodeURI(i.split('$')[1])
txt += (name + ': ' + url + '\n')
}
clipboard.writeText(txt)
this.$m.success('〖M3U8〗: ' + this.$t('copy_success'))
}
})
},
tbPageChange (e) {
this.tb.loading = true
this.tb.page = e
@@ -277,7 +306,7 @@ export default {
</script>
<style lang="scss" scoped>
.film{
height: 670px;
height: calc(100% - 40px);
width: 100%;
display: flex;
flex-direction: column;
@@ -323,7 +352,7 @@ export default {
}
}
.middle{
height: 620px;
height: calc(100% - 40px);
width: 100%;
margin-top: 10px;
padding-bottom: 0px;

View File

@@ -308,6 +308,16 @@ export default {
this.$m.warning(this.$t('last_video'))
}
},
prevEvent () {
const v = { ...this.video }
const i = v.index - 1
if (i > 0) {
this.video.currentTime = 0
this.video.index--
} else {
this.$m.warning(this.$t('first_video'))
}
},
listEvent () {
if (this.right.type === 'list') {
this.right.show = false
@@ -404,13 +414,27 @@ export default {
history.all().then(res => {
this.right.historyData = res
})
ipc.on('next', () => {
if (this.xg) {
if (this.xg.hasStart) {
this.nextEvent()
}
}
})
ipc.on('prev', () => {
if (this.xg) {
if (this.xg.hasStart) {
this.prevEvent()
}
}
})
}
}
</script>
<style lang="scss" scoped>
.play{
position: relative;
height: 660px;
height: calc(100% - 40px);
width: 100%;
display: flex;
justify-content: center;

View File

@@ -174,7 +174,7 @@ export default {
</script>
<style lang="scss" scoped>
.setting{
height: 660px;
height: calc(100% - 40px);
width: 100%;
padding: 20px 0;
.setting-box{

View File

@@ -6,7 +6,7 @@
<span class="type">{{$t('type')}}</span>
<span class="time">{{$t('time')}}</span>
<span class="from">{{$t('from')}}</span>
<span class="operate" style="width: 170px">{{$t('operate')}}</span>
<span class="operate" style="width: 220px">{{$t('operate')}}</span>
</div>
<div class="tBody zy-scroll">
<ul v-show="!loading">
@@ -15,11 +15,12 @@
<span class="type">{{i.type}}</span>
<span class="time">{{i.time}}</span>
<span class="from">{{i.site | ftSite}}</span>
<span class="operate" style="width: 170px">
<span class="operate" style="width: 220px">
<span class="btn" @click.stop="playEvent(i)">{{$t('play')}}</span>
<span class="btn" @click.stop="deleteEvent(i)">{{$t('delete')}}</span>
<span class="btn" @click.stop="shareEvent(i)">{{$t('share')}}</span>
<span class="btn" @click.stop="updateEvent(i)">{{$t('sync')}}</span>
<span class="btn" @click.stop="downloadEvent(i)">{{$t('download')}}</span>
</span>
</li>
</ul>
@@ -38,6 +39,7 @@ import { mapMutations } from 'vuex'
import tools from '../lib/site/tools'
import video from '../lib/dexie/video'
import { sites, getSite } from '../lib/site/sites'
const { clipboard } = require('electron')
export default {
name: 'star',
data () {
@@ -136,6 +138,33 @@ export default {
}
})
},
downloadEvent (e) {
tools.detail_get(e.site, e.detail).then(res => {
if (res.mp4_urls.length > 0) {
const urls = [...res.mp4_urls]
let txt = `${e.name}\n`
for (const i of urls) {
const name = i.split('$')[0]
const url = encodeURI(i.split('$')[1])
txt += (name + ': ' + url + '\n')
}
clipboard.writeText(txt)
this.$m.success('〖MP4〗: ' + this.$t('copy_success'))
return false
}
if (res.m3u8_urls.length > 0) {
const urls = [...res.m3u8_urls]
let txt = `${e.name}\n`
for (const i of urls) {
const name = i.split('$')[0]
const url = encodeURI(i.split('$')[1])
txt += (name + ': ' + url + '\n')
}
clipboard.writeText(txt)
this.$m.success('〖M3U8〗: ' + this.$t('copy_success'))
}
})
},
getAllStar () {
video.all().then(res => {
this.data = res.reverse()
@@ -150,7 +179,7 @@ export default {
</script>
<style lang="scss" scoped>
.star{
height: 660px;
height: calc(100% - 40px);
width: 100%;
display: flex;
flex-direction: column;

View File

@@ -36,6 +36,7 @@
"delete_success": "Delete successful.",
"delete_failed": "Delete failed.",
"star_success": "Collection success.",
"first_video": "This is the first episode.",
"last_video": "This is the last episode.",
"qr_tips": "Long click recognition.",
"zy_tips": "Prohibit the dissemination of illegal resources.",

View File

@@ -36,6 +36,7 @@
"delete_success": "删除成功。",
"delete_failed": "删除失败。",
"star_success": "收藏成功。",
"first_video": "这已经是第一集了。",
"last_video": "这已经是最后一集了。",
"qr_tips": "长按二维码,识别播放。",
"zy_tips": "『ZY Player』技术支持严禁传播违法资源。",

View File

@@ -130,6 +130,9 @@ export default {
}, 10000)
},
prevEvent () {
if (this.index === 0) {
return false
}
history.find({ detail: this.video.detail }).then(res => {
const v = res
v.index--
@@ -144,6 +147,9 @@ export default {
})
},
nextEvent () {
if (this.index >= this.d.m3u8_urls.length - 1) {
return false
}
history.find({ detail: this.video.detail }).then(res => {
const v = res
v.index++
@@ -163,6 +169,32 @@ export default {
},
mounted () {
this.xg = new Hls(this.config)
ipc.on('next', () => {
if (this.xg) {
if (this.xg.hasStart) {
this.nextEvent()
}
}
})
ipc.on('prev', () => {
if (this.xg) {
if (this.xg.hasStart) {
this.prevEvent()
}
}
})
ipc.on('up', () => {
if (this.opacity <= 95) {
this.opacity = this.opacity + 5
this.opacityChange(this.opacity)
}
})
ipc.on('down', () => {
if (this.opacity >= 10) {
this.opacity = this.opacity - 5
this.opacityChange(this.opacity)
}
})
}
}
</script>

3584
yarn.lock

File diff suppressed because it is too large Load Diff