Using electron + jQuery to develop desktop application from scratch


In the first two chapters, I wrote the basic usage of electronic. I originally wanted to write a complete program with jQuery. However, considering that JS is really not easy to write, and the program I am writing now does not want to open source, so it has not been written. In the past two days, the environment variables were reconfigured after the system was reinstalled. When some pits were encountered during the execution, they were recorded to avoid entering the pits again.

1、 Electron reference jquery.js

Electron cannot be referenced like a normal HTML file jq.js In that case, the Elecron reference jq.js The methods are as follows:

<script>window.$ = window.jQuery = require('jquery.js');</script>

2、 Communication between electron and JS

They can’t communicate with each other directly, they need to use IPC to communicate. For example:

var ipc = require('ipc');


var ipc = require('ipc');
ipc.on('isMessage', function () {});

3、 Precautions when packing with ASAR

When ASAR packages a folder, do not use weird files in the folder, such as.rar . zip, etc., as well as files with Chinese characters in their names.

4、 After packing

After the package is completed, the Resources folder will be generated. The code will follow this folder, which is a level higher than that during debugging.

Write this first, and then you’ll get worse when you meet a pit