From df82c7cd227f200e962e3748e69c2e797f1e585f Mon Sep 17 00:00:00 2001 From: StarsEnd <53161829+StarsEnd33A2D17@users.noreply.github.com> Date: Tue, 13 Aug 2024 14:28:05 +0800 Subject: [PATCH] feat(ui): add fullscreen button (#2276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(ui): add fullscreen button * fix: fullscreen图标修改,添加exit icon --- src/assets/icons/fullscreen-exit.svg | 3 +++ src/assets/icons/fullscreen.svg | 3 +++ src/views/lyrics.vue | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 src/assets/icons/fullscreen-exit.svg create mode 100644 src/assets/icons/fullscreen.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 new file mode 100644 index 0000000000..e6128c0a70 --- /dev/null +++ b/src/assets/icons/fullscreen.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/views/lyrics.vue b/src/views/lyrics.vue index a46695cc9f..a593fdd458 100644 --- a/src/views/lyrics.vue +++ b/src/views/lyrics.vue @@ -268,6 +268,12 @@ +
+ +
@@ -305,6 +311,7 @@ export default { minimize: true, background: '', date: this.formatTime(new Date()), + isFullscreen: !!document.fullscreenElement, }; }, computed: { @@ -435,6 +442,15 @@ export default { this.getLyric(); this.getCoverColor(); this.initDate(); + document.addEventListener('keydown', e => { + if (e.key === 'F11') { + e.preventDefault(); + this.fullscreen(); + } + }); + document.addEventListener('fullscreenchange', () => { + this.isFullscreen = !!document.fullscreenElement; + }); }, beforeDestroy: function () { if (this.timer) { @@ -466,6 +482,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'));