Files
global-navigation-satellite…/src/main/app.ts

55 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-07-19 10:56:45 +08:00
import { app, globalShortcut, BrowserWindow, dialog } from 'electron'
2021-09-14 07:31:59 +08:00
import { join } from "path"
2023-07-19 10:56:45 +08:00
import { promisified as regedit } from 'regedit'
// const regedit = require('regedit').promisified
const REG_DIR_PATH:string[] = ['HKCU\\SOFTWARE\\HwaSmart']
async function checkLaunchEnv() {
const result = await regedit.list(REG_DIR_PATH)
// console.log(result[REG_DIR_PATH[0]].exists)
return result[REG_DIR_PATH[0]].exists
}
2021-09-14 07:31:59 +08:00
function createWindow() {
2021-12-09 15:06:40 +08:00
const win = new BrowserWindow({
fullscreen: true,
frame: false,
webPreferences: {
nodeIntegration: true,
preload: join(__dirname, 'preload.js')
}
})
2021-09-14 07:31:59 +08:00
2021-12-09 15:06:40 +08:00
if (process.env.NODE_ENV === 'development') {
win.loadURL('http://localhost:3000/')
win.webContents.openDevTools()
} else {
win.loadFile('dist/render/index.html')
}
2021-09-14 07:31:59 +08:00
}
2023-07-19 10:56:45 +08:00
app.whenReady().then(async () => {
const checkReault = await checkLaunchEnv()
if (checkReault) {
createWindow()
// 屏蔽 F11 进入/退出全屏功能
globalShortcut.register('F11', () => {return})
} else {
dialog.showErrorBox('系统提示', '软件启动出错,请联系售后技术支持人员')
app.quit()
}
2021-12-24 10:53:41 +08:00
})
2021-09-14 07:31:59 +08:00
app.on('window-all-closed', () => {
2021-12-09 15:06:40 +08:00
if (process.platform !== 'darwin') {
app.quit()
}
2021-09-14 07:31:59 +08:00
})
app.on('activate', () => {
2021-12-09 15:06:40 +08:00
if (BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})