typescript - Electron-forge:如何将入口点设置为 url 而不是静态 html 文件
问题描述
我使用 electron-forge webpack-typescript 模板生成电子项目。
默认情况下,它会按照 in中index.html
的配置加载entryPoints
package.json
...
"plugins": [
[
"@electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"name": "main_window",
"html": "./src/index.html", // <-- HERE
"js": "./src/renderer.ts",
}
]
}
}
]
]
...
我想加载角度 urlhttp://localhost:4200
作为入口点。
当我更改为 时"html": "http://localhost:4200",
,它不起作用。
我试图从中删除该行package.json
并将网址硬编码在index.ts
...
// and load the index.html of the app.
// mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
mainWindow.loadURL("http://localhost:4200");
...
这也行不通。如何将条目设置为 url 而不是静态 HTML 文件?
解决方案
只需使用重定向将入口点设为空白 html
<html><head>
<meta http-equiv="refresh" content="2;url=http://example.com" />
<title>Page Moved</title>
</head><body>
<a href="http://www.example.com">continue</a></body>
</html>
这样做的好处是,您甚至可以添加小 javascript 来首先检查目标是否可用,可选择显示错误消息等,如果目标端口由于某种原因不适用于应用等,或者在应用打开之前显示简单的 splahh
推荐阅读
- javascript - 通过自定义 UVGenerator 在 Three.js 中为 ExtrudeGeometry 平铺纹理
- django - Django admin list_display 不显示模型方法返回项
- python - numba LLVM ERROR:,甚至没有更多的错误代码
- python - 在 Pandas Python 中使用日期读取和格式化数据框
- python - 如何使用 pip 安装带有额外组件的本地 Python 包?
- javascript - juery .on 值或变化函数
- video - ffmpeg concat 警告与同一文件上的非单调 DTS
- python - Python对存储在4D numpy数组中的图像进行蒙太奇
- python - 使用python自动上传和删除Sharepoint中的文件
- docker - 一个 256 字节的文件 `/etc/hosts` 如何使用 `1.9M` inode?