Page application rendering method and device, storage medium and electronic equipment
By parsing the page application, generating the request address and loading the resource file from the server, loading the module file from the local cache, and directly adding it to the resource file for rendering, it solves the problem of low page application rendering efficiency and improves resource reuse efficiency and user experience.
Patent Information
- Application Number
- CN202410813916.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-15
AI Technical Summary
In the existing technology, when rendering a page application, the client needs to request a large number of resource files from the server, which results in increased transmission time, low rendering efficiency, and low resource reuse efficiency, resulting in reduced user experience.
By parsing the target page application, the request address of the resource file and module file is generated, the resource file is loaded from the server based on the reference relationship of the resource file, and the module file is loaded from the local cache, and the module file is directly added to the resource file for rendering. Avoid loading module files repeatedly.
It reduces the transmission time of resource files, improves the rendering efficiency and user experience of page applications, and saves bandwidth resources.
Smart Images

Figure CN118784633A_ABST
Abstract
Description
Background Art
[0002] In the prior art, when a page application needs to be rendered, the client needs to request the server to render the resource files and module files of the page; that is, the client needs to request the server to render all the resource files required for the page application. However, this method increases the transmission time of the resource files, thereby reducing the rendering efficiency of the page application.
[0003] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0004] The purpose of the present disclosure is to provide a rendering method for a page application, a rendering device for a page application, a computer-readable storage medium, and an electronic device, thereby overcoming the problem of low rendering efficiency of page applications due to limitations and defects of related technologies, at least to a certain extent.
[0005] According to one aspect of the present disclosure, a method for rendering a page application is provided, comprising:
[0006] Parsing the target page application to obtain a target resource file required for rendering the target page application, and generating a first file request address corresponding to the target resource file;
[0007] Based on the target reference relationship in the target resource file, determine the target module file required for rendering the target page application, and generate a second file request address corresponding to the target module file;
[0008] Loading the target resource file from the server based on the first file request address, and loading the target module file from the local cache based on the second file request address;
[0009] The target module file is added to the target resource file based on the module reference relationship to obtain a file to be rendered, and the file to be rendered is rendered to obtain the target page application.
[0010] According to one aspect of the present disclosure, a rendering device for a page application is provided, comprising:
[0011] A first file request address generating module is used to parse the target page application, obtain the target resource file required for rendering the target page application, and generate a first file request address corresponding to the target resource file;
[0012] A second file request address generating module, used to determine the target module file required for rendering the target page application based on the target reference relationship in the target resource file, and generate a second file request address corresponding to the target module file;
[0013] A resource file loading module, used to load the target resource file from the server based on the first file request address, and to load the target module file from the local cache based on the second file request address;
[0014] The file rendering module is used to add the target module file to the target resource file based on the module reference relationship to obtain the file to be rendered, and render the file to be rendered to obtain the target page application.
[0015] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method for rendering a page application described in any one of the above is implemented.
[0016] According to one aspect of the present disclosure, there is provided an electronic device, including:
[0017] Processor; and
[0018] A memory, configured to store executable instructions of the processor;
[0019] The processor is configured to execute any one of the above-mentioned methods for rendering a page application by executing the executable instructions.
[0020] A rendering method for a page application provided by an embodiment of the present disclosure includes, on the one hand, obtaining a target resource file required for rendering the target page application by parsing the target page application, and generating a first file request address corresponding to the target resource file; then, based on the target reference relationship in the target resource file, determining the target module file required for rendering the target page application, and generating a second file request address corresponding to the target module file; then, loading the target resource file from the server based on the first file request address, and loading the target module file from the local cache based on the second file request address; finally, adding the target module file to the target resource file based on the module reference relationship to obtain a file to be rendered, and rendering the file to be rendered to obtain the target page application; since the target module file can be loaded from the local cache without having to be loaded from the server, the problem of long transmission time of the resource file caused by the need to load the target module file from the server can be solved, the transmission time of the resource file is reduced, and the rendering efficiency of the page application is improved; on the other hand, since the transmission time of the resource file can be reduced, the response time of the page application is reduced, and the user experience is improved; on the other hand, since the target module file can be loaded from the local cache without having to be loaded from the server, bandwidth resources are saved.
[0021] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0023] Figure 1 A flowchart of a method for rendering a page application according to an exemplary embodiment of the present disclosure is schematically shown.
[0024] Figure 2 A block diagram schematically illustrates a rendering system for a page application according to an exemplary embodiment of the present disclosure.
[0025] Figure 3 A method flow chart schematically illustrates a specific storage process of an original resource file of an application client according to an exemplary embodiment of the present disclosure.
[0026] Figure 4 A scene example diagram schematically illustrates original module files and original resource files included in an original page application according to an exemplary embodiment of the present disclosure.
[0027] Figure 5 A scene example diagram schematically illustrates a process of uploading an original module file and an original resource file according to an example embodiment of the present disclosure.
[0028] Figure 6 An example diagram schematically illustrates an original module file under a module directory according to an example embodiment of the present disclosure.
[0029] Figure 7 A method flow chart schematically illustrates a specific synchronization process of an original module file in a local cache according to an exemplary embodiment of the present disclosure.
[0030] Figure 8 A scenario example diagram schematically illustrates a synchronization process of an original module file according to an exemplary embodiment of the present disclosure.
[0031] Fig. 9 A block diagram schematically illustrates a rendering device for a page application according to an exemplary embodiment of the present disclosure.
[0032] Fig.10 An electronic device for implementing a rendering method of a page application according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0034] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0035] In the prior art, when a client needs to request a network resource from a server, if the network resource (i.e., resource file) is not optimized, the server needs to return the network resource to the client in its entirety. However, when the network resource is large in size, the time and traffic consumed for transmission often increase, and the waiting time for the client to receive the resource is also relatively long. During the interaction with the user, if the waiting time is too long, the user experience will be reduced.
[0036] Secondly, when the client requests multiple resources at the same time, if the multiple resources contain the same module file, but the same module file is not extracted and separated, each requested resource contains the same module file, which makes the resource reuse efficiency low and the resource request redundant.
[0037] In view of the above-mentioned problems, the exemplary embodiment of the present disclosure provides a rendering method for a page application, which aims to reduce resource volume, improve resource reuse efficiency, improve resource transmission efficiency and reduce traffic consumption based on the rendering method used for the page application. Specifically, the rendering method for a page application described in the exemplary embodiment of the present disclosure can be run on a terminal device, etc. Of course, those skilled in the art can also run the method of the present disclosure on other platforms as required, and this exemplary embodiment does not specifically limit this. Further, refer to Figure 1 As shown, the rendering method of the page application may include the following steps:
[0038] Step S110: parsing the target page application to obtain a target resource file required for rendering the target page application, and generating a first file request address corresponding to the target resource file;
[0039] Step S120. Based on the target reference relationship in the target resource file, determine the target module file required for rendering the target page application, and generate a second file request address corresponding to the target module file;
[0040] Step S130. Load the target resource file from the server based on the first file request address, and load the target module file from the local cache based on the second file request address;
[0041] Step S140: Add the target module file to the target resource file based on the module reference relationship to obtain a file to be rendered, and render the file to be rendered to obtain the target page application.
[0042] In the above-mentioned rendering method of the page application, on the one hand, by parsing the target page application, the target resource file required for rendering the target page application is obtained, and a first file request address corresponding to the target resource file is generated; then, based on the target reference relationship in the target resource file, the target module file required for rendering the target page application is determined, and a second file request address corresponding to the target module file is generated; then, based on the first file request address, the target resource file is loaded from the server side, and based on the second file request address, the target module file is loaded from the local cache; finally, based on the module reference relationship, the target module file is added to the target resource file to obtain the file to be rendered, and the file to be rendered is rendered to obtain the target page application; since the target module file can be loaded from the local cache, it is not necessary to load it from the server side, thereby solving the problem of long transmission time of the resource file caused by the need to load the target module file from the server side, reducing the transmission time of the resource file and thus improving the rendering efficiency of the page application; on the other hand, since the transmission time of the resource file can be reduced, the response time of the page application is reduced, and the user experience is improved; on the other hand, since the target module file can be loaded from the local cache, it is not necessary to load it from the server side, thereby saving bandwidth resources.
[0043] Hereinafter, the rendering method of the page application recorded in the exemplary embodiment of the present disclosure will be explained and illustrated in detail with reference to the accompanying drawings.
[0044] First, the terms involved in the exemplary embodiments of the present disclosure are explained and illustrated.
[0045] (1) Resource files: Specifically, the resource files involved in the exemplary embodiments of the present disclosure refer to files generated by software developers when using computers and other electronic devices to produce images, videos, websites, etc. during the process of developing application clients; for example, the resource files can be HTML (HyperText Markup Language) files, JS (JavaScript) script files, CSS (Cascading Style Sheets) files, etc. generated by Web developers using computers as development devices through encoding.
[0046] (2) Webpack build tool: Specifically, Webpack is a static module packaging tool for modern JavaScript applications. When Webpack processes an application, it internally builds a dependency graph from one or more entry points, and then combines each module required in your project into one or more Bundles, all of which are static resources.
[0047] (3) Rollup build tool: Specifically, Rollup is a JavaScript module bundler that can compile small blocks of code into large blocks of complex code, such as libraries or applications. From the usage scenarios, it can be concluded that Rollup tends to be applied to JS libraries, while Webpack tends to be applied to front-end projects and UI libraries.
[0048] (4) Gulp build tool: Specifically, Gulp is an automated packaging tool for Web front-ends implemented based on Node. Gulp can be used to compress, integrate, move, and obfuscate files, and Gulp can be used to process CSS files and JS files.
[0049] Secondly, the technical implementation principles and application scenarios of the example embodiments of the present disclosure are explained and illustrated. Specifically, the rendering method of the page application recorded in the example embodiments of the present disclosure can be processed for different types of resources; at the same time, due to the differences in the processing methods of different types of resources, the example embodiments of the present disclosure are only described for the file resources generated by website production. Furthermore, in the current website production process, build tools are an indispensable part of website development, mainly including tools such as Webpack, Rollup, Gulp, etc. The main function of these tools is to package multiple modules into one or more files, and optimize these files, so as to increase the speed at which these files are loaded by the page.
[0050] Furthermore, for the Webpack build tool, when an application client has entry A and entry B, both entry A and entry B reference module C. Without optimization, the resource files A1 and B1 generated by entry A and entry B both include module C. When resource files A1 and B1 are loaded in the page at the same time, since module C is not extracted into a common module, module C is loaded twice by the page although it is located in different resource files. Furthermore, in order to solve the problem that module C is loaded twice by the page, the Webpack build tool can be used to extract module C into an independent module, so that resource files A1 and B1 retain the reference to module C, and the code of module C will not be saved in the file. When the page loads resource files A1 and B1, no matter whether A1 or B1 loads module C first, the resource file loaded later will directly obtain the loaded module C from the local, and will not request module C from the server again. In this way, for the page, module C is only loaded once, realizing the optimization of the common module.
[0051] However, although the above method optimizes module C so that module C can be reused, a total of 3 network requests need to be initiated for resource file A1, resource file B1, and module C. The present invention can further optimize the network requests so that the number of network requests is reduced to 2; however, the rendering method of the page application recorded in the example embodiment of the present disclosure can enable the shared module to be obtained locally without initiating a request to the server, thereby improving rendering efficiency and reducing the waste of network resources.
[0052] The following will be combined Figure 2 The rendering system of the page application involved in the exemplary embodiment of the present disclosure is explained and illustrated. Figure 2 As shown, the rendering system of the page application may include a terminal device 210 where the application client is located and a server 220; wherein the terminal device can be connected to the server in a communication manner via a wired network or a wireless network; the terminal device can be used to implement the rendering method of the page application described in the example embodiment of the present disclosure, and the server can be used to store resource files, as well as store module files and synchronize the module files to the local cache of the terminal device.
[0053] The following will explain and illustrate the specific storage process of the original resource files of the application client. Figure 3 As shown, the specific storage process of the original resource file of the application client may include the following steps:
[0054] Step S310, obtaining the original page application included in the application client and the original resource file corresponding to the original page application;
[0055] Step S320, extracting the original module file included in the original resource file, and determining the original reference relationship of the original module file in the original resource file according to the original placement position of the original module file in the original resource file;
[0056] Step S330, deleting the original module file in the original resource file, and writing the original reference relationship at the original placement position to obtain the resource file to be uploaded;
[0057] Step S340, uploading the original module file and the resource files to be uploaded to the server, so that after receiving the first file request from the server, the target resource file can be matched from the uploaded resource files.
[0058] Among them, uploading the original module file and the resource file to be uploaded to the server side can be achieved in the following ways: naming the original module file according to the original module name of the original module file and the original file version number corresponding to the original module file, and uploading the named original module file to the server; naming the resource file to be uploaded according to the original file category and the original file name of the resource file to be uploaded, and uploading the named resource file to be uploaded to the server side.
[0059] The following will be combined Figure 4 as well as Figure 5 The specific storage process of the original resource file is further explained and illustrated. Specifically, in the actual application process, in order to improve the resource loading efficiency, before the resource file is uploaded to the server (that is, before the original resource file is stored), the original module file included in the original resource file needs to be extracted and separated. Among them, the specific extraction and separation process can be implemented in the following way: Specifically, when using a build tool (Webpack, Rollup, Gulp, etc.) to process a page application, it is necessary to generate a corresponding original resource file and an independent original module file for each page application involved in the application client; for example, when the page application entry A references module B and module C, the original resource file generated by the entry A according to the normal output process will include module B and module C, and for the example embodiment of the present disclosure, module B and module C will be separated into independent original module files, and the original resource file generated by entry A will retain the reference to module B and module C; and the original module files generated by module B and module C will be named in a specific format, for example, the file name of module B is moduleB@1.0.0, that is, the file name of the original module file can be composed of "module name + version number", because the introduced modules may have different versions, the name needs to include the version number for distinction.
[0060] For further reference, Figure 4 As shown, assuming that entry A contains module B and module C, after being processed by the build tool, the original resource file index and independent original module files moduleB@1.0.0 and moduleC@1.0.0 are generated. Furthermore, after obtaining the original module file and the original resource file, they can be uploaded to the server; after the server receives the uploaded original module file and the original resource file, the uploaded original resource file can be managed and the original module file can be managed uniformly.
[0061] Specifically, in the process of unified management of the uploaded original resource files and original module files, the server can place the original module files in the same module file directory corresponding to the application client; at the same time, since different page application builds may generate independent module files that are potentially the same, for example, page application A builds module C with version number 1.0.0, and page application B builds module C with version number 1.0.0. The files generated by the two page applications are uploaded to the server. Since the independent modules generated by the two page applications are placed in the same directory of the server, when the server detects that a module already exists in the module directory, the same module will not be put into place. This not only strengthens the independence and uniqueness of the modules, but also reduces the consumption of server hard disk capacity.
[0062] Further, refer to Figure 5 As shown in the figure, the original resource files index.html, index.js, index.css and the original module file moduleA@1.0.0 are generated by the build. These files are uploaded to the server. The server puts the independent original module files into the module directory and other resources into the corresponding directory. The original module files included in the module directory can be referred to Figure 6 As shown; further, in Figure 6 In the original module file shown, different modules exist in the module directory at the same time. Even if the module names are the same, they will be identified as independent modules due to inconsistent version numbers.
[0063] The following will explain and illustrate the specific synchronization process of the original module files in the local cache. Figure 7 As shown, the specific synchronization process of the original module file in the local cache may include the following steps:
[0064] Step S710, in response to an input event for an application client, starting the application client and generating a module file acquisition request corresponding to the application client;
[0065] Step S720, sending the module file acquisition request to the server, and receiving the original module file name list fed back by the server in response to the module file acquisition request;
[0066] Step S730, comparing the original module file name list with the local module file name list already in the local cache to obtain a list comparison result;
[0067] Step S740: acquiring a newly added original module file from the server based on the list comparison result, and adding the newly added original module file to the local cache.
[0068] Furthermore, the rendering method of the page application may also include: obtaining the new module name of the new original module file, and adding the new module name to the local module file name list; deleting the original module file that exists in the local cache but not on the server side according to the list comparison result.
[0069] The following will be combined Figure 8 The specific storage process of the original module files in the local cache is further explained and illustrated. Specifically, in the actual application process, in order to make the original module files included in the local cache consistent with the original module files in the module directory on the server side, it is necessary to perform the original module file synchronization operation every time the application client is started. Specifically, in the actual application process, after the application client is started, in order to be able to use the original module files that may be used by the page application in the application client at any time, it is necessary to synchronize the local module files with the server module files after the application client is started.
[0070] Furthermore, in the process of caching the original module files in the local cache and the original module files stored in the directory on the server side, first, a local module file record file (i.e., a local module file name list) needs to be maintained in the local cache of the terminal device where the application client is located, which is used to record all the original module files synchronized from the server to the local; at the same time, an original module file name list needs to be maintained in the module file directory on the server side; when the task of synchronizing the original module files needs to be executed, the original module file name list can be obtained from the server side first, and then the original module file name list and the local module file name list are compared; further, when the list comparison result shows that a new original module file has been added, the newly added original module file is obtained and written into the local cache, and the local module file name list is updated at the same time; when the list comparison result shows that a deleted original module file has been deleted, the original module file is deleted from the local cache, and the local module file name list is updated. That is, when a new module file is added, the record file adds the record of the module file, and when the module file is removed, the record file removes the record of the module file. At the same time, when the client obtains module resources from the server, it informs the server of the module files that already exist locally based on the record file, and the server returns the module files that the client does not have based on the module files that already exist on the client.
[0071] Further, refer to Figure 8As shown in the figure, when the original module file in the local cache corresponding to the application client is moduleA@1.0.0, and the module files on the server are moduleA@1.0.0 and moduleB@1.0.0, and the client informs the server that the module file moduleA@1.0.0 exists locally, then the server only needs to return moduleB@1.0.0 to the client for this synchronization.
[0072] The following will be combined Figure 2-Figure 8 right Figure 1 The rendering method of the page application shown in the figure is further explained and illustrated. Specifically:
[0073] In step S110, the target page application is parsed to obtain a target resource file required for rendering the target page application, and a first file request address corresponding to the target resource file is generated.
[0074] In this example embodiment, first, the target page application is parsed to obtain the target resource file required for rendering the target page application; specifically, it can be implemented in the following manner: first, in response to an input event for an application client, the application client is started, and the target page application corresponding to the application client is determined; secondly, the page attribute information of the target page application is obtained, and the page attribute information is parsed to obtain the target resource file required for rendering the target page application. That is to say, in the actual application process, if a target page application in a certain application client needs to be rendered, the application client needs to be started first; at the same time, the input event recorded here can be a touch event or an event input through an external device, and this example does not impose special restrictions on this; at the same time, the target page application recorded here can be the main display interface of the application client, or a secondary display interface corresponding to the main display interface, and of course it can also be a sub-display interface of a lower level, etc., and this example does not impose special restrictions on this. Furthermore, after the target page application is determined to be completed, the page attribute information of the target page application can be obtained; wherein, the page attribute information may include the page address, page detail information, etc. of the target page application; the page detail information may also include module information or image information or text information included in the target page application, etc., and this example does not impose any special restrictions on this.
[0075] Secondly, generate a first file request address corresponding to the target resource file; specifically, this can be achieved in the following manner: first, determine the target file category of the target resource file; wherein the target file category includes at least one of a hypertext markup language file category, a script file category, and a cascading style sheet file category; secondly, based on the target file name and target file category of the target resource file, generate a first file request address corresponding to the target resource file; wherein the first file request address is a remote file request address. Specifically, in the actual application process, since the target resource file needs to be obtained from the application server corresponding to the application client, it is necessary to generate the first file request address and record it from the server based on the first file request address.
[0076] In an example embodiment, since the target resource files to be loaded may include HTML files, CSS files, JS files, etc., and the HTML files, CSS files, and JS files are respectively stored in different directories on the server side, in order to facilitate the server to accurately obtain the corresponding target resource files and feed the target resource files back to the client, it is necessary to generate a first file request address corresponding to the target resource file based on the target file name and target file category of the target resource file; wherein the first file request address recorded here may be, for example: http: / / www.server.com / index.html; wherein the index recorded here is the target file name and target file category corresponding to the target source file; wherein the index may include a target file name + a target file category, or may include multiple target file names + multiple target file categories, and this example does not impose any special restrictions on this.
[0077] In step S120, based on the target reference relationship in the target resource file, a target module file required for rendering the target page application is determined, and a second file request address corresponding to the target module file is generated.
[0078] In this example embodiment, first, based on the target reference relationship in the target resource file, the target module file required for rendering the target page application is determined; specifically, it can be implemented in the following way: first, it is necessary to obtain the target reference relationship in the target resource file; wherein, the target reference relationship can be presented in a chain; for example, when rendering to a certain position, it is necessary to call the target resource file, then the corresponding target reference relationship can be generated in combination with the context relationship of the position; further, the target reference relationship can include context information, the target module name of the target module file, and the target file version number, etc., and of course, it can also include other information, and this example does not impose any special restrictions on this.
[0079] Secondly, generate a second file request address corresponding to the target module file; specifically, it can be achieved in the following way: determine the target module name of the target module file and the target file version number corresponding to the target module file; generate a second file request address corresponding to the target module file according to the target module name and the target file version number; wherein the second file request address is a local file request address. Specifically, the generated second file request address can be, for example, client: / / moduleA@1.0.0.js; it should be noted here that the second file request address can include a target module name and a target file version number, or multiple target module names and target file version numbers, and this example does not impose special restrictions on this; at the same time, when the second file request address includes multiple target module names and target file version numbers, the target module name and the target file version number can be separated from the target module name and the target file version number by a specific symbol, and the specific symbol can be selected according to actual needs, such as a semicolon or a colon, etc., and this example does not impose special restrictions on this.
[0080] It should be further explained here that the first file request address and the second file request address not only differ in the actual requested content, but more importantly, since the first file request address needs to be requested remotely (that is, it needs to be requested when the network is unobstructed), it needs to start with http; and the second file request address only needs to be requested locally, so it does not need to start with http, and can directly start with client, or other methods. This example does not impose any special restrictions on this.
[0081] In step S130, the target resource file is loaded from the server based on the first file request address, and the target module file is loaded from the local cache based on the second file request address.
[0082] Specifically, in the process of loading the target resource file from the server based on the first file request address, when the server receives a target resource file acquisition request corresponding to the first file request address, it can parse the target resource file acquisition request to determine the target resource file that needs to be fed back, and then based on the target file name and target file category of the target resource file, extract the target resource file from the corresponding directory and provide feedback.
[0083] Secondly, in the process of loading the target module file from the local cache based on the second file request address, it can be achieved in the following way: the second file request address is parsed to obtain the target module name and the target file version number in the second file request address; based on the target module name and the target file version number, the target module file corresponding to the target module name and the target file version number is matched from the local cache, and the matched target module file is loaded. That is, when the client detects that the request address starts with client: / / , it means that the request needs to return a module file from the client. The client parses the address to obtain the module file to be returned as moduleA@1.0.0. The client searches for the corresponding module file from the local module file and returns the module content to the page application. Finally, the page can be further loaded after obtaining the module file content.
[0084] In step S140, the target module file is added to the target resource file based on the module reference relationship to obtain a file to be rendered, and the file to be rendered is rendered to obtain the target page application.
[0085] In this example embodiment, first, based on the target reference relationship, the target module file is added to the target resource file to obtain the file to be rendered; specifically, it can be implemented in the following way: based on the target reference relationship, the target placement position of the target module file in the target resource file is determined; based on the target placement position, the target module file is added to the target resource file to obtain the file to be rendered. That is to say, in the actual rendering process, it is first necessary to ensure that the rendered file is a complete resource file before the corresponding rendering task can be executed; under this premise, since the target resource file only includes the target reference relationship to the target module file and does not include the actual target module file, it is first necessary to add the target module file to the target resource file to obtain the file to be rendered, and then execute the corresponding rendering task.
[0086] Secondly, the file to be rendered is rendered to obtain the target page application; specifically, in the specific rendering process, it can be implemented in the following way: first, the file to be rendered is parsed to obtain a page object model corresponding to the target page application; secondly, a page rendering tree is generated according to the page object model, and a page layout of the target page application is calculated based on the page rendering tree; finally, the page layout is rendered to obtain the target page application.
[0087] So far, the rendering method of the page application recorded in the example embodiment of the present disclosure has been fully realized. Based on the above-mentioned recorded content, it can be known that the rendering method of the page application recorded in the example embodiment of the present disclosure, on the one hand, can provide a resource loading method for the situation in the prior art where the network request resource is large or the resource sharing module cannot be separated, resulting in increased transmission time and increased traffic consumption, so as to improve the resource reuse efficiency, further reduce traffic consumption and improve resource transmission efficiency; on the other hand, the rendering method of the page application recorded in the example embodiment of the present disclosure separates and extracts the shared module, so that the shared module does not need to be merged into the generated file, thereby reducing the size of the generated file. The present invention manages the shared modules in a unified manner, so that each shared module is more independent, which can save the server hard disk capacity consumption. The present invention establishes synchronization between the client and server module files, so that when the resource type requested by the client is a shared module, it can be directly obtained from the client without requesting it from the server, thereby speeding up the resource loading efficiency.
[0088] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.
[0089] The exemplary embodiment of the present disclosure also provides a rendering device for a page application. Fig. 9 As shown, the rendering device of the page application may include a first file request address generating module 910, a second file request address generating module 920, a resource file loading module 930 and a file rendering module 940. Among them:
[0090] The first file request address generating module 910 may be used to parse the target page application, obtain the target resource file required for rendering the target page application, and generate a first file request address corresponding to the target resource file;
[0091] The second file request address generating module 920 may be used to determine the target module file required for rendering the target page application based on the target reference relationship in the target resource file, and generate a second file request address corresponding to the target module file;
[0092] The resource file loading module 930 may be used to load the target resource file from the server based on the first file request address, and load the target module file from the local cache based on the second file request address;
[0093] The file rendering module 940 may be configured to add the target module file to the target resource file based on the module reference relationship to obtain a file to be rendered, and render the file to be rendered to obtain the target page application.
[0094] In the rendering device of the page application, on the one hand, by parsing the target page application, the target resource file required for rendering the target page application is obtained, and a first file request address corresponding to the target resource file is generated; then, based on the target reference relationship in the target resource file, the target module file required for rendering the target page application is determined, and a second file request address corresponding to the target module file is generated; then, based on the first file request address, the target resource file is loaded from the server side, and based on the second file request address, the target module file is loaded from the local cache; finally, based on the module reference relationship, the target module file is added to the target resource file to obtain the file to be rendered, and the file to be rendered is rendered to obtain the target page application; since the target module file can be loaded from the local cache, it is not necessary to load it from the server side, thereby solving the problem of long transmission time of the resource file caused by the need to load the target module file from the server side, reducing the transmission time of the resource file and thus improving the rendering efficiency of the page application; on the other hand, since the transmission time of the resource file can be reduced, the response time of the page application is reduced, and the user experience is improved; on the other hand, since the target module file can be loaded from the local cache, it is not necessary to load it from the server side, thereby saving bandwidth resources.
[0095] In an exemplary embodiment of the present disclosure, generating a second file request address corresponding to a target module file includes: determining a target module name of the target module file and a target file version number corresponding to the target module file; generating a second file request address corresponding to the target module file according to the target module name and the target file version number; wherein the second file request address is a local file request address.
[0096] In an exemplary embodiment of the present disclosure, generating a first file request address corresponding to a target resource file includes: determining a target file category of the target resource file; wherein the target file category includes at least one of a hypertext markup language file category, a script file category, and a cascading style sheet file category; based on the target file name and the target file category of the target resource file, generating a first file request address corresponding to the target resource file; wherein the first file request address is a remote file request address.
[0097] In an exemplary embodiment of the present disclosure, the target module file is loaded from the local cache based on the second file request address, including: parsing the second file request address to obtain the target module name and the target file version number in the second file request address; based on the target module name and the target file version number, matching the target module file corresponding to the target module name and the target file version number from the local cache, and loading the matched target module file.
[0098] In an exemplary embodiment of the present disclosure, the target module file is added to the target resource file based on the target reference relationship to obtain the file to be rendered, including: determining the target placement position of the target module file in the target resource file based on the target reference relationship; and adding the target module file to the target resource file based on the target placement position to obtain the file to be rendered.
[0099] In an exemplary embodiment of the present disclosure, a target page application is parsed to obtain a target resource file required for rendering the target page application, including: in response to an input event to an application client, starting the application client and determining a target page application corresponding to the application client; obtaining page attribute information of the target page application, and parsing the page attribute information to obtain a target resource file required for rendering the target page application.
[0100] In an exemplary embodiment of the present disclosure, the original resource file is stored in the server side in the following manner: obtaining the original page application included in the application client and the original resource file corresponding to the original page application; extracting the original module file included in the original resource file, and determining the original reference relationship of the original module file in the original resource file according to the original placement position of the original module file in the original resource file; deleting the original module file in the original resource file, and writing the original reference relationship at the original placement position to obtain the resource file to be uploaded; uploading the original module file and the resource file to be uploaded to the server side, so that after receiving the first file request from the server side, the target resource file can be matched from the uploaded resource files.
[0101] In an exemplary embodiment of the present disclosure, the original module file and the resource file to be uploaded are uploaded to the server side, including: naming the original module file according to the original module name of the original module file and the original file version number corresponding to the original module file, and uploading the named original module file to the server; naming the resource file to be uploaded according to the original file category and the original file name of the resource file to be uploaded, and uploading the named resource file to be uploaded to the server side.
[0102] In an exemplary embodiment of the present disclosure, the original module file is synchronized to the local cache in the following manner: in response to an input event to an application client, the application client is started and a module file acquisition request corresponding to the application client is generated; the module file acquisition request is sent to a server, and an original module file name list fed back by the server in response to the module file acquisition request is received; the original module file name list and the local module file name list already in the local cache are compared to obtain a list comparison result; based on the list comparison result, a newly added original module file is obtained from the server, and the newly added original module file is added to the local cache.
[0103] In an exemplary embodiment of the present disclosure, the rendering device of the page application further includes:
[0104] A module name adding module can be used to obtain the new module name of the newly added original module file and add the new module name to the local module file name list; and / or
[0105] The module file deletion module can be used to delete the original module files that exist in the local cache but not on the server according to the list comparison results.
[0106] The specific details of each module in the above-mentioned rendering device for page application have been described in detail in the corresponding rendering method for page application, so they will not be repeated here.
[0107] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0108] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0109] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0110] Those skilled in the art will appreciate that various aspects of the present disclosure may be implemented as systems, methods or program products. Therefore, various aspects of the present disclosure may be specifically implemented in the following forms, namely: complete hardware implementation, complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as "circuits", "modules" or "systems".
[0111] Refer to the following Fig.10 The electronic device 1000 according to this embodiment of the present disclosure is described. Fig.10 The electronic device 1000 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0112] like Fig.10 As shown, the electronic device 1000 is in the form of a general computing device. The components of the electronic device 1000 may include, but are not limited to: the at least one processing unit 1010, the at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), and a display unit 1040.
[0113] The storage unit stores program codes, which can be executed by the processing unit 1010, so that the processing unit 1010 performs the steps according to various exemplary embodiments of the present disclosure described in the above “Exemplary Method” section of this specification. For example, the processing unit 1010 can perform the following steps: Figure 1 Step S110 shown in: parsing the target page application to obtain the target resource file required for rendering the target page application, and generating a first file request address corresponding to the target resource file; step S120: determining the target module file required for rendering the target page application based on the target reference relationship in the target resource file, and generating a second file request address corresponding to the target module file; step S130: loading the target resource file from the server based on the first file request address, and loading the target module file from the local cache based on the second file request address; step S140: adding the target module file to the target resource file based on the module reference relationship to obtain a file to be rendered, and rendering the file to be rendered to obtain the target page application.
[0114] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 10201 and / or a cache storage unit 10202 , and may further include a read-only storage unit (ROM) 10203 .
[0115] The storage unit 1020 may also include a program / utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0116] Bus 1030 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0117] The electronic device 1000 may also communicate with one or more external devices 1100 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or may communicate with any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1050. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1060. As shown, the network adapter 1060 communicates with other modules of the electronic device 1000 via a bus 1030. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0118] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0119] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of the present specification.
[0120] According to the program product for implementing the above method in the embodiment of the present disclosure, it can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0121] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0122] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0123] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0124] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0125] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0126] Other embodiments of the present disclosure will be readily apparent to those skilled in the art after considering the specification and practicing the inventions invented herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not invented by the present disclosure. The specification and examples are to be considered merely exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
Claims
1. A rendering method for a page application, characterized in that: include: Parsing the target page application to obtain a target resource file required for rendering the target page application, and generating a first file request address corresponding to the target resource file; Based on the target reference relationship in the target resource file, determine the target module file required for rendering the target page application, and generate a second file request address corresponding to the target module file; Loading the target resource file from the server based on the first file request address, and loading the target module file from the local cache based on the second file request address; The target module file is added to the target resource file based on the module reference relationship to obtain a file to be rendered, and the file to be rendered is rendered to obtain the target page application.
2. The method for rendering a page application according to claim 1, characterized in that: Generating a second file request address corresponding to the target module file includes: Determine the target module name of the target module file and the target file version number corresponding to the target module file; A second file request address corresponding to the target module file is generated according to the target module name and the target file version number; wherein the second file request address is a local file request address.
3. The method for rendering a page application according to claim 1, characterized in that: Generating a first file request address corresponding to a target resource file includes: Determine a target file category of the target resource file; wherein the target file category includes at least one of a hypertext markup language file category, a script file category, and a cascading style sheet file category; Based on the target file name and the target file category of the target resource file, a first file request address corresponding to the target resource file is generated; wherein the first file request address is a remote file request address.
4. The method for rendering a page application according to claim 1, characterized in that: Loading the target module file from the local cache based on the second file request address includes: Parsing the second file request address to obtain a target module name and a target file version number in the second file request address; Based on the target module name and the target file version number, the target module file corresponding to the target module name and the target file version number is matched from the local cache, and the matched target module file is loaded.
5. The method for rendering a page application according to claim 1, characterized in that: Adding the target module file to the target resource file based on the target reference relationship to obtain a file to be rendered includes: Based on the target reference relationship, determining a target placement position of the target module file in the target resource file; The target module file is added to the target resource file based on the target placement position to obtain a file to be rendered.
6. The method for rendering a page application according to claim 1, characterized in that: Parse the target page application to obtain the target resource file required for rendering the target page application, including: In response to an input event for an application client, starting the application client and determining a target page application corresponding to the application client; The page attribute information of the target page application is obtained, and the page attribute information is parsed to obtain the target resource file required for rendering the target page application.
7. The method for rendering a page application according to claim 1, characterized in that: The rendering method of the page application also includes: Obtaining an original page application included in the application client and an original resource file corresponding to the original page application; Extracting the original module file included in the original resource file, and determining the original reference relationship of the original module file in the original resource file according to the original placement position of the original module file in the original resource file; Deleting the original module file in the original resource file, and writing the original reference relationship at the original placement position to obtain the resource file to be uploaded; The original module file and the resource files to be uploaded are uploaded to the server side, so that after receiving the first file request from the server side, the target resource file can be matched from the uploaded resource files.
8. The method for rendering a page application according to claim 7, characterized in that: Upload the original module file and the resource files to be uploaded to the server, including: Naming the original module file according to the original module name of the original module file and the original file version number corresponding to the original module file, and uploading the named original module file to the server; The resource file to be uploaded is named according to the original file category and the original file name of the resource file to be uploaded, and the named resource file to be uploaded is uploaded to the server.
9. The method for rendering a page application according to claim 1, characterized in that: The rendering method of the page application also includes: In response to an input event for an application client, starting the application client and generating a module file acquisition request corresponding to the application client; Sending the module file acquisition request to the server, and receiving the original module file name list fed back by the server in response to the module file acquisition request; Compare the original module file name list with the local module file name list already in the local cache to obtain a list comparison result; Based on the list comparison result, newly added original module files are obtained from the server, and the newly added original module files are added to the local cache.
10. The method for rendering a page application according to claim 9, characterized in that: The rendering method of the page application also includes: Obtain the name of the newly added module of the newly added original module file, and add the name of the newly added module to the local module file name list; and / or According to the list comparison results, the original module files that exist in the local cache but not on the server are deleted.
11. A rendering device for a page application, characterized in that: include: A first file request address generating module is used to parse the target page application, obtain the target resource file required for rendering the target page application, and generate a first file request address corresponding to the target resource file; A second file request address generating module, used to determine the target module file required for rendering the target page application based on the target reference relationship in the target resource file, and generate a second file request address corresponding to the target module file; A resource file loading module, used to load the target resource file from the server based on the first file request address, and to load the target module file from the local cache based on the second file request address; The file rendering module is used to add the target module file to the target resource file based on the module reference relationship to obtain the file to be rendered, and render the file to be rendered to obtain the target page application.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for rendering a page application according to any one of claims 1 to 10 is implemented.
13. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the method for rendering a page application according to any one of claims 1 to 10 by executing the executable instructions.
