mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat(ui): add fullscreen button (#2276)
* feat(ui): add fullscreen button * fix: fullscreen图标修改,添加exit icon
This commit is contained in:
parent
bd5af9c721
commit
df82c7cd22
3 changed files with 29 additions and 0 deletions
|
|
@ -268,6 +268,12 @@
|
|||
<svg-icon icon-class="arrow-down" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="close-button" style="left: 24px" @click="fullscreen">
|
||||
<button>
|
||||
<svg-icon v-if="isFullscreen" icon-class="fullscreen-exit" />
|
||||
<svg-icon v-else icon-class="fullscreen" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
|
@ -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'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue