electron 打包后 invoking 失效,打开文件夹更功能失效。并且托盘不显示图标,托盘方法也失效了
时间: 2024-03-04 14:49:22 浏览: 20
这可能是由于 Electron 打包后的文件路径问题导致的。你可以尝试在 `main.js` 中使用 `__dirname` 和 `path.join()` 方法来获取正确的文件路径。例如:
```
const path = require('path')
const { app, BrowserWindow, Tray } = require('electron')
let mainWindow
let tray
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
})
mainWindow.loadFile('index.html')
mainWindow.on('closed', function () {
mainWindow = null
})
tray = new Tray(path.join(__dirname, 'tray-icon.png'))
tray.setToolTip('My App')
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
```
关于 `invoking` 失效的问题,你需要检查你的代码并确保路径正确,同时检查是否有权限执行相关操作。如果问题仍然存在,请提供更多的信息,以便我更好地帮助你解决问题。