Application resource processing method, application loading method and related devices
By caching the public dependency resources of sub-apps in the main application, the problems of slow loading speed and low resource processing efficiency are solved, and faster loading speed and higher resource utilization are achieved.
Patent Information
- Application Number
- CN202411613467.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-04-22
AI Technical Summary
In some computer application architectures, the coordination and communication between sub-applications through the main application results in slow loading speed or low resource processing efficiency.
By obtaining the target application, the dependency relationship between the main application and the sub-app is determined and cached to the main application, so that each sub-app is loaded with the public dependency resources cached by the main application.
It improves the loading speed of applications, reduces resource waste, improves resource utilization, and more effectively determines public-dependent resources, and improves the efficiency of extracting public-dependent resources.
Smart Images

Figure CN119861979A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer application technology, and in particular to an application resource processing method, an application loading method and related devices. Background Art
[0002] In the architecture of some computer applications, the overall large application can be split into multiple small, independent sub-applications, each of which can be run, developed and deployed independently, thereby achieving better modularity and maintainability.
[0003] Currently, in this type of architecture, each sub-application coordinates and communicates through the main application, which is responsible for managing the life cycle and status of each sub-application. In some application scenarios, some sub-applications may need to use the resources of other sub-applications, resulting in slow loading speed or low resource processing efficiency. Summary of the invention
[0004] The main technical problem solved by the present application is to provide an application resource processing method, an application loading method and related devices, which can improve the loading speed of the application.
[0005] The first aspect of the present application provides a resource processing method for an application, the method comprising: obtaining a target application, wherein the target application includes a main application and several sub-applications; determining common dependency resources by utilizing the dependency relationship between the main application and the several sub-applications; caching the common dependency resources to the main application, so that each sub-application is loaded by referencing the common dependency resources cached by the main application.
[0006] A second aspect of the present application provides a resource processing method for an application, the method comprising: obtaining a target application, wherein the target application includes a main application and several sub-applications, the main application cache has common dependency resources corresponding to the several sub-applications, and the common dependency resources are obtained by executing the resource processing method of the above application; in response to a loading request for the target sub-application, referencing the common dependency resources cached by the main application to load the target sub-application.
[0007] The third aspect of the present application provides a computer device, which includes a memory and a processor coupled to each other, wherein the memory stores program data, and the processor is used to execute the program data to implement any step of the above-mentioned resource processing method of the application and the application loading method.
[0008] In a fourth aspect, the present application provides a computer-readable storage medium, which stores program data that can be executed by a processor, and the program data is used to implement any step of the resource processing method of the above-mentioned application and the loading method of the application.
[0009] The above scheme obtains the target application, wherein the target application includes a main application and several sub-applications, and caches the common dependency resources to the main application, so that the common dependency resources cached by the main application are referenced to load each sub-application. When loading the sub-application, the common dependency resources can be directly obtained from the main application, thereby speeding up the loading speed of the sub-application, reducing resource waste, and improving resource utilization. In addition, the common dependency resources are determined based on the dependency relationship between the main application and several sub-applications, which can better determine the common dependency resources, improve the efficiency of extracting the common dependency resources, avoid the extraction of too large common dependency resources, and also speed up the loading speed of the main application / sub-application, which can improve the loading speed and performance of the application as a whole.
[0010] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in this application, the following briefly introduces the drawings required in the description of the embodiments. Obviously, the drawings described below are only some embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0012] Figure 1 It is a flowchart of an embodiment of a resource processing method applied in the present application;
[0013] Figure 2 This application Figure 1 A schematic diagram of a flow chart of an embodiment of step S12;
[0014] Figure 3 This application Figure 1 A schematic diagram of a flow chart of an embodiment of step S13;
[0015] Figure 4 This is a schematic diagram of an example of an embodiment of extracting common dependent resources in the present application;
[0016] Figure 5 It is a flowchart of an embodiment of a loading method applied in the present application;
[0017] Figure 6 It is a structural diagram of an embodiment of a resource processing device applied in the present application;
[0018] Figure 7 It is a structural schematic diagram of an embodiment of a loading device used in the present application;
[0019] Figure 8 It is a structural schematic diagram of an embodiment of a computer device of the present application;
[0020] Fig. 9 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0022] The terms "first" and "second" in this application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices.
[0023] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0024] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0025] The present application provides the following embodiments, and each embodiment is described in detail below.
[0026] It is understandable that the resource processing method and the loading method of the application in the present application can be executed by a computer device, and the computer device can be any device with processing capabilities, such as a mobile device, a computer, a server, etc., and the present application does not limit this. In some possible implementations, the resource processing method and the loading method of the application can be implemented by a processor calling program data stored in a memory.
[0027] See also Figure 1 , Figure 1 This is a flow chart of an embodiment of a resource processing method used in this application. The method may include the following steps:
[0028] S11: Obtain a target application, wherein the target application includes a main application and several sub-applications.
[0029] The target application may be an application generated in a computer architecture to implement a preset task. For example, the present application is described below using a micro front end as an example, and the present application is not limited to a micro front end.
[0030] Get the target application of micro frontend. Micro frontend is a frontend architecture pattern that can split a large frontend application into multiple small, independent sub-applications, each of which can be run, developed and deployed independently, thus achieving better modularity and maintainability.
[0031] The applications in the micro-frontend architecture include a main application and several sub-applications. Among them, the main application (or container) is responsible for coordinating and managing the loading and integration of each micro-frontend application, that is, the main application can be used to manage each sub-application, for example, management including the loading and unloading of sub-applications and the communication between each sub-application. The micro-frontend application is a split independent front-end sub-application, which can include several split small, independent sub-applications. Each sub-application can be independently developed, tested, and deployed. In some application scenarios, the micro-frontend architecture can also include basic applications, such as build tools, deployment processes, etc., to support the development, testing, and deployment of micro-frontends.
[0032] In some implementations, the main application and each of the several sub-applications have corresponding dependent resources, and each sub-application may include at least one sub-dependent resource, so that the dependent resources can be used to load the main application, sub-application, etc. The main application and the several sub-applications may create corresponding tasks for their project tasks, and use tools such as continuous integration (CI) and continuous deployment (CD) to integrate / deploy the main application and the several sub-applications with the tasks or functions corresponding to their applications.
[0033] S12: Determine common dependency resources by using the dependency relationship between the main application and several sub-applications.
[0034] The dependency relationship between the main application and several sub-applications can be obtained, and the dependency relationship includes the dependency information of each sub-dependent resource, the usage of the sub-dependent resources, the usage and dependency of the main application and each sub-application, etc., or, in some application scenarios, also includes information obtained from statistics of such information, etc. This application does not impose any restrictions on the dependency relationship.
[0035] Each sub-application depends on several sub-dependent resources respectively, and the dependency relationship between the main application and several sub-applications can be used to determine the common dependent resources from each sub-dependent resource. Specifically, according to the dependency relationship between the main application and several sub-applications, the dependency status and loading status of each dependent resource of the main application and several sub-applications can be obtained, so that the common dependent resources can be determined based on the dependency relationship. Among them, the common dependent resources can be sub-dependent resources shared by the main application and at least one sub-application, sub-dependent resources shared by at least two sub-applications, sub-dependent resources that need to be loaded by the main application, etc. It can be understood that in some application scenarios, the extracted common dependent resources may only be sub-dependent resources used by sub-applications alone, etc., and this application does not limit the extracted common dependent resources.
[0036] In some embodiments, see Figure 2 , the step S12 of the above embodiment can be further expanded. By using the dependency relationship between the main application and several sub-applications to determine the common dependency resources, this embodiment may include the following steps:
[0037] S121: Obtain dependency relationships between a main application and a plurality of sub-applications; wherein the dependency relationships include at least one of the following: the number of dependencies between the main application and sub-dependent resources of each sub-application, and the usage frequency of the main application and each sub-application.
[0038] The number of dependencies between the main application and the sub-dependent resources of each sub-application may include the number of dependencies, the number of times used, the number of repetitions or the same number of each sub-dependent resource, etc., which may indicate that each sub-application contains the same number of sub-dependent resources, thereby being able to express the dependency relationship between the main application and the sub-application. The usage frequency of the main application and each sub-application may include the number of entries, the number of starts, the length of use, etc. of the main application and each sub-application. For example, taking the number of entries as an example, the usage frequency may refer to the number of times the page corresponding to the main application and each sub-application is entered, which may indicate the dependency relationship between the main application and the sub-application. The dependency relationship between the main application and several sub-applications may be obtained based on the above-mentioned number of uses, frequency of use, etc.
[0039] In some implementations, the dependency counts of the sub-dependency resources of the main application and each sub-application are obtained as dependency relationships. Specifically, the sub-dependency resources of the main application and each sub-application can be traversed, and when the same or repeated sub-dependency resources are traversed, the dependency count of the sub-dependency resources is increased by 1, and when a new sub-dependency resource is traversed, its dependency count is initialized to 1, so that the dependency count of each sub-dependency resource can be obtained.
[0040] Exemplarily, sub-application 1 includes sub-dependent resource A and sub-dependent resource D, and sub-application 2 includes sub-dependent resource A. Then, the corresponding dependency number of sub-dependent resource A is 2, and the dependency number of sub-dependent resource D is 1.
[0041] In some embodiments, the usage frequency of the main application and each sub-application is obtained as a dependency. Specifically, the usage frequency of the main application and each sub-application in a preset period can be counted. Among them, the preset period may include a period of preset duration before the current time, or a preset time period, for example, one day, three days, one week, one month, etc., and another example, daytime, night, morning, afternoon, etc., and the present application does not limit the preset period. The record information can be obtained by using a preset data recording method, for example, the preset data recording method includes a data burying method, etc., to obtain the record information. The number of times a response click, load, start or enter the main application and each sub-application can be recorded as a usage frequency. Traverse the record information of the main application and each sub-application to obtain their respective usage frequencies.
[0042] Optionally, when a sub-application is loaded, the usage frequencies of the main application and the loaded sub-application are both increased by 1. Optionally, when only the main application is loaded, only the usage frequency of the main application is increased by 1.
[0043] Exemplarily, each time a sub-application is loaded, the usage frequency of the sub-application is increased by 1, and the usage frequency of the main application is increased by 1. For example, after sub-application a is loaded for the first time: the usage frequency of the main application is 1, and the usage frequency of sub-application a is 1. After sub-application a is loaded again: the usage frequency of the main application is 2, and the usage frequency of sub-application a is 2. Then, after sub-application b is loaded again: the usage frequency of sub-application b is 1, the usage frequency of sub-application a is 2, and the usage frequency of the main application is 3.
[0044] Through the above method, the dependency relationship between the main application and several sub-applications can be obtained.
[0045] S122: From a plurality of sub-applications, sub-dependent resources whose corresponding dependency relationships meet a preset threshold condition are determined to obtain common dependent resources.
[0046] According to the dependency relationship between the main application and several sub-applications, common dependency resources can be determined from several sub-applications. Specifically, each sub-application depends on several sub-dependency resources respectively. If the dependency relationship between the main application and the sub-application meets the preset threshold condition, the sub-dependency resources corresponding to the dependency relationship can be used as common dependency resources.
[0047] In some embodiments, the preset threshold condition includes at least one of the following: a first reference value corresponding to the number of dependencies is greater than an adaptive threshold, and a second reference value corresponding to the frequency of use is greater than an adaptive threshold. The first reference value corresponding to the number of dependencies is the ratio of the number of dependencies of the sub-dependent resources to the number of sub-applications. The second reference value corresponding to the frequency of use is the ratio of the frequency of use of the sub-application to the frequency of use of the main application.
[0048] In some embodiments, in response to the dependency numbers of sub-dependent resources of the main application and the sub-application satisfying corresponding preset threshold conditions, for example, a first reference value corresponding to the dependency number of the sub-dependent resource (the ratio of the dependency number of the sub-dependent resource to the number of sub-applications) is greater than an adaptive threshold, the sub-dependent resource of the sub-application is determined to be a common dependent resource, which means that the degree of dependency of the sub-dependent resource is relatively high, and the sub-dependent resource can be subsequently extracted to the main application.
[0049] In some embodiments, in response to the usage frequencies of the main application and the sub-application satisfying corresponding preset threshold conditions, for example, the second reference value corresponding to the usage frequency of the sub-application (the ratio of the usage frequency of the sub-application to the usage frequency of the main application) is greater than the adaptive threshold, it is determined that all sub-dependent resources of the sub-application are common dependent resources, which means that the usage frequency of the sub-application is high, and all sub-dependent resources of the sub-application can be subsequently extracted to the main application.
[0050] In other embodiments, in response to the dependency quantity of sub-dependent resources of the main application and the sub-application satisfying the corresponding preset threshold conditions, and the usage frequencies of the main application and the sub-application satisfying the corresponding preset threshold conditions, for example, the first reference value corresponding to the dependency quantity of the sub-dependent resources is greater than the adaptive threshold, and the second reference value corresponding to the usage frequency of the sub-application is greater than the adaptive threshold, it is determined that the sub-dependent resource of the sub-application is a common dependent resource, which means that the usage frequency of the sub-application is high and the degree of dependence of the sub-dependent resource is high, and the sub-dependent resource of the sub-application can be subsequently extracted to the main application.
[0051] In the above method, the dependency quantity and usage frequency of the sub-dependent resources of the main application and each sub-application are used as the dependency relationship. The dependency of the sub-dependent resources contained in the main application and each sub-application can be considered to determine the common dependent resources, which can improve the efficiency of extracting the common dependent resources.
[0052] In some embodiments, before the above step S12, the set adaptive threshold is obtained. The adaptive threshold is used to indicate the degree of limitation of extracting sub-dependent resources of each sub-application to load the main application, and / or to indicate the degree of limitation of the loading speed of each sub-application, etc. The larger the value of the adaptive threshold, the greater the degree of limitation, and vice versa. The adaptive threshold can be expressed as a percentage or a preset range value. Exemplarily, the adaptive threshold can include a value between [0,1]. For example, if the adaptive threshold is 1, it means that the degree of limitation of extracting sub-dependent resources of each sub-application to load the main application is the largest, and the common dependent resources may not be extracted, the sub-application loading speed is slow, and the main application loading speed is fast. For another example, if the adaptive threshold is 0, it means that the degree of limitation of extracting sub-dependent resources of each sub-application to load the main application is the smallest, and all common dependent resources can be extracted, the sub-application loading speed is fast, and the main application loading speed is slow.
[0053] In some embodiments, the set adaptive threshold can be obtained by: using the network usage status corresponding to the main application and / or the sub-application to determine the adaptive threshold. By dynamically adjusting the adaptive threshold according to the network usage status, resource management is made more flexible and efficient.
[0054] Among them, the network usage status includes at least one of the following: load conditions, resource utilization, network conditions, page loading time and other factors. This application does not limit the network usage status.
[0055] Specifically, the historical adaptive threshold can be adjusted according to the network usage status corresponding to the main application and / or the sub-application to obtain the current adaptive threshold; wherein the historical adaptive threshold includes: the previous adaptive threshold or the preset adaptive threshold. The preset adaptive threshold can be an initialized adaptive threshold, and the preset adaptive threshold can be obtained based on a pre-experienced value; or, the preset adaptive threshold can be obtained based on the user's limit on the degree of extraction of sub-dependent resources of each sub-application to the main application loading, and / or, for indicating the limit on the loading speed of each sub-application. The previous adaptive threshold can represent the adaptive threshold obtained last time.
[0056] In the process of extracting common dependency resources for the first time, a preset adaptive threshold can be used as the current adaptive threshold. For example, the adaptive threshold is 0.5. In the process of extracting common dependency resources for the subsequent times, the adaptive threshold can be adaptively adjusted according to the network usage status corresponding to the main application and / or sub-application to obtain a more adaptive preset threshold condition.
[0057] Exemplarily, for example, if the current sub-application loads slowly, while the main application loads quickly, and the sub-application loading speed needs to be increased, the value of the adaptive threshold can be reduced, otherwise, the value of the adaptive threshold can be increased. For another example, if the current sub-application has at least one of the following factors, such as high load pressure, poor network, and long page loading time, the value of the adaptive threshold can be reduced. For another example, if the resource utilization of the current main application and sub-application is low, and if you want to increase the resource utilization, you can reduce the value of the adaptive threshold. This application does not limit the method of dynamically adjusting the adaptive threshold.
[0058] In some embodiments, after executing the step of obtaining the set adaptive threshold, it is determined whether the set adaptive threshold is obtained. In response to obtaining the adaptive threshold, the above step S12 is executed, that is, the step of determining the common dependency resources by using the dependency relationship between the main application and several sub-applications and subsequent steps are executed. Alternatively, in response to not obtaining the adaptive threshold, the initial adaptive threshold is used as the acquired adaptive threshold, and the above step S12 is executed. Alternatively, in response to not obtaining the adaptive threshold, there is no need to extract the common dependency resources, and the main application and several sub-applications are packaged separately, so that the subsequent loading of each application is completed by loading their respective sub-dependency resources.
[0059] Through the above method, in the process of determining common dependent resources, the frequency of use and the number of dependencies of sub-applications are taken into consideration to ensure the accuracy of determining common dependent resources. By setting preset threshold conditions, it is possible to dynamically adjust which resources are identified as common dependent resources, making resource management more flexible and efficient. In addition, the adaptive threshold is dynamically determined based on the network usage status, and the preset threshold conditions are adaptively determined, so as to dynamically and adaptively extract common dependent resources. In addition, the adaptive threshold can be adaptively adjusted according to at least one of the load conditions, resource utilization, network conditions, page loading time and other factors, so as to be more in line with the actual usage of the application, adjust the dependent resources, and improve the overall performance and loading speed of the system to adapt to different network environments and application requirements.
[0060] Continue reading Figure 1 , after the above step S12, the following steps are also included:
[0061] S13: Cache the common dependency resources to the main application, so that each sub-application is loaded by referencing the common dependency resources cached by the main application.
[0062] Extract the common dependency resources. Then, cache the common dependency resources to the main application, so that the common dependency resources can be loaded in the main application, so that when loading the sub-application, the common dependency resources cached by the main application can be used to load the sub-application.
[0063] The above scheme obtains the target application, wherein the target application includes a main application and several sub-applications, and caches the common dependency resources to the main application, so that the common dependency resources cached by the main application are referenced to load each sub-application. When loading the sub-application, the common dependency resources can be directly obtained from the main application, thereby speeding up the loading speed of the sub-application, reducing resource waste, and improving resource utilization. In addition, the common dependency resources are determined based on the dependency relationship between the main application and several sub-applications, which can better determine the common dependency resources, improve the efficiency of extracting the common dependency resources, avoid the extraction of too large common dependency resources, and also speed up the loading speed of the main application / sub-application, which can improve the loading speed of the micro-front-end application and the performance of the application as a whole.
[0064] In addition, it can also effectively reduce the number of network requests when loading sub-applications, and improve the startup speed and operating efficiency of the application.
[0065] In some embodiments, see Figure 3 , step S13 of the above embodiment can be further expanded. The common dependency resources are cached to the main application, so that the common dependency resources cached by the main application are referenced to load each sub-application. This embodiment may include the following steps:
[0066] S131: Creating a public resource package for public dependent resources.
[0067] A public resource package may be created for all public dependency resources extracted by each sub-application, which may include all public dependency resources that need to be extracted and loaded into the main application. The public resource package may be generated for the public dependency resources by using a preset compression and packaging tool.
[0068] In some embodiments, the public resource package is uploaded to a preset server, such as a content storage and distribution server. Exemplarily, the public resource package can be uploaded to a content delivery network (CDN) so that the upload and download of public dependent resources can be guaranteed.
[0069] S132: Introduce a public resource package into the main application so that the public dependent resources are cached in the main application.
[0070] In the process of packaging the main application, the public resource package is introduced into the main application, so that the public dependency resources can be downloaded and cached in the main application.
[0071] In some implementations, a preset code compilation tool may be used to insert the first script file into the static file of the main application to introduce the public resource package.
[0072] Among them, the preset code compilation tool can realize module packaging, and can be a module packaging tool. For example, the preset code compilation tool includes: Webpack, Rollup, Parcel, etc., and this application does not limit this. This application uses Webpack as an example for explanation. Webpack is a module packaging tool that can be used to package various modules of the project (such as the main application / sub-application) into one or more static resource files.
[0073] Among them, the static files of the main application may include dependent files of the corresponding dependent resources, which is not limited in this application. For example, files of HTML type, CSS type or JavaScript type, etc., which are not limited in this application.
[0074] This application takes the static file of the main application as an example of HTML type, and the static file can be index.html, where index.html is the homepage file corresponding to the main application, and is an HTML document consisting of a series of tags, which is used to define the content and structure of the main application. It defines the title, metadata, content (such as text, images, videos or links), layout design, navigation menu or links to other pages (such as links to sub-applications) of the main application such as a website. It is loaded first when the main application such as a website is loaded.
[0075] The first script file may be in the form of a script tag. The script tag may be used to load a script from a preset server and execute it in the current page. The script tag may be loaded synchronously or asynchronously. For example, when the main application loads the script tag for the first time, the common resource package may be loaded or downloaded from the preset server, so that the common resource package may be cached, that is, the common dependent resources may be cached to the main application.
[0076] Exemplarily, a preset code compilation tool (such as Webpack) can be used to insert a first script file (such as a script tag) into the static file (such as index.html) of the main application to introduce a public resource package. In this way, the public resource package can be downloaded from the preset server and the public dependency resources can be cached in the main application.
[0077] S133: Delete the common dependency resources from the sub-dependency resources of the plurality of sub-applications, and introduce cache information of the common resource package into the sub-applications, so as to load each sub-application by referencing the common dependency resources cached by the main application.
[0078] The common dependency resources can be deleted from the sub-dependency resources of several sub-applications, which can reduce the loading and storage of the common dependency resources by the sub-applications. Then, in the process of packaging each sub-application, the cache information of the common resource package is introduced into the sub-application, so that the common dependency resources cached by the main application are referenced to load each sub-application. Among them, the cache information can be the cache path, the data and name of the cached common dependency resources, and other information, which is not limited in this application. For example, the cache information of the common resource package can be introduced into the sub-application that extracts the common dependency resources, so that in the process of loading the sub-application, the public dependency resources cached by the main application are referenced through the cache information to load its sub-application.
[0079] In some implementations, a preset script tool may be used to modify dependency configuration files corresponding to sub-dependency resources of several sub-applications, and delete common dependency resources from the sub-applications.
[0080] For example, a preset script tool (such as Node.js script) can be used to dynamically modify the sub-application dependency configuration file (such as package.json) to delete the public dependency resources from the sub-dependency resources of the sub-application. The package.json file is a description of the project or module package corresponding to each sub-application, and can contain a lot of meta information, such as project name, project version, project execution entry file, sub-dependency resources, etc.
[0081] Then, use a preset code compilation tool (such as Webpack) to insert a second script file (such as a script tag) into the static file of the sub-application (such as index.html) to introduce the cache information of the main application for the public resource package. Among them, the second script file can be in the form of a script tag. In this way, it is possible to reference the public resource package cached by the main application based on the cache information, that is, to reference the public dependent resources cached in the main application to load the sub-application. This part can refer to the packaging process of the main application, which will not be repeated here.
[0082] Optionally, during the sub-application packaging process, the sub-application may not delete the public dependency resources, but directly package the sub-dependency resources. Thus, during the sub-application loading process, the main application or the sub-application may reference the public dependency resources to load the sub-application.
[0083] In the above manner, the sub-application can load the public dependency resources cached by the main application, which can improve the loading speed of the sub-application and reduce the page loading time of the sub-application. Since the public dependency resources are cached in the main application, the sub-application can directly obtain these public dependency resources from the main application when loading, thereby avoiding the inefficient operation of repeatedly loading the same resources. In addition, through the use of preset script tools and preset code compilation tools, the packaging and caching of resources can be completed automatically, reducing development and maintenance costs. Further, the preset code compilation tool is used to modify the way the main application and sub-application load public dependency resources, so that the public dependency resources are loaded separately from the application code, and parallel loading is achieved during the page loading process, thereby improving the effect of page loading speed. In addition, the way the main application / sub-application loads public dependency resources uses script files (such as script tags) to load, which can improve the security of loading. The above technical solution of the present application can also reduce the load on the server and reduce bandwidth consumption.
[0084] For the above examples, see Figure 4 , the present application provides an example, the main application can manage at least multiple sub-applications, each of which contains sub-dependent resources. Among the multiple sub-applications, for example, sub-application 1 contains sub-dependent resources A and sub-dependent resources D, sub-application 2 contains sub-dependent resources A, sub-application 3 contains sub-dependent resources B and sub-dependent resources C, sub-application 4 contains sub-dependent resources A, sub-application 5 contains sub-dependent resources A and sub-dependent resources E, and sub-application 6 contains sub-dependent resources B and sub-dependent resources C.
[0085] Among the sub-dependent resources of each sub-application, sub-dependent resource A, sub-dependent resource B and sub-dependent resource C can be determined as common dependent resources, that is, common dependent resources to be extracted. The remaining sub-dependent resources are sub-dependent resources that are not to be extracted.
[0086] Extract common dependency resources for each sub-application, and sub-dependency resource A, sub-dependency resource B and sub-dependency resource C can be extracted as common dependency resources. Cache sub-dependency resource A, sub-dependency resource B and sub-dependency resource C to the main application, so that the common dependency resources cached by the main application can be referenced to load the corresponding sub-application. For example, sub-application 1, sub-application 2, sub-application 4 or sub-application 5 can reference the common dependency resource A cached by the main application to load the corresponding sub-application. For another example, sub-application 3 or sub-application 6 can reference the common dependency resource B cached by the main application to load the corresponding sub-application. For another example, sub-application 3 or sub-application 6 can reference the common dependency resource C cached by the main application to load the corresponding sub-application.
[0087] Regarding the loading process of the main application and each sub-application, the present application also provides an application loading method, and the details can be referred to the following embodiments.
[0088] See also Figure 5 , Figure 5 This is a flow chart of an embodiment of a loading method used in this application. The method may include the following steps:
[0089] S21: Obtain a target application, wherein the target application includes a main application and several sub-applications, the main application caches common dependency resources corresponding to the several sub-applications, and the common dependency resources are obtained by executing the resource processing method of the above application.
[0090] The specific implementation process of step S21 can refer to the resource processing method of the application described in the above embodiment, and this application will not repeat it here.
[0091] S22: In response to a loading request for a target sub-application, reference the common dependency resources cached by the main application to load the target sub-application.
[0092] Before this step, the main application may be loaded in response to a loading request of the main application, thereby loading the common dependent resources and caching the common dependent resources.
[0093] After responding to the loading request of the target sub-application of the main application, the sub-application can be loaded, that is, the public dependency resources cached by the main application can be referenced to load the sub-application. Among them, the target sub-application can be a sub-application that has extracted the sub-dependency resources to the main application. For the sub-application that has not extracted the public dependency resources, the sub-application can be loaded directly according to the sub-dependency resources of the sub-application.
[0094] In some implementations, it may be determined whether the target sub-application has cached public dependency resources. If the target sub-application does not have cached public dependency resources, in response to not caching public dependency resources, the step of referencing the public dependency resources cached by the main application to load the target sub-application is executed.
[0095] If the target sub-application cache has common dependency resources, in response to the common dependency resources being cached, the common dependency resources in the target sub-application cache are referenced to load the target sub-application.
[0096] Optionally, during the process of loading the target sub-application, if the target sub-application depends on at least one sub-dependent resource and a common dependent resource, the common dependent resources cached by the main application and the sub-dependent resources cached by the target sub-application can be referenced to load the target sub-application, so that the common dependent resources and the sub-dependent resources can be loaded separately, thereby achieving parallel loading during the page loading process and improving loading efficiency.
[0097] The above solution can improve the utilization rate of common dependency resources, reasonably use the cached common dependency resources and the cache of the main application, reduce resource requests, and improve the loading efficiency of the application.
[0098] It is understandable that in the above method of the specific implementation mode, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0099] For the above embodiments, the present application also provides an application resource processing device, which is used to implement the application resource processing method of any of the above embodiments.
[0100] See also Figure 6 , Figure 6 1 is a schematic diagram of a structure of an embodiment of a resource processing device of the present application. The resource processing device 30 of the application includes an acquisition module 31, a determination module 32 and a cache module 33. The modules are interconnected.
[0101] The acquisition module 31 is used to acquire a target application, wherein the target application includes a main application and several sub-applications.
[0102] The determination module 32 is used to determine common dependent resources by using the dependency relationship between the main application and several sub-applications.
[0103] The cache module 33 is used to cache the common dependency resources to the main application, so that each sub-application is loaded by referencing the common dependency resources cached by the main application.
[0104] It should be noted that the resource processing device for applications provided in the above embodiment and the resource processing method for applications provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here. In actual applications, the resource processing device for applications provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this application does not limit this.
[0105] For the above embodiments, the present application also provides an application loading device for implementing the application loading method of any of the above embodiments.
[0106] See also Figure 7 , Figure 7 1 is a schematic diagram of a structure of an embodiment of a loading device used in the present application. The loading device 40 of the application includes an application module 41 and a loading module 42. The modules are interconnected.
[0107] The application module 41 is used to obtain a target application, wherein the target application includes a main application and several sub-applications. The main application caches common dependency resources corresponding to the several sub-applications, and the common dependency resources are obtained by executing the resource processing method of the above application.
[0108] The loading module 42 is used to load the target sub-application by referencing the common dependency resources cached by the main application in response to a loading request for the target sub-application.
[0109] It should be noted that the application loading device provided in the above embodiment and the application loading method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In actual applications, the application loading device provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this application does not limit this.
[0110] For the above embodiment, the present application provides a computer device, see Figure 8 , Figure 8 1 is a schematic diagram of the structure of an embodiment of a computer device of the present application. The computer device 50 includes a memory 51 and a processor 52, wherein the memory 51 and the processor 52 are coupled to each other, the memory 51 stores program data, and the processor 52 is used to execute the program data to implement the steps of any embodiment of the resource processing method of the application and the loading method of the application.
[0111] In this embodiment, the processor 52 may also be referred to as a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip having the ability to process signals. The processor 52 may also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor may be a microprocessor or the processor 52 may also be any conventional processor, etc.
[0112] The method of the above embodiment can be implemented in the form of a computer program, so the present application proposes a computer readable storage medium, see Fig. 9 , Fig. 9The computer-readable storage medium 60 stores program data 61 that can be executed by a processor, and the program data 61 can be executed by the processor to implement the steps of any of the above-mentioned application resource processing methods and application loading methods.
[0113] The computer-readable storage medium 60 of this embodiment can be a medium that can store program data 61, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or it can also be a server that stores the program data 61. The server can send the stored program data 61 to other devices for execution, or it can also execute the stored program data 61 by itself.
[0114] In some embodiments, the functions or modules included in the device provided in the above embodiments of the present application can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, the present application will not go into details here.
[0115] The above description of the various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other. For the sake of brevity, this application will not go into details here.
[0116] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0117] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0118] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0119] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium, which is a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of each implementation method of the present application.
[0120] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a computer-readable storage medium and executed by a computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.
[0121] The above descriptions are merely embodiments of the present application and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A resource processing method for an application, characterized in that: include: Obtaining a target application, wherein the target application includes a main application and a plurality of sub-applications; Determining common dependent resources by using the dependency relationship between the main application and the plurality of sub-applications; The common dependency resources are cached in the main application, so that each sub-application is loaded by referencing the common dependency resources cached by the main application.
2. The method according to claim 1, characterized in that Each sub-application depends on several sub-dependent resources; The determining of common dependent resources by using the dependency relationship between the main application and the plurality of sub-applications includes: Obtaining a dependency relationship between the main application and the plurality of sub-applications; wherein the dependency relationship includes at least one of the following: the number of dependencies between the main application and the sub-dependent resources of each sub-application, and the usage frequency of the main application and each sub-application; From the plurality of sub-applications, sub-dependent resources corresponding to the dependency relationships that meet a preset threshold condition are determined to obtain the common dependent resources.
3. The method according to claim 2, characterized in that The preset threshold condition includes at least one of the following: a first reference value corresponding to the dependent quantity is greater than an adaptive threshold, and a second reference value corresponding to the usage frequency is greater than an adaptive threshold; Among them, the first reference value corresponding to the dependency quantity is: the ratio of the dependency quantity of the sub-dependent resources to the quantity of the sub-applications; the second reference value corresponding to the usage frequency is: the ratio of the usage frequency of the sub-application to the usage frequency of the main application.
4. The method according to claim 2 or 3, characterized in that: The step of determining, from the plurality of sub-applications, the sub-dependency resources corresponding to the dependency relationship that meets a preset threshold condition, and obtaining the common dependency resource comprises: In response to the dependency quantity between the main application and the sub-dependency resource of the sub-application satisfying the corresponding preset threshold condition, determining the sub-dependency resource of the sub-application as the common dependency resource; or, In response to the usage frequencies of the main application and the sub-application satisfying the corresponding preset threshold conditions, determining all sub-dependent resources of the sub-application as the common dependent resources; or, In response to the dependency quantity of the sub-dependent resources of the main application and the sub-application satisfying the corresponding preset threshold condition, and the usage frequency of the main application and the sub-application satisfying the corresponding preset threshold condition, the sub-dependent resources of the sub-application are determined to be the common dependent resources.
5. The method according to claim 2 or 3, characterized in that: The determining, from the plurality of sub-applications, of sub-dependent resources corresponding to the dependency relationship that meets a preset threshold condition, before obtaining the common dependent resource, includes: An adaptive threshold is determined using the network usage status corresponding to the main application and / or the sub-application.
6. The method according to claim 5, characterized in that The adaptive threshold is used to indicate the degree of limitation of extracting sub-dependent resources of each sub-application to load the main application, and / or to indicate the degree of limitation of the loading speed of each sub-application; And / or, the network usage status includes at least one of the following: load condition, resource utilization, network condition, and page loading time.
7. The method according to claim 1, characterized in that The step of caching the common dependency resources to the main application so as to load each sub-application by referencing the common dependency resources cached by the main application includes: Creating a public resource package for the public dependent resources; Introducing the common resource package in the main application so that the common dependent resources are cached in the main application; and The common dependency resources are deleted from the sub-dependency resources of the plurality of sub-applications, and cache information of the common resource package is introduced into the sub-applications, so that each sub-application is loaded by referencing the common dependency resources cached by the main application.
8. The method according to claim 7, characterized in that The introducing the common resource package into the main application comprises: Using a preset code compilation tool, inserting a first script file into the static file of the main application, and introducing the public resource package; And / or, deleting the common dependency resource from the sub-dependency resources of the plurality of sub-applications, and introducing cache information of the common resource package into the sub-applications, including: Using a preset script tool, modify the dependency configuration files corresponding to the sub-dependency resources of the plurality of sub-applications, and delete the common dependency resources from the sub-applications; Using a preset code compilation tool, insert a second script file into the static file of the sub-application, and introduce the cache information of the main application on the public resource package.
9. A method for loading an application, characterized in that: include: Obtain a target application, wherein the target application includes a main application and several sub-applications, the main application caches common dependency resources corresponding to the several sub-applications, and the common dependency resources are obtained by executing the method described in any one of claims 1 to 8; In response to a request to load a target sub-application, the target sub-application is loaded by referencing the common dependency resource cached by the main application.
10. The method according to claim 9, characterized in that After responding to the loading request for the target sub-application, the method further includes: Determine whether the target sub-application has cached common dependent resources; In response to the public dependency resource not being cached, executing the step of referencing the public dependency resource cached by the main application to load the target sub-application; or, In response to the common dependency resource being cached, the common dependency resource cached by the target sub-application is referenced to load the target sub-application.
11. A computer device, characterized in that: The invention comprises a memory and a processor coupled to each other, wherein the memory stores program data, and the processor is used to execute the program data to implement the steps of the method according to any one of claims 1 to 10.
12. A computer-readable storage medium, characterized in that: Program data that can be executed by a processor are stored, and the program data is used to implement the steps of the method according to any one of claims 1 to 10.