Skip to content

Commit 2476fbd

Browse files
committed
✨ feat: 添加mac状态栏播放按键控制功能开关
1 parent f7951ec commit 2476fbd

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

src/i18n/lang/en-US/settings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export default {
6666
noMusicSources: 'No sources selected',
6767
gdmusicInfo: 'GD Music Station intelligently resolves music from multiple platforms automatically',
6868
autoPlay: 'Auto Play',
69-
autoPlayDesc: 'Auto resume playback when reopening the app'
69+
autoPlayDesc: 'Auto resume playback when reopening the app',
70+
showStatusBar: "Show Status Bar",
71+
showStatusBarContent: "You can display the music control function in your mac status bar (effective after a restart)"
7072
},
7173
application: {
7274
closeAction: 'Close Action',

src/i18n/lang/zh-CN/settings.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ export default {
6666
noMusicSources: '未选择音源',
6767
gdmusicInfo: 'GD音乐台可自动解析多个平台音源,自动选择最佳结果',
6868
autoPlay: '自动播放',
69-
autoPlayDesc: '重新打开应用时是否自动继续播放'
69+
autoPlayDesc: '重新打开应用时是否自动继续播放',
70+
showStatusBar: '是否显示状态栏控制功能',
71+
showStatusBarContent: '可以在您的mac状态栏显示音乐控制功能(重启后生效)',
7072
},
7173
application: {
7274
closeAction: '关闭行为',

src/main/modules/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type SetConfig = {
2424
fontFamily: string;
2525
fontScope: 'global' | 'lyric';
2626
language: string;
27+
showTopAction: boolean;
2728
};
2829
interface StoreType {
2930
set: SetConfig;

src/main/modules/tray.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { join } from 'path';
1111

1212
import type { Language } from '../../i18n/main';
1313
import i18n from '../../i18n/main';
14+
import { getStore } from './config';
1415

1516
// 歌曲信息接口定义
1617
interface SongInfo {
@@ -327,7 +328,8 @@ export function updateTrayMenu(mainWindow: BrowserWindow) {
327328

328329
// 初始化状态栏Tray
329330
function initializeStatusBarTray(mainWindow: BrowserWindow) {
330-
if (process.platform !== 'darwin') return;
331+
const store = getStore()
332+
if (process.platform !== 'darwin' || !store.get('set.showTopAction')) return;
331333

332334
const iconSize = getProperIconSize();
333335

src/main/set.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
"alwaysShowDownloadButton": false,
2424
"unlimitedDownload": false,
2525
"enableMusicUnblock": true,
26-
"enabledMusicSources": ["migu", "kugou", "pyncmd", "bilibili", "kuwo"]
26+
"enabledMusicSources": ["migu", "kugou", "pyncmd", "bilibili", "kuwo"],
27+
"showTopAction": false
2728
}

src/renderer/views/set/index.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@
183183
</n-button>
184184
</div>
185185

186+
<div class="set-item" v-if="platform === 'darwin'">
187+
<div>
188+
<div class="set-item-title">{{ t('settings.playback.showStatusBar') }}</div>
189+
<div class="set-item-content">{{ t('settings.playback.showStatusBarContent') }}</div>
190+
</div>
191+
<n-switch v-model:value="setData.showTopAction">
192+
<template #checked>{{ t('common.on') }}</template>
193+
<template #unchecked>{{ t('common.off') }}</template>
194+
</n-switch>
195+
</div>
196+
186197
<div class="set-item">
187198
<div>
188199
<div class="set-item-title">{{ t('settings.playback.autoPlay') }}</div>
@@ -488,6 +499,8 @@ import config from '../../../../package.json';
488499
// 所有平台默认值
489500
const ALL_PLATFORMS: Platform[] = ['migu', 'kugou', 'pyncmd', 'bilibili', 'kuwo'];
490501
502+
const platform = window.electron.ipcRenderer.sendSync('get-platform');
503+
491504
const settingsStore = useSettingsStore();
492505
const userStore = useUserStore();
493506

0 commit comments

Comments
 (0)