我面临的一个问题是,我能够在electron+angular 10+的帮助下生成exe,并且能够安装它。但当我运行已安装的应用程序时,它会被trend micro antivirus阻止,在其他系统中,不安装允许我使用已安装应用程序的防病毒软件。我在谷歌上搜索并尝试了多种解决方案,但都没有成功。
下面是我的包裹。json文件代码
"name": "e-chat-announcement-angular",
"description": "CLI app",
"author": "Me me me",
"version": "0.0.1",
"main": "main.js",
"build": {
"appId": "eChatAnnouncement",
"productName": "ECHATANNOUNCEMENT",
"files": [
"**/*",
"dist/**/*"
],
"directories": {
"output": "release",
"buildResources": "dist"
},
"asar": false,
"win": {
"target": [
"nsis"
],
"icon": "src/icon.ico",
"requestedExecutionLevel": "requireAdministrator"
},
"nsis": {
"installerIcon": "src/icon.ico",
"uninstallerIcon": "src/icon.ico",
"uninstallDisplayName": "ECHATANNOUNCEMENT",
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"runAfterFinish": true
}
},
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"postinstall": "install-app-deps",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron-build": "ng build --prod && electron .",
"electron-package": "electron-packager . --platform=win32 --arch=x64",
"start:electron": "ng build --prod --base-href ./ && electron .",
"pack": "electron-builder --dir",
"setup": "electron-builder"
},
"private": true,
"dependencies": {
"@angular/animations": "~11.0.8",
"@angular/cdk": "^11.0.3",
"@angular/common": "~11.0.8",
"@angular/compiler": "~11.0.8",
"@angular/core": "~11.0.8",
"@angular/forms": "~11.0.8",
"@angular/material": "^11.0.3",
"@angular/platform-browser": "~11.0.8",
"@angular/platform-browser-dynamic": "~11.0.8",
"@angular/router": "~11.0.8",
"custom-electron-titlebar": "^3.2.6",
"jquery": "^3.5.1",
"ngx-toastr": "^10.0.4",
"rxjs": "~6.6.0",
"rxjs-compat": "^6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.5",
"@angular/cli": "~11.0.5",
"@angular/compiler-cli": "~11.0.5",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.19.13",
"codelyzer": "^6.0.0",
"electron": "^11.2.0",
"electron-builder": "^22.9.1",
"electron-packager": "^15.2.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.2",
"karma": "~5.1.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
}
以下是我的主要观点。js用于电子
const {app, BrowserWindow } = require('electron');
// SSL/TSL: this is the self signed certificate support
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
// On certificate error we disable default behaviour (stop loading the page)
// and we then say "it is all fine - true" to the callback
event.preventDefault();
callback(true);
});
const url = require("url");
const path = require("path");
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
frame:false,
webPreferences: {
nodeIntegration: true,
enableRemoteModule:true,
webSecurity: false
}
})
// new BrowserWindow({ webPreferences: { webSecurity: false } })
//mainWindow.setMenuBarVisibility= false;
mainWindow.loadURL(
url.format({
pathname: path.join(__dirname, `/dist/E-Chat-Announcement-Angular/index.html`),
protocol: "file:",
slashes: true
})
);
// Open the DevTools.
mainWindow.webContents.openDevTools()
mainWindow.on('closed', function () {
mainWindow = null
})
//mainWindow.maximize();
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
app.on('activate', function () {
if (mainWindow === null) createWindow()
})
似乎我的应用程序中的配置部分缺少了一些东西,或者我的应用程序可能是其他东西,
下面是防病毒日志的截图
如果需要更多信息,请告诉我。