CN115842733A - Resource sharing method, micro front-end system, application and computer readable storage medium - Google Patents
Resource sharing method, micro front-end system, application and computer readable storage medium Download PDFInfo
- Publication number
- CN115842733A CN115842733A CN202110914151.8A CN202110914151A CN115842733A CN 115842733 A CN115842733 A CN 115842733A CN 202110914151 A CN202110914151 A CN 202110914151A CN 115842733 A CN115842733 A CN 115842733A
- Authority
- CN
- China
- Prior art keywords
- resource
- application
- loading
- sharing method
- information
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 108
- 230000015654 memory Effects 0.000 claims description 30
- 238000004590 computer program Methods 0.000 claims description 11
- 230000004044 response Effects 0.000 abstract description 5
- 238000004904 shortening Methods 0.000 abstract description 2
- 238000007726 management method Methods 0.000 description 45
- 230000006870 function Effects 0.000 description 22
- 238000010586 diagram Methods 0.000 description 13
- 230000000694 effects Effects 0.000 description 7
- 238000004891 communication Methods 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 5
- 238000012545 processing Methods 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 230000008859 change Effects 0.000 description 3
- 238000011161 development Methods 0.000 description 3
- 230000010354 integration Effects 0.000 description 3
- 230000001419 dependent effect Effects 0.000 description 2
- 230000014509 gene expression Effects 0.000 description 2
- 238000012544 monitoring process Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 238000009877 rendering Methods 0.000 description 2
- 238000012800 visualization Methods 0.000 description 2
- 230000009471 action Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 230000009133 cooperative interaction Effects 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 230000004069 differentiation Effects 0.000 description 1
- 230000000977 initiatory effect Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000007723 transport mechanism Effects 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a resource sharing method, a micro front-end system, an application and a computer readable storage medium, wherein the resource sharing method is applied to the micro front-end system, the micro front-end system comprises a first application, a second application and a resource management device, the first application comprises a resource loading device for loading standby shared resources, and the method comprises the following steps: the second application sends registration information to the first application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of target shared resources required to be called by the second application; the resource management device determines a loading strategy aiming at the target shared resource according to the resource information and the standby shared resource; the first application updates the resource loading device according to the loading strategy; the second application calls the target shared resource from the updated resource loading device. In the embodiment of the invention, the resource sharing can be carried out under the conditions of saving network bandwidth and shortening response delay, and the execution efficiency of the micro front-end system aiming at the resource sharing is favorably improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of computer networks, in particular to a resource sharing method, a micro front-end system, application and a computer readable storage medium.
Background
At present, in the front-end field, single-page application is a project form which is widely concerned and used, but as time goes on and application functions are abundant, the single-page application is worse and harder to maintain, and the single-page application is often changed to affect the whole body of the single-page application, so that the version development cost is higher and higher. In order to solve the problem, the industry proposes a microservice concept, that is, the huge applications are split and decoupled therewith, so that each module can be maintained and deployed independently, and the development efficiency is improved. The micro-service concept is also applied to the front-end field, namely micro front-end, and the core idea is to convert the network application from a single application to a plurality of applications aggregated into one by a plurality of small front-end applications.
The micro front-end technology is different from the server-side technology, although independent development, independent operation and independent deployment are realized by splitting each front-end application, page-level integration needs to be carried out on a browser when the front-end application is displayed to a user, a large number of repeated static dependent resources can be introduced when the front-end application is loaded on the same browser after integration, the problems that the shared basic resources are repeatedly packaged, the storage space is occupied, the code reuse rate of a basic library is low and the like exist, the network bandwidth is wasted during operation, and the response time of access is increased. For this reason, the front-end field proposes to share repeated network resources to alleviate the above problems, and the related art mainly stores the requested shared resources in a cache of a certain network node, and makes a determination at each resource request, so as to select access from the cache or an original resource address, which has the disadvantages of increasing the computational complexity of resource requests and increasing the complexity of managing cache resources, for example, when multiple resource requests are involved, a large number of cache resources may need to be managed at the same time, resulting in an extended response time of access, and this way cannot exclude the occurrence of repeated requests, and may still waste network bandwidth.
Disclosure of Invention
The following is a summary of the subject matter described in detail herein. This summary is not intended to limit the scope of the claims.
The embodiment of the invention provides a resource sharing method, a micro front-end system, application and a computer readable storage medium, which can share resources under the conditions of saving network bandwidth and shortening response delay.
In a first aspect, an embodiment of the present invention provides a resource sharing method, which is applied to a micro front-end system, where the micro front-end system includes a first application, a second application, and a resource management device, the first application includes a resource loading device for loading a standby shared resource, and the resource sharing method includes:
the second application sends registration information to the first application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of a target shared resource required to be called by the second application;
the resource management device receives the resource information sent by the first application, and determines a loading strategy aiming at the target shared resource according to the resource information and the standby shared resource;
the first application receives the loading strategy sent by the resource management device and updates the resource loading device according to the loading strategy;
and the second application calls the target shared resource from the updated resource loading device.
In a second aspect, an embodiment of the present invention further provides a resource sharing method, applied to a first application in a micro-front-end system, where the first application includes a resource loading device for loading a standby shared resource, the micro-front-end system further includes a second application and a resource management device, and the resource sharing method includes:
acquiring registration information sent by the second application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of a target shared resource required to be called by the second application;
sending the resource information to a resource management device so that the resource management device determines a loading strategy for the target shared resource according to the resource information and the standby shared resource;
and receiving the loading strategy sent by the resource management device, and updating the resource loading device according to the loading strategy so that the second application calls the target shared resource from the updated resource loading device.
In a third aspect, an embodiment of the present invention further provides a resource sharing method, which is applied to a second application in a micro front-end system, where the micro front-end system further includes a first application and a resource management device, the first application includes a resource loading device for loading a standby shared resource, and the resource sharing method includes:
sending registration information to the first application, so that the first application sends resource information to the resource management device, and the resource management device determines a loading policy for a target shared resource according to the resource information and the standby shared resource, wherein the registration information includes resource information, and the resource information is used for characterizing features of the target shared resource required to be called by the second application;
invoking the target shared resource from the updated resource loading device, the updated resource loading device being determined by the first application according to the loading policy sent by the resource management device.
In a fourth aspect, an embodiment of the present invention further provides a micro front-end system, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the resource sharing method of the first aspect as described above when executing the computer program.
In a fifth aspect, an embodiment of the present invention further provides a network device, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the resource sharing method of the second aspect as described above when executing the computer program, or implementing the resource sharing method of the third aspect as described above.
In a sixth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions for performing the resource sharing method of the first aspect, or performing the resource sharing method of the second aspect, or performing the resource sharing method of the third aspect.
The embodiment of the invention comprises the following steps: the resource sharing method is applied to a micro front-end system, the micro front-end system comprises a first application, a second application and a resource management device, the first application comprises a resource loading device used for loading standby shared resources, and the resource sharing method comprises the following steps: the second application sends registration information to the first application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of target shared resources required to be called by the second application; the resource management device receives the resource information sent by the first application, and determines a loading strategy aiming at the target shared resource according to the resource information and the standby shared resource; the first application receives a loading strategy sent by the resource management device and updates the resource loading device according to the loading strategy; the second application calls the target shared resource from the updated resource loading device. According to the scheme provided by the embodiment of the invention, in the micro-front-end system, the first application enables the resource management device to determine the loading strategy by collecting the registration information of the second application, and updates the resource loading device according to the loading strategy, so that the resource loading device can dynamically introduce the target shared resource required to be called by the second application as required.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the present invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and do not constitute a limitation thereof.
FIG. 1 is a schematic diagram of a micro-front-end system for performing a resource sharing method, provided by an embodiment of the invention;
FIG. 2 is a schematic diagram of a page of a menu module provided by one embodiment of the present invention;
FIG. 3 is a flow chart of a resource sharing method provided by an embodiment of the invention;
fig. 4 is a flowchart of a resource management device determining a loading policy in a resource sharing method according to an embodiment of the present invention;
fig. 5 is a flowchart illustrating a resource management device determining a loading policy in a resource sharing method according to another embodiment of the present invention;
fig. 6 is a flowchart of a first application update resource loading apparatus in a resource sharing method according to an embodiment of the present invention;
FIG. 7 is a flowchart of a second application in a resource sharing method according to an embodiment of the present invention after calling a target shared resource;
FIG. 8 is a schematic page diagram of a first application provided by an embodiment of the invention;
FIG. 9 is a schematic diagram of a micro-headend system provided by another embodiment of the invention;
FIG. 10 is a flow diagram of a method for a micro-front-end system to perform resource sharing as provided by the embodiment shown in FIG. 9;
FIG. 11 is a flow chart of a resource sharing method provided by another embodiment of the present invention;
fig. 12 is a flowchart of an update resource loading apparatus in a resource sharing method according to an embodiment of the present invention;
FIG. 13 is a flow chart of a resource sharing method provided by another embodiment of the present invention;
FIG. 14 is a schematic diagram of a micro-headend system provided by another embodiment of the invention;
fig. 15 is a schematic diagram of a network device according to an embodiment of the present invention;
fig. 16 is a schematic diagram of a network device according to another embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not limit the invention.
It should be noted that although functional block divisions are performed in apparatus diagrams and logical orders are illustrated in flowcharts, in some cases, steps shown or described may be performed in orders different from block divisions in apparatus diagrams or flowcharts. The terms first, second and the like in the description and in the claims, and the drawings described above, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The invention provides a resource sharing method, a micro front-end system, an application and a computer readable storage medium, wherein in the micro front-end system, a first application enables a resource management device to determine a loading strategy by collecting registration information of a second application, and updates a resource loading device according to the loading strategy, so that the resource loading device can dynamically introduce target shared resources required to be called by the second application as required.
The embodiments of the present invention will be further explained with reference to the drawings.
As shown in fig. 1, fig. 1 is a schematic diagram of a micro-front-end system 400 for performing a resource sharing method according to an embodiment of the present invention.
In the example of fig. 1, the micro-front end system 400 includes, but is not limited to: a first application 100, a second application 200 and a resource management apparatus 300, the first application 100 may include, but is not limited to, a resource loading apparatus 110 for loading a standby shared resource. In another embodiment, the micro-front-end system 400 may further include a shared resource library, wherein the shared resource library is used for storing shared resources, the stored shared resources may be spare contributed resources, and may also be other types or forms of shared resources, and the shared resource library may be, but is not limited to, a micro-application running independently for being responsible for storage and version management of the shared resources.
In an embodiment, the micro-front-end system 400 may be, but is not limited to, constructed based on micro-services, and is capable of implementing related functions of a micro-front-end, in the micro-front-end system 400, the first application 100 and the second application 200 are in a dependent relationship with each other, where the first application 100 is a master application, the second application 200 is a sub-application, and the resource management device 300 is capable of implementing normal function execution of the micro-front-end system 400 through cooperative interaction between the two applications, it should be noted that the second application 200 may be provided in plural, in this case, each second application 200 is a sub-application corresponding to the first application 100, that is, each second application 200 is capable of implementing normal function execution of the micro-front-end system 400 in cooperation with the first application 100 and the resource management device 300, and therefore, the present embodiment does not need nor does it need to limit the specific number of the second applications 200.
In an embodiment, the first application 100 may be a micro application that the terminal finally accesses, that is, an application that the terminal finally confirms to access is taken as the first application 100 no matter how many applications the terminal relates to access, so that the determined first application 100 can better match routing rules under network conditions, so as to more accurately and reliably integrate one or more second applications 200 split at the micro front end, and thus, the loading presentation, communication and resource sharing of the one or more second applications 200 are cooperatively realized, in other words, in the micro front end system 400, the first application 100 and the second application 200 are integrated on the same hypertext Markup Language (HTML) page, and thus, the second application 200 may share a resource pool of the first application 100, that is, not only the first application 100 may call a corresponding standby shared resource from the resource loading device 110, but also the second application 200 may call a corresponding shared standby resource from the resource loading device 110.
In one embodiment, the number of terminals accessing the first application 100 is not limited, and may be set to be multiple, and each terminal may be referred to as an access terminal, a User Equipment (UE), a subscriber unit, a subscriber station, a mobile station, a remote terminal, a mobile device, a User terminal, a wireless communication device, a User agent, or a User Equipment. For example, each terminal may be a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA), a handheld device with a Wireless communication function, a computing device or other processing device connected to a Wireless modem, a vehicle-mounted device, a wearable device, a terminal device in a 5G network or a future 5G or higher network, and the like, and this embodiment is not particularly limited thereto.
In an embodiment, the second application 200 may be, but not limited to, a front-end micro application which can be independently developed and independently deployed according to a division of internal function modules and has a certain function and responsibility, and the second application 200 may run independently or may be integrated into a page of the first application 100 to run.
In an embodiment, various types of function modules may be integrated inside the second application 200 and presented in a menu form, for example, the second application 200 includes, but is not limited to, function modules, resource modules, and a registration module, and the modules are arranged on a page of the second application 200 in a menu form, where the function modules may embody and display a life cycle function of the second application 200 itself to the outside, the resource modules are used to introduce and manage shared resources matched with the second application 200, the registration module may be suitable for a situation of the second application 200 at the time of integration, may register related information inside the second application 200 to the first application 100, and simultaneously have a function of monitoring a menu and receiving an information definition file related to the menu (for example, an identification information file, a resource information file, a serial number information file, and the like), so that a terminal can know a change situation that may occur in the menu, and it is understood that a manner of implementing message registration and reception by the registration module is not limited, and a person skilled in the art may set the manner according to an actual scenario.
In an embodiment, the resource loading apparatus 110 is provided as a resource pool, can accommodate different shared resources as a standby, and has a capability of continuous update, that is, a new shared resource can be continuously introduced under the action of the first application 100, so as to achieve an effect of timely updating the shared resource, it should be noted that the resource loading apparatus 110 may also be set as an independently running micro application, that is, the resource loading apparatus 110 is distinguished from the first application 100, which does not affect the function execution of the resource loading apparatus 110; in addition, other types of modules may be integrated inside the first application 100, for example, the first application 100 further includes, but is not limited to, a route loading module, a menu module, a Document Object Model (DOM) container, and the like, where the route loading module is configured to trigger loading of the corresponding second application 200 in response to a route switch, so as to expose interface elements of the second application 200 to the DOM container, the menu module is configured to receive and expose registration information from the second application 200, and may cache content information of one or more shared resources corresponding to the second application 200, and the DOM container is used as an HTML container and may be configured to expose interface elements of the second application 200, so that a visualization degree for loading the second application 200 becomes higher.
It is understood that the types and the number of the plurality of functional modules integrated inside the first application 100 and the second application 200 may be more, which is not limited; moreover, the purpose of integrating a plurality of functional modules in the first application 100 and the second application 200 is to implement function differentiation, that is, the corresponding functional modules execute corresponding functions, which greatly reduces the probability of errors in function execution, and is more convenient for management and control, and when a problem occurs, the functional module corresponding to the problem is more intuitively found out, so that the corresponding functional module is adjusted or updated conveniently.
Example one:
as shown in fig. 2, fig. 2 shows a form of a menu module presented in a table, and as can be seen from fig. 2, the types and meanings of the attributes corresponding to the second application 200 are determined in a one-to-one correspondence manner, for example, the ID corresponds to the string type and is a unique identifier, and the mfaHash embodies a routing rule triggering the second application 200 to load, and also serves as a globally unique name of the second application 200; if there are related sub-attributes, for example, share Component represents a shared resource list, the first sub-attribute Component Name represents a shared resource Name, and the second sub-attribute Component Version represents a shared resource Version, so that the menu module shown in fig. 2 can accurately know the registration information related to the second application 200.
In fig. 2, for each attribute, ID represents a unique identifier, names are divided into zh Name and en Name, which respectively represent chinese Name and english Name, parentid represents a parent menu identifier, order represents a menu sort number, href represents a Uniform Resource Locator (URL) address, mfaHash represents a hash Name for triggering loading, share Component is divided into Component Name and Component Version, which respectively represent a shared Resource Name and a shared Resource Version, and group represents other extension fields; for each type, string represents a string type, int represents an integer type, and object represents a software set type of related variables and methods.
The first application 100 and the second application 200 in the micro-headend system 400 may each include a memory and a processor, respectively, wherein the memory and the processor may be connected by a bus or other means.
The memory, as a non-transitory computer-readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer-executable programs. Further, the memory may include high speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and these remote memories may be connected to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The micro-front-end system 400 and the application scenario described in the embodiment of the present invention are for more clearly illustrating the technical solution of the embodiment of the present invention, and do not constitute a limitation to the technical solution provided in the embodiment of the present invention, and it is known to those skilled in the art that the technical solution provided in the embodiment of the present invention is also applicable to similar technical problems with the evolution of the micro-front-end system 400 and the appearance of new application scenarios.
Those skilled in the art will appreciate that the micro-front end system 400 shown in FIG. 1 is not intended to limit embodiments of the present invention and may include more or fewer components than shown, or some components may be combined, or a different arrangement of components.
In the micro-front-end system 400 shown in fig. 1, the first application 100 and the second application 200 may respectively call the resource sharing programs stored therein to execute the resource sharing method.
Based on the structure of the micro front-end system 400, various embodiments of the resource sharing method of the present invention are proposed.
As shown in fig. 3, fig. 3 is a flowchart of a resource sharing method according to an embodiment of the present invention, which can be applied to, but is not limited to, the micro-front-end system shown in the embodiment of fig. 1, and the resource sharing method includes, but is not limited to, steps S100 to S400.
Step S100, the second application sends registration information to the first application, where the registration information includes resource information, and the resource information is used to characterize the feature of the target shared resource that the second application needs to invoke.
In an embodiment, since the registration information can characterize the characteristic conditions of each module or device inside the second application, for example, the registration information includes resource information, that is, discloses the characteristics of the target shared resource that the second application needs to invoke, the second application can make the first application accurately know the internal condition of the second application by sending the registration information to the first application, and use it as the basis of interaction, so as to facilitate to subsequently load the second application as a corresponding reference condition.
In an embodiment, the second application sends the registration information to the first application in a model-driven message middleware manner, that is, the registration information is transmitted based on the model-driven message middleware manner, the information transmission process is relatively stable, the registration information is not easily lost, and good sending efficiency can be ensured.
It should be noted that the type of the registration information may be various, for example, referring to the type shown in fig. 2, and a person skilled in the art may select the registration information according to an actual scenario, which is not limited in this embodiment.
Step S200, the resource management apparatus receives the resource information sent by the first application, and determines a loading policy for the target shared resource according to the resource information and the standby shared resource.
In an embodiment, the resource management device may perform runtime management on the shared resource as an independently running micro application, maintain the currently loaded standby shared resource, and dynamically construct a new resource access address as needed according to a loading policy and introduce the new resource access address to the first application, that is, the resource management device may lay a foundation for the first application to update the resource loading device by determining the loading policy for the first application, so that the first application performs a subsequent corresponding operation according to the loading policy.
It should be noted that, in a certain scenario, the resource management apparatus may also be integrated into the first application for use, which is not limited.
As shown in fig. 4, the step S200 of "determining a loading policy for the target shared resource according to the resource information and the standby shared resource" includes, but is not limited to, steps S210 to S220.
Step S210, the resource management device determines the loading condition of the target shared resource in the resource loading device according to the resource information and the standby shared resource;
in step S220, the resource management device determines a loading policy for the target shared resource according to the loading condition.
In an embodiment, since the resource information is used to characterize the feature of the target shared resource that needs to be invoked by the second application, the resource information is matched with the standby shared resource, so that the actual situation of the target shared resource corresponding to the resource information in the resource loading device can be determined, and based on this, the resource management device can determine an accurate and reliable loading policy according to the loading situation.
Specifically, as shown in fig. 5, step S220 includes, but is not limited to, step S221.
Step S221, in a case that the target shared resource is not loaded in the resource loading device, the resource management device constructs a target access address corresponding to the target shared resource according to the target shared resource, and embeds the target access address into the first application.
In an embodiment, if the target shared resource is loaded in the resource loading device, it indicates that the standby shared resource in the resource loading device already includes the target shared resource, and therefore the resource loading device can be directly applied without adjusting the standby shared resource in the resource loading device, which is a loading policy for the target shared resource in one situation; on the contrary, if the target shared resource is not loaded in the resource loading device, it indicates that the standby shared resource in the resource loading device does not include the target shared resource, and therefore the standby shared resource in the resource loading device needs to be adjusted, so the resource management device constructs a target access address corresponding to the target shared resource according to the target shared resource, and embeds the target access address into the first application, that is, the target shared resource corresponding to the target access address can be introduced into the first application, so that the first application correspondingly updates the resource loading device, that is, the loading policy of the target shared resource in another situation.
It is to be understood that the target access address corresponds to the target shared resource, and therefore, embedding the target access address into the first application is equivalent to introducing the target shared resource into the first application, but this is not a limitation, and other expressions may be used instead of the access address, and it is only necessary to ensure that the replaced expression is related to the target shared resource. In addition, the loading policy is not limited to only being associated with the loading condition of the target shared resource on the resource loading device, and a person skilled in the art may also set the loading policy according to a specific application scenario, which is not limited in this embodiment.
Step S300, the first application receives the loading policy sent by the resource management apparatus, and updates the resource loading apparatus according to the loading policy.
In an embodiment, the first application updates the resource loading device according to the loading policy, so that the resource loading device can dynamically introduce the target shared resource that the second application needs to call as needed, and therefore, the standby shared resource in the updated resource management device includes the target shared resource and can meet the loading requirement.
Specifically, as shown in fig. 6, step S300 includes, but is not limited to, step S310.
Step S310, the first application introduces the target shared resource from the shared resource library according to the target access address and sends the target shared resource to the resource loading device.
In an embodiment, since the target access address corresponds to the target shared resource, the related information of the target shared resource can be determined through the target access address, so that the target shared resource can be introduced from the shared resource library to the resource loading device only through the target access address.
In step S400, the second application calls the target shared resource from the updated resource loading apparatus.
In an embodiment, the resource loading device dynamically introduces the target shared resource required to be called by the second application as required, and the first application and the second application in the micro front-end system are loaded on the same page, so that the second application can directly call the target shared resource from the resource loading device.
In the example of fig. 7, after step S400, step S500 is also included, but not limited to.
Step S500, the first application displays interface elements of the second application, and the interface elements correspond to the target shared resources.
In an embodiment, interface elements of the second application are integrally displayed on the first application, so that the loading condition of the second application can be displayed, the visualization degree for loading the second application is higher, and for a terminal, the loading condition of the second application can be more intuitively known, so that the application requirement of the terminal can be met.
It should be noted that a plurality of second applications may be provided, and the steps of executing the above embodiments by each second application and the related component are not affected by each other, so that, since each application is loaded on the same page, the required component resource can be loaded only once during running, and thus, global shared access can be realized, the effect of saving network bandwidth is achieved, and the access performance is improved; in the process, no matter how many second applications are set, the resource sharing is uniformly managed by the first application, even though the registration information of different second applications may also be changed, the first application can still be dynamically introduced as required according to the loading condition, so that the second application directly calls the required target shared resource, and therefore, the micro front-end system of the embodiment realizes the 'one-time introduction and multiple-time use' of the shared resource, and is concise, reliable and higher in efficiency.
The following continues to give specific examples to illustrate the basic principles of the above-described embodiments.
Example two:
as shown in fig. 8, fig. 8 is a schematic page diagram of a first application according to an embodiment of the present invention.
As shown in fig. 8, the menu area and the module menu area of the second application are integrated on the first application, and the first application also integrates its own function menu area, and specifically, the page presented to the user is composed of 1 portal master application (i.e., the first application) and several independently deployed sub-applications (i.e., the second application). The first application menu area is formed by dynamically combining each second application through menu registration, the menu model information includes resource information of the second application, the second application content display area is arranged in an interface element display container in the first application, a DOM container can be adopted, for the first application, the corresponding second application is dynamically matched and loaded according to the change of the routing address, the first application is rendered on the DOM container, so that the interface element is displayed, a module menu area of the second application is displayed in fig. 8 and is simultaneously rendered on the corresponding DOM container, for different second applications (namely, the second application 1, the second application 2, the second application 3, the second application 4 and the second application 5 shown in fig. 8), the second applications can independently run in different DOM containers after being loaded through the first application, the second applications are isolated from each other, so that the coupling among the function modules is greatly reduced, the integrated display mode shown in fig. 8 ensures that the first application and the second application have good display spaces, and the display effect of the second applications is not influenced by each other, so that the rendering effect of the second applications is improved.
Example three:
as shown in fig. 9, fig. 9 is a schematic diagram of a micro front-end system according to another embodiment of the present invention.
As shown in fig. 10, fig. 10 is a flowchart of the method for performing resource sharing by the micro-head system shown in fig. 9.
In the example of fig. 9, the second application includes two, respectively, a second application 1 and a second application 2, and since the operating principle of the second application 1 is the same as that of the second application 2, in order to avoid redundancy, only one of them is described below, and referring to fig. 9 and fig. 10, an embodiment of a specific operation mode of the micro-front-end system is given.
Firstly, extracting a shared resource component in the second application 1, where the shared resource component includes but is not limited to a component of a target shared resource, and compared with a case where the shared resource component is packaged into an engineering module for individual deployment in the conventional technology, or a case where the shared resource component is stored in a third-party common shared resource library for respective reference, in this embodiment, the extracted shared resource component is selected to be uniformly stored in the shared resource library, a shared access of a similar Content Delivery Network (CDN) is provided, and a code volume after compiling the shared resource component can be reduced.
Secondly, after acquiring the shared resource library address, the resource module may introduce the shared resource component into the head tag of the homepage HTML of the second application 1 by default, and mount the shared resource component on the window global object, so as to ensure that the second application 1 operates normally in the independent access scene, where the second application 1 may add an ignore attribute in the introduced tag as a distinguishing identifier, that is, when the second application 1 is loaded in the micro-front-end system environment, the resource with the ignore attribute may be ignored through the analysis of the first application, and the second application 1 itself during independent access may normally load the component resource through the resource module.
Secondly, the second application 1 registers resource information to the first application through a registration module, and the first application dynamically integrates a page of the second application 1 through a menu module, namely, the menu module receives the registration information from the second application 1 and converts menu tree nodes, so that the registration information is converted into interface elements to be displayed in a portal unit, and meanwhile, corresponding resource information is cached for later use;
the menu information is registered to the first application by the second application 1 in a model-driven message middleware manner, and the menu information includes a unique ID of the second application 1, a displayed Chinese and English name, an IP address, a shared resource list, and the like, where the registration module may register the relevant information of the second application 1 to the first application through the message middleware, specifically, a message middleware deployed in a cluster manner is used to receive the message related to the menu and notify a message terminal monitoring the menu change, and in this embodiment, a kafka cluster is used to implement distributed publishing and subscribing of the message.
Secondly, when a user or a terminal clicks a menu of the second application 1, triggering a page loading process of the second application 1, and starting to judge a resource loading mode of the second application 1, namely, the second application 1 realizes a script and a style of a service function through a function module, thereby exposing a necessary life cycle function to the first application, so that the first application identifies the first application under a micro-front-end system, and on the basis of the life cycle function, judging whether the registered information is registered with resource information, if not, directly loading a target shared resource and isolating a container, otherwise, if the registered resource information is registered, sending the registered resource information to a resource management device for next processing.
Secondly, in the life cycle of the second application 1 page, the resource management device compares the received resource information with the standby shared resource in the resource loading device, if the target shared resource corresponding to the resource information is loaded, the resource information is directly returned without processing, otherwise, if the target shared resource corresponding to the resource information is not loaded, the resource loading device dynamically constructs a target access address corresponding to the target shared resource, and returns the address to the current HTML of the first application, and the address is introduced by the head tag of the current HTML.
Secondly, the first application requests and introduces a target shared resource from the shared resource library according to the address, and mounts the target shared resource to the window global object for the second application 1 to directly call.
And finally, displaying the interface element of the second application 1 to the DOM container of the first application, and finishing the page rendering of the second application 1.
As shown in fig. 11, fig. 11 is a flowchart of a resource sharing method according to another embodiment of the present invention, which may be applied to, but is not limited to, a first application in the micro-front-end system shown in the embodiment of fig. 1, and the resource sharing method includes, but is not limited to, steps S600 to S800.
Step S600, acquiring registration information sent by the second application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of a target shared resource required to be called by the second application;
step S700, sending resource information to a resource management device, so that the resource management device determines a loading strategy aiming at a target shared resource according to the resource information and a standby shared resource;
step S800, receiving the loading policy sent by the resource management apparatus, and updating the resource loading apparatus according to the loading policy, so that the second application invokes the target shared resource from the updated resource loading apparatus.
In an embodiment, the resource management device determines a loading policy by collecting registration information of the second application, and updates the resource loading device according to the loading policy, so that the resource loading device can dynamically introduce a target shared resource that the second application needs to call as needed, and because the first application and the second application in the micro front-end system are loaded on the same page, the second application can directly call the target shared resource from the resource loading device.
Specifically, as shown in fig. 12, "updating the resource loading device according to the loading policy" in step S800 includes, but is not limited to, step S810.
Step S810, introducing the target shared resource from the shared resource library to the resource loading device according to the loading policy under the condition that the target shared resource is not loaded in the resource loading device.
It should be noted that, since the resource sharing method in this embodiment and the resource sharing methods in the foregoing embodiments belong to the same inventive concept, and only the execution subject of the resource sharing method in this embodiment is the first application in the micro front-end system, and the execution subject of the resource sharing method in the foregoing embodiments is the micro front-end system, the specific implementation of the resource sharing method in this embodiment may refer to the specific implementation of the resource sharing method in the foregoing embodiments, and in order to avoid redundancy, the specific implementation of the resource sharing method in this embodiment is not described herein again.
As shown in fig. 13, fig. 13 is a flowchart of a resource sharing method according to another embodiment of the present invention, which can be applied to, but is not limited to, a second application in the micro-front-end system shown in the embodiment of fig. 1, and the resource sharing method includes, but is not limited to, steps S900 to S1000.
Step S900, sending registration information to the first application to enable the first application to send resource information to the resource management device and enable the resource management device to determine a loading strategy aiming at the target shared resource according to the resource information and the standby shared resource, wherein the registration information comprises the resource information, and the resource information is used for representing the characteristics of the target shared resource required to be called by the second application;
step S1000, a target shared resource is called from the updated resource loading device, which is determined by the first application according to the loading policy sent by the resource management device.
In an embodiment, the resource management device determines a loading policy by sending registration information to the first application, and the first application updates the resource loading device according to the loading policy, so that the resource loading device can dynamically introduce the target shared resource required to be called by the second application as required.
Specifically, "send registration information to the first application" in step S900 includes, but is not limited to, step S910.
Step S910, sending registration information to the first application in a model-driven message middleware manner.
Specifically, step S1000 is followed by, but not limited to, step S1100.
Step S1100, an interface element is displayed on the first application, and the interface element corresponds to the target shared resource.
It should be noted that, since the resource sharing method in this embodiment and the resource sharing methods in the foregoing embodiments belong to the same inventive concept, and only the execution subject of the resource sharing method in this embodiment is the second application in the micro front-end system, and the execution subject of the resource sharing method in the foregoing embodiments is the micro front-end system, the specific implementation of the resource sharing method in this embodiment may refer to the specific implementation of the resource sharing method in the foregoing embodiments, and in order to avoid redundancy, the specific implementation of the resource sharing method in this embodiment is not described herein again.
Additionally, referring to fig. 14, an embodiment of the present invention also provides a micro-front end system, including: a first memory, a first processor, and a computer program stored on the first memory and executable on the first processor.
The first processor and the first memory may be connected by a first bus or otherwise.
It should be noted that the server in this embodiment may be applied to, for example, the micro-front-end system in the embodiment shown in fig. 1, and the micro-front-end system in this embodiment can form a part of, for example, the micro-front-end system in the embodiment shown in fig. 1, and these embodiments all belong to the same inventive concept, so these embodiments have the same implementation principle and technical effect, and are not described in detail here.
The non-transitory software programs and instructions required to implement the resource sharing methods of the above embodiments are stored in the first memory and, when executed by the first processor, perform the resource sharing methods of the above embodiments, e.g., performing the above-described method steps S100 to S400 in fig. 3, method steps S210 to S220 in fig. 4, method step S221 in fig. 5, method step S310 in fig. 6, or method step S500 in fig. 7.
In addition, referring to fig. 15, an embodiment of the present invention also provides a network device, including: a second memory, a second processor, and a computer program stored on the second memory and executable on the second processor.
The second processor and the second memory may be connected by a second bus or otherwise.
It should be noted that the network device in this embodiment may be applied to, for example, the micro-front-end system in the embodiment shown in fig. 1, and the network device in this embodiment can form a part of, for example, the micro-front-end system in the embodiment shown in fig. 1, and these embodiments all belong to the same inventive concept, so these embodiments have the same implementation principle and technical effect, and are not described in detail here.
The non-transitory software programs and instructions required to implement the resource sharing methods of the above embodiments are stored in the second memory and, when executed by the second processor, perform the resource sharing methods of the above embodiments, e.g., performing the above-described method steps S600 to S800 in fig. 11 or S810 in fig. 12.
In addition, referring to fig. 16, an embodiment of the present invention also provides a network device, including: a third memory, a third processor, and a computer program stored on the third memory and executable on the third processor.
The third processor and the third memory may be connected by a third bus or otherwise.
It should be noted that the network device in this embodiment may be applied to a micro-front-end system in the embodiment shown in fig. 1, for example, the network device in this embodiment can form a part of the micro-front-end system in the embodiment shown in fig. 1, and these embodiments all belong to the same inventive concept, so these embodiments have the same implementation principle and technical effect, and detailed description is omitted here.
The non-transitory software programs and instructions required to implement the resource sharing methods of the above embodiments are stored in the third memory, and when executed by the third processor, perform the resource sharing methods of the above embodiments, for example, performing the above-described method steps S900 to S1000, method step S910, or method step S1100 in fig. 13.
The above described embodiments of the apparatus are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, may be located in one place, or may be distributed over a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Furthermore, an embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions, which are executed by a first processor, a second processor, a third processor or a controller, for example, by a first processor, a second processor or a third processor in the above-mentioned device embodiment, and can cause the above-mentioned first processor, second processor or third processor to execute the resource sharing method in the above-mentioned embodiment, for example, execute the above-described method steps S100 to S400 in fig. 3, method steps S210 to S220 in fig. 4, method step S221 in fig. 5, method step S310 in fig. 6, method step S500 in fig. 7, method steps S600 to S800 in fig. 11, method step S810 in fig. 12, method steps S900 to S1000 in fig. 13, method step S910 or method step S1100.
One of ordinary skill in the art will appreciate that all or some of the steps, systems, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.
While the preferred embodiments of the present invention have been described in detail, it will be understood by those skilled in the art that the foregoing and various other changes, omissions and deviations in the form and detail thereof may be made without departing from the scope of this invention.
Claims (14)
1. A resource sharing method is applied to a micro-front-end system, the micro-front-end system comprises a first application, a second application and a resource management device, the first application comprises a resource loading device used for loading standby shared resources, and the resource sharing method comprises the following steps:
the second application sends registration information to the first application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of target shared resources required to be called by the second application;
the resource management device receives the resource information sent by the first application, and determines a loading strategy aiming at the target shared resource according to the resource information and the standby shared resource;
the first application receives the loading strategy sent by the resource management device and updates the resource loading device according to the loading strategy;
and the second application calls the target shared resource from the updated resource loading device.
2. The resource sharing method according to claim 1, wherein the resource management device determines a loading policy for the target shared resource according to the resource information and the backup shared resource, and includes:
the resource management device determines the loading condition of the target shared resource in the resource loading device according to the resource information and the standby shared resource;
and the resource management device determines a loading strategy aiming at the target shared resource according to the loading condition.
3. The resource sharing method according to claim 2, wherein the resource management device determines a loading policy for the target shared resource according to the loading condition, and the method comprises:
and under the condition that the target shared resource is not loaded on the resource loading device, the resource management device constructs a target access address corresponding to the target shared resource according to the target shared resource and embeds the target access address into the first application.
4. The resource sharing method of claim 3, wherein the micro-front-end system further comprises a shared resource repository for storing shared resources;
the first application updating the resource loading device according to the loading policy, comprising:
and the first application introduces the target shared resource from the shared resource library according to the target access address and sends the target shared resource to the resource loading device.
5. The resource sharing method according to claim 1, wherein the second application sends registration information to the first application, including:
and the second application sends registration information to the first application in a mode of message middleware driven by a model.
6. The resource sharing method according to claim 1, wherein after the second application calls the target shared resource from the updated resource loading device, further comprising:
the first application presents an interface element of the second application, the interface element corresponding to the target shared resource.
7. A resource sharing method applied to a first application in a micro-front-end system, the first application including a resource loading device for loading a standby shared resource, the micro-front-end system further including a second application and a resource management device, the resource sharing method comprising:
acquiring registration information sent by the second application, wherein the registration information comprises resource information, and the resource information is used for representing the characteristics of a target shared resource required to be called by the second application;
sending the resource information to a resource management device so that the resource management device determines a loading strategy for the target shared resource according to the resource information and the standby shared resource;
and receiving the loading strategy sent by the resource management device, and updating the resource loading device according to the loading strategy so that the second application calls the target shared resource from the updated resource loading device.
8. The resource sharing method of claim 7, wherein the micro-head system further comprises a shared resource repository for storing shared resources;
the updating the resource loading device according to the loading policy includes:
and under the condition that the target shared resource is not loaded on the resource loading device, introducing the target shared resource from the shared resource library to the resource loading device according to the loading strategy.
9. A resource sharing method applied to a second application in a micro-front-end system, the micro-front-end system further comprising a first application and a resource management device, the first application comprising a resource loading device for loading a standby shared resource, the resource sharing method comprising:
sending registration information to the first application, so that the first application sends resource information to the resource management device, and the resource management device determines a loading policy for a target shared resource according to the resource information and the standby shared resource, wherein the registration information includes resource information, and the resource information is used for characterizing features of the target shared resource required to be called by the second application;
invoking the target shared resource from the updated resource loading device, the updated resource loading device being determined by the first application according to the loading policy sent by the resource management device.
10. The resource sharing method of claim 9, wherein the sending registration information to the first application comprises:
and sending the registration information to the first application by adopting a model-driven message middleware mode.
11. The resource sharing method according to claim 9, wherein the invoking the target shared resource from the updated resource loading apparatus further comprises:
displaying an interface element on the first application, the interface element corresponding to the target shared resource.
12. A micro-front end system, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the resource sharing method according to any one of claims 1 to 6 when executing the computer program.
13. A network device, comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the resource sharing method as claimed in claim 7 or 8 or implements the resource sharing method as claimed in any one of claims 9 to 11 when executing the computer program.
14. A computer-readable storage medium storing computer-executable instructions for performing the resource sharing method of any one of claims 1 to 6, or performing the resource sharing method of claim 7 or 8, or performing the resource sharing method of any one of claims 9 to 11.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110914151.8A CN115842733A (en) | 2021-08-10 | 2021-08-10 | Resource sharing method, micro front-end system, application and computer readable storage medium |
PCT/CN2022/093303 WO2023016019A1 (en) | 2021-08-10 | 2022-05-17 | Resource sharing methods and micro-front-end system, application, and computer-readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110914151.8A CN115842733A (en) | 2021-08-10 | 2021-08-10 | Resource sharing method, micro front-end system, application and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115842733A true CN115842733A (en) | 2023-03-24 |
Family
ID=85199807
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110914151.8A Pending CN115842733A (en) | 2021-08-10 | 2021-08-10 | Resource sharing method, micro front-end system, application and computer readable storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN115842733A (en) |
WO (1) | WO2023016019A1 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116501364B (en) * | 2023-05-05 | 2024-06-07 | 南京领行科技股份有限公司 | Application registration method and device and micro front-end system |
CN118093058B (en) * | 2024-04-28 | 2024-07-23 | 浙江锦智人工智能科技有限公司 | Shared component realization method, device and medium based on micro-application |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8832154B1 (en) * | 2009-12-08 | 2014-09-09 | Netapp, Inc. | Object location service for network-based content repository |
CN111737032B (en) * | 2020-07-27 | 2020-11-20 | 腾讯科技(深圳)有限公司 | Subprogram running method and device based on microkernel system and electronic equipment |
CN112948035A (en) * | 2021-01-29 | 2021-06-11 | 北京高途云集教育科技有限公司 | Method and device for controlling micro front-end page, terminal equipment and storage medium |
CN112988153B (en) * | 2021-03-17 | 2023-12-29 | 薪得付信息技术(上海)有限公司 | Data processing method and frame based on micro front end |
-
2021
- 2021-08-10 CN CN202110914151.8A patent/CN115842733A/en active Pending
-
2022
- 2022-05-17 WO PCT/CN2022/093303 patent/WO2023016019A1/en unknown
Also Published As
Publication number | Publication date |
---|---|
WO2023016019A1 (en) | 2023-02-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112073405B (en) | Webpage data loading method and device, computer equipment and storage medium | |
CN108228282B (en) | Method and device for loading website page | |
CN110636093B (en) | Microservice registration and discovery method, microservice registration and discovery device, storage medium and microservice system | |
US20070220083A1 (en) | Estimation of initial dynamic rendering control data | |
CN110413418B (en) | Cache synchronization device and method, cache synchronization system and electronic equipment | |
CN110365724B (en) | Task processing method and device and electronic equipment | |
WO2023016019A1 (en) | Resource sharing methods and micro-front-end system, application, and computer-readable storage medium | |
CN112579319B (en) | Service calling method and device based on LRU Cache optimization | |
CN113779452B (en) | Data processing method, device, equipment and storage medium | |
CN115390897A (en) | Method and device for micro front-end management, electronic equipment and storage medium | |
CN113254753B (en) | Page rollback method, device, electronic equipment and storage medium | |
CN112702441B (en) | Container-based access data processing method, device, system and storage medium | |
CN112114871B (en) | Code sharing method, device, server, terminal and medium | |
CN111813467B (en) | Interface refreshing method and device and readable storage medium | |
CN111338717B (en) | Interface calling method, application program upgrading method, server and client | |
CN112926002A (en) | Service request processing method and device | |
CN111666074B (en) | Web application customization method, related device and system | |
CN112000618B (en) | File change management method, device, equipment and storage medium for cluster nodes | |
CN111400060B (en) | Equipment linkage method, device, server and medium | |
CN111447279B (en) | Server and interface analysis service package generation method | |
CN112765503A (en) | Static processing method and device for page loading data | |
CN113157722A (en) | Data processing method, device, server, system and storage medium | |
CN117883789B (en) | Data acquisition method, apparatus, device, readable storage medium, and program product | |
CN113472903B (en) | Data processing method and device | |
CN118337700A (en) | Application routing method and system, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |