题记
Electron可以轻松的使用 Html5 / CSS3 / ES6 / Node.js 等等时兴技术开发。近期用Electron做一个需要通过手写实现毛笔签名,手头有一个AS3的版本。网上提供的JS算法基本都只能圆珠笔的线条效果,无法实现类似毛笔的笔锋效果。
研究预期:swf文件实现签名功能,完成后交给JS处理。
Electron 中使用flash插件
ppapi-flash插件
PPAPI是Google开发的浏览器插件接口,以沙箱模式运行插件。
在 Electron 中可以使用ppapi-flash插件加载swf程序
获取ppapi-flash插件
flash 插件安装好后,Windows系统可以在以下路径找到相应的dll文件。
C:\Windows\System32\Macromed\Flash\pepflashplayer64_23_0_0_207.dl
C:\Windows\SysWOW64\Macromed\Flash\pepflashplayer32_23_0_0_207.dll
上面依次对应 64位 及 32位的插件,必须与Electron 的对应
其他系统可以通过chrome打开 chrome://plugins/ 查看插件位置
建议将插件复制到项目的目录或子目录下
使用ppapi-flash插件
在 index.js
入口文件中引入插件
//index.js 入口文件
const electron = require('electron');
const {app,BrowserWindow} = electron;
//此处仅兼容了Windows 的 32位 与 64位
const pepflashplayer = (process.arch == 'x64')? `${__dirname}/flash/pepflashplayer64_23_0_0_207.dll`:`${__dirname}/flash/pepflashplayer32_23_0_0_207.dll`;
//设定插件
app.commandLine.appendSwitch('ppapi-flash-path', pepflashplayer);
//设定插件版本(不知道是否真有用,不匹配貌似也能运行)
app.commandLine.appendSwitch('ppapi-flash-version', '23.0.0.207');
let win;
function createWindow() {
//...
}
ppapi-flash-path 设定的时候 千万不要 加 file://
使用 <webview>
标签启用插件 并在