diff --git a/src/common/defaultSetting.js b/src/common/defaultSetting.js index 85aa7437..64e8a07f 100644 --- a/src/common/defaultSetting.js +++ b/src/common/defaultSetting.js @@ -3,7 +3,7 @@ const os = require('os') const { isMac } = require('./utils') const defaultSetting = { - version: '1.0.31', + version: '1.0.32', player: { togglePlayMethod: 'listLoop', highQuality: false, @@ -76,6 +76,7 @@ const defaultSetting = { tray: { isShow: false, isToTray: false, + themeId: 0, }, windowSizeId: 2, themeId: 0, diff --git a/src/main/event.js b/src/main/event.js index 169ee76e..089673a4 100644 --- a/src/main/event.js +++ b/src/main/event.js @@ -17,9 +17,14 @@ global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.quit, () => { global.modules.mainWindow.close() }) global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.toggle_minimize, () => { - global.modules.mainWindow.isMinimized() - ? global.modules.mainWindow.restore() - : global.modules.mainWindow.minimize() + if (global.modules.mainWindow.isMinimized()) { + if (!global.modules.mainWindow.isVisible()) { + global.modules.mainWindow.show() + } + global.modules.mainWindow.restore() + } else { + global.modules.mainWindow.minimize() + } }) global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.toggle_hide, () => { global.modules.mainWindow.isVisible() diff --git a/src/main/modules/tray.js b/src/main/modules/tray.js index 5b26825c..2a5f8254 100644 --- a/src/main/modules/tray.js +++ b/src/main/modules/tray.js @@ -3,8 +3,25 @@ const { isWin } = require('../../common/utils') const { tray: TRAY_EVENT_NAME, common: COMMON_EVENT_NAME } = require('../events/_name') const path = require('path') let isEnableTray = null +let themeId = null +const themeList = [ + { + id: 0, + fileName: 'tray0Template', + isNative: true, + }, + { + id: 1, + fileName: 'tray1Template', + isNative: false, + }, +] global.lx_event.common.on(COMMON_EVENT_NAME.config, sourceName => { if (sourceName === TRAY_EVENT_NAME.name) return + if (themeId !== global.appSetting.tray.themeId) { + themeId = global.appSetting.tray.themeId + setTrayImage(themeId) + } if (isEnableTray !== global.appSetting.tray.isToTray) { isEnableTray = global.appSetting.tray.isToTray global.appSetting.tray.isToTray ? createTray() : destroyTray() @@ -15,7 +32,9 @@ global.lx_event.common.on(COMMON_EVENT_NAME.config, sourceName => { const createTray = () => { if ((global.modules.tray && !global.modules.tray.isDestroyed()) || !global.appSetting.tray || !global.appSetting.tray.isShow) return - const iconPath = path.join(global.__static, 'images/tray', isWin ? 'trayTemplate@2x.ico' : 'trayTemplate.png') + themeId = global.appSetting.tray.themeId + let themeName = (themeList.find(item => item.id === themeId) || themeList[0]).fileName + const iconPath = path.join(global.__static, 'images/tray', isWin ? themeName + '@2x.ico' : themeName + '.png') // 托盘 global.modules.tray = new Tray(iconPath) @@ -85,3 +104,9 @@ const createMenu = tray => { tray.setContextMenu(contextMenu) } +const setTrayImage = themeId => { + if (!global.modules.tray) return + let themeName = (themeList.find(item => item.id === themeId) || themeList[0]).fileName + const iconPath = path.join(global.__static, 'images/tray', isWin ? themeName + '@2x.ico' : themeName + '.png') + global.modules.tray.setImage(iconPath) +} diff --git a/src/renderer/lang/en-us/view/setting.json b/src/renderer/lang/en-us/view/setting.json index c838d060..19b58a25 100644 --- a/src/renderer/lang/en-us/view/setting.json +++ b/src/renderer/lang/en-us/view/setting.json @@ -128,6 +128,9 @@ "backup_part_export_list_desc": "Save the list to...", "other": "Extras", + "other_tray_theme": "Tray Icon Style", + "other_tray_theme_native": "Solid Color", + "other_tray_theme_origin": "Primary Color", "other_cache": "Cache size (Not recommended since resources such as pictures after the cache is cleaned need re-downloading. The software will dynamically manage the cache size based on disk space)", "other_cache_label": "Cache size used: ", "other_cache_label_title": "Currently used cache size", diff --git a/src/renderer/lang/zh-cn/view/setting.json b/src/renderer/lang/zh-cn/view/setting.json index 8407ef37..22ca5200 100644 --- a/src/renderer/lang/zh-cn/view/setting.json +++ b/src/renderer/lang/zh-cn/view/setting.json @@ -128,6 +128,9 @@ "backup_part_export_list_desc": "选择歌单保存位置", "other": "其他", + "other_tray_theme": "托盘图标样式", + "other_tray_theme_native": "纯色", + "other_tray_theme_origin": "原色", "other_cache": "缓存大小(清理缓存后图片等资源将需要重新下载,不建议清理,软件会根据磁盘空间动态管理缓存大小)", "other_cache_label": "软件已使用缓存大小:", "other_cache_label_title": "当前已用缓存", diff --git a/src/renderer/lang/zh-tw/view/setting.json b/src/renderer/lang/zh-tw/view/setting.json index f69ff385..94695c95 100644 --- a/src/renderer/lang/zh-tw/view/setting.json +++ b/src/renderer/lang/zh-tw/view/setting.json @@ -118,6 +118,9 @@ "backup_part_import_list_desc": "選擇列表文件", "backup_part_export_list_desc": "選擇列表保存位置", "other": "其他", + "other_tray_theme": "托盤圖標樣式", + "other_tray_theme_native": "純色", + "other_tray_theme_origin": "原色", "other_cache": "緩存大小(清理緩存後圖片等資源將需要重新下載,不建議清理,軟件會根據磁盤空間動態管理緩存大小)", "other_cache_label": "軟件已使用緩存大小:", "other_cache_label_title": "當前已用緩存", diff --git a/src/renderer/views/Setting.vue b/src/renderer/views/Setting.vue index 901b6422..1dffef68 100644 --- a/src/renderer/views/Setting.vue +++ b/src/renderer/views/Setting.vue @@ -191,6 +191,11 @@ div.scroll(:class="$style.setting") material-btn(:class="[$style.btn, $style.gapLeft]" min @click="handleImportAllData") {{$t('view.setting.backup_all_import')}} material-btn(:class="[$style.btn, $style.gapLeft]" min @click="handleExportAllData") {{$t('view.setting.backup_all_export')}} dt {{$t('view.setting.other')}} + dd + h3 {{$t('view.setting.other_tray_theme')}} + div + material-checkbox(:id="'setting_tray_theme_' + item.id" v-model="current_setting.tray.themeId" name="setting_tray_theme" need :class="$style.gapLeft" + :label="$t('view.setting.other_tray_theme_' + item.name)" :key="item.id" :value="item.id" v-for="item in trayThemeList") dd h3 {{$t('view.setting.other_cache')}} div @@ -358,6 +363,18 @@ export default { }, ] }, + trayThemeList() { + return [ + { + id: 0, + name: 'native', + }, + { + id: 1, + name: 'origin', + }, + ] + }, }, data() { return { @@ -418,6 +435,7 @@ export default { tray: { isShow: false, isToTray: false, + themeId: 0, }, windowSizeId: 1, langId: 'cns', diff --git a/src/static/images/tray/trayTemplate.ico b/src/static/images/tray/tray0Template.ico similarity index 100% rename from src/static/images/tray/trayTemplate.ico rename to src/static/images/tray/tray0Template.ico diff --git a/src/static/images/tray/trayTemplate.png b/src/static/images/tray/tray0Template.png similarity index 100% rename from src/static/images/tray/trayTemplate.png rename to src/static/images/tray/tray0Template.png diff --git a/src/static/images/tray/trayTemplate@2x.ico b/src/static/images/tray/tray0Template@2x.ico similarity index 100% rename from src/static/images/tray/trayTemplate@2x.ico rename to src/static/images/tray/tray0Template@2x.ico diff --git a/src/static/images/tray/trayTemplate@2x.png b/src/static/images/tray/tray0Template@2x.png similarity index 100% rename from src/static/images/tray/trayTemplate@2x.png rename to src/static/images/tray/tray0Template@2x.png diff --git a/src/static/images/tray/tray1Template.ico b/src/static/images/tray/tray1Template.ico new file mode 100644 index 00000000..75e5a0d5 Binary files /dev/null and b/src/static/images/tray/tray1Template.ico differ diff --git a/src/static/images/tray/tray1Template.png b/src/static/images/tray/tray1Template.png new file mode 100644 index 00000000..5ef12a4f Binary files /dev/null and b/src/static/images/tray/tray1Template.png differ diff --git a/src/static/images/tray/tray1Template@2x.ico b/src/static/images/tray/tray1Template@2x.ico new file mode 100644 index 00000000..5a513f08 Binary files /dev/null and b/src/static/images/tray/tray1Template@2x.ico differ diff --git a/src/static/images/tray/tray1Template@2x.png b/src/static/images/tray/tray1Template@2x.png new file mode 100644 index 00000000..8e0224ad Binary files /dev/null and b/src/static/images/tray/tray1Template@2x.png differ