gRPC is added
This commit is contained in:
parent
7fb66f3358
commit
e9cf4adac2
2226
package-lock.json
generated
2226
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
|
@ -11,10 +11,25 @@
|
|||
"scripts": {
|
||||
"electron": "tsc --p ./ && electron ."
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"electron-devtools-installer": "^2.2.4",
|
||||
"electron-log": "^3.0.5",
|
||||
"electron-window-state": "^5.0.3",
|
||||
"file-uri-to-path": "^1.0.0",
|
||||
"file-url": "^3.0.0",
|
||||
"fs-extra": "^7.0.1",
|
||||
"grpc": "^1.20.3",
|
||||
"rxjs": "^6.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/electron": "^1.6.10",
|
||||
"@odds-crawler/proto": "^0.0.4",
|
||||
"@types/google-protobuf": "^3.2.7",
|
||||
"@types/node": "^8.9.4",
|
||||
"electron": "^5.0.0",
|
||||
"electron-builder": "^20.40.2",
|
||||
"electron-connect": "^0.6.3",
|
||||
"electron-debug": "^3.0.0",
|
||||
"google-protobuf": "^3.8.0-rc.1",
|
||||
"ts-node": "^8.1.0",
|
||||
"tslint": "^5.16.0",
|
||||
"typescript": "^3.4.5"
|
||||
|
|
32
src/main.ts
32
src/main.ts
|
@ -2,25 +2,36 @@ import { app, BrowserWindow, ipcMain } from 'electron';
|
|||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
import * as fs from 'fs';
|
||||
import * as grpc from 'grpc';
|
||||
|
||||
let win: BrowserWindow;
|
||||
import { CDPServiceClient } from '@odds-crawler/proto/cdp/cdp.service_grpc_pb';
|
||||
|
||||
let mainWindow: BrowserWindow;
|
||||
|
||||
app.on('ready', createWindow);
|
||||
|
||||
app.on('activate', () => {
|
||||
if (win === null) {
|
||||
if (null === mainWindow) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if ('darwin' !== process.platform) {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
function createWindow() {
|
||||
win = new BrowserWindow({
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
webPreferences: { nodeIntegration: true }
|
||||
});
|
||||
|
||||
win.loadURL(
|
||||
mainWindow.loadURL(
|
||||
url.format({
|
||||
pathname: path.join(
|
||||
__dirname,
|
||||
|
@ -31,14 +42,19 @@ function createWindow() {
|
|||
})
|
||||
);
|
||||
|
||||
win.webContents.openDevTools();
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
win.on('closed', () => {
|
||||
win = null;
|
||||
mainWindow.on('closed', () => {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
let cdpServiceClient = new CDPServiceClient(
|
||||
'localhost:50051',
|
||||
grpc.credentials.createInsecure()
|
||||
);
|
||||
}
|
||||
|
||||
ipcMain.on('getFiles', (event, arg) => {
|
||||
const files = fs.readdirSync(__dirname);
|
||||
win.webContents.send('getFilesResponse', files);
|
||||
mainWindow.webContents.send('getFilesResponse', files);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user