From 9fd181ee065d850d5f466f807bf9e7eebe3d48f8 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Mon, 29 Jun 2020 01:06:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=98=E7=9B=98=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=A0=B7=E5=BC=8F=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/defaultSetting.js | 3 +- src/main/event.js | 11 +++++-- src/main/modules/tray.js | 27 +++++++++++++++++- src/renderer/lang/en-us/view/setting.json | 3 ++ src/renderer/lang/zh-cn/view/setting.json | 3 ++ src/renderer/lang/zh-tw/view/setting.json | 3 ++ src/renderer/views/Setting.vue | 18 ++++++++++++ .../{trayTemplate.ico => tray0Template.ico} | Bin .../{trayTemplate.png => tray0Template.png} | Bin ...ayTemplate@2x.ico => tray0Template@2x.ico} | Bin ...ayTemplate@2x.png => tray0Template@2x.png} | Bin src/static/images/tray/tray1Template.ico | Bin 0 -> 1150 bytes src/static/images/tray/tray1Template.png | Bin 0 -> 417 bytes src/static/images/tray/tray1Template@2x.ico | Bin 0 -> 4286 bytes src/static/images/tray/tray1Template@2x.png | Bin 0 -> 770 bytes 15 files changed, 63 insertions(+), 5 deletions(-) rename src/static/images/tray/{trayTemplate.ico => tray0Template.ico} (100%) rename src/static/images/tray/{trayTemplate.png => tray0Template.png} (100%) rename src/static/images/tray/{trayTemplate@2x.ico => tray0Template@2x.ico} (100%) rename src/static/images/tray/{trayTemplate@2x.png => tray0Template@2x.png} (100%) create mode 100644 src/static/images/tray/tray1Template.ico create mode 100644 src/static/images/tray/tray1Template.png create mode 100644 src/static/images/tray/tray1Template@2x.ico create mode 100644 src/static/images/tray/tray1Template@2x.png 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 0000000000000000000000000000000000000000..75e5a0d52e0c75d57bc5c2827328b4110390e454 GIT binary patch literal 1150 zcmbV~!7D^j6vod)Nr_q62(yxfjRnb0iBd)u7E%*Y=3h`FvqVf&%J2s$3k}Ljskawa zGntL-tdtcJ^Zc%Pr>@(57H0a*J@-4`ckb=I5lQe(CWYUWWSd1gMWi2)P#QXm2)(~P z2i43f)F6as*oO|2$(>H8VIVG#F9#;)vPNzjLU@I7cZN9w-ra1elG((67-db~@By>- z406M6mVFstDavS8*Dv%boq@N@ldtXFEv#$>bED3TOZF*f)x25BpLk}NXR+wy&(MBl zqkKF1v1i5-d2?UAdl}C>EZgU6jot$jFbL-Si}mxgnNfsY7((lYPZ-ghZ>6vAvS9bo zd!yd1t-H0AFWNoyg7$3Pt<}SN1Y?keE6{s|ZpPl*zL@&n_PcdVM$dkr-{)rReN6rd zeFNHTudl{)18;B*J1_}NKJS0E#~G2JMI_JEe4;@>9ZSRKm{x_7! BfyV#< literal 0 HcmV?d00001 diff --git a/src/static/images/tray/tray1Template.png b/src/static/images/tray/tray1Template.png new file mode 100644 index 0000000000000000000000000000000000000000..5ef12a4fabf977c3d07da01c17f80daf14e0bf7e GIT binary patch literal 417 zcmV;S0bc%zP);xHDJQWl*Q{x zx6-_AV9M6Snd-p?Fjk{|*Eg!%@7kKkS3NKsD_o;ERVoxG^G~^yPjAU4@7qRV^UWw^ z3Gm1DTl%r*Gy8t(I~W9RfqoT`1PZ=HJ=7V_dA_Jo1jggKc~Aw|nvjX+j~)VnxllBc z1{OR;&OIF0&6sM)ci5Vc03m1hq!(ZnSc&WAEHDc6#&t7My#V+EM*(h>UpipT00000 LNkvXXu0mjf^5?ZE literal 0 HcmV?d00001 diff --git a/src/static/images/tray/tray1Template@2x.ico b/src/static/images/tray/tray1Template@2x.ico new file mode 100644 index 0000000000000000000000000000000000000000..5a513f0858673a881db4607ea90e772ebfe8a6e5 GIT binary patch literal 4286 zcmdUyPizcP9LL|7YSRN6L4wHkB#0)0CQe-k2M&935rPAPXj~jBh?Q2-I3Z1NE)^GX zmyiwVMFd8A7=$1Yvu0P-3fiv&U`Y6-`d2-#8 zK)=sjxCgwIHoFV;fO{ywKRNdDK&RuHXU_cSeJ^m21o)5Rt{C@O-s5_`&2>-WJ{jO2 z$GsT(U`vY4Ic3yrW`B{#zcIis_x&V{!Jy=kYxCD#zD9FoJ_Yj`ckS0Cqs{)U_-6up z2=bG)8e-`+WTSR3g!E98Jm2|~bp&oh6ylc}YPW;D&#vqLLTd5K>2T(v?qj;<&v#ZfS9Bz&mS#y0k6;BZc_w=d zI?P;Z9;a)*FfKLcite-C^h*!Zu*8*zm7EiC=L3WySobv`%WjL$}Xkn`dqQ z{GER4cR|)?Htw09l z5Aq(HzWn|P+xhv9liSFj&v(6^C1b76W1DY-|C%j3E}M{ zrwRXO*6hpHw>lQ^zoT{#T0Up9XY%CvvfbbES#tx*5d3{_=KJ=^-30GJ{{MOn<8TVr z`_}%8^O|io);ftsbzQ{}>6%hP70OVWCyI1^fpQW>r5Tu0(N&$qqdF-IBM|Fk0CoUj S3v@9G%b*NZWC%;5*1rJ_GD>j( literal 0 HcmV?d00001 diff --git a/src/static/images/tray/tray1Template@2x.png b/src/static/images/tray/tray1Template@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..8e0224ad7b54ff93701a860d2154b3e983246c67 GIT binary patch literal 770 zcmV+d1O5DoP)F|9LGPUwI$deLi(qm(4hu8RGuWFE)m5ZwhoEKGcaO|x(3BU2lr6kq>u+5!ZC>s zw$M@-Mnq81p}ORw^-u>FJ4kJ%q(xagc(aV-?#`^OZr{tyo8NDKzt6nCzoF7vQEGmn zqy^junt*q}E8rzC;#l@rsqq#AFa#VgVEzCM19yREj%EJ|inp><0AN!Qo9>lP;3+UB zl)NC6Tw88{u-XCKFd(g!0B}_g+!0C+=If2+0C3d?JP=AoDg~f*2)JHJ04+T+x4Vt% zG6g+rmb4!4-R4U-7VxbCqJS(Xz>s6vU)+XJay4)g=mxgr@vnDpmShMV%l_$D_5iTY zY)*d7EGd8oWCA#s$Mkwx01U)qVBGU4Yj(=A0n7rw1AN|l?t2}}&JDr8PQoX8vSrhm z*=RDp!Sj4N6-)f`wCBuq!c5GZiUJ5F-6f^h?RVfUP-DzLfYxj}(+(tnHJ(>zqRDt? zDwgOs?Iv^Wa4h>J9K8$fh$Lz)o|hXuT=mtH1oHxz|flrDBOWzmsQ-$- z-Nh0hbnY50(4R!5P)}YjsUz4{$yYM5yFi3x3T^?cN8RD)QbZ;IzB9N0V_K=Mr#CFV$2m(HHU~ z3jZ4lB@dYKJ!tAWeddn>_kf#@Wq%Hv