mirror of https://github.com/vector-im/riot-web
Merge pull request #3622 from t3chguy/t3chguy/electron-persist-window-layout
Remember and Recall window layout/position statepull/3829/head
commit
2c36506342
|
@ -5,6 +5,7 @@
|
|||
/key.pem
|
||||
/lib
|
||||
/node_modules
|
||||
/electron/node_modules
|
||||
/packages/
|
||||
/webapp
|
||||
/.npmrc
|
||||
|
|
|
@ -135,7 +135,7 @@ To run as a desktop app:
|
|||
|
||||
```
|
||||
npm install electron
|
||||
node_modules/.bin/electron .
|
||||
npm run electron
|
||||
```
|
||||
|
||||
To build packages, use electron-builder. This is configured to output:
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "riot-web",
|
||||
"main": "src/electron-main.js",
|
||||
"version": "0.9.8",
|
||||
"description": "A feature-rich client for Matrix.org",
|
||||
"author": "Vector Creations Ltd.",
|
||||
"dependencies": {
|
||||
"electron-window-state": "^4.1.0"
|
||||
}
|
||||
}
|
|
@ -30,6 +30,8 @@ const tray = require('./tray');
|
|||
|
||||
const VectorMenu = require('./vectormenu');
|
||||
|
||||
const windowStateKeeper = require('electron-window-state');
|
||||
|
||||
let vectorConfig = {};
|
||||
try {
|
||||
vectorConfig = require('../../webapp/config.json');
|
||||
|
@ -187,11 +189,21 @@ electron.app.on('ready', () => {
|
|||
process.platform == 'win32' ? 'ico' : 'png'
|
||||
);
|
||||
|
||||
// Load the previous window state with fallback to defaults
|
||||
let mainWindowState = windowStateKeeper({
|
||||
defaultWidth: 1024,
|
||||
defaultHeight: 768,
|
||||
});
|
||||
|
||||
mainWindow = new electron.BrowserWindow({
|
||||
icon: icon_path,
|
||||
width: 1024, height: 768,
|
||||
show: false,
|
||||
autoHideMenuBar: true,
|
||||
|
||||
x: mainWindowState.x,
|
||||
y: mainWindowState.y,
|
||||
width: mainWindowState.width,
|
||||
height: mainWindowState.height,
|
||||
});
|
||||
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
|
||||
electron.Menu.setApplicationMenu(VectorMenu);
|
||||
|
@ -230,6 +242,8 @@ electron.app.on('ready', () => {
|
|||
onLinkContextMenu(ev, params);
|
||||
}
|
||||
});
|
||||
|
||||
mainWindowState.manage(mainWindow);
|
||||
});
|
||||
|
||||
electron.app.on('window-all-closed', () => {
|
||||
|
|
21
package.json
21
package.json
|
@ -36,6 +36,8 @@
|
|||
"build": "npm run build:res && npm run build:bundle",
|
||||
"build:dev": "npm run build:res && npm run build:bundle:dev",
|
||||
"dist": "scripts/package.sh",
|
||||
"install:electron": "install-app-deps",
|
||||
"electron": "npm run install:electron && electron .",
|
||||
"start:res": "node scripts/copy-res.js -w",
|
||||
"start:js": "webpack-dev-server --output-filename=bundles/_dev_/[name].js --output-chunk-file=bundles/_dev_/[name].js -w --progress",
|
||||
"start:js:prod": "cross-env NODE_ENV=production webpack-dev-server -w --progress",
|
||||
|
@ -145,10 +147,12 @@
|
|||
"dereference": true,
|
||||
"//files": "We bundle everything, so we only need to include webapp/",
|
||||
"files": [
|
||||
"electron/src/**",
|
||||
"electron/img/**",
|
||||
"webapp/**",
|
||||
"package.json"
|
||||
"node_modules/**",
|
||||
"src/**",
|
||||
"img/**"
|
||||
],
|
||||
"extraResources": [
|
||||
"webapp/**/*"
|
||||
],
|
||||
"linux": {
|
||||
"target": "deb",
|
||||
|
@ -159,10 +163,11 @@
|
|||
},
|
||||
"win": {
|
||||
"target": "squirrel"
|
||||
},
|
||||
"directories": {
|
||||
"buildResources": "electron/build",
|
||||
"output": "electron/dist",
|
||||
"app": "electron"
|
||||
}
|
||||
},
|
||||
"directories": {
|
||||
"buildResources": "electron/build",
|
||||
"output": "electron/dist"
|
||||
}
|
||||
}
|
||||
|
|
15
release.sh
15
release.sh
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# Script to perform a release of vector-web.
|
||||
#
|
||||
|
@ -9,4 +9,17 @@ set -e
|
|||
|
||||
cd `dirname $0`
|
||||
|
||||
|
||||
# bump Electron's package.json first
|
||||
release="${1#v}"
|
||||
tag="v${release}"
|
||||
echo "electron npm version"
|
||||
|
||||
cd electron
|
||||
npm version --no-git-tag-version "$release"
|
||||
git commit package.json -m "$tag"
|
||||
|
||||
|
||||
cd ..
|
||||
|
||||
exec ./node_modules/matrix-js-sdk/release.sh -z "$@"
|
||||
|
|
Loading…
Reference in New Issue