gpt4 book ai didi

javascript - Electron js应用程序构建后无法正常工作

转载 作者:行者123 更新时间:2023-12-03 12:41:28 25 4
gpt4 key购买 nike

我用 Electron js和用knex创建sqlite的小应用程序
当我运行npm start时,它可以正常工作,但是当我尝试使用 Electron 生成器在Windows中构建应用程序时
我有问题,登录表单不起作用,我激活了开发人员模式,控制台日志中没有任何错误,我使用jQuery提交了事件

package.json

{
"name": "olad-amtaia-water-manager",
"version": "0.0.1",
"description": "Gérer les factures d'eau d'une association villageoise",
"main": "main.js",
"scripts": {
"postinstall": "electron-builder install-app-deps",
"start": "electron .",
"pack": "build --dir",
"dist": "electron-builder",
"rebuild": "electron-rebuild -f -w sqlite3"
},
"build": {
"appId": "olad-amtaia-water-manager",
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
]
},
"win": {
"target": "NSIS",
"icon": "build/icon.ico"
}
},
"author": "Boutamente abdessamad",
"license": "MIT",
"dependencies": {
"mssql": "^6.1.0",
"mysql": "^2.18.1",
"mysql2": "^2.1.0",
"moment": "^2.24.0",
"sessionstorage": "^0.1.0",
"pg": "^7.18.2",
"jquery": "^3.4.1",
"knex": "^0.20.10",
"sqlite3": "^4.1.1"
},
"devDependencies": {
"mssql": "^6.1.0",
"mysql": "^2.18.1",
"mysql2": "^2.1.0",
"moment": "^2.24.0",
"sessionstorage": "^0.1.0",
"pg": "^7.18.2",
"electron": "^8.0.3",
"electron-builder": "^22.4.0",
"jquery": "^3.4.1",
"knex": "^0.20.10",
"sqlite3": "^4.1.1"
}
}

login sumbmit


$('#loginForm').submit(function (e) { 
e.preventDefault();
let formData = new Object();
formData.email = $(this).find('#login_email').val();
formData.password = $(this).find('#login_password').val();
ipcRenderer.send('login',formData);
});

databade connexion


process.env.NODE_ENV = 'development';
const dbPath = path.resolve(__dirname, 'database.db')
var db = new sqlite3.Database(dbPath);


const knex = require("knex")({
client: "sqlite",
connection: {
filename: db.filename
},
useNullAsDefault: true
});

最佳答案

试试这个:

"nsis": {
"deleteAppDataOnUninstall": true,
"uninstallDisplayName": "app"
}
...
"win": {
"target": [
"nsis"
]
}
...

我好一阵子没看 Electron 项目了,但是我学到的东西对我来说是最好的选择,那就是将应用程序部署在一个带有Windows的虚拟机中,另一个部署在具有Linux的虚拟机中,因此我可以在“真实”环境中尝试

关于javascript - Electron js应用程序构建后无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60662388/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com