跟我一起使用electron搭建一个文件浏览器应用吧(四)

在软件的世界里面,创建一个新项目很容易,但是坚持将他们开发完成并发布却并非易事。分发软件就是一个分水岭,
分水岭的一边是那些完成的被全世界用户在用的软件,而另外一边则是启动了无数项目却没有一个完成的。
In the world of software, it's easy to create a new project, but it's not easy to stick with their development and release.
Distribution software is a watershed. On one side of the watershed is the software that is used by users all over the world.
On the other side, it starts countless projects but none of them is completed.
接下来我们将对应用进行分发相关的设置
Next, we will distribute the relevant settings for the application.
1.为应用显示自定义图标来替换默认的应用图标
Display custom icons for applications to replace default application icons
2.针对不同操作系统为应用制作原生二进制文件
Making native binary files for applications based on different operating systems
3.针对不同平台进行测试
Testing for different platforms
我们一起来使用一种electron的构建工具
首先安装工具 sudo cnpm install electron-builder electron --save
Let's use an electronic build tool together
我们会将package.json中的文件修改为
We will change the file in package. JSON to

{
  "name": "lorikeet",
  "version": "1.0.0",
  "main": "main.js",
  "author":"dimple",
  "description": "an file explorer application",
  "dependencies": {
    "async": "^2.6.1",
    "lunr": "^0.7.2",
    "osenv": "^0.1.5"
  },
  "scripts": {
    "pack":"build",
    "dist":"build"
  },
  "devDependencies": {
    "electron": "^4.0.2",
    "electron-builder": "^20.38.5"
  },
  "build":{}
}

接下来我们通过npm运行如下命令开始创建独立可执行文件
Next, we run the following command in NPM to start creating a separate executable file
cnpm run pack
我们会看到生成一个一个dist文件夹,里面还有一个名为mac的文件夹
We'll see that a dist folder is generated with a folder named MAC in it.

接下来我们来修改应用的图标了
Next, let's modify the icon of the application.

接下来我们就会发现应用长成这个样子了
Next we'll see that apps grow like this

我们可以看到除了控制台启动项目,我们可以在文件夹中直接启动项目
We can see that in addition to the console startup project, we can start the project directly in the folder.

本文的例子学习自 <<跨平台桌面应用开发基于Electron与NW.js>>这本书

猜你喜欢

转载自www.cnblogs.com/smart-girl/p/10318324.html