Resource loading method and apparatus, medium, and electronic device
By merging resource addresses in the cloud to load multiple resources at once, the problem of low download efficiency caused by scattered resources in game resource packs is solved, thus improving download speed and application running efficiency.
Patent Information
- Application Number
- CN202310567596.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2043-05-18
AI Technical Summary
The fragmented nature of the game's resource pack leads to low download efficiency and slow download speeds, negatively impacting the user experience.
By determining the address where the target resource is stored in the cloud, the storage addresses of multiple resources are merged to obtain the target address, enabling the loading of multiple resources at once, reducing the frequency of network requests, and improving download efficiency.
It improves the efficiency of resource loading and application operation, supports real-time application after resource loading, and enhances the user experience.
Smart Images

Figure CN116527658B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of computer, in particular, to a resource loading method and device, medium and electronic equipment. BACKGROUND
[0002] The resource package in the game usually includes in-game logic script (Lua, JS) and static resources (pictures, special effect materials, audio and video materials, text files, configuration files, etc.). Generally, the number of resources of the game is large (thousands to tens of thousands), the resources in the game are very scattered, and the file size of each resource is very small, usually several KB to several MB.
[0003] Because the resources in the resource package are scattered, the download efficiency of the resource package is usually low, and the download speed is very slow. For example, more than 10,000 files need to be downloaded, and each file is only several hundred KB to several MB. In this case, the resource download speed is very slow, which is not convenient for users to use. SUMMARY
[0004] This summary is provided to introduce a selection of concepts, which will be described with greater specificity in the detailed description section. This summary does not intend to identify key or essential features of the claimed technology nor does it intend to limit the scope of the claimed technology.
[0005] In a first aspect, the present disclosure provides a resource loading method, the method comprising:
[0006] determining a target resource to be loaded in a target application;
[0007] determining a storage address of the target resource in a target package file stored in the cloud according to the target resource and a resource management table, wherein the resource management table contains a corresponding relationship between a path and a storage address of the target resource in the target package file;
[0008] if the target resource is multiple, merging the storage addresses of the multiple target resources to obtain a target address for applying for the multiple target resources;
[0009] sending a resource request to the cloud according to the target address, and loading the target resource according to target data returned by the cloud.
[0010] In a second aspect, the present disclosure provides a resource loading device, the device comprising:
[0011] a first determining module configured to determine a target resource to be loaded in a target application;
[0012] The second determining module is configured to determine a storage address of the target resource in a target package file stored in the cloud according to the target resource and a resource management table, wherein the resource management table comprises a corresponding relationship between a path and a storage address of the target resource in the target package file.
[0013] The third determining module is configured to, if the target resource is a plurality of target resources, merge the storage addresses of the plurality of target resources to obtain a target address for applying for the plurality of target resources.
[0014] The loading module is configured to send a resource request to the cloud according to the target address, and load the target resource according to target data returned by the cloud.
[0015] In a third aspect, the present disclosure provides a computer readable medium having a computer program stored thereon, wherein the program, when executed by a processing device, implements the steps of the method of the first aspect.
[0016] In a fourth aspect, the present disclosure provides an electronic device comprising:
[0017] A storage device having a computer program stored thereon;
[0018] A processing device configured to execute the computer program in the storage device to implement the steps of the method of the first aspect.
[0019] In the above technical solution, for the target package file stored in the cloud and comprising various resources, the target resource loaded therein can be determined to obtain a target address corresponding to the target resource to be loaded at one time, and then the corresponding resource can be requested from the cloud based on the target address, so as to realize the loading of the target resource, thereby realizing the on-demand loading of the resource, and at the same time, a resource request can be sent based on the target addresses corresponding to a plurality of resources to realize the loading of the plurality of resources at one time, thereby avoiding the problem of low efficiency and low loading success rate caused by too frequent resource loading requests, further improving the efficiency of resource loading, and supporting real-time application after resource loading, thereby improving the running efficiency and response efficiency of the application program.
[0020] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF DRAWINGS
[0021] The above and other features and advantages of the embodiments of the present disclosure will become more apparent from the following detailed description with reference to the accompanying drawings. Throughout the drawings, the same or similar reference numerals refer to the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale. In the drawings:
[0022] Figure 1is a flowchart of a resource loading method according to an embodiment of the present disclosure.
[0023] Figure 2 is a schematic diagram of a resource information area in a target package file according to an embodiment of the present disclosure.
[0024] Figure 3 is a structural schematic diagram of target data returned by a cloud according to an embodiment of the present disclosure.
[0025] Figure 4 is a schematic diagram of a target resource recording process in a target package file according to an embodiment of the present disclosure.
[0026] Figure 5 is a block diagram of a resource loading apparatus according to an embodiment of the present disclosure.
[0027] Figure 6 is a structural schematic diagram of an electronic device suitable for implementing an embodiment of the present disclosure. DETAILED DESCRIPTION
[0028] Embodiments of the present disclosure will be described in more detail with reference to the drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided to more completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for exemplary purposes only and are not intended to limit the scope of the present disclosure.
[0029] It should be understood that each step recited in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.
[0030] The term "comprising" and variations thereof as used herein are open-ended, that is, "comprising but not limited to." The term "based on" is "based, at least in part, on." The term "one embodiment" means "at least one embodiment." The term "another embodiment" means "at least one additional embodiment." The term "some embodiments" means "at least some embodiments." Related definitions are given below in the description of the embodiments.
[0031] It should be noted that the concepts of "first", "second", etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0032] It should be noted that the modification of "one", "multiple" mentioned in the present disclosure is illustrative but not restrictive, and those skilled in the art should understand that unless otherwise explicitly indicated in the context, it should be understood as "one or more".
[0033] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not used to limit the scope of the messages or information.
[0034] It can be understood that before using the technical solutions disclosed in the embodiments of the present disclosure, the type, use range, use scenario, etc. of the personal information involved in the present disclosure should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.
[0035] For example, in response to receiving the active request of the user, the prompt information is sent to the user to explicitly prompt the user that the operation requested to be performed will require obtaining and using the personal information of the user. Thus, the user can voluntarily choose whether to provide the personal information to the software or hardware such as electronic device, application program, server or storage medium, etc. that performs the operation of the technical solutions of the present disclosure according to the prompt information.
[0036] As an optional but non-limiting implementation manner, in response to receiving the active request of the user, the prompt information can be sent to the user in the form of a pop-up window, and the prompt information can be presented in the form of text in the pop-up window. In addition, the pop-up window can also carry selection controls for the user to select "agree" or "disagree" to provide the personal information to the electronic device.
[0037] It can be understood that the above notification and obtaining of user authorization process is only illustrative, and does not limit the implementation manner of the present disclosure, and other manners meeting the relevant laws and regulations can also be applied to the implementation manner of the present disclosure.
[0038] At the same time, it can be understood that the data involved in the present technical solution (including but not limited to the data itself, the acquisition or use of the data) should comply with the requirements of the relevant laws and regulations and relevant provisions.
[0039] As shown above, the resource package of the game application usually contains a large number of resources. When the resource package is loaded, the server can be requested for a list of resources that need to be updated after the application is started, and the resources that need to be updated are loaded one by one. Alternatively, the discrete resources are packaged into a zip package, and the zip package is loaded. The applicant finds that when the resources are loaded one by one, a new download request needs to be initiated for each downloaded resource, resulting in low resource loading efficiency. Due to the slow start mechanism of TCP, the network transmission speed will slow down, making it difficult to achieve high-speed download, and multiple requests will also reduce the overall download success rate of the resources. The zip-based download method requires downloading a zip file on the client side during resource loading. After the download is completed, the zip file is decompressed and restored to individual resources, and finally the zip file is deleted. In the process, not only intermediate files are generated, but also the resources in the zip file cannot be used until the entire zip file is downloaded and decompressed.
[0040] Based on this, the present disclosure provides the following embodiments. Figure 1 As shown in the figure, a flowchart of a resource loading method according to an embodiment of the present disclosure is provided, which comprises the following steps. Figure 1 As shown in the figure, the method can comprise:
[0041] In step 11, the target resource to be loaded in the target application is determined.
[0042] In this embodiment, all resources in the resource package of the target application can be loaded, or the resources can be loaded on demand, that is, the part of the resource is loaded first, so that the corresponding application program can respond in time.
[0043] In step 12, the storage address of the target resource in the target package file in the cloud storage is determined according to the target resource and the resource management table, wherein the resource management table contains the corresponding relationship between the path and the storage address of the target resource in the target package file.
[0044] The target package file contains all resources required by the application program, and the path and the storage address of the target resource in the target package file can be determined based on the resource management table, so that the corresponding resource can be loaded from the cloud. As an example, the resource data in the target package file can be downloaded in a streaming manner, so that the application of the target resource can be realized after the target resource is loaded, further improving the efficiency of resource loading and application.
[0045] In step 13, if the target resource is multiple, the storage addresses of the multiple target resources are merged to obtain a target address for applying for the multiple target resources. In this embodiment, partial resource files can be loaded from the target package file, and the storage addresses of the multiple target resources are merged to obtain a target address for loading the multiple target resources at one time.
[0046] In step 14, a resource request is sent to the cloud according to the target address, and the target resource is loaded according to the target data returned by the cloud.
[0047] Therefore, in the above technical solution, for the target package file stored in the cloud and containing each resource, the target resource loaded therein is determined to obtain a target address for loading the target resource at one time, and then the corresponding resource is requested from the cloud based on the target address, so as to load the target resource, thereby realizing on-demand loading of the resource, sending a resource request based on the target addresses of multiple resources to realize loading of the multiple resources at one time, avoiding the problem of low efficiency and low loading success rate caused by too frequent resource loading requests, further improving the efficiency of resource loading, and supporting real-time application after resource loading to improve the running efficiency and response efficiency of the application program.
[0048] In a possible embodiment, the target package file contains a resource information area and a resource data area, and the resource management table is determined in the following manner:
[0049] A header acquisition request of the target package file is sent to the cloud, where the header acquisition request is used to acquire information of a header area in the resource information area of the target package file. As an example, the resource information area can be as shown in Figure 2 The header area can be used to represent the header area. As an example, the header acquisition request can be sent according to the URL (Uniform Resource Locator, uniform resource locator) of the target package file to load the header area in the target package file. The length of the header area is fixed, for example, it can be preset as 64 bytes, and the data range requested in the header acquisition request can be represented as 0-63, so as to load the information of the header area in the target package file.
[0050] The total length of the resource information area is determined according to the information of the header area.
[0051] The information of the header area can contain multiple fields, as shown in Table 1 below:
[0052]
[0053] Table 1
[0054] Thus, after obtaining the information of the head area, the value of the metaLength field indicates the total length of the resource information area.
[0055] According to the total length, determine the information request address of the resource information area, and send an information acquisition request to the cloud based on the information request address of the resource information area, wherein the information acquisition request is used to acquire the resource data information in the resource information area except the information of the head area.
[0056] Wherein, the information of the head area in the resource information area has been acquired, and thus there is no need to acquire it again. Therefore, the address of the resource information area can be determined as the address after the end address of the head area of the target package file and offset by the length indicated by the metaLength, so that an information acquisition request can be sent to the cloud based on the address of the resource information area, to acquire the resource data information in the resource information area except the information of the head area.
[0057] Parse the resource data information to obtain the path and storage address corresponding to each resource in the target package file, to form the resource management table.
[0058] Thus, the information in the resource information area in the target package file can be acquired first, and the index of each resource in the target package file can be obtained by parsing the information, so as to realize on-demand downloading of resources.
[0059] In one possible embodiment, the resource information area further includes a basic information area, a resource index area and a resource path area.
[0060] The exemplary implementation of the step of parsing the resource data information to obtain the path and storage address corresponding to each resource in the target package file, to form the resource management table, can include: determining the addresses corresponding to the resource index area and the resource path area according to the resource data information in the basic information area. Wherein, the basic information area can include the following fields, as shown in Table 2:
[0061]
[0062]
[0063] Table 2
[0064] Thus, the address corresponding to the resource index area and the resource path area can be determined based on the field value in the basic information area, for example, according to the starting offset address of the resource index area in the package file and the length of the resource index area, the address corresponding to the resource index area can be determined as the starting offset address of the resource index area in the package file with a length of the length of the resource index area, and similarly, the address corresponding to the resource path area can be determined based on the starting offset address of the resource path area in the package file and the length of the resource path area.
[0065] Then, the resource index information is obtained from the resource data information according to the address corresponding to the resource index area, wherein the resource index information contains the storage address of the path of each resource in the target package file and the storage address of the resource. The data corresponding to the address corresponding to the resource index area in the resource data information can be taken as the resource index information.
[0066] The resource path information is obtained from the resource data information according to the address corresponding to the resource path area. Similarly, the data corresponding to the address corresponding to the resource path area in the resource data information can be taken as the resource path information.
[0067] The path of the resource is obtained from the resource path information according to the storage address of the path of each resource.
[0068] The resource index information can contain the index information corresponding to each resource in the package file, wherein each index information can contain the fields as shown in Table 3.
[0069]
[0070]
[0071] Table 3
[0072] Thus, the storage address of the path of each resource can be determined based on the value of path_m.startOffest and path_m.length, and the storage address of the resource, i.e. the storage address of the data corresponding to the resource, can be determined based on data_m.startOffest and data_m.length.
[0073] The resource path information stores the path of each resource in the package file. In the above example, the storage address of the path can be determined by path_m.startOffset and path_m.length in the resource index area. The storage order of the resource path information of each resource in the resource path area is consistent with the storage order of the corresponding resource in the resource index area. For the third resource, the storage address of the path of the third resource can be determined by path_3.startOffset and path_3.length, and the information corresponding to the storage address of the third resource in the resource path information can be used as the path of the third resource. For example, the path of the third resource is root / A / A1.
[0074] It should be noted that the path corresponding to each resource in the package file is indefinite length, which can represent the hierarchical relationship between resources. In this embodiment, the resource path information in the resource path area stores the path corresponding to each resource, and the resource index area indexes the path of each resource, thereby realizing unified management and storage of indefinite length paths under each resource, improving the query efficiency of the path, and providing support for subsequent improvement of resource loading efficiency.
[0075] For each resource, a corresponding relationship is formed according to the path of the resource and the storage address of the resource, so as to obtain the resource management table.
[0076] Correspondingly, for the third resource in the package file, the path corresponding to the third resource is root / A / A1, and the storage address corresponding to the third resource is the storage address add3 determined by data_3.startOffest and data_3.length. The corresponding relationship can be represented in the form of Map, such as <root / A / A1, add3>. That is, the storage address of the resource with the path root / A / A1 in the package file is add3. When the client applies for the resource with the path root / A / A1, the storage address of the resource in the package file can be determined based on the resource management table, and the resource request can be generated based on the add3, thereby realizing on-demand loading and use of the resource.
[0077] Therefore, by analyzing the information in the resource information area of the target package file, the path and the storage address of each resource in the target package file can be obtained, and the resource management table can be generated, so as to quickly and accurately determine the address of the target resource to be loaded based on the resource management table, thereby improving the resource loading efficiency.
[0078] As an example, the target resource to be loaded in the target application can be determined by triggering the path of the target resource through the running of the application program, so as to determine the target resource.
[0079] As another example, the resource information area further comprises a label area; the implementation of determining the target resource to be loaded in the target application can comprise:
[0080] obtaining a target label of the target resource to be loaded, wherein the target label can be determined from a resource loading operation triggered by the application program, such as a game program, and the target label can be level 4, i.e., used to load various resources corresponding to level 4.
[0081] querying a label management table according to the target label, and determining the resource corresponding to the target label in the target package file as the target resource;
[0082] wherein the label management table comprises a corresponding relationship between each label and the identification of each resource corresponding to each label, and the label management table is determined by the following method:
[0083] determining the address corresponding to the label area according to the resource data information of the basic information area.
[0084] wherein the address corresponding to the label area can be determined according to the field values of label.startOffest and label.length in the basic information area.
[0085] obtaining resource label information from the resource data information according to the address corresponding to the label area, wherein the resource label information comprises various label information in the target package file.
[0086] the information corresponding to the address of the label area in the resource data information is taken as the resource label information. For example, there are 8 labels in the target package file, denoted as L1-L8, and the arrangement order is L1-L8, i.e., the first bit corresponds to L1, the second bit corresponds to L2, and so on.
[0087] determining the label corresponding to each resource in the resource index information according to the label flag bit of each resource in the resource index information.
[0088] According to the above example, each index information in the resource index information can comprise a data_m.label field, and the value of the field, i.e., the label flag bit, can be used to indicate the label of the resource corresponding to the index information. If the value of data_1.label of resource 1 is 10000000, the first bit is 1, indicating that the label of resource 1 is L1, and the value of data_1.label of resource 2 is 00010000, the fourth bit is 1, indicating that the label of resource 2 is L4. Thus, the label corresponding to each resource can be parsed.
[0089] For each of the labels, a correspondence between the label and an identifier of a resource corresponding to the label is generated to obtain the label management table, wherein the identifier of the resource corresponds to a path of the resource one-to-one.
[0090] Wherein the identifier of the resource and the path of the resource correspond one-to-one, after the label corresponding to each resource is parsed, a correspondence between the identifiers of the resources corresponding to the same label is generated. Thus, after the target label of the target resource to be loaded is determined, the label management table can be directly queried based on the target label. As described above, the target resource corresponding to the target label L4 can be queried, thereby improving the efficiency of determining the target resource and improving the loading efficiency of the resource.
[0091] In a possible embodiment, the storage addresses of the plurality of target resources are merged to obtain a target address for applying for the plurality of target resources. An exemplary implementation manner is as follows, and the step can include:
[0092] If the storage addresses of the plurality of target resources are continuous, the storage addresses of the plurality of target resources are merged to obtain the target address.
[0093] For example, the target resources include resources D1, D2 and D3, and the storage addresses thereof are [101, 200], [201, 500] and [501, 1000] respectively. It is indicated that the storage addresses of the plurality of target resources are continuous, and the storage addresses can be directly merged to obtain the address [101, 1000] as the target address.
[0094] If there are at least two resources with discontinuous storage addresses in the plurality of target resources, the storage addresses of the plurality of resources with continuous storage addresses in the target resources are merged to obtain a merged address, and the merged address and the storage addresses of the at least two resources with discontinuous storage addresses are taken as the target address.
[0095] For example, if the storage addresses of the plurality of target resources are discontinuous with each other, the storage addresses of the plurality of target resources can be directly taken as the target address.
[0096] As another example, the target resource contains resources D1, D3, D4 and D5, and the storage addresses thereof are [101, 200], [501, 1000], [2001, 3000] and [3001, 3400] respectively, wherein the storage addresses of D1 and D3 are discontinuous, and the storage addresses of D4 and D5 are continuous, the storage addresses of D4 and D5 can be merged, such as merging [2001, 3000] and [3001, 3400] to obtain the merged address [2001, 3400], and further, [101, 200], [501, 1000] and [2001, 3400] are taken as the target address.
[0097] Therefore, by the above technical solution, the addresses of multiple target resources can be merged, thereby effectively avoiding the process of frequently sending network requests in the resource loading process, avoiding the influence of frequent requests on the network transmission speed, so as to improve the resource loading efficiency and resource loading success rate. At the same time, the storage addresses of resources in network requests under any condition can be merged, completely avoiding the problem of low download efficiency caused by frequent network requests in scatter file download, greatly improving the network request and transmission efficiency, fully utilizing the network bandwidth, and accelerating the download speed.
[0098] In a possible embodiment, the exemplary implementation manner of sending a resource request to the cloud according to the target address can include:
[0099] According to the resource application data amount corresponding to the target address, the request address corresponding to each thread under multi-threading is determined.
[0100] As an example, the requests of each thread under multi-threading can be evenly distributed, such as the target address including [101, 200], [501, 1000] and [2001, 3400], the resource application data amount corresponding to the target address can be determined as 2000 (100+500+1400), and if there are 4 threads in multi-threading, the resource application amount can be evenly distributed to the 4 threads, such as the request address corresponding to thread 1 being [100, 200] and [501, 900], the request address corresponding to thread 2 being [901, 1000] and [2001, 2400], the request address corresponding to thread 3 being [2401, 2900], and the request address corresponding to thread 4 being [2901, 3400].
[0101] For another example, the resource application amount can be distributed in combination with the utilization rate of each thread in multi-threading, such as the resource application amount corresponding to the thread with high current utilization rate being small, and the resource application amount corresponding to the thread with low current utilization rate being large, thereby further improving the efficiency of resource loading.
[0102] generate the resource request according to the request address, and send the resource request based on the multi-threading.
[0103] Thus, by the technical solution, the resource loading process can be performed by multi-threading, so as to further improve the resource utilization, improve the application processing efficiency, and improve the user experience.
[0104] In a possible embodiment, after the resource corresponding to a thread in the multi-threading is loaded, the request address can be determined according to the address corresponding to the resource not loaded in other threads, and the resource request can be sent, so as to accelerate the download speed until the target resources are loaded.
[0105] In a possible embodiment, the exemplary implementation of loading the target resource according to the target data returned by the cloud can include:
[0106] The data corresponding to the storage address of the target resource in the target data is determined as the resource data corresponding to the target resource, and the data corresponding to the non-continuous addresses in the target data is separated by a delimiter.
[0107] As described above, the target address for performing the resource request can be one or more. If the target address is one, the target data returned by the cloud is a piece of address-continuous data. If the target address is more than one, the data corresponding to the non-continuous addresses in the target data returned by the cloud can be separated by a delimiter, as shown in Figure 3 . The H1 line is used to represent the delimiter, the boundary is used to represent the boundary delimiter, and the CRLF is used to represent the carriage return line feed. The H2 line and the H3 line are used to represent the response header, the type / pkg is used to represent the type of data, and the bytes:x1-y1 / length is used to represent the range of the first piece of data. The H4 line is used to represent the blank line, the H5 line is used to represent the first piece of data, and the H6 line is used to represent the second piece of data. The bytes:x2-y2 / length is used to represent the range of the second piece of data. For the target data returned as shown in Figure 3 , the target data can be parsed to delete the delimiter and obtain the entity data of the target resource.
[0108] Generate the target file corresponding to the target resource according to the path of the target resource, and write the resource data of the target resource into the target file to load the target resource.
[0109] Further, as shown above, for the parsed data corresponding to the address [2001, 3400], wherein the storage address of resource D4 is [2001, 3000] and the storage address of resource D5 is [3001, 3400]. The path of D4 is root / A / C / x and the path of D5 is root / B / y, then two files can be generated according to the above paths respectively, and the data corresponding to [2001, 3000] in the target data is written into the file corresponding to root / A / C / x, and the data corresponding to [3001, 3400] in the target data is written into the file corresponding to root / B / y, so that the user side can obtain the same structure of the resource file developed by the game development side after loading the resource. As shown in Figure 4 After the game development side develops the code file of each resource, the target package file can be obtained by packaging through the packaging tool, and uploaded to the CDN (Content Delivery Network), and the client corresponding to the target application on the user side can load part or all of the resources in the target package file from the CDN, and keep the same structure as the resource file of the game development side. For other resources, the target data returned from the cloud is loaded in the same way, which will not be described here. Figure 4
[0110] Thus, through the above technical solution, the response and data stream corresponding to the resource request can be parsed, and when parsing the data stream, the obtained target data can be restored and saved as the original resource scatter file according to the correspondence between the address range of each target resource and the target address of the resource request, that is, the target file corresponding to each resource, which can directly decompose and restore the network data stream to the original scatter file from the network data stream level, without the need for decompression, without the generation of intermediate temporary files, thereby further improving the efficiency of resource loading.
[0111] In a possible embodiment, based on the scheme of the present disclosure, when multiple target resources are requested at a time, each target resource in the returned target data can be loaded in sequence, and after the resource data corresponding to any target resource is written into the target file corresponding thereto, the loading and use of the target resource can be realized. Compared with the resource loading through the ZIP compressed package in the prior art, the on-demand downloading and on-the-fly use of resources can be realized without waiting for the completion of the loading of other resources, thereby further improving the stability and response efficiency of the application program.
[0112] In a possible embodiment, the target package file contains a resource information area and a resource data area, and the method further comprises:
[0113] In a case where it is determined that the target application corresponds to a target package file to be updated, data information in a resource information area corresponding to the updated target package file is obtained from the cloud, wherein the data information contains digest information of each resource in the updated target package file.
[0114] In a case where it is determined that the target application corresponds to a target package file to be updated, data information in a resource information area corresponding to the updated target package file is obtained from the cloud, wherein the data information contains digest information of each resource in the updated target package file.
[0115] As an example, the data information in the resource information area corresponding to the updated target package file obtained from the cloud can include:
[0116] The head part of the updated target package file is sent to the cloud to obtain a request for the head part of the resource information area of the updated target package file;
[0117] According to the information of the head part of the resource information area of the updated target package file, the total length of the resource information area of the updated target package file is determined;
[0118] According to the total length of the resource information area of the updated target package file, the request address of the resource information area of the updated target package file is determined, and an information request is sent to the cloud based on the information request address of the resource information area of the updated target package file, wherein the information request is used to obtain resource data information in the resource information area of the updated target package file except the information of the head part of the resource information area, and the structure and the fields contained therein have been described above and will not be repeated here.
[0119] Then, the value of data_m.md5 of each resource in the resource index area of the updated target package file obtained can be used as the digest information of the resource.
[0120] Each resource in the resource management table and the digest information of each resource are matched with each resource in the data information and the digest information of each resource;
[0121] The target resource to be loaded in the target application includes:
[0122] The resource in the data information that is not matched with the resource management table and the resource in the resource management table whose digest information is not matched with the digest information in the data information are determined as the target resource.
[0123] For example, the path of each resource in the resource management table can be matched with the path of each resource in the data information. If there is no matching resource in the resource management table for the resource in the data information, it indicates that the resource in the data information is newly added in the updated target package file, and the resource can be determined as the target resource at this time. If there is a matching resource in the resource management table for the resource in the data information, the digest information of the two resources can be further matched. If the digest information is different, it indicates that the resource in the data information is modified in the updated target package file, and the resource can be determined as the target resource at this time.
[0124] Therefore, by using the technical solution, after the target package file is updated, the difference comparison of a single resource can be supported. The resources in the resource management table and the resources in the updated target package file are respectively compared to determine the resources that need to be updated and loaded. Therefore, after the target package file is updated, only the resources that are modified and newly added need to be downloaded, which can effectively solve the problem that the entire new zip file must be reloaded when a resource in the zip file is modified or newly added, and further improves the efficiency of resource loading.
[0125] The present disclosure also provides a resource loading device, such as Figure 5 As shown in the figure, the device 10 includes:
[0126] A first determining module 100 is configured to determine a target resource to be loaded in a target application.
[0127] A second determining module 200 is configured to determine a storage address of the target resource in a target package file stored in a cloud according to the target resource and a resource management table. The resource management table includes a corresponding relationship between the path and the storage address of the target resource in the target package file.
[0128] A third determining module 300 is configured to, if the target resource is multiple, merge the storage addresses of the multiple target resources to obtain a target address for applying for the multiple target resources.
[0129] A loading module 400 is configured to send a resource request to the cloud according to the target address, and load the target resource according to the target data returned by the cloud.
[0130] Optionally, the target package file includes a resource information area and a resource data area, and the resource management table is determined by a generating module. The generating module includes:
[0131] The first sending sub-module is configured to send a header obtaining request of the target package file to the cloud, wherein the header obtaining request is used to obtain information of a header area in a resource information area of the target package file.
[0132] The first determining sub-module is configured to determine a total length of the resource information area according to the information of the header area.
[0133] The second sending sub-module is configured to determine a request address of the resource information area according to the total length, and send an information obtaining request to the cloud based on the request address of the resource information area, wherein the information obtaining request is used to obtain resource data information of the resource information area except the information of the header area.
[0134] The first generating sub-module is configured to parse the resource data information to obtain a path and a storage address of each resource in the target package file, so as to form the resource management table.
[0135] Optionally, the resource information area further comprises a basic information area, a resource index area and a resource path area.
[0136] The first generating sub-module comprises:
[0137] The second determining sub-module is configured to determine addresses corresponding to the resource index area and the resource path area according to the resource data information of the basic information area.
[0138] The first obtaining sub-module is configured to obtain resource index information from the resource data information according to the address corresponding to the resource index area, wherein the resource index information comprises a storage address of a path of each resource in the target package file and a storage address of the resource.
[0139] The second obtaining sub-module is configured to obtain resource path information from the resource data information according to the address corresponding to the resource path area.
[0140] The third obtaining sub-module is configured to obtain the path of the resource from the resource path information according to the storage address of the path of each resource.
[0141] The second generating sub-module is configured to form a corresponding relationship between the path of the resource and the storage address of the resource for each resource, so as to obtain the resource management table.
[0142] Optionally, the resource information area further comprises a label area; and the first determining module comprises:
[0143] The second obtaining sub-module is configured to obtain a target label of a target resource to be loaded.
[0144] a third determining sub-module, configured to query a label management table according to the target label, and determine the resource corresponding to the target label in the target package file as the target resource;
[0145] The label management table comprises a corresponding relationship between each label and the identifier of each resource corresponding to the label.
[0146] According to the resource data information of the basic information area, an address corresponding to the label area is determined.
[0147] According to the address corresponding to the label area, resource label information is obtained from the resource data information, wherein the resource label information comprises each label information in the target package file.
[0148] According to the label flag bit of each resource in the resource index information, a label corresponding to the resource is determined.
[0149] For each label, a corresponding relationship between the label and the identifier of the resource corresponding to the label is generated to obtain the label management table, wherein the identifier of the resource corresponds to the path of the resource one by one.
[0150] Optionally, the third determining module comprises:
[0151] a fourth determining sub-module, configured to, if the storage addresses of the target resources are continuous, merge the storage addresses of the target resources to obtain the target address.
[0152] a fifth determining sub-module, configured to, if there are at least two resources with discontinuous storage addresses in the target resources, merge the storage addresses of the resources with continuous storage addresses in the target resources to obtain a merged address, and take the merged address and the storage addresses of the resources with discontinuous storage addresses as the target address.
[0153] Optionally, the loading module comprises:
[0154] a sixth determining sub-module, configured to determine a request address corresponding to each thread under multi-threading according to the resource application data volume corresponding to the target address.
[0155] a third sending sub-module, configured to generate the resource request according to the request address, and send the resource request based on the multi-threading.
[0156] Optionally, the loading module comprises:
[0157] A seventh determining sub-module is configured to determine, as the resource data corresponding to the target resource, data in the target data corresponding to the storage address of the target resource, wherein data corresponding to non-continuous addresses in the target data are separated by a separator;
[0158] A loading sub-module is configured to generate a target file corresponding to the target resource according to the path of the target resource, and write the resource data of the target resource into the target file, so as to load the target resource.
[0159] Optionally, the apparatus further comprises:
[0160] An obtaining module is configured to, in a case where it is determined that the target package file corresponding to the target application is to be updated, obtain data information in a resource information area of the updated target package file from the cloud, wherein the data information contains the digest information of each resource in the updated target package file.
[0161] A matching module is configured to match each resource and the digest information of each resource in the resource management table with each resource and the digest information of each resource in the data information.
[0162] The first determining module is configured to:
[0163] Determine, as the target resource, resources in the data information that are not matched with the resource management table, and resources in the resource management table whose digest information is not matched with the digest information in the data information.
[0164] Reference will be made to the following description Figure 6 which shows a structural schematic diagram of an electronic device 600 suitable for implementing the embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Tablet Personal Computers), PMPs (Portable Multimedia Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. Figure 6 The electronic device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present disclosure.
[0165] As Figure 6As shown, the electronic device 600 can include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601 that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 602 or loaded into a random access memory (RAM) 603 from a storage device 608. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0166] Generally, the following devices can be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 608 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 609. The communication devices 609 can allow the electronic device 600 to communicate wirelessly or wired with other devices to exchange data. Although Figure 6 The electronic device 600 is shown with various devices, but it should be understood that all of the illustrated devices are not required, and fewer or different devices can alternatively be implemented.
[0167] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication devices 609, or installed from the storage devices 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-described functions defined in the methods of embodiments of the present disclosure are performed.
[0168] It should be noted that the computer-readable medium described above can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any suitable combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is contained. Such a propagated data signal can take many forms, including but not limited to, an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium that can send, propagate or transfer the program for use by or in connection with the instruction execution system, apparatus or device. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to, wire, cable, RF (radio frequency), etc., or any suitable combination of the above.
[0169] In some embodiments, the client, server, or both can communicate using any current known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.
[0170] The computer-readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device, and is not assembled into the electronic device.
[0171] The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to determine a target resource to be loaded in a target application; determine a storage address of the target resource in a target package file stored in the cloud according to the target resource and a resource management table, wherein the resource management table contains a correspondence between a path and a storage address of a target resource in the target package file; if the target resource is multiple, merge the storage addresses of the multiple target resources to obtain a target address for applying for the multiple target resources; send a resource request to the cloud according to the target address, and load the target resource according to target data returned by the cloud.
[0172] Computer program code for carrying out operations of the present disclosure can be written in any one or more of a variety of programming languages or combinations of languages including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages such as the "C" programming language or similar programming languages. The program code may
[0173] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present disclosure. In this regard, each block in the flow diagrams and the block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may
[0174] The modules described in the embodiments of the present disclosure can be implemented in the form of software or in the form of hardware. In some cases, the name of a module does not constitute a limitation on the module itself. For example, the first determining module can also be described as a module for determining target resources to be loaded in a target application.
[0175] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, and without limitation, example types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Application-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0176] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0177] According to one or more embodiments of the present disclosure, example 1 provides a resource loading method, wherein the method comprises:
[0178] determining target resources to be loaded in a target application;
[0179] determining a storage address of the target resource in a target package file stored in the cloud according to the target resource and a resource management table, wherein the resource management table contains a corresponding relationship between a path and a storage address of a target resource in the target package file;
[0180] if the target resource is multiple, merging the storage addresses of the multiple target resources to obtain a target address for applying for the multiple target resources;
[0181] sending a resource request to the cloud according to the target address, and loading the target resource according to target data returned by the cloud.
[0182] According to one or more embodiments of the present disclosure, example 2 provides the method of example 1, wherein the target package file contains a resource information area and a resource data area, and the resource management table is determined by the following ways:
[0183] sending a header acquisition request of the target package file to the cloud, wherein the header acquisition request is used to acquire information of a header area in the resource information area of the target package file;
[0184] determining a total length of the resource information area according to the information of the header area;
[0185] determining a request address of the resource information area according to the total length, and sending an information acquisition request to the cloud based on the request address of the resource information area, wherein the information acquisition request is used to acquire resource data information in the resource information area except the information of the header area;
[0186] parsing the resource data information to obtain a path and a storage address corresponding to each resource in the target package file, so as to form the resource management table.
[0187] According to one or more embodiments of the present disclosure, example 3 provides the method of example 2, wherein the resource information area further includes a basic information area, a resource index area and a resource path area;
[0188] the parsing of the resource data information to obtain the path and the storage address corresponding to each resource in the target package file to form the resource management table, comprising:
[0189] determining addresses corresponding to the resource index area and the resource path area according to the resource data information of the basic information area;
[0190] acquiring resource index information from the resource data information according to the address corresponding to the resource index area, wherein the resource index information contains a storage address of a path of each resource in the target package file and a storage address of the resource;
[0191] acquiring resource path information from the resource data information according to the address corresponding to the resource path area;
[0192] acquiring the path of the resource from the resource path information according to the storage address of the path of each resource;
[0193] for each resource, forming a corresponding relationship according to the path of the resource and the storage address of the resource, so as to obtain the resource management table.
[0194] According to one or more embodiments of the present disclosure, example 4 provides the method of example 3, wherein the resource information area further comprises a label area; the determining the target resource to be loaded in the target application comprises:
[0195] obtaining a target label of the target resource to be loaded;
[0196] querying the label management table according to the target label, and determining the resource corresponding to the target label in the target package file as the target resource;
[0197] wherein the label management table comprises a corresponding relationship between each label and the identification of each resource corresponding to each label, and the label management table is determined by the following way:
[0198] determining the address corresponding to the label area according to the resource data information of the basic information area;
[0199] obtaining resource label information from the resource data information according to the address corresponding to the label area, wherein the resource label information comprises each label information in the target package file;
[0200] determining the label corresponding to each resource according to the label flag bit of each resource in the resource index information;
[0201] for each label, generating a corresponding relationship between the label and the identification of the resource corresponding to the label to obtain the label management table, wherein the identification of the resource corresponds to the path of the resource one by one.
[0202] According to one or more embodiments of the present disclosure, example 5 provides the method of example 1, wherein the merging the storage addresses of the plurality of target resources to obtain the target address for applying for the plurality of target resources comprises:
[0203] if the storage addresses of the plurality of target resources are continuous, merging the storage addresses of the plurality of target resources to obtain the target address;
[0204] if there are at least two resources with discontinuous storage addresses in the plurality of target resources, merging the storage addresses of the plurality of resources with continuous storage addresses in the target resources to obtain a merged address, and taking the merged address and the storage addresses of the resources with discontinuous storage addresses as the target address.
[0205] According to one or more embodiments of the present disclosure, example 6 provides the method of example 1, wherein the sending a resource request to the cloud according to the target address comprises:
[0206] determine a request address corresponding to each thread under the multi-threading according to the resource application data amount corresponding to the target address;
[0207] generate the resource request according to the request address, and send the resource request based on the multi-threading.
[0208] According to one or more embodiments of the present disclosure, example 7 provides the method of example 1, wherein the loading of the target resource according to the target data returned by the cloud comprises:
[0209] determining data corresponding to the storage address of the target resource in the target data as resource data corresponding to the target resource, wherein data corresponding to discontinuous addresses in the target data are separated by a separator;
[0210] generating a target file corresponding to the target resource according to the path of the target resource, and writing resource data of the target resource into the target file to load the target resource.
[0211] According to one or more embodiments of the present disclosure, example 8 provides the method of example 1, wherein the method further comprises:
[0212] in a case where it is determined that the target package file corresponding to the target application needs to be updated, obtaining data information in a resource information area of the updated target package file from the cloud, wherein the data information contains digest information of each resource in the updated target package file;
[0213] matching each resource and the digest information of each resource in the resource management table with each resource and the digest information of each resource in the data information;
[0214] the determination of the target resource to be loaded in the target application comprises:
[0215] determining, as the target resource, resources in the data information that are not matched in the resource management table, and resources in the resource management table whose digest information does not match the digest information in the data information.
[0216] According to one or more embodiments of the present disclosure, example 9 provides a resource loading device, the device comprising:
[0217] a first determination module configured to determine a target resource to be loaded in a target application;
[0218] a second determining module, configured to determine a storage address of the target resource in a target package file stored in the cloud according to the target resource and a resource management table, wherein the resource management table comprises a corresponding relationship between a path and a storage address of a target resource in the target package file;
[0219] a third determining module, configured to, if the target resource is a plurality of target resources, merge the storage addresses of the plurality of target resources to obtain a target address for applying for the plurality of target resources;
[0220] a loading module, configured to send a resource request to the cloud according to the target address, and load the target resource according to target data returned by the cloud.
[0221] According to one or more embodiments of the present disclosure, example 10 provides a computer readable medium having stored thereon a computer program which, when executed by a processing device, implements the steps of the method of any one of examples 1-8.
[0222] According to one or more embodiments of the present disclosure, example 11 provides an electronic device comprising:
[0223] a storage device having stored thereon a computer program;
[0224] a processing device configured to execute the computer program in the storage device to implement the steps of the method of any one of examples 1-8.
[0225] The above description is merely preferred embodiments of the present disclosure and a description of the principles of the technology employed. It should be understood by those skilled in the art that the disclosed scope of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also encompass other technical solutions formed by any combinations of the above technical features or equivalent features without departing from the above disclosed concept. For example, the above technical features can be replaced with technical features disclosed in the present disclosure (but not limited to) having similar functions to form technical solutions.
[0226] In addition, although each operation is depicted in a particular order, this should not be interpreted as requiring the operations to be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing can be advantageous. Similarly, although several implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments can also be combined in a single embodiment. Conversely, various features described in the context of a single embodiment can also be separated and implemented in multiple embodiments.
[0227] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With respect to the devices in the above-described embodiments, in which various modules perform operations, the specific manner in which the operations are performed by the various modules has been described in detail in the embodiments relating to the method. Here, no detailed explanation will be given.
Claims
1. A resource loading method, characterized in that, The method comprises: determining target resources to be loaded in a target application; determining a storage address of the target resources in a target package file stored in the cloud according to the target resources and a resource management table, wherein the resource management table contains a corresponding relationship between a path and a storage address of the target resources in the target package file; if the target resources are multiple, merging the storage addresses of the multiple target resources to obtain a target address for applying for the multiple target resources; sending a resource request to the cloud according to the target address, and loading the target resources according to target data returned by the cloud; wherein the target package file contains a resource information area and a resource data area, and the resource management table is determined by the following method: sending a header acquisition request of the target package file to the cloud, wherein the header acquisition request is used to acquire information of a header area in the resource information area of the target package file; determining the total length of the resource information area according to the information of the header area; determining a request address of the resource information area according to the total length, and sending an information acquisition request to the cloud based on the information request address of the resource information area, wherein the information acquisition request is used to acquire resource data information in the resource information area except the information of the header area; parsing the resource data information to obtain the path and the storage address corresponding to each resource in the target package file to form the resource management table.
2. The method of claim 1, wherein, The resource information area further comprises a basic information area, a resource index area and a resource path area; the parsing of the resource data information to obtain the path and the storage address corresponding to each resource in the target package file to form the resource management table comprises: determining the addresses corresponding to the resource index area and the resource path area according to the resource data information of the basic information area; acquiring resource index information from the resource data information according to the address corresponding to the resource index area, wherein the resource index information contains the storage address of the path of each resource in the target package file and the storage address of the resource; acquiring resource path information from the resource data information according to the address corresponding to the resource path area; acquiring the path of the resource from the resource path information according to the storage address of the path of each resource; for each resource, forming a corresponding relationship according to the path of the resource and the storage address of the resource to obtain the resource management table.
3. The method of claim 2, wherein, The resource information area further comprises a label area; the determining of the target resources to be loaded in the target application comprises: acquiring a target label of the target resources to be loaded; querying a label management table according to the target label, and determining the resources corresponding to the target label in the target package file as the target resources according to the query result; wherein the label management table contains a corresponding relationship between each label and the identification of each resource corresponding to each label, and the label management table is determined by the following method: determining the address corresponding to the label area according to the resource data information of the basic information area; According to the address corresponding to the label area, resource label information is obtained from the resource data information, wherein the resource label information contains each label information in the target package file; According to the label flag bit of each resource in the resource index information, the label corresponding to the resource is determined; For each label, a corresponding relationship between the label and the identifier of the resource corresponding to the label is generated to obtain the label management table, wherein the identifier of the resource corresponds to the path of the resource one by one.
4. The method of claim 1, wherein, The storage addresses of the plurality of target resources are merged to obtain a target address for applying for the plurality of target resources, including: If the storage addresses of the plurality of target resources are continuous, the storage addresses of the plurality of target resources are merged to obtain the target address; If there are at least two resources with non-continuous storage addresses in the plurality of target resources, the storage addresses of the plurality of resources with continuous storage addresses in the target resources are merged to obtain a merged address, and the merged address and the storage addresses of the at least two resources with non-continuous storage addresses are taken as the target address.
5. The method of claim 1, wherein, The resource request is sent to the cloud according to the target address, including: According to the resource application data amount corresponding to the target address, a request address corresponding to each thread under multi-threading is determined; According to the request address, the resource request is generated, and the resource request is sent based on the multi-threading.
6. The method of claim 1, wherein, The target resource is loaded according to the target data returned by the cloud, including: The data corresponding to the storage address of the target resource in the target data is determined as the resource data corresponding to the target resource, wherein the data corresponding to the non-continuous addresses in the target data is separated by a separator; According to the path of the target resource, a target file corresponding to the target resource is generated, and the resource data of the target resource is written into the target file to load the target resource.
7. The method of claim 1, wherein, The method further includes: In a case where it is determined that the target package file corresponding to the target application is updated, data information in the resource information area of the updated target package file is obtained from the cloud, wherein the data information contains the digest information of each resource in the updated target package file; Each resource in the resource management table and the digest information of each resource are matched with each resource in the data information and the digest information of each resource; The target resource to be loaded in the target application is determined, including: The resources in the data information that are not matched with the resource management table, and the resources in the resource management table whose digest information does not match the digest information in the data information, are determined as the target resources.
8. A resource loading apparatus characterized by comprising: The device includes: A first determination module for determining a target resource to be loaded in a target application; A second determination module for determining a storage address of the target resource in a target package file stored in the cloud according to the target resource and a resource management table, wherein the resource management table contains a corresponding relationship between the path and the storage address of the target resource in the target package file. A third determining module is configured to, if the target resources are multiple, merge storage addresses of the multiple target resources to obtain a target address for applying for the multiple target resources; A loading module is configured to send a resource request to the cloud according to the target address, and load the target resources according to target data returned by the cloud; The target package file comprises a resource information area and a resource data area, and the resource management table is determined by a generating module, the generating module comprising: A first sending sub-module is configured to send a head obtaining request of the target package file to the cloud, wherein the head obtaining request is used to obtain information of a head area in the resource information area of the target package file; A first determining sub-module is configured to determine a total length of the resource information area according to the information of the head area; A second sending sub-module is configured to determine a request address of the resource information area according to the total length, and send an information obtaining request to the cloud based on the information request address of the resource information area, wherein the information obtaining request is used to obtain resource data information in the resource information area except the information of the head area; A first generating sub-module is configured to parse the resource data information to obtain paths and storage addresses corresponding to each resource in the target package file, so as to form the resource management table.
9. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processing device to implement the steps of the method in any one of claims 1-7.
10. An electronic device, comprising: Comprise: A storage device having a computer program stored thereon; A processing device configured to execute the computer program in the storage device to implement the steps of the method in any one of claims 1-7.
Citation Information
Patent Citations
Webpage style address merging method and device
CN104063401A