【发布时间】:2021-04-22 13:10:36
【问题描述】:
因此 Redux 选项卡已添加到 Chome 开发工具中,但是当我单击该选项卡时,它会显示消息 No store found. Make sure to follow the instructions.。我还控制台记录了我的state 对象以检查我的商店是否为空,但不是。我使用的是 Electron 版本 12.0.4,我的操作系统是 Arch Linux。
这是我的 main.js 文件中的代码块:
const { app, BrowserWindow, Notification, ipcMain } = require('electron'),
path = require('path'),
os = require('os');
const isDev = !app.isPackaged;
const installExtensions = async () => {
const installer = require('electron-devtools-installer');
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
const extensions = ['REACT_DEVELOPER_TOOLS', 'REDUX_DEVTOOLS'];
return Promise.all(
extensions.map(name => installer.default(installer[name], forceDownload))
)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err));
};
let win;
function createWindow() {
win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false,
worldSafeExecuteJavaScript: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
});
win.loadFile('index.html');
isDev && win.webContents.openDevTools();
win.on('close', () => {
win = null;
});
}
if (isDev) {
require('electron-reload')(__dirname, {
Electron: path.join(__dirname, 'node_modules', '.bin', 'electron')
});
}
app.whenReady().then(async () => {
await installExtensions(); // devtools extensions
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
【问题讨论】:
标签: electron