Skip to content

Commit ab64cf0

Browse files
committed
Merge branch 'flystar233-dev' into dev
1 parent d34aead commit ab64cf0

7 files changed

Lines changed: 36 additions & 11 deletions

File tree

electron/main/ipc/ipc-window.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ const initWindowsIpc = (): void => {
163163
});
164164

165165
// 开启设置
166-
ipcMain.on("open-setting", (_, type) => {
166+
ipcMain.on("open-setting", (_, type, scrollTo) => {
167167
const mainWin = mainWindow.getWin();
168168
if (!mainWin) return;
169169
mainWin?.show();
170170
mainWin?.focus();
171-
mainWin?.webContents.send("openSetting", type);
171+
mainWin?.webContents.send("openSetting", type, scrollTo);
172172
});
173173
};
174174

src/components/Player/PlayerRightMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<n-flex :size="8" align="center" class="right-menu">
33
<n-badge v-if="isElectron" value="ON" :show="statusStore.showDesktopLyric">
4-
<div class="menu-icon" @click.stop="player.toggleDesktopLyric">
4+
<div class="menu-icon" @click.stop="player.toggleDesktopLyric()">
55
<SvgIcon name="DesktopLyric2" :depth="statusStore.showDesktopLyric ? 1 : 3" />
66
</div>
77
</n-badge>

src/components/Setting/LyricsSetting.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@
400400
/>
401401
</n-card>
402402
</div>
403-
<div v-if="isElectron" class="set-list">
403+
<div v-if="isElectron" ref="desktopLyricRef" class="set-list">
404404
<n-h3 prefix="bar">
405405
桌面歌词
406406
<n-tag type="warning" size="small" round>Beta</n-tag>
@@ -414,7 +414,7 @@
414414
:value="statusStore.showDesktopLyric"
415415
:round="false"
416416
class="set"
417-
@update:value="player.toggleDesktopLyric"
417+
@update:value="player.setDesktopLyricShow"
418418
/>
419419
</n-card>
420420
<n-card class="set-item">
@@ -641,10 +641,15 @@ import { usePlayerController } from "@/core/player/PlayerController";
641641
import { SelectOption } from "naive-ui";
642642
import defaultDesktopLyricConfig from "@/assets/data/lyricConfig";
643643
644+
const props = defineProps<{ scrollTo?: string }>();
645+
644646
const player = usePlayerController();
645647
const statusStore = useStatusStore();
646648
const settingStore = useSettingStore();
647649
650+
// 桌面歌词区域引用
651+
const desktopLyricRef = ref<HTMLElement | null>(null);
652+
648653
// 全部字体
649654
const allFontsData = ref<SelectOption[]>([]);
650655
@@ -757,6 +762,12 @@ onMounted(async () => {
757762
// 恢复地址
758763
await window.api.store.set("amllDbServer", settingStore.amllDbServer);
759764
}
765+
// 如果需要滚动到桌面歌词部分
766+
if (props.scrollTo === "desktop" && desktopLyricRef.value) {
767+
nextTick(() => {
768+
desktopLyricRef.value?.scrollIntoView({ behavior: "instant", block: "start" });
769+
});
770+
}
760771
});
761772
</script>
762773

src/components/Setting/MainSetting.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<!-- 播放 -->
3737
<PlaySetting v-else-if="activeKey === 'play'" />
3838
<!-- 歌词 -->
39-
<LyricsSetting v-else-if="activeKey === 'lyrics'" />
39+
<LyricsSetting v-else-if="activeKey === 'lyrics'" :scroll-to="props.scrollTo" />
4040
<!-- 快捷键 -->
4141
<KeyboardSetting v-else-if="activeKey === 'keyboard'" />
4242
<!-- 本地 -->
@@ -59,7 +59,7 @@ import { renderIcon } from "@/utils/helper";
5959
import { isDevBuild, isElectron } from "@/utils/env";
6060
import packageJson from "@/../package.json";
6161
62-
const props = defineProps<{ type: SettingType }>();
62+
const props = defineProps<{ type: SettingType; scrollTo?: string }>();
6363
6464
// 设置内容
6565
const setScrollbar = ref<InstanceType<typeof NScrollbar> | null>(null);

src/utils/initIpc.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ const initIpc = () => {
4242
await toLikeSong(musicStore.playSong, !dataStore.isLikeSong(musicStore.playSong.id));
4343
});
4444
// 开启设置
45-
window.electron.ipcRenderer.on("openSetting", (_, type: SettingType) => openSetting(type));
45+
window.electron.ipcRenderer.on("openSetting", (_, type: SettingType, scrollTo?: string) =>
46+
openSetting(type, scrollTo),
47+
);
4648
// 桌面歌词开关
4749
window.electron.ipcRenderer.on("toogleDesktopLyric", () => player.toggleDesktopLyric());
4850
// 显式关闭桌面歌词

src/utils/modal.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,17 @@ export const openDownloadSongs = (songs: SongType[]): void => {
236236
});
237237
};
238238

239+
// 设置页面是否已打开
240+
let isSettingOpen = false;
241+
239242
// 打开设置
240-
export const openSetting = (type: SettingType = "general") => {
243+
export const openSetting = (type: SettingType = "general", scrollTo?: string) => {
244+
// 如果设置页面已打开,显示提醒
245+
if (isSettingOpen) {
246+
window.$message.warning("设置页面已打开");
247+
return;
248+
}
249+
isSettingOpen = true;
241250
window.$modal.create({
242251
preset: "card",
243252
transformOrigin: "center",
@@ -247,7 +256,10 @@ export const openSetting = (type: SettingType = "general") => {
247256
bordered: true,
248257
class: "main-setting",
249258
content: () => {
250-
return h(MainSetting, { type });
259+
return h(MainSetting, { type, scrollTo });
260+
},
261+
onAfterLeave: () => {
262+
isSettingOpen = false;
251263
},
252264
});
253265
};

src/views/DesktopLyric/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525
</n-flex>
2626
<n-flex :wrap="false" align="center" justify="flex-end" size="small" @pointerdown.stop>
27-
<div class="menu-btn" @click.stop="sendToMain('open-setting', 'lyrics')">
27+
<div class="menu-btn" @click.stop="sendToMain('open-setting', 'lyrics', 'desktop')">
2828
<SvgIcon name="Settings" />
2929
</div>
3030
<div

0 commit comments

Comments
 (0)