Skip to content

Commit 121716e

Browse files
committed
Init project keyboardtools
0 parents  commit 121716e

17 files changed

+21077
-0
lines changed

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

Procfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
react: npm start
2+
electron: node electron-wait-react

README.md

Lines changed: 2444 additions & 0 deletions
Large diffs are not rendered by default.

electron-starter.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const electron = require('electron');
2+
// Module to control application life.
3+
const app = electron.app;
4+
// Module to create native browser window.
5+
const BrowserWindow = electron.BrowserWindow;
6+
7+
const path = require('path');
8+
const url = require('url');
9+
10+
// Keep a global reference of the window object, if you don't, the window will
11+
// be closed automatically when the JavaScript object is garbage collected.
12+
let mainWindow;
13+
14+
function createWindow() {
15+
// Create the browser window.
16+
mainWindow = new BrowserWindow({
17+
width: 800,
18+
height: 300,
19+
transparent: true,
20+
frame: false,
21+
alwaysOnTop: true,
22+
});
23+
24+
25+
// and load the index.html of the app.
26+
const startUrl = process.env.ELECTRON_START_URL || url.format({
27+
pathname: path.join(__dirname, '/../build/index.html'),
28+
protocol: 'file:',
29+
slashes: true
30+
});
31+
mainWindow.loadURL(startUrl);
32+
// Open the DevTools.
33+
// mainWindow.webContents.openDevTools();
34+
35+
// Emitted when the window is closed.
36+
mainWindow.on('closed', function () {
37+
// Dereference the window object, usually you would store windows
38+
// in an array if your app supports multi windows, this is the time
39+
// when you should delete the corresponding element.
40+
mainWindow = null
41+
})
42+
43+
mainWindow.setSimpleFullScreen(true);
44+
mainWindow.setResizable(false);
45+
mainWindow.setIgnoreMouseEvents(true);
46+
47+
}
48+
49+
// This method will be called when Electron has finished
50+
// initialization and is ready to create browser windows.
51+
// Some APIs can only be used after this event occurs.
52+
app.on('ready', createWindow);
53+
54+
// Quit when all windows are closed.
55+
app.on('window-all-closed', function () {
56+
// On OS X it is common for applications and their menu bar
57+
// to stay active until the user quits explicitly with Cmd + Q
58+
if (process.platform !== 'darwin') {
59+
app.quit()
60+
}
61+
});
62+
63+
app.on('activate', function () {
64+
// On OS X it's common to re-create a window in the app when the
65+
// dock icon is clicked and there are no other windows open.
66+
if (mainWindow === null) {
67+
createWindow()
68+
}
69+
});
70+
71+
// In this file you can include the rest of your app's specific main process
72+
// code. You can also put them in separate files and require them here.

electron-wait-react.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const net = require('net');
2+
const port = process.env.PORT ? (process.env.PORT - 100) : 3000;
3+
4+
process.env.ELECTRON_START_URL = `http://localhost:${port}`;
5+
6+
const client = new net.Socket();
7+
8+
let startedElectron = false;
9+
const tryConnection = () => client.connect({port: port}, () => {
10+
client.end();
11+
if(!startedElectron) {
12+
console.log('starting electron');
13+
startedElectron = true;
14+
const exec = require('child_process').exec;
15+
exec('npm run electron');
16+
}
17+
}
18+
);
19+
20+
tryConnection();
21+
22+
client.on('error', (error) => {
23+
setTimeout(tryConnection, 1000);
24+
});

0 commit comments

Comments
 (0)