19 lines
563 B
JavaScript
19 lines
563 B
JavaScript
|
const { app, webContents, protocol, session } = require('electron');
|
||
|
|
||
|
protocol.registerSchemesAsPrivileged([
|
||
|
{ scheme: 'test', privileges: { standard: true, secure: true } }
|
||
|
]);
|
||
|
|
||
|
app.whenReady().then(function () {
|
||
|
const ses = session.fromPartition('persist:test-standard-shutdown');
|
||
|
const web = webContents.create({ session: ses });
|
||
|
|
||
|
ses.protocol.registerStringProtocol('test', (request, callback) => {
|
||
|
callback('Hello World!');
|
||
|
});
|
||
|
|
||
|
web.webContents.loadURL('test://abc/hello.txt');
|
||
|
|
||
|
web.webContents.on('did-finish-load', () => app.quit());
|
||
|
});
|