@@ -18,7 +18,7 @@ npm test # 编译然后跑测试
1818
1919## 加密
2020
21- 先生成密钥保存在本地的文件中,方便 JS 打包脚本导入和 C++ include 内联。
21+ 以 AES-256-CBC 为例, 先生成密钥保存在本地的文件中,方便 JS 打包脚本导入和 C++ include 内联。
2222
2323``` js
2424// 这个脚本不会被打包进客户端,本地开发用
@@ -219,9 +219,9 @@ static Napi::Value _runScript(Napi::Env& env, const char* script) {
219219` node - addon - api ` v3 以上可以直接使用:
220220
221221` ` ` cpp
222- Napi ::Value Napi ::Env ::RunScript (const char * utf8script )
223- Napi ::Value Napi ::Env ::RunScript (const std ::string & utf8script )
224- Napi ::Value Napi ::Env ::RunScript (Napi ::String script )
222+ Napi ::Value Napi ::Env ::RunScript (const char * utf8script );
223+ Napi ::Value Napi ::Env ::RunScript (const std ::string & utf8script );
224+ Napi ::Value Napi ::Env ::RunScript (Napi ::String script );
225225` ` `
226226
227227然后就可以愉快地 JS in C++ 了。
@@ -391,7 +391,7 @@ require('./main.node')
391391
392392` ` ` js
393393for (let i = 0 ; i < process .argv .length ; i ++ ) {
394- if (process .argv [i ].indexOf (' --inspect' ) !== - 1 || process .argv [i ].indexOf (' --remote-debugging-port' ) !== - 1 ) {
394+ if (process .argv [i ].startsWith (' --inspect' ) || process .argv [i ].startsWith (' --remote-debugging-port' )) {
395395 throw new Error (' Not allow debugging this program.' )
396396 }
397397}
@@ -474,6 +474,7 @@ new BrowserWindow({
474474 // ...
475475 webPreferences: {
476476 nodeIntegration: true , // 渲染进程要使用 require
477+ contextIsolation: false , // Electron 12 开始默认值为 true,要关掉
477478 devTools: false // 关掉开发者工具,因为开发者工具可以看到渲染进程的代码
478479 }
479480})
0 commit comments