Electron支持使用PepperFlash插件。要在Electron中使用PepperFlash插件,我们需要手动设置PepperFlash路径并在应用程序中启用PepperFlash。保留一份Flash插件在macOS和Linux上,我们可以在Chrome浏览器的chrome://plugins页面找到PepperFlash插件信息。插件的路径和版本将帮助Election支持它。您也可以将插件复制到另一个路径以保留副本。在Electron中添加插件开关,我们可以直接在命令行中使用--ppapi-flash-path和ppapi-flash-version或者在app的准备事件之前调用app.commandLine.appendSwitch方法。同时添加浏览器窗口插件开关。例如:const{app,BrowserWindow}=require('electron')constpath=require('path')//指定flash路径,假设和main.js放在同一个目录下。letpluginNameswitch(process.platform){case'win32':pluginName='pepflashplayer.dll'breakcase'darwin':pluginName='PepperFlashPlayer.plugin'breakcase'linux':pluginName='libpepflashplayer.so'break}app.commandLine.appendSwitch('ppapi-flash-path',path.join(__dirname,pluginName))//可选:指定flash版本,例如v17.0.0.169app.commandLine.appendSwitch('ppapi-flash-version','17.0.0.169')app.on('ready',()=>{letwin=newBrowserWindow({width:800,height:600,webPreferences:{plugins:true}})win.loadURL(`file://${__dirname}/index.html`)//...})或尝试加载系统安装的PepperFlash插件而不是运输插件,其路径可以通过调用app.getPath('pepperFlashSystemPlugin')获取。要使用webview标签启用插件,请在
