Method for checking that H5 offline resource does not contain sub-routing in terminal
By formulating routing configuration protocols and generating routing configuration files, the problem of sub-routing judgment in H5 offline resources is solved, and the timeliness and availability of H5 offline resources is effectively guaranteed, which improves the reliability of H5 offline capabilities.
Patent Information
- Application Number
- CN202411671093.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-02-25
AI Technical Summary
There is a problem with subroutine judgment in the mobile terminal of H5 offline resources, and it is impossible to effectively judge the availability and effectiveness of subroutines, which affects the full availability of H5 offline capabilities.
By formulating a routing configuration protocol, extracting a single H5 page route to generate a routing configuration file, and putting it into the H5 offline package, realizing the method of checking whether the H5 offline resources contain subroutines.
It solves the routing configuration problem, ensures the timeliness of offline resources, quickly judges the availability of resources, avoids the erroneous resource loading problems caused by misjudgment, and improves the reliability of H5 offline capabilities.
Smart Images

Figure CN119520265A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an in-terminal inspection method, in particular to an in-terminal inspection method for H5 offline resources not containing sub-routes, and belongs to the technical field of mobile Internet. Background Art
[0002] H5 is the abbreviation of HTML5, which is a language description form for building Web content. The website pages seen in the browser are all in HTML format. H5 is the latest generation of HTML technical standards; H5 offline resources refer to the fact that in HTML5 development, in order to improve user experience and application performance, users are allowed to download and store some or all resources, such as style sheets, JavaScript files, pictures, etc., when they first visit a website or application, so that functions and content can be used normally even without a network connection.
[0003] Sub-routing is a protocol in H5 language for determining the path of HTML pages. Based on the path of the main page, sub-routing can be spliced in the URL format to dynamically display H5 sub-pages. Sub-routing is also the URL of the sub-page.
[0004] At present, the H5 page resources on mobile terminals are large in size and of various types. Under the condition of limited resources on mobile devices, offline H5 has become the most popular way to accelerate loading. However, although offline H5 resources can greatly improve the loading of H5 pages in mobile applications, it mainly adopts page reuse technology, which has certain defects and will cause problems in sub-route judgment. For example, based on the main route, how to judge whether this H5 supports a certain sub-route; based on the offline package, how to judge whether the sub-route is the latest available; the availability and effectiveness of sub-routes are the key to ensuring that the H5 offline capability is fully available in the H5 offline solution. Therefore, a method for checking whether the H5 offline resources do not contain sub-routes is proposed. Summary of the invention
[0005] In view of this, the present invention provides a method for checking in a terminal whether an H5 offline resource contains a sub-route, so as to solve or alleviate the technical problems existing in the prior art, and at least provide a beneficial option.
[0006] The technical solution of the embodiment of the present invention is implemented as follows: a method for checking in a terminal that an H5 offline resource does not contain a sub-route, including resource publishing and sub-route checking;
[0007] The resource publishing comprises the following steps:
[0008] Develop routing configuration protocols;
[0009] Extract the routing of a single H5 page and generate a routing configuration file according to the routing configuration protocol;
[0010] Pack H5 offline resources, put the routing configuration file into the offline resource package, and compress it to generate the H5 offline package;
[0011] H5 offline package released, updating the configuration of online and offline pages;
[0012] The sub-route checking comprises the following steps:
[0013] H5 offline resource check and update, check and update local resources;
[0014] H5 offline resource cache;
[0015] The H5 page opens and reads local offline resources;
[0016] Check the routing configuration to determine routing support;
[0017] Resource access loading H5.
[0018] Further preferably, the routing configuration protocol is used to specify the arrangement order of the routes according to the routing configuration format.
[0019] Further preferably, the extracting of the single H5 page route is performed by an automated script program, extracting all routes in the single H5 project, constructing a route configuration according to a route configuration protocol, and generating a specified route configuration file;
[0020] The file format is router.txt.
[0021] Further preferably, the H5 offline resource packaging is to package the H5 static resource file in combination with the offline configuration extracted resource, and at the same time put the routing configuration file in the folder of the offline package, compress it to generate the H5 offline package, and upload it to the cloud space.
[0022] Further preferably, the configuration corresponding to the online offline page includes but is not limited to the download address of the H5 offline package and the file MD5 information.
[0023] Further preferably, the H5 offline resource check and update is to send a data request in the mobile terminal according to the configuration data of the last local check and update to check and update local resources.
[0024] Further preferably, the H5 offline resource cache is to cache the configuration after pulling the updated configuration, and download, replace, and delete the local offline package according to the configuration content;
[0025] Among them, deleting the local offline package means deleting the local historical offline package.
[0026] Further preferably, the reading of the local offline resource is to find the local offline package file path according to the opened H5 ur l when the mobile terminal H5 page is opened, and read the offline resource.
[0027] Further preferably, the checking of routing configuration and judging routing support is to judge whether the routing configuration file exists according to the read offline resources, and if it exists, parse the configuration content according to the routing configuration protocol, generate a set of routing tables, intercept the key string in the H5ur l, search the routing table, and judge whether the sub-route is included if the key string is included, and judge whether the routing configuration file does not exist or does not contain the key string, then the routing is not supported, and the offline process ends;
[0028] Among them, the key string is the sub-route.
[0029] Further preferably, the resource access and loading of H5 is to use the H5 offline package to load H5 when the sub-routes are included in the routing table.
[0030] The embodiment of the present invention has the following advantages due to the adoption of the above technical solution:
[0031] 1. The present invention solves the routing configuration problem: it solves the configuration problem that the H5 project packaged resources lack the basis for judging the availability of sub-routes.
[0032] 2. The present invention ensures the timeliness of offline resources: cold start checks and updates, and hot start checks and updates according to the duration, so that the timeliness of offline resources can be guaranteed.
[0033] 3. The present invention solves the problem of determining whether a route is included: it solves the problem of being unable to determine whether a sub-route is included when a route is reused, and avoids the problem of incorrect resource loading caused by misjudging the inclusion of a sub-route.
[0034] 4. The present invention solves the efficiency problem of resource availability judgment: according to the supportability of the routing configuration, the availability of resources is quickly judged, and pre-judgment conditions are added to avoid unnecessary operations such as resource reading and loading that do not support routing.
[0035] The above summary is for illustrative purposes only and is not limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present invention will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1A schematic diagram of the process of publishing resources of the present invention;
[0038] Figure 2 It is a schematic diagram of the flow of sub-routing checking of the present invention. DETAILED DESCRIPTION
[0039] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present invention. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.
[0040] It should be noted that the terms "first", "second", "symmetrical", "array", etc. are only used to distinguish between description and position description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the definition of "first", "symmetrical", etc. can explicitly or implicitly include one or more of these features; similarly, when the number of certain features is not limited in the form of words such as "two" or "three", it should be noted that this feature also explicitly or implicitly includes one or more feature quantities.
[0041] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0042] like Figure 1 and Figure 2 As shown, an embodiment of the present invention provides a method for checking in a terminal that an H5 offline resource does not contain a sub-route, including resource publishing and sub-route checking;
[0043] Resource publishing includes the following steps:
[0044] Develop routing configuration protocols;
[0045] Extract the routing of a single H5 page and generate a routing configuration file according to the routing configuration protocol;
[0046] Pack H5 offline resources, put the routing configuration file into the offline resource package, and compress it to generate the H5 offline package;
[0047] H5 offline package released, updating the configuration of online and offline pages;
[0048] Sub-route checking includes the following steps:
[0049] H5 offline resource check and update, check and update local resources;
[0050] H5 offline resource cache;
[0051] The H5 page opens and reads local offline resources;
[0052] Check the routing configuration to determine routing support;
[0053] Resource access loading H5.
[0054] In one embodiment, Figure 1 As shown, the routing configuration protocol is used to configure the routing format and specify the order in which the routes are arranged.
[0055] The routing configuration protocol is a data protocol that is easy to build on the front end and easy to parse and read on the client side. It is also the routing configuration format. It specifies the order of routing, takes into account both parsing efficiency and reading mapping efficiency, and facilitates quick search of subroutes.
[0056] Routing configuration protocol example, using JSON format:
[0057]
[0058]
[0059] In the protocol, routes: an array containing all routing configurations;
[0060] Path: The path of the route, which is the unique identifier of the route;
[0061] Component: The component corresponding to the route. This component is loaded to the corresponding path when the front-end is built.
[0062] child_route: sub-route array, used to indicate nested routes;
[0063] In the protocol, each route can have subroutes, which are represented by a children array. Each subroute is also an object, containing its own path and component.
[0064] In one embodiment, Figure 1 As shown, extracting the routing of a single H5 page is done by using an automated script program to extract all routing in a single H5 project, build routing configuration according to the routing configuration protocol, and generate a specified routing configuration file;
[0065] The file format is router.txt.
[0066] Take the Python script as an example:
[0067]
[0068]
[0069] The script is just a basic example. The specific implementation needs to be adjusted according to the actual H5 project structure and routing configuration protocol.
[0070] In one embodiment, Figure 1 As shown, H5 offline resource packaging is to combine H5 static resource files with offline configuration to extract resources and package them, and at the same time put the routing configuration file in the folder of the offline package, compress it to generate an H5 offline package, and upload it to the cloud space.
[0071] First, identify the static resources in H5, then extract the identified static resources according to the offline configuration file, and package them to generate a folder for the offline package. Then put the routing configuration file into a specific folder in the offline package, and then compress the offline package to generate an H5 offline package. Then upload the H5 offline package to the cloud space to ensure that the offline package can be quickly downloaded and accessed by users.
[0072] In one embodiment, Figure 1 As shown, the configuration corresponding to the online offline page includes but is not limited to the download address of the H5 offline package and the file MD5 information.
[0073] MD5 (Message Digest Algorithm 5) is a widely used cryptographic hash function that can generate a 128-bit (16-byte) hash value to ensure the integrity and consistency of information transmission. It is often used to verify data integrity and is widely used in various scenarios, such as software publishing, digital signatures, and security authentication.
[0074] File MD5 information refers to the result obtained by calculating the file content with the MD5 algorithm. This result is a unique fixed-length string that reflects the characteristics of the file. If the content of the file changes, even a very small change, its MD5 value will change significantly.
[0075] The MD5 value of a file is calculated as follows:
[0076] Initialize the MD5 algorithm: prepare the initial value (IV) of the MD5 algorithm, which is a fixed string;
[0077] Padding file data: If the number of bits in a file is not a multiple of 512, the file data needs to be padded to ensure that the final data block size is 512 bits;
[0078] Processing data blocks: split the padded data into multiple 512-bit data blocks, and process each data block according to the MD5 algorithm;
[0079] Generate hash value: Combine the hash values of all processed data blocks to form the final MD5 hash value, which is a 128-bit large integer, usually expressed as 32 hexadecimal digits.
[0080] In one embodiment, Figure 1 As shown, H5 offline resource check and update is to send a data request in the mobile terminal based on the last updated local configuration data to check and update local resources.
[0081] First, the mobile terminal reads the configuration data of the last check update from the local storage, and sends a request to the server based on the read data to check whether there is a new update. Then the server determines whether the local resources need to be updated based on the requested data. If the server has a new H5 offline package, it will return the updated data to the mobile terminal.
[0082] In one embodiment, Figure 1 As shown, H5 offline resource cache is to pull the updated configuration, cache the configuration, and download, replace, and delete the local offline package according to the configuration content;
[0083] Among them, deleting the local offline package means deleting the local historical offline package.
[0084] When the mobile terminal receives the H5 offline package data returned by the server, since the H5 offline package usually contains new configuration content, the mobile terminal first caches the new configuration information into the local storage, then downloads the H5 offline package according to the configuration information, and then uses the downloaded H5 offline package to replace the old version of the local historical offline package and delete it.
[0085] In one embodiment, Figure 2 As shown, reading local offline resources means that when the mobile terminal H5 page is opened, the local offline package file path is found according to the opened H5 ur l to read the offline resources.
[0086] When a user opens an H5 page, the mobile terminal parses the page URL and extracts necessary information, such as path, query parameters, etc. Then the mobile terminal determines the file path of the corresponding H5 offline package based on the extracted URL information, and then calls and reads the H5 offline package based on the path.
[0087] In one embodiment, Figure 2As shown, check the routing configuration and determine the routing support. This is to determine whether the routing configuration file exists based on the read offline resources. If it does exist, parse the configuration content according to the routing configuration protocol, generate a set of routing tables, intercept the key string in the H5 ur l, search the routing table, and determine if the sub-route is included if the key string is included. If the routing configuration file does not exist or does not contain the key string, the routing is not supported, and the offline process ends.
[0088] Among them, the key string is the sub-route.
[0089] By judging whether the routing configuration file exists based on the read offline resources, if it exists, the routing support judgment is performed, that is, the configuration content is parsed according to the routing configuration protocol. The protocol-compliant configuration can correctly parse a set of routing tables, and then intercept the key string in the H5 ur l, use the key string to search the routing table, and if the routing table contains the key string, it is determined that the sub-route is included;
[0090] If there is no routing configuration file or there is a routing configuration file but the key string is not found in the routing table, the routing is not supported, the offline process ends, and the user cannot currently access the requested resource.
[0091] In one embodiment, Figure 2 As shown, resource retrieval and loading of H5 is to use the H5 offline package to load H5 when the routing table contains sub-routes.
[0092] By utilizing the pre-judgment conditions, unnecessary operations such as resource reading and loading that do not support routing are avoided. By using the H5 offline package to load H5, the mobile terminal can still access the H5 page without a network connection.
[0093] The present invention mainly solves the natural defects of H5 offline reuse capability by judging the existence, timeliness and reuse of H5 sub-routes, and also ensures the timeliness of routes, providing a basic guarantee for the practical application of H5 offline capabilities, and has the following characteristics:
[0094] 1. Solve the routing configuration problem: Solve the configuration problem that the H5 project packaged resources lack the basis for judging the availability of sub-routes.
[0095] 2. Ensure the timeliness of offline resources: Check and update during cold start, and check and update based on the duration of hot start, so that the timeliness of offline resources can be guaranteed.
[0096] 3. Solve the problem of judging whether a route is included: Solve the problem of being unable to judge whether a sub-route is included when reusing routes, and avoid the problem of incorrect resource loading caused by misjudgment of the inclusion of sub-routes.
[0097] 4. Solve the efficiency problem of resource availability judgment: According to the support of routing configuration, quickly judge the availability of resources, add pre-judgment conditions, and avoid unnecessary operations such as resource reading and loading that do not support routing.
[0098] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of various changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for checking in a terminal that an H5 offline resource does not contain a sub-route, characterized in that: Includes resource publishing and sub-route checking; The resource publishing comprises the following steps: Develop routing configuration protocols; Extract the routing of a single H5 page and generate a routing configuration file according to the routing configuration protocol; Pack H5 offline resources, put the routing configuration file into the offline resource package, and compress it to generate the H5 offline package; H5 offline package released, updating the configuration of online and offline pages; The sub-route checking comprises the following steps: H5 offline resource check and update, check and update local resources; H5 offline resource cache; The H5 page opens and reads local offline resources; Check the routing configuration to determine routing support; Resource access loading H5.
2. According to claim 1, the method for checking that H5 offline resources do not contain sub-routes is characterized in that: The routing configuration protocol is used to specify the arrangement order of routes according to the routing configuration format.
3. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 2, characterized in that: The extraction of single H5 page routes is performed by an automated script program to extract all routes in a single H5 project, build a route configuration according to a route configuration protocol, and generate a specified route configuration file; The file format is router.txt.
4. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 3 is characterized in that: The H5 offline resource packaging is to combine the H5 static resource file with the offline configuration to extract the resource packaging, and at the same time put the routing configuration file in the folder of the offline package, compress it to generate the H5 offline package, and upload it to the cloud space.
5. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 1, characterized in that: The configuration corresponding to the online offline page includes but is not limited to the download address of the H5 offline package and the file MD5 information.
6. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 1, characterized in that: The H5 offline resource check and update is to send a data request in the mobile terminal according to the configuration data of the last local check and update to check and update local resources.
7. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 4, characterized in that: The H5 offline resource cache is to pull the updated configuration, cache the configuration, and download, replace, and delete the local offline package according to the configuration content; Among them, deleting the local offline package means deleting the local historical offline package.
8. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 7, characterized in that: The reading of local offline resources is to find the local offline package file path according to the opened H5 URL when the mobile terminal H5 page is opened, and read the offline resources.
9. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 8, characterized in that: The checking of routing configuration and judging routing support is to judge whether the routing configuration file exists according to the read offline resources. If it exists, the configuration content is parsed according to the routing configuration protocol, a set of routing tables is generated, the key string in the H5 URL is intercepted, and the routing table is searched. If the key string is included, it is judged that the sub-route is included. If it is judged that the routing configuration file does not exist or does not contain the key string, the routing is not supported, and the offline process ends; Among them, the key string is the sub-route.
10. The method for checking that H5 offline resources do not contain sub-routes in a terminal according to claim 9, characterized in that: The resource acquisition and loading of H5 is to use the H5 offline package to load H5 when the sub-route is included in the routing table.