first commit

This commit is contained in:
yezhichao@hwasmart.com
2021-09-14 07:31:59 +08:00
commit d0f3fccb12
35 changed files with 4191 additions and 0 deletions

31
src/main/app.ts Normal file
View File

@@ -0,0 +1,31 @@
import { app, BrowserWindow } from 'electron'
import { join } from "path"
const URL = (process.env.NODE_ENV === 'development') ? 'http://localhost:3000/' : 'gnss.cesium.hwasmart.com'
function createWindow() {
const win = new BrowserWindow({
fullscreen: true,
frame: false,
webPreferences: {
nodeIntegration: true,
preload: join(__dirname, 'preload.js')
}
})
win.loadURL(URL)
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})

20
src/main/preload.js Normal file
View File

@@ -0,0 +1,20 @@
const {ipcRenderer, contextBridge} = require('electron')
contextBridge.exposeInMainWorld('ipcRenderer', {
send: (channel, data) => {
// whitelist channels
let validChannels = ['toMain']
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data)
}
ipcRenderer.send(channel, data)
},
receive: (channel, func) => {
let validChannels = ['fromMain']
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args))
}
ipcRenderer.on(channel, (event, ...args) => func(...args))
}
})