1
0
mirror of https://github.com/kremalicious/blowfish.git synced 2024-12-27 23:27:52 +01:00

preferences menu item

This commit is contained in:
Matthias Kretschmann 2019-05-16 22:25:19 +02:00
parent ef09f70388
commit ee2f1d4d96
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 174 additions and 136 deletions

View File

@ -16,6 +16,7 @@
"dist": "npm run build && npm run package"
},
"repository": "https://github.com/kremalicious/ocean-balance.git",
"homepage": "https://github.com/kremalicious/ocean-balance",
"author": "Matthias Kretschmann",
"license": "MIT",
"dependencies": {

View File

@ -1,7 +1,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { Router, Location } from '@reach/router'
import { webFrame } from 'electron'
import { Router, Location, navigate } from '@reach/router'
import { webFrame, ipcRenderer } from 'electron'
import posed, { PoseGroup } from 'react-pose'
import Titlebar from './components/Titlebar'
import Home from './screens/Home'
@ -35,6 +35,12 @@ PosedRouter.propTypes = {
}
export default class App extends PureComponent {
componentDidMount() {
ipcRenderer.on('goTo', (evt, route) => {
navigate(route)
})
}
render() {
return (
<>

View File

@ -1,6 +1,7 @@
const path = require('path')
const { app, BrowserWindow, systemPreferences } = require('electron')
const { touchBarWrapper } = require('react-touchbar-electron')
const buildMenu = require('./menu')
let mainWindow
@ -106,11 +107,13 @@ const createWindow = async () => {
switchTheme()
// Load menubar menu items
require('./menu.js')
buildMenu(mainWindow)
touchBarWrapper(mainWindow)
}
module.exports = { mainWindow }
app.on('ready', () => {
createWindow()

View File

@ -1,6 +1,8 @@
const { app, Menu } = require('electron')
const { openUrl } = require('./app/util/openUrl')
const { homepage } = require('../package.json')
const buildMenu = mainWindow => {
const template = [
{
label: 'Edit',
@ -71,7 +73,7 @@ const template = [
{
label: 'Learn More',
click() {
openUrl('https://electron.atom.io')
openUrl(homepage)
}
}
]
@ -88,6 +90,16 @@ if (process.platform === 'darwin') {
{
type: 'separator'
},
{
label: 'Preferences...',
accelerator: 'CmdOrCtrl+,',
click() {
mainWindow.webContents.send('goTo', '/preferences')
}
},
{
type: 'separator'
},
{
role: 'services',
submenu: []
@ -133,15 +145,15 @@ if (process.platform === 'darwin') {
// Window menu
template[3].submenu = [
{
role: 'close'
},
{
role: 'minimize'
},
{
role: 'zoom'
},
{
role: 'close'
},
{
type: 'separator'
},
@ -151,5 +163,21 @@ if (process.platform === 'darwin') {
]
}
if (process.platform !== 'darwin') {
template[0].submenu.push(
{ type: 'separator' },
{
label: 'Preferences...',
accelerator: 'CmdOrCtrl+,',
click() {
mainWindow.webContents.send('goTo', '/preferences')
}
}
)
}
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
}
module.exports = buildMenu