添加启动验证功能

This commit is contained in:
叶志超
2023-07-19 10:56:45 +08:00
parent 51744eac8f
commit fc337e951d
3 changed files with 1384 additions and 704 deletions

View File

@@ -1,5 +1,14 @@
import { app, globalShortcut, BrowserWindow } from 'electron'
import { app, globalShortcut, BrowserWindow, dialog } from 'electron'
import { join } from "path"
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
}
function createWindow() {
const win = new BrowserWindow({
@@ -19,11 +28,17 @@ function createWindow() {
}
}
app.whenReady().then(() => {
createWindow()
// 屏蔽 F11 进入/退出全屏功能
globalShortcut.register('F11', () => {return})
app.whenReady().then(async () => {
const checkReault = await checkLaunchEnv()
if (checkReault) {
createWindow()
// 屏蔽 F11 进入/退出全屏功能
globalShortcut.register('F11', () => {return})
} else {
dialog.showErrorBox('系统提示', '软件启动出错,请联系售后技术支持人员')
app.quit()
}
})
app.on('window-all-closed', () => {