安装React-Devtool
TypeError:BrowserWindow.addDevToolsExtension不是函数
感谢您抽出宝贵的时间报告此问题,并帮助改善Electron。
请提供一个独立的测试程序,测试人员可以运行该程序来重现该问题。 这使解决问题的过程更加顺利:不仅可以确保测试正确的事物,而且还可以避免由于使测试人员为每个新问题编写新测试而造成的分类困难。
由于上述原因,我正在设置更多信息所需的标签。 在您回复之后,请@我进行后续评论。
提前致谢! 感谢您的帮助。
@MarshallOfSound
我不知道您是否需要main.js中的代码段,但这是
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const scraper = require('./scraper.js');
const helpers = require('./electron/helpers.js');
const windowStateKeeper = require('electron-window-state');
const { autoUpdater } = require("electron-updater");
require('v8-compile-cache');
// for nodemon
process.env.IS_DEV ? require('electron-reload') : null;
// disable security warning
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
// Application already running, so we close now
if (!app.requestSingleInstanceLock()) {
app.quit()
}
app.removeAllListeners('ready');
let mainWindow
function createWindow() {
// check for uppdate
autoUpdater.checkForUpdatesAndNotify();
// Load the previous state with fallback to defaults
let mainWindowState = windowStateKeeper({
defaultWidth: 1100,
defaultHeight: 600
});
mainWindow = new BrowserWindow({
'x': mainWindowState.x,
'y': mainWindowState.y,
'width': mainWindowState.width,
'height': mainWindowState.height,
minWidth: 1100,
minHeight: 500,
backgroundColor: '#121212',
frame: false,
icon: __dirname + '../build/icon.png',
webPreferences: {
webSecurity: false,
nodeIntegration: true,
webviewTag: true
},
});
// Let us register listeners on the window, so we can update the state
// automatically (the listeners will be removed when the window is closed)
// and restore the maximized or full screen state
mainWindowState.manage(mainWindow);
// http://localhost:3000
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '../build/index.html'),
protocol: 'file:',
slashes: true,
});
mainWindow.loadURL(startUrl);
// in dev mode
if (process.env.ELECTRON_START_URL) {
// open devTools
mainWindow.webContents.openDevTools({ mode: 'undocked' });
}
// in build mode
if (process.env.IS_DEV) {
// close menubar
mainWindow.setMenuBarVisibility(false);
}
//clear session + cookies on start to avoid blocking requests
mainWindow.on('closed', () => {
mainWindow = null
});
mainWindow.webContents.on('new-window', function (e, url) {
e.preventDefault();
})
// Add React Devtool
if (app.isReady() && process.env.ELECTRON_START_URL) {
console.log('___INSTALL React Devtool_____')
BrowserWindow.addDevToolsExtension("./extensions/react")
.then(name => console.log('INSTALLING', name))
.catch(err => console.log('Install React-Devtool err', err));
}
}
app.setAppUserModelId('com.MyMovies.app');
app.on('ready', createWindow);
app.on('window-all-closed', () => {
app.quit();
})
Devtron,React和Redux扩展都无法安装在浏览器窗口中。 如果有人知道解决方法,不妨听听。
[electron] Added Extension: React Developer Tools
[electron] Added Extension: Redux DevTools
[electron] [41948:0228/141801.424392:ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read[electron] [41948:0228/141801.424392:ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'panels' of undefined", source: chrome-extension://redux-devtools/js/devtools.bundle.js (1)
[electron] [41948:0228/141801.512131:ERROR:CONSOLE(40)] "Uncaught TypeError: Cannot read property 'inspectedWindow' of undefined", source: chrome-extension://react-developer-tools/build/main.js (40)
[electron] Unable to create basic Accelerated OpenGL renderer.
[electron] Unable to create basic Accelerated OpenGL renderer.
[electron] Core Image is now using the software OpenGL renderer. This will be slow.
@ stevenroussey-privicy我们可以通过@MarshallOfSound制作的electronic-devtools-installer软件包(感谢他🙏)在我们的应用程序中安装react和redux扩展程序,但是devtools有时不会出现相同的错误。 。
[35280:0324/122320.140:ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'panels' of undefined", source: chrome-extension://redux-devtools/js/devtools.bundle.js (1)
[35280:0324/122320.233:ERROR:CONSOLE(40)] "Uncaught TypeError: Cannot read property 'inspectedWindow' of undefined", source: chrome-extension://react-developer-tools/build/main.js (40)
感觉就像在浏览器窗口中加载了扩展名之后创建了扩展名选项卡。 我在后端捕获的唯一错误与chrome存储有关,但可能与问题原因无关。
Exception has occurred: Error
Error: ENOENT: no such file or directory, open "\AppData\Roaming\AppName\Chrome Storage\redux-devtools-sync.json"
我们在事件did-frame-finish-load
中打开devtools
win.webContents.on('did-frame-finish-load', () => {
win.webContents.openDevTools();
});
我们使用相同的安装程序方法。 它可以正常安装,但无法运行。 同样的错误。 即使我手动打开devtools,也不是计时问题。
我们使用启动屏幕窗口。 据我所知,它在创建的第一个窗口中运行良好,但在其他窗口中则失败。 其他人可以验证吗?
最有用的评论
Devtron,React和Redux扩展都无法安装在浏览器窗口中。 如果有人知道解决方法,不妨听听。