修复“添加启动验证功能”在生产模式下不能正常工作的问题
parent
fc337e951d
commit
09f7eefe31
|
@ -13,7 +13,6 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cesium": "^1.88.0",
|
"cesium": "^1.88.0",
|
||||||
"regedit": "^5.1.2",
|
|
||||||
"vue": "^3.2.26",
|
"vue": "^3.2.26",
|
||||||
"vue-cesium": "^3.0.4",
|
"vue-cesium": "^3.0.4",
|
||||||
"vuex": "^4.0.1"
|
"vuex": "^4.0.1"
|
||||||
|
|
|
@ -1,15 +1,42 @@
|
||||||
import { app, globalShortcut, BrowserWindow, dialog } from 'electron'
|
import { app, globalShortcut, BrowserWindow, dialog } from 'electron'
|
||||||
import { join } from "path"
|
import { join } from 'path'
|
||||||
import { promisified as regedit } from 'regedit'
|
|
||||||
// const regedit = require('regedit').promisified
|
|
||||||
|
|
||||||
const REG_DIR_PATH:string[] = ['HKCU\\SOFTWARE\\HwaSmart']
|
const child_process = require('child_process')
|
||||||
async function checkLaunchEnv() {
|
|
||||||
const result = await regedit.list(REG_DIR_PATH)
|
function queryKeys(keyPath: string, value: string) {
|
||||||
// console.log(result[REG_DIR_PATH[0]].exists)
|
return new Promise(function (resolve, reject) {
|
||||||
return result[REG_DIR_PATH[0]].exists
|
try {
|
||||||
|
child_process.exec(`reg query ${keyPath} /v ${value}`, (error: Error, stdout: string, stderr: string) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve({stdout, stderr});
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const keyPath = 'HKEY_CURRENT_USER\\SOFTWARE\\HwaSmart'
|
||||||
|
const value = 'global-navigation-satellite-system'
|
||||||
|
async function checkLaunchEnv() {
|
||||||
|
try {
|
||||||
|
const result: any = await queryKeys(keyPath, value);
|
||||||
|
// console.log('stdout', result.stdout);
|
||||||
|
return true
|
||||||
|
// 成功
|
||||||
|
// 查询到 有这个app启动项
|
||||||
|
} catch (error) {
|
||||||
|
// 没有查询到该app启动项目
|
||||||
|
// console.log('error :>> ', error);
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
fullscreen: true,
|
fullscreen: true,
|
||||||
|
@ -28,27 +55,37 @@ function createWindow() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(async () => {
|
|
||||||
const checkReault = await checkLaunchEnv()
|
|
||||||
if (checkReault) {
|
|
||||||
createWindow()
|
|
||||||
|
|
||||||
// 屏蔽 F11 进入/退出全屏功能
|
async function main() {
|
||||||
globalShortcut.register('F11', () => {return})
|
// 异步代码
|
||||||
|
const checkReault: any = await checkLaunchEnv()
|
||||||
|
console.log('env right:', checkReault);
|
||||||
|
|
||||||
|
// 异步代码执行完毕后执行的代码
|
||||||
|
if (checkReault) {
|
||||||
|
app.whenReady().then(async () => {
|
||||||
|
|
||||||
|
createWindow()
|
||||||
|
|
||||||
|
// 屏蔽 F11 进入/退出全屏功能
|
||||||
|
globalShortcut.register('F11', () => {return})
|
||||||
|
})
|
||||||
|
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
createWindow()
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
dialog.showErrorBox('系统提示', '软件启动出错,请联系售后技术支持人员')
|
dialog.showErrorBox('系统提示', '软件启动出错,请联系售后技术支持人员')
|
||||||
app.quit()
|
process.exit(1)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
main();
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
app.on('activate', () => {
|
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
|
||||||
createWindow()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
Loading…
Reference in New Issue