Есть ли способ, которым я могу перейти к app: //index.html как электрон в ядре кукловода? - PullRequest
0 голосов
/ 15 марта 2020

электрон имеет модуль с именем Protocol, который может зарегистрировать новую схему в uri, если есть способ в кукловод , который может осуществлять перехват, перейдя на новую нестандартную схему, такую ​​как app://xxx.html?

как код ниже. page.on('request') также не будет работать page.on('requestfail'), и сообщать об ошибке напрямую, как Error: net::ERR_ABORTED at app://index.html

? find Chrome. js

const puppeteer = require('puppeteer-core');
const findChrome = require('./findChrome');
const {readFileSync} = require('fs');

(async ()=>{
    const { executablePath, type } = await findChrome({});
    if (!executablePath) {
      console.error('Could not find Chrome installation, please make sure Chrome browser is installed from https://www.google.com/chrome/.');
      process.exit(0);
      return;
    }

    const browser = await puppeteer.launch({
        executablePath,
        headless: false,
        defaultViewport: null,
        userDataDir: '.local-data',
        args: [
            // // '--app=data:text/html,<title>app</title>', 
            // '--allow-file-access-from-files',
            // '--disable-web-security', 
            // `--enable-features=NetworkService,NetworkServiceInProcess`,
        ] });
    let pages = await browser.pages();
    let page = pages[0];
    page.on('request', (request)=>{
        console.log(request);// ? can't be reached
        request.continue();
    });
    page.on('requestfinished', (request)=>{
        console.log(request);
    })
    await page.setRequestInterception(true);
    try{
        await page.goto('app://index.html');
    }catch(err){
        console.error(err);
    }
})();
...