Trying to find out how to reference my Tray object. It has been created, but for some reason, I cannot seem to find out how to call it for reference. Trying via dev console...
require('electron').remote.Tray
This seems to get the native function for Tray... I have tried remote.getTray()
and a few others.. I am using electron-vue . Here is my electron.js
setup.
'use strict'
const electron = require('electron')
const path = require('path')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
var {Menu, Tray} = require('electron')
let tray = null
app.on('ready', () => {
tray = new Tray(__dirname + '\\icons\\twitch.ico')
const contextMenu = Menu.buildFromTemplate([
{label: 'Item1', type: 'radio'},
{label: 'Item2', type: 'radio'},
{label: 'Item3', type: 'radio', checked: true},
{label: 'Item4', type: 'radio'}
]);
tray.setToolTip('Welcome')
tray.setContextMenu(contextMenu)
})
...
I do not know how to reference it correctly. Here is the Tray Documentation
My ultimate goal is to use some of the (located in the Tray Documentation) (位于托盘文档中)
Thanks!
You need to use ipcMain
and ipcRenderer
for the interaction between your UI and your Electron instance.
Let's say you wrote the following in the *.vue
file:
const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
.....
.....
ipcRenderer.on('interactionSignalFromUI');
Then again in the electron.js
setup you need to simply call:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.