Added system tray service

This commit is contained in:
2025-06-08 23:07:56 +08:00
parent d5a0b07f2a
commit 8522a47b5f
12 changed files with 136 additions and 646 deletions

View File

@@ -76,6 +76,7 @@ export default {
enableGlobalHotkey: 'Enable Global Hotkeys',
window: 'Window/Application',
showInSystemTray: 'Show in System Tray',
enableSystemTray: 'Enable System Tray',
alwaysOnTop: 'Always on Top',
dataStorage: 'Data Storage',
dataPath: 'Data Storage Path',

View File

@@ -76,6 +76,7 @@ export default {
enableGlobalHotkey: '启用全局热键',
window: '窗口/应用程序',
showInSystemTray: '在系统托盘中显示',
enableSystemTray: '启用系统托盘',
alwaysOnTop: '窗口始终置顶',
dataStorage: '数据存储',
dataPath: '数据存储路径',

View File

@@ -49,6 +49,7 @@ type NumberConfigKey = 'fontSize' | 'tabSize' | 'lineHeight';
const GENERAL_CONFIG_KEY_MAP: GeneralConfigKeyMap = {
alwaysOnTop: 'general.always_on_top',
dataPath: 'general.data_path',
enableSystemTray: 'general.enable_system_tray',
enableGlobalHotkey: 'general.enable_global_hotkey',
globalHotkey: 'general.global_hotkey'
} as const;
@@ -116,6 +117,7 @@ const DEFAULT_CONFIG: AppConfig = {
general: {
alwaysOnTop: false,
dataPath: '',
enableSystemTray: true,
enableGlobalHotkey: false,
globalHotkey: {
ctrl: false,
@@ -406,6 +408,9 @@ export const useConfigStore = defineStore('config', () => {
// 热键配置相关方法
setEnableGlobalHotkey: (value: boolean) => safeCall(() => updateGeneralConfig('enableGlobalHotkey', value), 'config.saveFailed', 'config.saveSuccess'),
setGlobalHotkey: (hotkey: any) => safeCall(() => updateGeneralConfig('globalHotkey', hotkey), 'config.saveFailed', 'config.saveSuccess')
setGlobalHotkey: (hotkey: any) => safeCall(() => updateGeneralConfig('globalHotkey', hotkey), 'config.saveFailed', 'config.saveSuccess'),
// 系统托盘配置相关方法
setEnableSystemTray: (value: boolean) => safeCall(() => updateGeneralConfig('enableSystemTray', value), 'config.saveFailed', 'config.saveSuccess')
};
});

View File

@@ -187,6 +187,12 @@ const alwaysOnTop = computed({
}
});
// 计算属性 - 启用系统托盘
const enableSystemTray = computed({
get: () => configStore.config.general.enableSystemTray,
set: (value: boolean) => configStore.setEnableSystemTray(value)
});
// 修饰键配置 - 只读计算属性
const modifierKeys = computed(() => ({
ctrl: configStore.config.general.globalHotkey.ctrl,
@@ -338,6 +344,9 @@ onUnmounted(() => {
<SettingItem :title="t('settings.alwaysOnTop')">
<ToggleSwitch v-model="alwaysOnTop"/>
</SettingItem>
<SettingItem :title="t('settings.enableSystemTray')">
<ToggleSwitch v-model="enableSystemTray"/>
</SettingItem>
</SettingSection>
<SettingSection :title="t('settings.dataStorage')">