Browse Source

Improved build, fix center window with multiscreen

master
Loëck Vézien 7 years ago
parent
commit
0df6e7f152
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 4
      .babelrc
  2. 36
      electron-builder.yml
  3. 16
      src/components/base/Defer.js
  4. 36
      src/main/app.js

4
.babelrc

@ -3,9 +3,11 @@
[
"env",
{
"loose": true,
"modules": false,
"targets": {
"node": "8"
"electron": "1.8",
"node": "current"
}
}
],

36
electron-builder.yml

@ -1,4 +1,4 @@
appId: com.electron.ledger
appId: com.ledger.desktop
protocols:
name: Ledger Wallet Desktop
@ -6,9 +6,39 @@ protocols:
- ledgerhq
mac:
category: public.app-category.utilities
artifactName: ${name}-${version}-${os}.${ext}
category: public.app-category.wallet
target:
- dmg
- zip
linux:
target: appImage
artifactName: ${name}-${version}-${os}-${arch}.${ext}
target:
- target: AppImage
arch:
- x64
- target: tar.gz
arch:
- x64
win:
artifactName: ${name}-${version}-${os}-${arch}.${ext}
target:
- target: nsis
arch:
- x64
- ia32
- target: zip
arch:
- x64
- ia32
nsis:
oneClick: false
perMachine: true
allowToChangeInstallationDirectory: true
files:
- dist/internals

16
src/components/base/Defer.js

@ -7,31 +7,25 @@ type Props = {
}
type State = {
show: boolean,
shouldRender: boolean,
}
class Defer extends PureComponent<Props, State> {
state = {
show: false,
shouldRender: false,
}
componentDidMount() {
window.requestAnimationFrame(() =>
this.setState({
show: true,
}),
window.requestAnimationFrame(() => this.setState({ shouldRender: true })),
)
}
render() {
const { children } = this.props
const { show } = this.state
const { shouldRender } = this.state
if (show) {
return children
}
return null
return shouldRender ? children : null
}
}

36
src/main/app.js

@ -1,6 +1,6 @@
// @flow
import { app, BrowserWindow, Menu, ipcMain } from 'electron'
import { app, BrowserWindow, Menu, ipcMain, screen } from 'electron'
import menu from 'main/menu'
@ -12,31 +12,43 @@ let forceClose = false
const devTools = __DEV__
const defaultWindowOptions = {
const getWindowPosition = (height, width) => {
const { bounds } = screen.getPrimaryDisplay()
return {
x: Math.ceil(bounds.x + (bounds.width - width) / 2),
y: Math.ceil(bounds.y + (bounds.height - height) / 2),
}
}
const defaultWindowOptions = ({ height, width }) => ({
...getWindowPosition(height, width),
backgroundColor: '#fff',
center: true,
webPreferences: {
devTools,
},
}
})
function createMainWindow() {
const MIN_HEIGHT = 768
const MIN_WIDTH = 1024
const height = MIN_HEIGHT
const width = MIN_WIDTH
const windowOptions = {
...defaultWindowOptions,
...defaultWindowOptions({ height, width }),
...(process.platform === 'darwin'
? {
frame: false,
titleBarStyle: 'hiddenInset',
}
: {}),
height: MIN_HEIGHT,
height,
minHeight: MIN_HEIGHT,
minWidth: MIN_WIDTH,
show: false,
width: MIN_WIDTH,
width,
webPreferences: {
...defaultWindowOptions.webPreferences,
// Enable, among other things, the ResizeObserver
@ -80,19 +92,19 @@ function createPreloadWindow() {
// Preload renderer of main windows
mainWindow = createMainWindow()
const HEIGHT = 144
const WIDTH = 256
const height = 144
const width = 256
const windowOptions = {
...defaultWindowOptions,
...defaultWindowOptions({ height, width }),
closable: false,
frame: false,
fullscreenable: false,
height: HEIGHT,
height,
resizable: false,
show: false,
skipTaskbar: true,
width: WIDTH,
width,
}
const window = new BrowserWindow(windowOptions)

Loading…
Cancel
Save