Disclosure of Invention
In view of the above disadvantages of the prior art, an object of the present invention is to provide an application program upgrading method and system, which are used to solve the problems of large flow and long time of the upgrading method in the prior art.
The technical scheme of the invention is as follows:
a method for upgrading a Web application program comprises the following steps:
A. acquiring upgrading information of a Web application program from an upgrading server in advance, judging whether upgrading is needed according to the upgrading information, and analyzing an upgrading file list returned by the upgrading server if upgrading is needed to generate upgrading preprocessing information;
B. when the Web application program is started, judging whether upgrade preprocessing information corresponding to the Web application program exists, if so, sending an upgrade request to an upgrade server according to the upgrade preprocessing information, writing a returned updated application source code program into an application program cache, reading original application program package resources of the Web application program, writing the original application program package resources into the application program cache, and analyzing the application source code program which does not need to be upgraded.
The method for upgrading the Web application program includes the following specific steps:
a1, monitoring a Web application program in a desktop visual area;
and A2, carrying out upgrading preprocessing on the Web application program of the visible area at preset time intervals.
The upgrading method of the Web application program, wherein the step B specifically includes:
b1, analyzing the application source code program which does not need to be upgraded, and starting to render an interface;
b2, writing the application source code program returned by the upgrade server into a cache to replace the original corresponding application source code program, analyzing the updated application source code program, and continuing to render an interface;
and B3, repackaging the cache to replace the original application program package after the application source code program is completely downloaded.
In the method for upgrading a Web application program, in step B1, if the application source code program to be upgraded includes index.
In the step B2, the application source code program with strong association returned by the upgrade server is written into the backup, and is written into the cache after all files with strong association are downloaded.
An upgrade system for a Web application, comprising:
the upgrading preprocessing module is used for acquiring upgrading information of the Web application program from the upgrading server in advance, judging whether upgrading is needed according to the upgrading information, and analyzing an upgrading file list returned by the upgrading server if upgrading is needed to generate upgrading preprocessing information;
and the upgrade management module is used for judging whether upgrade preprocessing information corresponding to the Web application program exists or not when the Web application program is started, if so, sending an upgrade request to an upgrade server according to the upgrade preprocessing information, writing the returned updated application source code program into an application program cache, reading the original application program package resource of the Web application program, writing the original application program package resource into the application program cache, and analyzing the application source code program which does not need to be upgraded.
The upgrading system of the Web application program, wherein the upgrading preprocessing module specifically includes:
the monitoring unit is used for monitoring the Web application program in the desktop visual area;
and the upgrading preprocessing unit is used for carrying out upgrading preprocessing on the Web application program in the visual area at preset time intervals.
The upgrading system of the Web application program, wherein the upgrading module specifically includes:
the first analysis unit is used for analyzing the application source code program which does not need to be upgraded and starting to render an interface;
the second analysis unit is used for writing the application source code program returned by the upgrade server into the cache to replace the original corresponding application source code program, analyzing the updated application source code program and continuously rendering an interface;
and the packaging unit is used for repackaging the cache to replace the original application program package after the application source code program is completely downloaded.
In the system for upgrading the Web application program, if the application source code program to be upgraded contains index.html, the first parsing unit waits for the upgrade server to return the index.html, and then parses the application source code program according to the source code sequence quoted in the index.html.
In the system for upgrading the Web application program, in the second parsing unit, the application source code program with strong association returned by the upgrade server is written into the backup, and after downloading of all files with strong association is completed, the application source code program is written into the cache.
Has the advantages that: the invention realizes the upgrading of the Web application program by utilizing the differential technology, reduces the upgrading time and the data flow, shortens the processing time of the upgrading information by preprocessing, is transparent to the user in the upgrading process, and simultaneously performs the upgrading process and the application starting, improves the user experience and is convenient for the user to use.
Detailed Description
The present invention provides a method and a system for upgrading a Web application, and the present invention is further described in detail below to make the purpose, technical solution, and effect of the present invention clearer and clearer. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating a method for upgrading a Web application according to a preferred embodiment of the present invention, as shown in the figure, the method includes the following steps:
s101, obtaining upgrading information of a Web application program from an upgrading server in advance, judging whether upgrading is needed or not according to the upgrading information, and analyzing an upgrading file list returned by the upgrading server if upgrading is needed to generate upgrading preprocessing information;
s102, when the Web application program is started, judging whether upgrade preprocessing information corresponding to the Web application program exists, if so, sending an upgrade request to an upgrade server according to the upgrade preprocessing information, writing a returned updated application source code program into an application program cache, reading original application program package resources of the Web application program, writing the application program cache, and analyzing the application source code program which does not need to be upgraded.
In this embodiment, the application is upgraded by using a differential technology, and all the packages are not downloaded, but only the application source code programs (which refer to the source code files required for upgrading the Web application) required for upgrading are downloaded from the upgrade server, so that the upgrade time is reduced, the data traffic is saved, the upgrade process is transparent to the user, and the upgrade process and the application start process are performed simultaneously, so that the normal use of the user is not affected, and the upgrade granularity is reduced, so that the upgrade process is simpler, for example, when the Web application is upgraded, only a certain picture resource needs to be updated or a certain source file needs to be repaired with a major bug. The application in the invention is Web application, which has the characteristics of traditional Web pages and also has the advantages of local application, so the upgrading method is more suitable for being adopted.
The Web application program is upgraded when being started, an upgrade request is sent to an upgrade server, the upgrade server returns an application source code program and writes the application source code program into a cache, and meanwhile, the original application program package resources of the Web application program are read and written into the application program cache, and the application source code program which does not need to be upgraded is analyzed, so that the upgrade time and the data flow are reduced.
Further, as shown in fig. 2, the step S101 specifically includes:
s201, monitoring a Web application program in a desktop visual area;
s202, upgrading the Web application program in the visible area at preset time intervals;
monitoring a desktop visual area in real time, when a user switches a desktop view, acquiring Web application programs in the visual area because the Web application programs in the visual range are most likely to be started by the user, and then preferentially performing upgrade preprocessing on the Web application programs, namely acquiring upgrade information of the Web application programs from an upgrade server every preset time, judging whether the upgrade is needed, if so, analyzing an upgrade file list and generating upgrade preprocessing information. The purpose of this is to improve the upgrade speed when the application starts, because the data volume of the upgrade file list is small, only simple upgrade information communication is carried out between the mobile terminal and the server at this time, the consumed bandwidth is small, and the upgrade preprocessing is carried out at this time, so that the processing procedure when the application starts can be reduced. In addition, if it is determined that a certain Web application needs to be upgraded, an upgradable flag may be marked on the application icon of the Web application, so that a user knows in advance that the upgrading process will be performed when the Web application is started.
The upgrade file list returned by the upgrade server includes the name information of the application source code program and the version information of the Web application program required by the upgrade. And if the upgrade is needed, analyzing the upgrade file list, and verifying the version of the Web application, the application source code program and the like. In addition, if upgrading is needed, the upgrading file list can be analyzed to generate and store the list object data block, then the Web application program is started, and the list object data block is judged to exist, and if the upgrading is needed, the upgrading is indicated.
Further, as shown in fig. 3, the step S102 specifically includes:
s301, analyzing the application source code program which does not need to be upgraded, and starting to render an interface;
when a Web application program is started and needs to be upgraded, a system allocates resources for the Web application program, then reads an original application program package and writes the original application program package into a cache, analyzes an application source code program which does not need to be upgraded, and starts to render an interface. And the upgrading process is carried out in the background, so that the upgrading process is very transparent.
S302, writing the application source code program returned by the upgrade server into a cache to replace the original corresponding application source code program, analyzing the updated application source code program, and continuing to render an interface;
and after the upgrading server returns the application source code program, replacing the corresponding application source code program in the cache with the new application source code program, continuously analyzing the updated application source code program, and continuously rendering the interface.
And S303, repacking the cache to replace the original application program package after the application source code program is completely downloaded.
And when the application source code program is completely downloaded, repackaging the cache to replace the original application program package, and during packaging, respectively packaging the cache and the application configuration file (containing version, authority and other information) to replace the cache and the application configuration file originally stored in the equipment.
In step S301, if the application source code program that needs to be upgraded includes index.html (navigation page), the source code program is analyzed according to the order of the source codes referenced in index.html after the upgrade server returns index.html. Html is the earliest file to be loaded, and therefore, it is necessary to analyze other files after the file is downloaded.
Further, in step S302, the application source code program with strong association returned by the upgrade server is written into the backup, and is written into the cache after all files with strong association are downloaded. The files with strong association relation are the parts which need to be upgraded in the upgrading process, so that the files are preferably written into the backup (cache backup) after all the files are completely downloaded, and the abnormal starting of the application caused by accidental interruption in the upgrading process can be prevented, so that the program error is caused.
Based on the above method, the present invention further provides a block diagram of a preferred embodiment of an upgrade system for a Web application, as shown in fig. 4, including:
an upgrade preprocessing module 100, configured to obtain upgrade information of a Web application from an upgrade server in advance, determine whether upgrade is needed according to the upgrade information, and if upgrade is needed, parse an upgrade file list returned by the upgrade server, to generate upgrade preprocessing information;
the upgrade management module 200 is configured to, when the Web application is started, determine whether upgrade preprocessing information corresponding to the Web application exists, if so, send an upgrade request to the upgrade server according to the upgrade preprocessing information, write the returned updated application source code program into the application cache, read the original application package resource of the Web application, write the application cache, and analyze the application source code program that does not need to be upgraded.
Further, as shown in fig. 5, the upgrade preprocessing module 100 specifically includes:
the monitoring unit 110 is used for monitoring a Web application program in a desktop visual area;
and an upgrade preprocessing unit 120 for performing upgrade preprocessing on the Web application of the visible area at predetermined intervals.
Further, as shown in fig. 6, the upgrade management module 200 specifically includes:
a first parsing unit 210, configured to parse an application source code program that does not need to be upgraded, and start rendering an interface;
the second parsing unit 220 is configured to write the application source code program returned by the upgrade server into the cache to replace the original corresponding application source code program, parse the updated application source code program, and continue to render an interface;
and the packaging unit 230 is configured to repackage the cache to replace the original application package after the application source code program is completely downloaded.
Further, in the first parsing unit 210, if the application source code program that needs to be upgraded includes index.
Further, in the second parsing unit 220, the application source code program with strong association returned by the upgrade server is written into the backup, and is written into the cache after all files with strong association are downloaded.
The technical details of the above module unit have been described in the foregoing method, and thus are not described again.
In summary, the present invention utilizes the differential technology to upgrade the Web application, reduces the upgrade time and data traffic, shortens the upgrade information processing time by preprocessing, is transparent to the user in the upgrade process, and is performed simultaneously with the application start, thereby improving the user experience and facilitating the use of the user.
It is to be understood that the invention is not limited to the examples described above, but that modifications and variations may be effected thereto by those of ordinary skill in the art in light of the foregoing description, and that all such modifications and variations are intended to be within the scope of the invention as defined by the appended claims.