protocol 自定义协议

最后更新于:2022-04-02 03:34:41

[TOC] ## 方法 ``` protocol.registerStandardSchemes(schemes) protocol.registerServiceWorkerSchemes(schemes) protocol.registerFileProtocol(scheme, handler[, completion]) protocol.registerStringProtocol(scheme, handler[, completion]) protocol.registerHttpProtocol(scheme, handler[, completion]) protocol.unregisterProtocol(scheme[, completion]) protocol.interceptFileProtocol(scheme, handler[, completion]) protocol.interceptStringProtocol(scheme, handler[, completion]) protocol.interceptBufferProtocol(scheme, handler[, completion]) protocol.interceptHttpProtocol(scheme, handler[, completion]) protocol.uninterceptProtocol(scheme[, completion]) ``` ## 例子 ``` const {app} = require('electron'); const path =require('path'); if (!app) return; if (process.defaultApp) { if (process.argv.length >= 2) { app.setAsDefaultProtocolClient('electron-demo', process.execPath, [path.resolve(process.argv[1])]) } } else { app.setAsDefaultProtocolClient('electron-demo') } ```
';