From 9e2a169347f3616370ab6302b30996b7a583bbd7 Mon Sep 17 00:00:00 2001 From: StarsEnd Date: Mon, 22 Jul 2024 22:51:55 +0800 Subject: [PATCH 1/2] feat(ui): add fullscreen button --- src/assets/icons/fullscreen.svg | 1 + src/views/lyrics.vue | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 src/assets/icons/fullscreen.svg diff --git a/src/assets/icons/fullscreen.svg b/src/assets/icons/fullscreen.svg new file mode 100644 index 0000000000..86751429e8 --- /dev/null +++ b/src/assets/icons/fullscreen.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/lyrics.vue b/src/views/lyrics.vue index a46695cc9f..80b5730b23 100644 --- a/src/views/lyrics.vue +++ b/src/views/lyrics.vue @@ -268,6 +268,11 @@ +
+ +
@@ -435,6 +440,12 @@ export default { this.getLyric(); this.getCoverColor(); this.initDate(); + document.addEventListener('keydown', e => { + if (e.key === 'F11') { + e.preventDefault(); + this.fullscreen(); + } + }); }, beforeDestroy: function () { if (this.timer) { @@ -466,6 +477,13 @@ export default { second.padStart(2, '0') ); }, + fullscreen() { + if (document.fullscreenElement) { + document.exitFullscreen(); + } else { + document.documentElement.requestFullscreen(); + } + }, addToPlaylist() { if (!isAccountLoggedIn()) { this.showToast(locale.t('toast.needToLogin')); From b9e6c22081a6d1dd08a966614534a1dcd1a330aa Mon Sep 17 00:00:00 2001 From: StarsEnd Date: Thu, 8 Aug 2024 03:30:26 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20fullscreen=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E6=B7=BB=E5=8A=A0exit=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/icons/fullscreen-exit.svg | 3 +++ src/assets/icons/fullscreen.svg | 4 +++- src/views/lyrics.vue | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/assets/icons/fullscreen-exit.svg diff --git a/src/assets/icons/fullscreen-exit.svg b/src/assets/icons/fullscreen-exit.svg new file mode 100644 index 0000000000..f76f601e87 --- /dev/null +++ b/src/assets/icons/fullscreen-exit.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/assets/icons/fullscreen.svg b/src/assets/icons/fullscreen.svg index 86751429e8..e6128c0a70 100644 --- a/src/assets/icons/fullscreen.svg +++ b/src/assets/icons/fullscreen.svg @@ -1 +1,3 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/views/lyrics.vue b/src/views/lyrics.vue index 80b5730b23..a593fdd458 100644 --- a/src/views/lyrics.vue +++ b/src/views/lyrics.vue @@ -270,7 +270,8 @@
@@ -310,6 +311,7 @@ export default { minimize: true, background: '', date: this.formatTime(new Date()), + isFullscreen: !!document.fullscreenElement, }; }, computed: { @@ -446,6 +448,9 @@ export default { this.fullscreen(); } }); + document.addEventListener('fullscreenchange', () => { + this.isFullscreen = !!document.fullscreenElement; + }); }, beforeDestroy: function () { if (this.timer) {