fix: bugs

This commit is contained in:
qier222 2021-06-09 20:53:33 +08:00
parent e54c606c6d
commit f3076f21b2
No known key found for this signature in database
GPG Key ID: 9C85007ED905F14D
13 changed files with 32 additions and 36 deletions

View File

@ -2,7 +2,11 @@
<div id="app" :class="{ 'user-select-none': userSelectNone }"> <div id="app" :class="{ 'user-select-none': userSelectNone }">
<Scrollbar v-show="!showLyrics" ref="scrollbar" /> <Scrollbar v-show="!showLyrics" ref="scrollbar" />
<Navbar v-show="showNavbar" ref="navbar" /> <Navbar v-show="showNavbar" ref="navbar" />
<main ref="main" @scroll="handleScroll"> <main
ref="main"
:style="{ overflow: enableScrolling ? 'auto' : 'hidden' }"
@scroll="handleScroll"
>
<keep-alive> <keep-alive>
<router-view v-if="$route.meta.keepAlive"></router-view> <router-view v-if="$route.meta.keepAlive"></router-view>
</keep-alive> </keep-alive>
@ -50,7 +54,7 @@ export default {
}; };
}, },
computed: { computed: {
...mapState(['showLyrics', 'settings', 'player']), ...mapState(['showLyrics', 'settings', 'player', 'enableScrolling']),
isAccountLoggedIn() { isAccountLoggedIn() {
return isAccountLoggedIn(); return isAccountLoggedIn();
}, },

View File

@ -15,8 +15,6 @@
</template> </template>
<script> <script>
import { disableScrolling, enableScrolling } from '@/utils/ui';
export default { export default {
name: 'ContextMenu', name: 'ContextMenu',
data() { data() {
@ -42,7 +40,7 @@ export default {
if (this.$parent.closeMenu !== undefined) { if (this.$parent.closeMenu !== undefined) {
this.$parent.closeMenu(); this.$parent.closeMenu();
} }
enableScrolling(); this.$store.commit('enableScrolling', true);
}, },
openMenu(e) { openMenu(e) {
@ -54,7 +52,7 @@ export default {
}.bind(this) }.bind(this)
); );
e.preventDefault(); e.preventDefault();
disableScrolling(); this.$store.commit('enableScrolling', false);
}, },
}, },
}; };

View File

@ -32,7 +32,6 @@ import { mapActions, mapMutations, mapState } from 'vuex';
import Modal from '@/components/Modal.vue'; import Modal from '@/components/Modal.vue';
import locale from '@/locale'; import locale from '@/locale';
import { addOrRemoveTrackFromPlaylist } from '@/api/playlist'; import { addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui';
export default { export default {
name: 'ModalAddTrackToPlaylist', name: 'ModalAddTrackToPlaylist',
@ -57,9 +56,9 @@ export default {
value, value,
}); });
if (value) { if (value) {
disableScrolling(); this.$store.commit('enableScrolling', false);
} else { } else {
enableScrolling(); this.$store.commit('enableScrolling', true);
} }
}, },
}, },

View File

@ -33,7 +33,6 @@ import Modal from '@/components/Modal.vue';
import locale from '@/locale'; import locale from '@/locale';
import { mapMutations, mapState, mapActions } from 'vuex'; import { mapMutations, mapState, mapActions } from 'vuex';
import { createPlaylist, addOrRemoveTrackFromPlaylist } from '@/api/playlist'; import { createPlaylist, addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui';
export default { export default {
name: 'ModalNewPlaylist', name: 'ModalNewPlaylist',
@ -59,9 +58,9 @@ export default {
value, value,
}); });
if (value) { if (value) {
disableScrolling(); this.$store.commit('enableScrolling', false);
} else { } else {
enableScrolling(); this.$store.commit('enableScrolling', true);
} }
}, },
}, },

View File

@ -1,4 +1,3 @@
import { disableScrolling, enableScrolling } from '@/utils/ui';
import shortcuts from '@/utils/shortcuts'; import shortcuts from '@/utils/shortcuts';
import cloneDeep from 'lodash/cloneDeep'; import cloneDeep from 'lodash/cloneDeep';
@ -47,8 +46,8 @@ export default {
if (key === 'show') { if (key === 'show') {
// 100ms的延迟是为等待右键菜单blur之后再disableScrolling // 100ms的延迟是为等待右键菜单blur之后再disableScrolling
value === true value === true
? setTimeout(() => disableScrolling(), 100) ? setTimeout(() => (state.enableScrolling = false), 100)
: enableScrolling(); : (state.enableScrolling = true);
} }
}, },
toggleLyrics(state) { toggleLyrics(state) {
@ -71,4 +70,7 @@ export default {
restoreDefaultShortcuts(state) { restoreDefaultShortcuts(state) {
state.settings.shortcuts = cloneDeep(shortcuts); state.settings.shortcuts = cloneDeep(shortcuts);
}, },
enableScrolling(state, status = null) {
state.enableScrolling = status ? status : !state.enableScrolling;
},
}; };

View File

@ -12,6 +12,7 @@ updateApp();
export default { export default {
showLyrics: false, showLyrics: false,
enableScrolling: true,
liked: { liked: {
songs: [], songs: [],
songsWithDetails: [], // 只有前12首 songsWithDetails: [], // 只有前12首

View File

@ -137,7 +137,7 @@ export function getLyricFromCache(id) {
export function cacheAlbum(id, album) { export function cacheAlbum(id, album) {
db.album.put({ db.album.put({
id, id: Number(id),
album, album,
updateTime: new Date().getTime(), updateTime: new Date().getTime(),
}); });

View File

@ -1,7 +0,0 @@
export function disableScrolling() {
document.documentElement.style.setProperty('--html-overflow-y', 'hidden');
}
export function enableScrolling() {
document.documentElement.style.setProperty('--html-overflow-y', 'overlay');
}

View File

@ -137,7 +137,6 @@ import locale from '@/locale';
import { splitSoundtrackAlbumTitle, splitAlbumTitle } from '@/utils/common'; import { splitSoundtrackAlbumTitle, splitAlbumTitle } from '@/utils/common';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import ExplicitSymbol from '@/components/ExplicitSymbol.vue'; import ExplicitSymbol from '@/components/ExplicitSymbol.vue';
import ButtonTwoTone from '@/components/ButtonTwoTone.vue'; import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
@ -279,9 +278,9 @@ export default {
toggleFullDescription() { toggleFullDescription() {
this.showFullDescription = !this.showFullDescription; this.showFullDescription = !this.showFullDescription;
if (this.showFullDescription) { if (this.showFullDescription) {
disableScrolling(); this.$store.commit('enableScrolling', false);
} else { } else {
enableScrolling(); this.$store.commit('enableScrolling', true);
} }
}, },
openMenu(e) { openMenu(e) {

View File

@ -184,7 +184,6 @@ import {
} from '@/api/artist'; } from '@/api/artist';
import locale from '@/locale'; import locale from '@/locale';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import NProgress from 'nprogress'; import NProgress from 'nprogress';
import ButtonTwoTone from '@/components/ButtonTwoTone.vue'; import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
@ -330,9 +329,9 @@ export default {
toggleFullDescription() { toggleFullDescription() {
this.showFullDescription = !this.showFullDescription; this.showFullDescription = !this.showFullDescription;
if (this.showFullDescription) { if (this.showFullDescription) {
disableScrolling(); this.$store.commit('enableScrolling', false);
} else { } else {
enableScrolling(); this.$store.commit('enableScrolling', true);
} }
}, },
openMenu(e) { openMenu(e) {

View File

@ -204,7 +204,6 @@ import VueSlider from 'vue-slider-component';
import { formatTrackTime } from '@/utils/common'; import { formatTrackTime } from '@/utils/common';
import { getLyric } from '@/api/track'; import { getLyric } from '@/api/track';
import { lyricParser } from '@/utils/lyrics'; import { lyricParser } from '@/utils/lyrics';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import ButtonIcon from '@/components/ButtonIcon.vue'; import ButtonIcon from '@/components/ButtonIcon.vue';
import * as Vibrant from 'node-vibrant'; import * as Vibrant from 'node-vibrant';
import Color from 'color'; import Color from 'color';
@ -295,10 +294,10 @@ export default {
showLyrics(show) { showLyrics(show) {
if (show) { if (show) {
this.setLyricsInterval(); this.setLyricsInterval();
disableScrolling(); this.$store.commit('enableScrolling', false);
} else { } else {
clearInterval(this.lyricsInterval); clearInterval(this.lyricsInterval);
enableScrolling(); this.$store.commit('enableScrolling', true);
} }
}, },
}, },

View File

@ -231,7 +231,6 @@ import { getTrackDetail } from '@/api/track';
import { isAccountLoggedIn } from '@/utils/auth'; import { isAccountLoggedIn } from '@/utils/auth';
import nativeAlert from '@/utils/nativeAlert'; import nativeAlert from '@/utils/nativeAlert';
import locale from '@/locale'; import locale from '@/locale';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import ButtonTwoTone from '@/components/ButtonTwoTone.vue'; import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
import ContextMenu from '@/components/ContextMenu.vue'; import ContextMenu from '@/components/ContextMenu.vue';
@ -534,9 +533,9 @@ export default {
toggleFullDescription() { toggleFullDescription() {
this.showFullDescription = !this.showFullDescription; this.showFullDescription = !this.showFullDescription;
if (this.showFullDescription) { if (this.showFullDescription) {
disableScrolling(); this.$store.commit('enableScrolling', false);
} else { } else {
enableScrolling(); this.$store.commit('enableScrolling', true);
} }
}, },
}, },

View File

@ -445,7 +445,8 @@
:class="{ :class="{
active: active:
shortcutInput.id === shortcut.id && shortcutInput.id === shortcut.id &&
shortcutInput.type === 'globalShortcut', shortcutInput.type === 'globalShortcut' &&
enableGlobalShortcut,
}" }"
@click.stop=" @click.stop="
readyToRecordShortcut(shortcut.id, 'globalShortcut') readyToRecordShortcut(shortcut.id, 'globalShortcut')
@ -927,6 +928,9 @@ export default {
return shortcut.replace('CommandOrControl', 'Ctrl'); return shortcut.replace('CommandOrControl', 'Ctrl');
}, },
readyToRecordShortcut(id, type) { readyToRecordShortcut(id, type) {
if (type === 'globalShortcut' && this.enableGlobalShortcut === false) {
return;
}
this.shortcutInput = { id, type, recording: true }; this.shortcutInput = { id, type, recording: true };
this.recordedShortcut = []; this.recordedShortcut = [];
ipcRenderer.send('switchGlobalShortcutStatusTemporary', 'disable'); ipcRenderer.send('switchGlobalShortcutStatusTemporary', 'disable');