mirror of
https://github.com/Av0idD4rk/packmate.git
synced 2026-10-23 21:42:06 +00:00
Добавил хоткей для навигации между стримами
This commit is contained in:
parent
829595264d
commit
918c7ca85a
@ -28,6 +28,33 @@ export default {
|
|||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
streams: [],
|
streams: [],
|
||||||
|
navigationKeysCallback: (e) => {
|
||||||
|
if (e.key === 'ArrowUp') {
|
||||||
|
e.preventDefault();
|
||||||
|
const index = this.$data.streams.findIndex(e => e.id === this.$props.streamId);
|
||||||
|
const newStream = this.$data.streams[index - 1];
|
||||||
|
if (!newStream) return;
|
||||||
|
const newId = newStream.id;
|
||||||
|
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}});
|
||||||
|
} else if (e.key === 'ArrowDown') {
|
||||||
|
e.preventDefault();
|
||||||
|
const index = this.$data.streams.findIndex(e => e.id === this.$props.streamId);
|
||||||
|
const newStream = this.$data.streams[index + 1];
|
||||||
|
if (!newStream) return;
|
||||||
|
const newId = newStream.id;
|
||||||
|
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}});
|
||||||
|
} else if (e.key === 'Home') {
|
||||||
|
const newStream = this.$data.streams[0];
|
||||||
|
if (!newStream) return;
|
||||||
|
const newId = newStream.id;
|
||||||
|
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}});
|
||||||
|
} else if (e.key === 'End') {
|
||||||
|
const newStream = this.$data.streams[this.$data.streams.length - 1];
|
||||||
|
if (!newStream) return;
|
||||||
|
const newId = newStream.id;
|
||||||
|
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}});
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -85,6 +112,12 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {Stream, InfiniteLoading,},
|
components: {Stream, InfiniteLoading,},
|
||||||
|
mounted() {
|
||||||
|
document.addEventListener('keyup', this.$data.navigationKeysCallback);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
document.removeEventListener('keyup', this.$data.navigationKeysCallback);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user