Electron 无法获取资源 (.swf)
Electron unable to fetch resources (.swf)
我正在使用 electron(使用 pepper flash 插件)将 swf 文件直接加载到我的 BrowserWindow 中。
.swf 文件加载正确,但 .swf 文件内的代码请求单独的资源(例如:something.labels)。
出于某种原因,无法请求 something.labels 文件,每次都会立即失败(屏幕截图)。我无法弄清楚为什么会发生错误,没有提供详细信息...有什么想法吗?
网络请求
main.js
const { app, BrowserWindow } = require('electron');
const path = require('path');
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 900,
titleBarStyle: 'hidden',
resizable: true,
autoHideMenuBar: true,
webPreferences: {
plugins: true
}
});
// and load the index.html of the app.
mainWindow.loadURL('https://example.org/myapplication.swf');
// Open the DevTools.
mainWindow.webContents.openDevTools({ mode: 'detach' });
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
};
app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, 'pepflashplayer.dll'));
app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.270');
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
对于遇到同样问题的每个人..
这是 elctron 框架中的一个错误,版本 7 中引入
将您的电子版本更改为 6.1.2 将解决此问题
我正在使用 electron(使用 pepper flash 插件)将 swf 文件直接加载到我的 BrowserWindow 中。 .swf 文件加载正确,但 .swf 文件内的代码请求单独的资源(例如:something.labels)。
出于某种原因,无法请求 something.labels 文件,每次都会立即失败(屏幕截图)。我无法弄清楚为什么会发生错误,没有提供详细信息...有什么想法吗?
网络请求
main.js
const { app, BrowserWindow } = require('electron');
const path = require('path');
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 900,
titleBarStyle: 'hidden',
resizable: true,
autoHideMenuBar: true,
webPreferences: {
plugins: true
}
});
// and load the index.html of the app.
mainWindow.loadURL('https://example.org/myapplication.swf');
// Open the DevTools.
mainWindow.webContents.openDevTools({ mode: 'detach' });
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
};
app.commandLine.appendSwitch('ppapi-flash-path', path.join(__dirname, 'pepflashplayer.dll'));
app.commandLine.appendSwitch('ppapi-flash-version', '32.0.0.270');
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
对于遇到同样问题的每个人.. 这是 elctron 框架中的一个错误,版本 7 中引入
将您的电子版本更改为 6.1.2 将解决此问题