preface
Since web pages and PC client applications are needed, some products of the company use Electron to package web projects into applications. On the one hand, it is simple and convenient, and on the other hand, because the requirements are not very complicated, the electron can basically solve our requirements. In addition, electron has realized automatic version update installation with electric-Builder, which seems beautiful, but is still ridiculed by sales and customer service. It is well known that Electron does not support Windows 7 well, or twitch type, normal Windows 7 May have no problems, some need to set compatibility to open properly. But once you update it, and you reinstall it, the compatibility check box in the properties is gone. You said the customer can understand the document is ok, write a document check, everything is fine. But there are some maverick, never the whole do not understand, the whole do not understand how to do, find our customer service, let us customer service remote one-way installation. A kind of above also go, more outrageous is installed some anti-virus software, 360 ah, Jinshan drug bully, update after the direct do not let install, direct attack street, then contact customer service, one by one reinstall. Last month, WHEN I was online a little too often, the customer service directly rushed to me, pointed at my head and scolded me, asking me to give an explanation. I can’t stand being pointed at the head by a girl. I just give in. Anyway, coax girls are a truth, not over the direct circuitous tactics, immediately change, next time certain! But, just recently at hand empty come down, reluctant, do not cheat with female feelings of man!
start
A check of the material, found that indeed we have encountered this problem, also found a big guy’s article, written very well, the link to the article will be thrown out at the end. Since electron can be viewed as a browser, it can also open the f12 developer tools, just load our resources in and render them in the application. After all, the API uses a nice image win.loadfile (***.html); In fact, the idea is very simple, we often function requirements, or bug modification, are only static resources change, such as JS, CSS, HTML, etc., just need to replace the original static resources, and then refresh the resources, do not need to reinstall the whole program.
implementation
At the same time of packaging, generate exe file at the same time, will also generate an unpack folder, resource is the static resources we pack, if you do not choose ASAR mode, our JS files, and HTML files, will be directly exposed in the folder.
Then, after we finish installation exe, we find the install directory, find the resources folder, find our static resource, is here, (if there is no use asar packaging, displays an app folder, it is our static resource files), the problem seems to be easier to get up!
We just need to take out the static resources in the new package file, and then overwrite the original static files in the local, is it complete update?
Post code link
The logic is simple. Check if the version number is consistent. If not, load the file, unzip it, overwrite the original static file, and reload the webContent. It is recommended not to use the ASAR mode for packaging, because there was a small problem in the middle test, but it never appeared again, but there are still hidden dangers, and we will supplement it next time. This is the index.html before the update, and here is the GIF after the update. You can see that both the HTML and JS have changed.
subsequent
The basic scheme has been decided, and the follow-up is to update the scheme completely. The initial decision is to add a JSON file in the download directory to read the update content, update the version, and whether to reinstall or update only static resources. The application then reads the JSON file to determine which update method to perform.
conclusion
This time there is really no good conclusion, is to step on the shoulders of giants, according to the ideas and codes found online, to achieve a specific application, because I feel that the scheme is not perfect, if there is a problem in front of the writing, I hope to be able to communicate more, help me correct the problem, thank you thank you thank you!
Routine, public account: lazy dog little front end
References: www.cnblogs.com/mapleChain/…