gpt4 book ai didi

pug - 哈巴狗拦截器: Error: The scheme has been intercepted失败

转载 作者:行者123 更新时间:2023-12-03 12:29:21 24 4
gpt4 key购买 nike

我已经使用Electron创建了一个electron-forge应用程序。
在这个应用程序中,我想呈现pug(Jade)模板,所以我安装了electron-pug。我面临的问题如下。

如果我使用electron-forge start启动我的应用程序,则我的应用程序将显示一个包含未渲染的pug文件的窗口(它将仅显示该文件的内容)
它将记录以下内容:

Pug interceptor failed: Error: The scheme has been intercepted

但是,如果我使用 electron src/index.js运行,则pug模板将呈现没有问题。
这是我的 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 模板,所以我只是将所有哈巴狗文件重命名为 Jade ,它的工作原理很像

关于pug - 哈巴狗拦截器: Error: The scheme has been intercepted失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45612999/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com