使用Nativefier将任何网站/网页转换为桌面应用程序
您可以通过以下链接以PDF格式下载本文来支持我们。以PDF格式下载指南关闭关闭关闭
您是否知道可以从OS命令行界面将任何网页转换为桌面应用程序?在此博客文章中,我将向您展示一个名为Nativefier的出色工具。 Nativefier是一个命令行工具,可让您以最少的配置为任何网站创建桌面应用程序。创建的桌面应用程序是 电子 (内部使用Chromium)操作系统可执行文件(.app
, .exe
等等)在Windows,macOS,Linux上使用。
本机功能:
- 自动获取应用程序图标/名称。
- JavaScript和CSS注入。
- 看更多, API文档 要么
nativefier --help
如何在Linux上安装Nativefier | Mac OS
如何在Linux或macOS操作系统上安装Nativefier?安装要求如下:
- macOS 10.9+ / Windows / Linux
- Node.js
>= 10
还有npm>= 6
- 选项依赖性:
在Linux / macOS上安装Node.js
第一个安装要求是Node.js。使用以下命令在Linux或macOS上安装Node.js。
### Install Node.js on macOS ###
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install node
### Install Node.js on Ubuntu / Debian ###
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
### Install Node.js on CentOS / Fedora / RHEL ###
curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
sudo yum install nodejs
在Linux上安装Nativefier | Mac OS
安装Node.js之后,运行以下命令以全局安装Nativefier。
$ npm install -g nativefier
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: this library is no longer supported
/usr/local/bin/nativefier -> /usr/local/lib/node_modules/nativefier/lib/cli.js
> [email protected] postinstall /usr/local/lib/node_modules/nativefier/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock
Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
+ [email protected]
added 290 packages from 341 contributors in 75.93s
使用Nativefier将任何网页转换为桌面应用程序
在此示例中,我们正在转换 Computingforgeeks.com 网站到桌面应用程序。
$ nativefier "computingforgeeks.com"
URL "computingforgeeks.com" lacks a protocol. Will try to parse it as HTTPS: "https://computingforgeeks.com". Please pass "//computingforgeeks.com" if this is what you meant.
Preparing Electron app...
Converting icons...
Packaging... This will take a few seconds, maybe minutes if the requested Electron isn't cached yet...
Downloading electron-v10.1.0-darwin-x64.zip: [============================================================================================] 100% ETA: 0.0 seconds
Packaging app for platform darwin x64 using electron v10.1.0
Finalizing build...
App built to /Users/jkmutai/Documents/Home ComputingForGeeks-darwin-x64 , move it wherever it makes sense for you and run the app bundle.
您可以选择指定要创建的应用程序的名称。
nativefier --name 'Computingforgeeks' 'computingforgeeks.com'
等待它完成,然后检查创建的文件夹的内容。
$ ls -1 ~/Documents/Home ComputingForGeeks-darwin-x64
Home ComputingForGeeks.app
LICENSE
LICENSES.chromium.html
version
要了解所有可用的命令行标志,请使用:
$ nativefier --help
转到文件夹并启动应用程序。
启动/安装Nativefier生成的应用程序。
现在,您可以像常规桌面应用程序一样控制网站或网页。
使用Docker运行Nativefier
如果您不想安装Node软件包,则可以选择将应用程序作为Docker容器运行。
拉最新的Docker镜像
docker pull jiahaog/nativefier
您也可以克隆存储库并创建自己的映像。
git clone https://github.com/jiahaog/nativefier.git
cd nativefier
docker build -t nativefier .
默认情况下,该命令 nativefier --help
它将被执行。例如,要构建可在本地编写的Gmail本机Fire应用 ~/nativefier-apps
,
docker run -v ~/nativefier-apps:/target/ jiahaog/nativefier https://mail.google.com/ /target/
您可以传递Nativefier标志来装载卷并提供本地文件。例如,使用图标
docker run -v ~/my-icons-folder/:/src -v $TARGET-PATH:/target jiahaog/nativefier --icon /src/icon.png --name whatsApp -p linux -a x64 https://web.whatsapp.com/ /target/
标签:
- 如何将Linux上的网页转换为桌面应用程序
- 如何将macOS网页转换为桌面应用程序
- 如何将Windows上的网页转换为桌面应用程序
- 如何将网站转换为桌面应用程序
- 如何从网页生成桌面应用程序
Linux学习视频资料。
★★★★★(24800)$ 17.60 $ 187.67有库存
Udemy.com
Linux Administration Bootcamp:从初学者到高级
★★★★★(14311)$ 14.08 $ 152.48有库存
Udemy.com
★★★★☆(12902)$ 14.08 $ 152.48有库存
Udemy.com
★★★★★(9868)$ 14.08 $ 152.48有库存
Udemy.com
您可以通过以下链接以PDF格式下载本文来支持我们。以PDF格式下载指南关闭关闭关闭