๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ–ฅ๏ธํ”„๋ก ํŠธ์—”๋“œ/Electron.js

Electron - Tray ์ƒ์„ฑ ๋ฐ ํด๋ฆญ ์ด๋ฒคํŠธ, Tray ์•„์ด์ฝ˜ ๋ณ€๊ฒฝ

by Janger 2022. 3. 28.
728x90
๋ฐ˜์‘ํ˜•
const { app, BrowserWindow, Menu, Tray } = require('electron');


let tray = null
app.whenReady().then(() => {
  tray = new Tray('./icon1.png');

    var contextMenu = Menu.buildFromTemplate([
        { label: 'Hello world!', click:  function(){
            console.log('Hello world!');
            tray.setImage('./icon2.png');
        } },
        { label: 'Quit', click:  function(){
            app.quit();
        } }
    ]);
    tray.setContextMenu(contextMenu);
})

 

Tray ์ƒ์„ฑ ๋ฐ ํด๋ฆญ ์ด๋ฒคํŠธ, Tray ์•„์ด์ฝ˜ ๋ณ€๊ฒฝ

 

์ถœ์ฒ˜: 

https://www.electronjs.org/docs/latest/api/tray

 

Tray | Electron

Add icons and context menus to the system's notification area.

www.electronjs.org

https://stackoverflow.com/questions/43689286/how-to-update-tray-icon

 

How to update tray icon

In Electron, it is possible to create a tray icon by using new Tray(image), for example: let iconPath = path.join(__dirname, 'icon.png'); appIcon = new Tray(iconPath); As stated in the documentat...

stackoverflow.com

 

728x90
๋ฐ˜์‘ํ˜•