
Kelin
31.07.2018
19:12:25
Загуглилось быстро
ща найду
Короче, создаешь трей (new Tray) и окно
const getWindowPosition = () => {
const windowBounds = mainWindow.getBounds()
const trayBounds = tray.getBounds()
// Center mainWindow horizontally below the tray icon
const x = Math.round(
trayBounds.x + trayBounds.width / 2 - windowBounds.width / 2
)
// Position mainWindow 4 pixels vertically below the tray icon
const y = Math.round(trayBounds.y + trayBounds.height + 4)
return { x: x, y: y }
}
Координаты для окна берутся так
+ это для того, чтобы иконка активная/неактивная становилась
mainWindow.on("show", () => {
tray.setHighlightMode("always")
})
mainWindow.on("hide", () => {
tray.setHighlightMode("never")
})
+ это обработчик клика по иконке, который скроет/покажет окно
tray.on("click", toggleWindow)
const toggleWindow = () => {
if (mainWindow.isVisible()) {
mainWindow.hide()
} else {
showWindow()
}
}
const showWindow = () => {
const position = getWindowPosition()
mainWindow.setPosition(position.x, position.y, false)
mainWindow.show()
mainWindow.focus()
}
сори за портянку

Ernest
04.08.2018
13:03:03
{
"name": "Behive-Desktop",
"version": "1.1.4",
"description": "Behive Desktop App",
"main": "main.js",
"license": "MIT",
"scripts": {
"start": "webpack --progress --config webpack.config.js && electron .",
"dev": "webpack-dev-server --progress --config webpack.config.dev.js",
"compile": "webpack --progress --config webpack.config.js",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"fmt:prettier": "prettier --write --single-quote",
"lint:eslint": "eslint --ignore-path .gitignore",
"precommit": "lint-staged"
},
"repository": {
"type": "git",
"url": "git@git.bluenet.io:behive/behive-desktop.git"
},
"contributors": [
"Sirarpi Manukyan",
"Ernest Chakhoyan <chakhoyanernest@gmail.com>",
"Grigor Apresyan"
],
"build": {
"appId": "org.behive.blunet",
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"category": "Hospital",
"target": [
"AppImage",
"deb"
]
},
"win": {
"target": "NSIS",
"icon": "build/icon.ico"
},
"mac": {
"category": "public.app-category.hospitality"
}
},
"devDependencies": {
"axios": "^0.17.1",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.7",
"electron": "^1.8.7",
"electron-builder": "^19.49.0",
"eslint": "^4.15.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.4.0",
"eslint-plugin-react": "^7.5.1",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.6",
"history": "^4.7.2",
"html-webpack-plugin": "^2.30.1",
"husky": "^0.14.3",
"image-compressor": "^1.2.0",
"lint-staged": "^6.0.0",
"material-ui": "^1.0.0-beta.33",
"material-ui-icons": "^1.0.0-beta.17",
"node-sass": "^4.7.2",
"prettier": "1.9.2",
"prettier-eslint-cli": "^4.7.0",
"prop-types": "^15.6.0",
"react": "^16.2.0",
"react-bootstrap": "^0.32.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-router-dom": "^4.2.2",
"react-telephone-input": "^4.3.4",
"redux": "^3.7.2",
"redux-devtools-extension": "^2.13.2",
"redux-immutable-state-invariant": "^2.1.0",
"redux-thunk": "^2.2.0",
"sass-loader": "^6.0.6",
"style-loader": "^0.19.1",
"url-loader": "^0.6.2",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7"
},
"dependencies": {
"@aspnet/signalr": "^1.0.2",
"@livechat/ui-kit": "^0.1.0",
"electron-windows-notifications": "^2.1.1",
"image-compressor.js": "^1.0.0",
"lodash": "^4.17.5",
"moment": "^2.22.1",
"msgpack5": "^4.2.0",
"qrcode.react": "^0.8.0",
"react-datepicker": "^1.4.1",
"react-dropzone": "^4.2.9",
"react-progress-bar-plus": "^1.3.1",
"react-select-plus": "^1.2.0",
"react-soundplayer": "^1.0.4",
"redux-logger": "^3.0.6",
"store": "^2.0.12",
"tslib": "^1.9.3"
},
"stylelint": {
"extends": "stylelint-config-standard",
"rules": {
"indentation": null
}
},
"lint-staged": {
"src/**/*.{js,jsx}": [
"fmt:prettier",
"lint:eslint",
"git add"
]
},
"prettier": {
"singleQuote": true
}
}
Вебпак тоже есть