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

View File

@ -15,8 +15,6 @@
</template>
<script>
import { disableScrolling, enableScrolling } from '@/utils/ui';
export default {
name: 'ContextMenu',
data() {
@ -42,7 +40,7 @@ export default {
if (this.$parent.closeMenu !== undefined) {
this.$parent.closeMenu();
}
enableScrolling();
this.$store.commit('enableScrolling', true);
},
openMenu(e) {
@ -54,7 +52,7 @@ export default {
}.bind(this)
);
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 locale from '@/locale';
import { addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui';
export default {
name: 'ModalAddTrackToPlaylist',
@ -57,9 +56,9 @@ export default {
value,
});
if (value) {
disableScrolling();
this.$store.commit('enableScrolling', false);
} else {
enableScrolling();
this.$store.commit('enableScrolling', true);
}
},
},

View File

@ -33,7 +33,6 @@ import Modal from '@/components/Modal.vue';
import locale from '@/locale';
import { mapMutations, mapState, mapActions } from 'vuex';
import { createPlaylist, addOrRemoveTrackFromPlaylist } from '@/api/playlist';
import { disableScrolling, enableScrolling } from '@/utils/ui';
export default {
name: 'ModalNewPlaylist',
@ -59,9 +58,9 @@ export default {
value,
});
if (value) {
disableScrolling();
this.$store.commit('enableScrolling', false);
} 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 cloneDeep from 'lodash/cloneDeep';
@ -47,8 +46,8 @@ export default {
if (key === 'show') {
// 100ms的延迟是为等待右键菜单blur之后再disableScrolling
value === true
? setTimeout(() => disableScrolling(), 100)
: enableScrolling();
? setTimeout(() => (state.enableScrolling = false), 100)
: (state.enableScrolling = true);
}
},
toggleLyrics(state) {
@ -71,4 +70,7 @@ export default {
restoreDefaultShortcuts(state) {
state.settings.shortcuts = cloneDeep(shortcuts);
},
enableScrolling(state, status = null) {
state.enableScrolling = status ? status : !state.enableScrolling;
},
};

View File

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

View File

@ -137,7 +137,7 @@ export function getLyricFromCache(id) {
export function cacheAlbum(id, album) {
db.album.put({
id,
id: Number(id),
album,
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 NProgress from 'nprogress';
import { isAccountLoggedIn } from '@/utils/auth';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import ExplicitSymbol from '@/components/ExplicitSymbol.vue';
import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
@ -279,9 +278,9 @@ export default {
toggleFullDescription() {
this.showFullDescription = !this.showFullDescription;
if (this.showFullDescription) {
disableScrolling();
this.$store.commit('enableScrolling', false);
} else {
enableScrolling();
this.$store.commit('enableScrolling', true);
}
},
openMenu(e) {

View File

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

View File

@ -204,7 +204,6 @@ import VueSlider from 'vue-slider-component';
import { formatTrackTime } from '@/utils/common';
import { getLyric } from '@/api/track';
import { lyricParser } from '@/utils/lyrics';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import ButtonIcon from '@/components/ButtonIcon.vue';
import * as Vibrant from 'node-vibrant';
import Color from 'color';
@ -295,10 +294,10 @@ export default {
showLyrics(show) {
if (show) {
this.setLyricsInterval();
disableScrolling();
this.$store.commit('enableScrolling', false);
} else {
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 nativeAlert from '@/utils/nativeAlert';
import locale from '@/locale';
import { disableScrolling, enableScrolling } from '@/utils/ui';
import ButtonTwoTone from '@/components/ButtonTwoTone.vue';
import ContextMenu from '@/components/ContextMenu.vue';
@ -534,9 +533,9 @@ export default {
toggleFullDescription() {
this.showFullDescription = !this.showFullDescription;
if (this.showFullDescription) {
disableScrolling();
this.$store.commit('enableScrolling', false);
} else {
enableScrolling();
this.$store.commit('enableScrolling', true);
}
},
},

View File

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