From 733005489f1dde41fd930b890cfa6a6680364495 Mon Sep 17 00:00:00 2001 From: mayandev Date: Thu, 18 Feb 2021 16:51:18 +0800 Subject: [PATCH 1/2] fix(tray.js): delete unused closing brace --- src/electron/tray.js | 81 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/src/electron/tray.js b/src/electron/tray.js index 3ae3436..a787472 100644 --- a/src/electron/tray.js +++ b/src/electron/tray.js @@ -21,55 +21,54 @@ export function createTray(win) { tray.on("right-click", () => { const contextMenu = Menu.buildFromTemplate([ { - label: "播放/暂停", - icon: "src/assets/icons/play.png", - click: () => { - win.webContents.send("play"); - }, + label: "播放/暂停", + icon: "src/assets/icons/play.png", + click: () => { + win.webContents.send("play"); }, - { - label: "上一首", - icon: "src/assets/icons/left.png", - accelerator: "CmdOrCtrl+Left", - click: () => { - win.webContents.send("previous"); - }, + }, + { + label: "上一首", + icon: "src/assets/icons/left.png", + accelerator: "CmdOrCtrl+Left", + click: () => { + win.webContents.send("previous"); }, - { - label: "下一首", - icon: "src/assets/icons/right.png", - accelerator: "CmdOrCtrl+Right", - click: () => { - win.webContents.send("next"); - }, + }, + { + label: "下一首", + icon: "src/assets/icons/right.png", + accelerator: "CmdOrCtrl+Right", + click: () => { + win.webContents.send("next"); }, - { - label: "循环播放", - icon: "src/assets/icons/repeat.png", - accelerator: "Alt+R", - click: () => { - win.webContents.send("repeat"); - }, + }, + { + label: "循环播放", + icon: "src/assets/icons/repeat.png", + accelerator: "Alt+R", + click: () => { + win.webContents.send("repeat"); }, - { - label: "加入喜欢", - icon: "src/assets/icons/like.png", - accelerator: "CmdOrCtrl+L", - click: () => { - win.webContents.send("like"); - }, + }, + { + label: "加入喜欢", + icon: "src/assets/icons/like.png", + accelerator: "CmdOrCtrl+L", + click: () => { + win.webContents.send("like"); }, - { - label: "退出", - icon: "src/assets/icons/exit.png", - accelerator: "CmdOrCtrl+W", - click: () => { - app.exit(); - }, + }, + { + label: "退出", + icon: "src/assets/icons/exit.png", + accelerator: "CmdOrCtrl+W", + click: () => { + app.exit(); }, }, ]); - + tray.popUpContextMenu(contextMenu); }); From 4de69bd647a8e28ec375ab8b69126b03d1a92466 Mon Sep 17 00:00:00 2001 From: mayandev Date: Tue, 23 Feb 2021 15:18:52 +0800 Subject: [PATCH 2/2] fix: touchbar icon display --- public/img/touchbar/backward.png | Bin 0 -> 801 bytes public/img/touchbar/forward.png | Bin 0 -> 779 bytes public/img/touchbar/like.png | Bin 0 -> 1150 bytes public/img/touchbar/like_fill.png | Bin 0 -> 871 bytes public/img/touchbar/next_up.png | Bin 0 -> 855 bytes public/img/touchbar/pause.png | Bin 0 -> 499 bytes public/img/touchbar/play.png | Bin 0 -> 746 bytes public/img/touchbar/route_next.png | Bin 0 -> 656 bytes public/img/touchbar/route_prev.png | Bin 0 -> 610 bytes public/img/touchbar/search.png | Bin 0 -> 1084 bytes src/electron/touchBar.js | 35 +++++++++++++++++++---------- 11 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 public/img/touchbar/backward.png create mode 100644 public/img/touchbar/forward.png create mode 100644 public/img/touchbar/like.png create mode 100644 public/img/touchbar/like_fill.png create mode 100644 public/img/touchbar/next_up.png create mode 100644 public/img/touchbar/pause.png create mode 100644 public/img/touchbar/play.png create mode 100644 public/img/touchbar/route_next.png create mode 100644 public/img/touchbar/route_prev.png create mode 100644 public/img/touchbar/search.png diff --git a/public/img/touchbar/backward.png b/public/img/touchbar/backward.png new file mode 100644 index 0000000000000000000000000000000000000000..83b205358637f73a04182916530868e5810101ed GIT binary patch literal 801 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1|+Ti+$;i8jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(;Zvw#`F1}W^m|1ySwfvMZm#W5s< z_3aEt?@&jHw!M*&dOA)^uL)gr68gj5%95wj^le?%W4#To{}q%B#CLk$;mkV}wPiv_ zQ(c1~OW>C7Nn&Zzmv`9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Jyd5qYL%&wHKx0xro_)H%P{b}}5G0F6mxDp*D@R8N&+S;VgMtKWs7d(@^x8V=Z zlB{Jw4N*a%UebF~6s^rz?tPj3BmA1qz2%P?%yVA`2v`~0tWSIxe(J%gtM#fMZSuow z4|6s6L|f_Taozrm=rimA&iVXjsXo zkyV#07dmn36Ng~6mZN(EXZ8qepCc5#EkAD8(2V6Ut5Y&fy a%?;eY)V;TvqKz3+BZL1EYR}9BPi2hL%55`#tR~C4IEtpIxM+I?wztfcq)qJE5E=|rwyJP z)i|FeP>G-RJT6;Rw8oX{>p~A|I!lfv zs9Cq5`q3PNX&HAI0=Q)jZ)x8#jJH+-?jSbGG?><%$p1LJd}B`@%)y^>r&zYcv-fU zt&P9bb#%?8b2(wE8=mgxDmCuBw9xB8+oombZ`cOkdX{}m@?NLig1qFJ@o}f7ABvDP zSbnkpzd(KBzg31Q|DHMUE^c4ZD0b0gS96eE{B!uRnKLMU%A=* zDt2r5)NJjc-B(}5m)IFBbEDePB25TAW8$$a=10-l3)a8RS$%VT!oKMySDNQr?^@TiPdxLtgZ|R%%QE+QU)*$E{%U>grw$)X76>2yv(zz6+4Q^Or|FlwpaA!D^>bP0l+XkKbHl-k literal 0 HcmV?d00001 diff --git a/public/img/touchbar/play.png b/public/img/touchbar/play.png new file mode 100644 index 0000000000000000000000000000000000000000..101b92ff49e633c9da226166f5dc1655cf7ff367 GIT binary patch literal 746 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1|+Ti+$;i8jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(;Zvw#`F1}W^m|1ySwfhok(#W5s< z_3cb+j~GXhwpd=lEfYjCmBNyQ6?>C52>LADI^mGh!D9)j3nQW;Zbh_iN%GS5ncOgU z8TTwNk-&`;Tm)RWmF=$Qb95{1zCN=!{avypvwis-%jai)*168zZE9+Dg|XB@Hh>+8 zdgS0ZDdd!Kf)xy>>q4p7MqjFI8u6UZGjcu#VR?aN14lv|OI6JLgTF`NJr{%zHM= z*HpGcO9iEObH3hNZB zRd|-LeYtaRoeAH^)kn%~%IhBe=3|%?@LB)0O_ra`noEsBT#n}~EibQF7$o1hmU~wJ zRXWWPw6YipZ+N06&IhIAF0;m zKk$s}hv?Rdd_9+gGY;6Fe9v_;e8ViK2eqH<*s`@!65SsdKUyA8dtzSGwQVeB>y!2` zsM*uiTg1b`ENoi0;ig=ua(MNDHz5m5<(GeX&UI{AlY1U!yC25yPjN)>JBRrfr4}=^(dwHp77nSKvOo&_e3_OOd-=`*-G$#L%=oB(%PiLiB=c&q0ZWzp=5?8Q5299x z3mJ>Oh`oHwq?>tr$GrdvroGD}ubY?`aKBJhNz=K&zN|M>j6F}zcJW1vD{Hc6Nnf)3 zV&Zk?>%`3DSw|aZyY>sdNItu3+0Mqfj{Jfzgu&)m_r6oUuzXgjZ!!OZ_evL@gN-QT zy6d(;-{keIXKdR#^OP>Q-oH1QA->t+en;VYM^i>Sw0O>i?TZX{Gay~&IOxpb?Mr4?deUmm5q*?wtXI3$(?5l_s9xwc)YFs>D$i6 zsmu*GRvxcgblk}neCMVebz^`-|rB+A@-{E@~MclZF`t27ie8^PduSM z{cO#@oK7o7t#2z`6RbPEo=j$2!FAMb+1lrqQxEwy>~%^!ab}&W&ctx72fG;8<~#`h y{K}xvoMGEUo0;|(iynQMcMdsfz!AkG`-6E#ZMNjG6>qnKQiG?fpUXO@geCx?&jg(S literal 0 HcmV?d00001 diff --git a/public/img/touchbar/route_prev.png b/public/img/touchbar/route_prev.png new file mode 100644 index 0000000000000000000000000000000000000000..52cb588d3c8db9265fd42e0037fff1dda02abd46 GIT binary patch literal 610 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1|+Ti+$;i8jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(;Zvw#`F1}W^m|1t)s?2M<2V@L+; z+gXub%#H$Wi_;74_dj%Gk#~tH=-u&pp-uDhfWr7i{&I&@>zMgO&dxu+AarG0(v10O z%l7Y|?O7fw)tmFu!D<5E5@rM?aHz3tx2^jgVf`aH94q_;81w|@yWBlz{k3$x^A3-i zt4sD@H~yZ$#jrzlQA@4!?6AMF*$%qgH^R3_UQfvS;INkKhFH{znX$}oW^Y*g%gA4| zI40X6S3vcR@vSA<2BsAY%vj$j-)edFK8iUj`heYn-ra1$&Foq28navTS9$uc zPok7}85{qVeGPkEr2|1$$a36}-jWEmLYDK!>lGW+nZ9x5ddz$r#r!JZK-?nUT|jfz zFX-rJ`qA{8@#=s5E&ufPY+28J{?GpY6tn7d&+C^NzGQA(v-7KdF^up_;WziWQg+8)HsXj@b7R6H%TBK>8V%VL@R>k^aQbP0 Hl+XkK6PW6^ literal 0 HcmV?d00001 diff --git a/public/img/touchbar/search.png b/public/img/touchbar/search.png new file mode 100644 index 0000000000000000000000000000000000000000..e62e725609a9f33dee7741a26eea9c0d336f87d7 GIT binary patch literal 1084 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1|+Ti+$;i8jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(;Zvw#`F1}W^m|1t)se3_?;GQfkpaVW*5z;wy@?Z z-O-TT*}25GTVavGqDh;0es54Z_2#Q}0lQ!S?;Y>Y$=1FKe!p+$ z_BCf_uW!JFzN|)Oj)8_ZbIPQO%^K1+@LXw(`oOz~x%q+Ii&H5^`k9wARjl~uu-ZE= z{5GM}cjYOGgOV56_Ay8Ac7D**>1XqCn%k2Sm$D{Z%Ov-g-y7mSuLnqU{fn({Ab z!CU6JV%sYB%jrnQPh#zF*d}OI?HD>G;Mp2R{)TPwC1!3%{eG3YOl{U%EAn4&hG;mC z;qC(x2H!;8<;s>Ob66!@VSOuliz~YIh#BMG4bltjk4`(EDdY6&Ab-Ld@#RJ@l?rmq zTO4msn{wIHCh19@)a3g)Z*u4ObHs@A7`_!Zu)crCQ_|hRbOL+##<1z!&QZ*6yq0hC zrvKTvQ(%K{r(ohl|HnJJ4^&32y(n&e?`2I(On6eBl`8*<2l*k{e-6%nm^HVEd(lxX zw{wSu6Td6Ua(6sEdH+F{;Ov&yS06Q>Dt}gVNvb`^L-5qgGo3e8Y{J+63H-V4ZlY_% z;y*6yd=JgP(sk}%pUCn;)9))JeQw=S(Rsi5*q3i+$(_-1L7##aZ{N7@cIS^=p=g0~BL{~9@-Nn3D# z!i%)^R-$j3cmh8~ew(@?_?yiBr2=)&bXm*~#0#VytxtHW)^y5B;r_JZx01}q4^(a7 zIKgf|bGOhN7F&n^aWC6$Excpeeb0Sa&in2Jn~57rgsft8kT5RB7Il?~IivD;TA?J3kiJuwueV b;Sc0D-jP0}J@=_ADCc^*`njxgN@xNA5oX)g literal 0 HcmV?d00001 diff --git a/src/electron/touchBar.js b/src/electron/touchBar.js index f8f791e..7976dab 100644 --- a/src/electron/touchBar.js +++ b/src/electron/touchBar.js @@ -1,70 +1,81 @@ -const { TouchBar, ipcMain } = require("electron"); +const { TouchBar, nativeImage, ipcMain } = require("electron"); const { TouchBarButton, TouchBarSpacer } = TouchBar; +const path = require("path"); export function createTouchBar(window) { const renderer = window.webContents; - // use SF Symbols as label, you probably will see a 􀂒 instead of real icon + // Icon follow touchbar design guideline. + // See: https://developer.apple.com/design/human-interface-guidelines/macos/touch-bar/touch-bar-icons-and-images/ + // Icon Resource: https://devimages-cdn.apple.com/design/resources/ + function getNativeIcon(name) { + return nativeImage.createFromPath( + path.join(__static, "img/touchbar/", name) + ); + } const previousPage = new TouchBarButton({ - label: "􀆉", click: () => { renderer.send("routerGo", "back"); }, + icon: getNativeIcon("page_prev.png"), }); const nextPage = new TouchBarButton({ - label: "􀆊", click: () => { renderer.send("routerGo", "forward"); }, + icon: getNativeIcon("page_next.png"), }); const searchButton = new TouchBarButton({ - label: "􀊫", click: () => { renderer.send("search"); }, + icon: getNativeIcon("search.png"), }); const playButton = new TouchBarButton({ - label: "􀊄", click: () => { renderer.send("play"); }, + icon: getNativeIcon("play.png"), }); const previousTrackButton = new TouchBarButton({ - label: "􀊎", click: () => { renderer.send("previous"); }, + icon: getNativeIcon("backward.png"), }); const nextTrackButton = new TouchBarButton({ - label: "􀊐", click: () => { renderer.send("next"); }, + icon: getNativeIcon("forward.png"), }); const likeButton = new TouchBarButton({ - label: "􀊴", click: () => { renderer.send("like"); }, + icon: getNativeIcon("like.png"), }); const nextUpButton = new TouchBarButton({ - label: "􀑬", click: () => { renderer.send("nextUp"); }, + icon: getNativeIcon("next_up.png"), }); ipcMain.on("player", (e, { playing, likedCurrentTrack }) => { - playButton.label = playing === true ? "􀊆" : "􀊄"; - likeButton.label = likedCurrentTrack ? "􀊵" : "􀊴"; + playButton.icon = + playing === true ? getNativeIcon("pause.png") : getNativeIcon("play.png"); + likeButton.icon = likedCurrentTrack + ? getNativeIcon("like_fill.png") + : getNativeIcon("like.png"); }); const touchBar = new TouchBar({