Pug interceptor failed: Error: The scheme has been intercepted
Pug interceptor failed: Error: The scheme has been intercepted
我使用 electron-forge
创建了一个 Electron
应用程序。
在这个应用程序中,我想呈现 pug(Jade)
个模板,所以我安装了 electron-pug
。我面临的问题如下。
如果我使用 electron-forge start
启动我的应用程序,我的应用程序将显示 window 和未呈现的哈巴狗文件(它只会显示该文件的内容)
它将记录以下内容:
Pug interceptor failed: Error: The scheme has been intercepted
但是,如果我 运行 和 electron src/index.js
哈巴狗模板将毫无问题地呈现。
这是我的 index.js
文件:
const { app, BrowserWindow } = require('electron');
const pug = require('electron-pug')({pretty:true},{});
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/demo.pug`);
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
这里是 index.pug
:
doctype
html
head
title Nope
body
h1 Hello
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
知道为什么会这样
对于遇到此问题的任何人,这就是我所做的:
Electron-Forge 支持 jade 模板,所以我只是将我所有的 pug 文件重命名为 jade 并且它非常有效
我使用 electron-forge
创建了一个 Electron
应用程序。
在这个应用程序中,我想呈现 pug(Jade)
个模板,所以我安装了 electron-pug
。我面临的问题如下。
如果我使用 electron-forge start
启动我的应用程序,我的应用程序将显示 window 和未呈现的哈巴狗文件(它只会显示该文件的内容)
它将记录以下内容:
Pug interceptor failed: Error: The scheme has been intercepted
但是,如果我 运行 和 electron src/index.js
哈巴狗模板将毫无问题地呈现。
这是我的 index.js
文件:
const { app, BrowserWindow } = require('electron');
const pug = require('electron-pug')({pretty:true},{});
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/demo.pug`);
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
这里是 index.pug
:
doctype
html
head
title Nope
body
h1 Hello
p
| Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
知道为什么会这样
对于遇到此问题的任何人,这就是我所做的:
Electron-Forge 支持 jade 模板,所以我只是将我所有的 pug 文件重命名为 jade 并且它非常有效