mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-15 07:20:49 +08:00
Merge pull request #83 from algerkong/fix/duplicate-playback
✨ feat: 增强歌词窗口处理逻辑,修复可能引起的歌词初始化重复播放问题
This commit is contained in:
@@ -19,7 +19,7 @@ import homeRouter from '@/router/home';
|
||||
import { useMenuStore } from '@/store/modules/menu';
|
||||
import { usePlayerStore } from '@/store/modules/player';
|
||||
import { useSettingsStore } from '@/store/modules/settings';
|
||||
import { isElectron } from '@/utils';
|
||||
import { isElectron, isLyricWindow } from '@/utils';
|
||||
|
||||
import { initAudioListeners } from './hooks/MusicHook';
|
||||
import { isMobile } from './utils';
|
||||
@@ -64,19 +64,25 @@ const handleSetLanguage = (value: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
settingsStore.initializeSettings();
|
||||
handleSetLanguage(settingsStore.setData.language);
|
||||
settingsStore.initializeTheme();
|
||||
settingsStore.initializeSystemFonts();
|
||||
if (isMobile.value) {
|
||||
menuStore.setMenus(homeRouter.filter((item) => item.meta.isMobile));
|
||||
if (!isLyricWindow.value) {
|
||||
settingsStore.initializeSettings();
|
||||
settingsStore.initializeTheme();
|
||||
settingsStore.initializeSystemFonts();
|
||||
if (isMobile.value) {
|
||||
menuStore.setMenus(homeRouter.filter((item) => item.meta.isMobile));
|
||||
}
|
||||
}
|
||||
|
||||
handleSetLanguage(settingsStore.setData.language);
|
||||
|
||||
if (isElectron) {
|
||||
window.api.onLanguageChanged(handleSetLanguage);
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (isLyricWindow.value) {
|
||||
return;
|
||||
}
|
||||
// 先初始化播放状态
|
||||
await playerStore.initializePlayState();
|
||||
// 如果有正在播放的音乐,则初始化音频监听器
|
||||
|
||||
@@ -97,3 +97,7 @@ export const isMobile = computed(() => {
|
||||
});
|
||||
|
||||
export const isElectron = (window as any).electron !== undefined;
|
||||
|
||||
export const isLyricWindow = computed(() => {
|
||||
return window.location.hash.includes('lyric');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user