WO2023016019A1 - Resource sharing methods and micro-front-end system, application, and computer-readable storage medium - Google Patents

Resource sharing methods and micro-front-end system, application, and computer-readable storage medium Download PDF

Info

Publication number
WO2023016019A1
WO2023016019A1 PCT/CN2022/093303 CN2022093303W WO2023016019A1 WO 2023016019 A1 WO2023016019 A1 WO 2023016019A1 CN 2022093303 W CN2022093303 W CN 2022093303W WO 2023016019 A1 WO2023016019 A1 WO 2023016019A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource
application
loading
shared resource
information
Prior art date
Application number
PCT/CN2022/093303
Other languages
French (fr)
Chinese (zh)
Inventor
唐华
熊大旺
王淼
孟照星
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2023016019A1 publication Critical patent/WO2023016019A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Definitions

  • Embodiments of the present application relate to but are not limited to the technical field of computer networks, and in particular, relate to a resource sharing method, a micro front-end system, an application, and a computer-readable storage medium.
  • Micro front-end technology is different from server-side technology. Although each front-end application has been split to achieve independent development, independent operation and independent deployment, it still needs to be integrated at the browser level when it is displayed to users. When the browser loads, it will refer to a large number of repeated static dependent resources.
  • This shared basic resource has problems such as repeated packaging, storage space occupation, and low reuse rate of basic library code. It not only wastes network bandwidth at runtime, but also increases Access response time. For this reason, the front-end field proposes to share duplicate network resources to alleviate the above problems.
  • it mainly stores the requested shared resources in the cache of a network node and makes a judgment every time a resource is requested, thereby Choosing to access from the cache or the original resource address has the disadvantage 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 , causing the response time of the access to be extended, and this method cannot rule out the occurrence of repeated requests, which may still waste network bandwidth.
  • Embodiments of the present application provide a resource sharing method, a micro front-end system, an application, and a computer-readable storage medium.
  • the embodiment of the present application provides a resource sharing method, which is applied to a micro front-end system, and the micro front-end system includes a first application, a second application, and a resource management device, and the first application includes a A resource loading device for standby shared resources
  • the resource sharing method includes: the second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the second application The characteristics of the target shared resource to be called; the resource management device receives the resource information sent by the first application, and determines the loading of the target shared resource according to the resource information and the standby shared resource strategy; the first application receives the loading strategy sent by the resource management device, and updates the resource loading device according to the loading strategy; the second application calls from the updated resource loading device The objects share resources.
  • the embodiment of the present application also provides a resource sharing method, which is applied to the first application in the micro front end system, and the first application includes a resource loading device configured to load a spare shared resource, and the micro front end
  • the 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, the registration information including resource information, and the resource information is used to characterize the second application The characteristics of the target shared resource to be called; sending the resource information to the resource management device, so that the resource management device determines the loading strategy for the target shared resource according to the resource information and the standby shared resource; receiving The loading strategy sent by the resource management device, and updating the resource loading device according to the loading policy, so that the second application calls the target shared resource from the updated resource loading device.
  • the embodiment of the present application also provides a resource sharing method, which is applied to the second application in the micro front end system, and the micro front end system also includes a first application and a resource management device, and the first application includes the A resource loading device configured to load standby shared resources
  • 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 makes the resource
  • the management device determines a loading strategy for the target shared resource according to the resource information and the backup shared resource, wherein the registration information includes resource information, and the resource information is used to characterize the The characteristics of the target shared resource; the target shared resource is called from the updated resource loading device, and the updated resource loading device is the first application according to the loading sent by the resource management device. determined by the strategy.
  • the embodiment of the present application also provides a micro front-end system, including: a memory, a processor, and a computer program stored on the memory and operable on the processor, and the processor implements the computer program when executing the computer program.
  • a micro front-end system including: a memory, a processor, and a computer program stored on the memory and operable on the processor, and the processor implements the computer program when executing the computer program.
  • the embodiment of the present application also provides a network device, including: a memory, a processor, and a computer program stored on the memory and operable on the processor.
  • a network device including: a memory, a processor, and a computer program stored on the memory and operable on the processor.
  • the processor executes the computer program, the above-mentioned The resource sharing method in the second aspect, or, implement the resource sharing method in the third aspect as described above.
  • the embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to execute the resource sharing method in the first aspect as described above, or to execute the above-mentioned The resource sharing method in the second aspect, or execute the resource sharing method in the third aspect as described above.
  • FIG. 1 is a schematic diagram of a micro front-end system for performing a resource sharing method provided by an embodiment of the present application
  • Fig. 2 is a schematic diagram of a page of a menu module provided by an embodiment of the present application
  • FIG. 3 is a flowchart of a resource sharing method provided by an embodiment of the present application.
  • FIG. 4 is a flow chart of determining a loading policy by a resource management device in a resource sharing method provided by an embodiment of the present application
  • FIG. 5 is a flow chart of determining a loading policy by a resource management device in a resource sharing method provided by another embodiment of the present application;
  • Fig. 6 is a flow chart of the first application update resource loading device in the resource sharing method provided by an embodiment of the present application
  • FIG. 7 is a flow chart after the second application calls the target shared resource in the resource sharing method provided by an embodiment of the present application
  • Fig. 8 is a schematic diagram of the page of the first application provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of a micro front-end system provided by another embodiment of the present application.
  • Fig. 10 is a flow chart of the resource sharing method performed by the micro front-end system provided by the embodiment shown in Fig. 9;
  • FIG. 11 is a flowchart of a resource sharing method provided by another embodiment of the present application.
  • Fig. 12 is a flowchart of updating a resource loading device in a resource sharing method provided by an embodiment of the present application
  • FIG. 13 is a flowchart of a resource sharing method provided by another embodiment of the present application.
  • Fig. 14 is a schematic diagram of a micro front-end system provided by another embodiment of the present application.
  • Fig. 15 is a schematic diagram of a network device provided by an embodiment of the present application.
  • Fig. 16 is a schematic diagram of a network device provided by another embodiment of the present application.
  • the present application provides a resource sharing method, a micro-frontend system, an application, and a computer-readable storage medium.
  • the first application collects the registration information of the second application so that the resource management device determines the loading strategy, and according to The loading strategy updates the resource loading device, so that the resource loading device can dynamically introduce the target shared resources that the second application needs to call as needed. Since the first application and the second application in the micro front-end system are loaded on the same page, it is available for The second application directly calls the target shared resource from the resource loading device. Compared with some situations, it does not need to perform address access or cache call resource multiple times, so resource sharing can be performed while saving network bandwidth and shortening response delay. It is beneficial to improve the execution efficiency of the micro front-end system for resource sharing.
  • FIG. 1 is a schematic diagram of a micro front-end system 400 for performing a resource sharing method provided by an embodiment of the present application.
  • the micro frontend system 400 includes, but is not limited to: a first application 100, a second application 200, and a resource management device 300.
  • the first application 100 may include, but is not limited to, the Resource loading means 110.
  • the micro front end system 400 may also include a shared resource library, where the shared resource library is used to store shared resources, and the stored shared resources may be spare contribution resources, or other types or forms of shared resources , the shared resource library can be, but not limited to, a micro-application that runs independently, and is responsible for storage and version management of shared resources.
  • the micro-frontend system 400 can be constructed based on micro-services, but not limited to, and can realize related functions of the micro-frontend.
  • the first application 100 and the second application 200 are mutually subordinate, Among them, the first application 100 serves as the main application, and the second application 200 serves as the sub-application, and the normal function execution of the micro front-end system 400 can be realized through cooperation and interaction between the two and the resource management device 300.
  • each second application 200 is a sub-application corresponding to the first application 100, that is, each second application 200 can also realize The normal function of the micro frontend system 400 is executed, therefore, this embodiment does not and does not need to limit the specific number of the second applications 200 .
  • the first application 100 may be the micro-application that the terminal finally accesses, that is, no matter how many applications the terminal accesses, the application that the terminal finally confirms to access is used as the first application 100, so that the determined first application 100 can better match the routing rules under network conditions, so as to more accurately and reliably integrate one or more second applications 200 split from the micro front end, so as to cooperate to realize one or more second applications 200's loading display, communication and resource sharing, 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 (Hyper Text Markup Language, HTML) page, therefore, the second The application 200 can share the resource pool of the first application 100, that is, not only the first application 100 can call the corresponding standby shared resource from the resource loading device 110, but the second application 200 can also call the corresponding standby shared resource from the resource loading device 110 .
  • HTML Hyper Text Markup Language
  • the number of terminals accessing the first application 100 is not limited, it can be set to multiple, and each terminal can be called an access terminal, user equipment (User Equipment, UE), user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, wireless communication device, user agent, or user device.
  • user equipment User Equipment
  • UE User Equipment
  • 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 devices with wireless communication functions, computing devices or other processing devices connected to wireless modems, vehicle-mounted devices, wearable devices, 5G networks or terminal devices in future 5G or higher networks, etc., are not specifically limited in this embodiment.
  • SIP Session Initiation Protocol
  • WLL Wireless Local Loop
  • PDA Personal Digital Assistant
  • the second application 200 can be, but not limited to, a front-end micro-application that can be independently developed and deployed independently according to the division of internal functional modules and has certain functional responsibilities.
  • the second application 200 can run independently or be integrated into Running on the page of the first application 100, the embodiment of the present application is mainly aimed at resource sharing by integrating the second application 200 into running on the page of the first application 100, those skilled in the art can select the second application 200 according to the actual scene
  • the mode of operation is not limited.
  • the second application 200 includes but not limited to functional modules, resource modules, and registration modules.
  • the functional modules can reflect the situation of the life cycle function of the second application 200 itself and display it to the outside, and the resource module is set to be imported and managed with the second application 200 Matching shared resources, the registration module can be applied to the situation when the second application 200 is integrated, can register relevant information inside the second application 200 to the first application 100, and can monitor menus and receive menu-related information definition files (For example, it can be an identification information file, a resource information file, and a serial number information file, etc.), so that the terminal can know the possible changes in the menu.
  • menu-related information definition files For example, it can be an identification information file, a resource information file, and a serial number information file, etc.
  • the resource loading device 110 is provided as a resource pool, which can accommodate different shared resources as backup, and has the capability of continuous updating, that is, under the action of the first application 100, new shared resources can be continuously introduced. , to achieve the effect of updating shared resources in a timely manner.
  • the resource loading device 110 can also be set as an independently running micro-application, that is, the resource loading device 110 is distinguished from the first application 100, which does not affect the function execution of the resource loading device 110; in addition, other types of modules can also be integrated inside the first application 100, for example, the first application 100 also includes but is not limited to a routing loading module, a menu module and a document object model (Document Object Model, DOM) container, etc., wherein, the route loading module is set to respond to route switching and trigger the loading of the corresponding second application 200, thereby displaying the interface elements of the second application 200 to the DOM container, and the menu module is responsible for receiving and displaying information from the second application
  • the registration information of the application 200 can cache the content information of one or more shared resources corresponding to the second application 200 at the same time, and the DOM container, as a kind of HTML container, can be used to display the interface elements of the second application 200, so that the second The degree of visualization of the application 200 becomes higher.
  • FIG. 2 shows a form of a menu module presented in a table. It can be seen from FIG. 2 that the types and meanings of the attributes corresponding to the second application 200 are determined in one-to-one correspondence. For example, the ID corresponds to the string type and is a unique identifier.
  • mfaHash embodies the routing rule that triggers the loading of the second application 200, and also serves as the globally unique name of the second application 200; Shown together, for example, Share Component embodies the shared resource list, the first subattribute Component Name embodies the name of the shared resource, and the second subattribute Component Version embodies the shared resource version, therefore, the menu module shown in Figure 2 can accurately The registration information about the second application 200 is obtained.
  • ID represents a unique identifier
  • name is divided into zh name and en name, representing the Chinese name and English name respectively
  • parentid represents the parent menu identification
  • order represents the menu sorting number
  • href represents the uniform resource locator ( Uniform Resource Locator, URL) address
  • mfaHash indicates the hash name that triggers loading
  • Share Component is divided into Component Name and Component Version, which respectively indicate the shared resource name and shared resource version
  • group indicates other extended fields; for each type, string indicates characters String type, int means integer type, and object means software set type of related variables and methods.
  • Both the first application 100 and the second application 200 in the micro-frontend system 400 may respectively include a memory and a processor, wherein the memory and the processor may be connected through a bus or in other ways.
  • memory can be configured to store non-transitory software programs and non-transitory computer-executable programs.
  • the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices.
  • the memory may include memory located remotely from the processor, which remote memory may be connected to the processor through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • micro front-end system 400 and the application scenarios described in the embodiment of the present application are to illustrate the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation to the technical solutions provided in the embodiments of the present application.
  • Those skilled in the art know that as With the evolution of the micro front-end system 400 and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
  • micro front end system 400 shown in FIG. layout of the components.
  • the first application 100 and the second application 200 can respectively call their stored resource sharing programs to execute the resource sharing method.
  • Figure 3 is a flow chart of a resource sharing method provided by an embodiment of the present application, which can be but not limited to be applied to the micro front-end system shown in the embodiment of Figure 1, the resource sharing method includes but is not limited to the steps S100 to S400.
  • Step S100 the second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call.
  • the registration information can represent the characteristics of each module or device inside the second application, for example, the registration information includes resource information, which discloses the characteristics of the target shared resource that the second application needs to call, therefore, By sending the registration information to the first application, the second application can make the first application accurately know the internal situation of the second application, and use it as a basis for interaction, so as to facilitate subsequent loading of the second application as a corresponding reference condition.
  • the second application uses the model-driven message middleware method to send registration information to the first application, that is, the information is transmitted based on the model-driven message middleware method, the information transmission process is relatively stable, and registration information is not easy to occur. In the case of information loss, good sending efficiency can be guaranteed.
  • step S200 the resource management device receives the resource information sent by the first application, and determines a loading strategy for the target shared resource according to the resource information and the standby shared resource.
  • the resource management device can be used as an independently running micro-application to manage the shared resources at runtime, maintain the currently loaded standby shared resources, and dynamically construct new resource access addresses as needed according to the loading strategy and introduce them to the first An application, that is, by determining the loading policy for the first application, the resource management device can lay a foundation for the first application to update the resource loading device, so that the first application performs subsequent corresponding operations according to the loading policy.
  • the resource management device may also be integrated into the first application for use, which is not limited.
  • step S200 includes but is not limited to steps S210 to S220.
  • Step S210 the resource management device determines the loading status of the target shared resource in the resource loading device according to the resource information and the backup shared resource;
  • step S220 the resource management device determines a loading strategy for the target shared resource according to the loading situation.
  • the resource management device can determine an accurate and reliable loading strategy according to the loading situation.
  • step S220 includes but is not limited to step S221.
  • Step S221 if 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.
  • the target shared resource is loaded on the resource loading device, it means that the backup shared resource in the resource loading device already contains the target shared resource, so there is no need to adjust the backup shared resource in the resource loading device, and you can directly Applying the resource loading device, this is a loading strategy 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 means that the backup shared resource in the resource loading device does not include the target shared resource, Therefore, it is necessary to adjust the spare shared resources in the resource loading device.
  • the resource management device constructs the 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, equivalent to The target shared resource corresponding to the target access address can be introduced into the first application, so that the first application can correspondingly update the resource loading device, which is the loading strategy of the target shared resource in another situation.
  • the target access address corresponds to the target shared resource. Therefore, embedding the target access address into the first application is equivalent to introducing the target shared resource into the first application.
  • Other forms of expression replace the access address, as long as the replaced form of expression is related to the target shared resource.
  • the loading policy is not limited to only being related to the loading situation of the target shared resource on the resource loading device, and those skilled in the art can also set the loading policy according to specific application scenarios, which is not limited in this embodiment.
  • Step S300 the first application receives the loading policy sent by the resource management device, and updates the resource loading device according to the loading policy.
  • the first application updates the resource loading device according to the loading strategy, so that the resource loading device can dynamically introduce the target shared resources that the second application needs to call as needed. Therefore, the backup shared resources in the updated resource management device Resources, including target shared resources, are able to meet loading requirements.
  • step S300 includes but is not limited to step S310.
  • Step S310 the first application imports 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.
  • the relevant information of the target shared resource can be determined through the target access address, so that the target shared resource can be imported from the shared resource library only through the target access address.
  • the loading strategy can realize the introduction of shared resources only depending on the network access address, without consuming a large amount of network resources, which is beneficial to reduce network costs.
  • Step S400 the second application invokes the target shared resource from the updated resource loading device.
  • the resource loading device dynamically imports the target shared resources that the second application needs to call as needed. Since the first application and the second application in the micro frontend system are loaded on the same page, they can be used by the second application Directly call the target shared resource from the resource loading device. Compared with some situations, there is no need to perform multiple address access or cache call resources. Therefore, resource sharing can be carried out while saving network bandwidth and shortening response delay, which is conducive to improving micro The execution efficiency of the front-end system for resource sharing.
  • 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 target shared resources.
  • the interface elements of the second application integratedly on the first application, it can be used to display the loading status of the second application, so that the visibility of loading the second application becomes higher.
  • the terminal it is possible to understand the loading situation of the second application more intuitively, so as to meet the application requirements of the terminal.
  • each second application and related components execute the steps of the above embodiments independently of each other. Therefore, since each application is loaded on the same page, the required component resources are running It can be loaded only once to achieve global shared access, saving network bandwidth and improving access performance; in this process, no matter how many second applications are set, resource sharing is managed by the first application in a unified manner , even though the registration information of different second applications may change, the first application will still implement dynamic on-demand import according to the loading situation, so that the second application can directly call the required target shared resources. Therefore, this implementation
  • the micro-frontend system of the example realizes "one-time introduction, multiple use" of shared resources, which is simple, reliable and more efficient.
  • FIG. 8 is a schematic diagram of a page of a first application provided by an embodiment of the present application.
  • the menu area and the module menu area of the second application are integrated into the first application, and the first application also integrates its own function menu area.
  • the page presented to the user is composed of a Portal main application (namely the first application) and several independently deployed sub-applications (namely the second application).
  • the first application menu area is dynamically combined by each second application through menu registration.
  • the menu model information includes the resource information of the second application.
  • the second application content display area is set in the interface element display container inside the first application, which can Using a DOM container, for the first application, dynamically match and load the corresponding second application according to the change of the routing address, and render it to a DOM container to display its interface elements, as shown in Figure 8
  • the module menu area of the second application is also rendered to the corresponding DOM container at the same time.
  • the second application 5 through the first application, each second application can run independently in different DOM containers after being loaded, and be isolated from each other, so that the coupling between the various functional modules is greatly reduced. It can be seen that, as The integrated display method shown in FIG. 8 ensures that both the first application and the second application have a good display space, and the second applications do not affect each other, thereby improving the rendering and display effect of the second application.
  • FIG. 9 is a schematic diagram of a micro front-end system provided by another embodiment of the present application.
  • FIG. 10 is a flow chart of the resource sharing method performed by the micro front-end system shown in FIG. 9 .
  • the second application includes two, respectively, the second application 1 and the second application 2. Since the second application 1 and the second application 2 work on the same principle, in order to avoid redundancy, only One of them is used for illustration, referring to FIG. 9 and FIG. 10 , an embodiment of a specific operation mode of the micro front-end system is given.
  • the shared resource component in the second application 1 is extracted, the shared resource component includes but not limited to the component of the target shared resource.
  • the shared resource component includes but not limited to the component of the target shared resource.
  • this embodiment chooses to uniformly store the extracted shared resource components in the shared resource library to provide a similar Content Delivery Network (Content Delivery Network, CDN) shared access can reduce the code volume of compiled shared resource components.
  • CDN Content Delivery Network
  • the resource module can import the shared resource component into the head tag of the home page HTML of the second application 1 by default, and mount it in the window global object to ensure that the second application 1 is in the independent access scenario It is running normally, and the second application 1 can add the ignore attribute in the imported tag as a distinguishing mark, that is, when the second application 1 is loaded in the micro-frontend system environment, after the analysis of the first application, it will The loading of the resources with the ignore attribute is ignored, and the second application 1 itself can normally load the component resources through the resource module during independent access.
  • the second application 1 registers resource information with the first application through the registration module, and the first application dynamically integrates the pages of the second application 1 through the menu module, that is, the menu module receives the registration information from the second application 1 and performs Conversion, so that the registration information is converted into interface elements to be displayed on the portal unit, and the corresponding resource information is cached for backup;
  • the menu information is registered from the second application 1 to the first application by adopting a model-driven message middleware method, and the menu information includes the unique ID of the second application 1, the displayed Chinese and English names, the IP address and the list of shared resources, etc.
  • the registration module can register the relevant information of the second application 1 to the first application through the message middleware.
  • the message middleware deployed in a cluster mode is used to receive menu-related messages and notify the message terminals that monitor menu changes.
  • a kafka cluster is used to implement distributed publication and subscription of messages.
  • the page loading process of the second application 1 is triggered, and the resource loading method of the second application 1 is judged, that is, the script of the second application 1 to realize the business function through the function module and style, so as to expose the necessary life cycle function to the first application, so that the first application can identify it under the micro front-end system, and judge whether the registration information has resource information registered on the basis of the life cycle function, if If it is not registered, it will directly load the target shared resource and perform container isolation. On the contrary, if it has been registered, it will send the registered resource information to the resource management device for further processing.
  • the resource management device compares the received resource information with the spare shared resource in the resource loading device, and if the target shared resource corresponding to the resource information has been loaded, directly returns the resource Information, do not process it, otherwise, if the target shared resource corresponding to the resource information has not been loaded, then the target access address corresponding to the target shared resource is dynamically constructed by the resource loading device, and the address is returned to the current HTML of the first application, Introduced by the head tag of the current HTML.
  • the first application requests and imports the target shared resource from the shared resource library according to the address, and mounts it to the window global object for direct calling by the second application 1 .
  • Figure 11 is a flow chart of a resource sharing method provided by another embodiment of the present application, which can be but not limited to be applied to the first application in the micro front-end system shown in the embodiment of Figure 1, the resource sharing The method includes but not limited to steps S600 to S800.
  • Step S600 obtaining the registration information sent by the second application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
  • Step S700 sending resource information to the 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 backup shared resource;
  • Step S800 receiving the loading policy sent by the resource management device, and updating the resource loading device according to the loading policy, so that the second application calls the target shared resource from the updated resource loading device.
  • the resource management device determines 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 that the second application needs to call Shared resources, since the first application and the second application are loaded on the same page in the micro-frontend system, the second application can directly call the target shared resource from the resource loading device.
  • the resource management device determines 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 that the second application needs to call Shared resources, since the first application and the second application are loaded on the same page in the micro-frontend system, the second application can directly call the target shared resource from the resource loading device.
  • resource sharing can be performed while saving network bandwidth and shortening response delay, which is conducive to improving the execution efficiency of the micro front-end system for resource sharing.
  • step S800 includes but is not limited to step S810.
  • Step S810 if the target shared resource is not loaded in the resource loading device, import the target shared resource from the shared resource library to the resource loading device according to the loading strategy.
  • the execution subject of the resource sharing method in this embodiment is the first
  • the execution subject of the resource sharing method in the above-mentioned embodiments is the micro front-end system, so the specific implementation manner of the resource sharing method in this embodiment can refer to the specific embodiments of the resource sharing method in the above-mentioned embodiments, In order to avoid redundancy, the specific implementation manner of the resource sharing method in this embodiment will not be repeated here.
  • Figure 13 is a flowchart of a resource sharing method provided by another embodiment of the present application, which can be but not limited to be applied to the second application in the micro front-end system shown in the embodiment of Figure 1, the resource sharing The method includes but not limited to steps S900 to S1000.
  • Step S900 sending registration information to the first application, so that the first application sends resource information to the resource management device, and makes the resource management device determine a loading policy for the target shared resource according to the resource information and the backup shared resource, wherein the registration information includes Resource information, the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
  • Step S1000 call the target shared resource from the updated resource loading device, the updated resource loading device is determined by the first application according to the loading strategy sent by the resource management device.
  • the resource management device determines the loading policy by sending the registration information to the first application, and makes the first application update the resource loading device according to the loading policy, so that the resource loading device can dynamically import the resource loaded by the second application as needed.
  • the target shared resource that needs to be called because the first application and the second application in the micro front-end system are loaded on the same page, so the target shared resource can be called directly from the resource loading device. Access or cache call resources, so resource sharing can be performed while saving network bandwidth and shortening response delay, which is conducive to improving the execution efficiency of the micro front-end system for resource sharing.
  • step S900 sending registration information to the first application includes but is not limited to step S910.
  • step S910 the registration information is sent to the first application in a model-driven message middleware manner.
  • step S1100 is also included after step S1000.
  • Step S1100 display interface elements on the first application, where the interface elements correspond to target shared resources.
  • the resource sharing method in this embodiment and the resource sharing methods in the above-mentioned embodiments belong to the same inventive concept, the only difference is that the execution subject of the resource sharing method in this embodiment is the first Two applications, the execution subject of the resource sharing method in the above-mentioned embodiments is the micro front-end system, so the specific implementation manner of the resource sharing method in this embodiment can refer to the specific embodiments of the resource sharing method in the above-mentioned embodiments, In order to avoid redundancy, the specific implementation manner of the resource sharing method in this embodiment will not be repeated here.
  • an embodiment of the present application also provides a micro front-end system
  • the micro front-end system includes: a first memory, a first processor, and a A computer program that runs.
  • the first processor and the first memory may be connected through a first bus or in other ways.
  • server in this embodiment can be applied, for example, to the micro front-end system in the embodiment shown in FIG.
  • micro front-end system in the embodiment shown in FIG.
  • the non-transitory software programs and instructions required to realize the resource sharing method of the above-mentioned embodiments are stored in the first memory, and when executed by the first processor, the resource sharing methods of the above-mentioned embodiments are executed, for example, 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 .
  • an embodiment of the present application also provides a network device, which includes: a second memory, a second processor, and a program stored in the second memory and operable on the second processor.
  • a network device which includes: a second memory, a second processor, and a program stored in the second memory and operable on the second processor.
  • Computer program stored in the second memory and operable on the second processor.
  • the second processor and the second memory may be connected through a second bus or in other ways.
  • the network device in this embodiment can be applied, for example, to the micro front-end system in the embodiment shown in Figure 1, and the network device in this embodiment can constitute, for example, the micro front-end system in the embodiment shown in Figure 1
  • the network device in this embodiment can constitute, for example, the micro front-end system in the embodiment shown in Figure 1
  • the non-transitory software programs and instructions required to realize the resource sharing method of the above-mentioned embodiments are stored in the second memory, and when executed by the second processor, the resource sharing methods of the above-mentioned embodiments are executed, for example, the above-described Method steps S600 to S800 in FIG. 11 or method step S810 in FIG. 12 .
  • an embodiment of the present application also provides a network device, the network device includes: a third memory, a third processor, and a program stored in the third memory and operable on the third processor Computer program.
  • the third processor and the third memory may be connected through a third bus or in other ways.
  • the network device in this embodiment can be applied, for example, to the micro front-end system in the embodiment shown in Figure 1, and the network device in this embodiment can constitute, for example, the micro front-end system in the embodiment shown in Figure 1
  • the network device in this embodiment can constitute, for example, the micro front-end system in the embodiment shown in Figure 1
  • the non-transitory software programs and instructions required to realize the resource sharing method of the above-mentioned embodiments are stored in the third memory, and when executed by the third processor, the resource sharing methods of the above-mentioned embodiments are executed, for example, the above-described Method steps S900 to S1000, method step S910 or method step S1100 in FIG. 13 .
  • the device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • an embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a first processor, a second processor, and a second processor. Execution by three processors or controllers, for example, being executed by a first processor, a second processor or a third processor in the above-mentioned device embodiment, may cause the above-mentioned first processor, second processor or third processing
  • the device executes the resource sharing method in the above embodiment, for example, executes the method steps S100 to S400 in FIG. 3 described above, the method steps S210 to S220 in FIG. 4 , the method step S221 in FIG. 5 , and the method in FIG. 6 Step S310, method step S500 in FIG. 7, method step S600 to S800 in FIG. 11, method step S810 in FIG. 12, method step S900 to S1000 in FIG. 13, method step S910 or method step S1100.
  • the embodiment of the present application includes: a resource sharing method applied to a micro front-end system, 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 configured to load a backup shared resource, and the resource sharing
  • the method includes: the second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call; the resource management device receives the resource information sent by the first application , and determine the loading strategy for 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; the second application loads the device from the updated resource Invoking the target shared resource.
  • the first application collects the registration information of the second application so that the resource management device determines the loading strategy, and updates the resource loading device according to the loading strategy, so that the resource loading device can press It is necessary to dynamically introduce the target shared resource that the second application needs to call. Since the first application and the second application in the micro-frontend system are loaded on the same page, the second application can directly call the target shared resource from the resource loading device. Compared with some situations, there is no need to perform address access or cache call resources multiple times, so resource sharing can be performed while saving network bandwidth and shortening response delay, which is conducive to improving the execution efficiency of the micro front-end system for resource sharing.
  • Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, tape, magnetic disk storage or other magnetic storage devices, or can Any other medium used to store desired information and which can be accessed by a computer.
  • 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 may include any information delivery media .

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

Resource sharing methods, a micro-front-end system, an application, and a computer-readable storage medium. A resource sharing method is applied to a micro-front-end system. The micro-front-end system comprises a first application (100), a second application (200), and a resource management apparatus (300). The first application (100) comprises a resource loading apparatus (110) that is configured to load a standby shared resource. The method comprises: a second application sending registration information to a first application, the registration information comprising resource information, and the resource information being used to represent a feature of a target shared resource that needs to be invoked by the second application (S100); a resource management apparatus determining, according to the resource information and the standby shared resource, a loading policy for the target shared resource (S200); the first application updating a resource loading apparatus according to the loading policy (S300); and the second application invoking the target shared resource from the updated resource loading apparatus (S400).

Description

资源共享方法及微前端系统、应用、计算机可读存储介质Resource sharing method, micro-frontend system, application, and computer-readable storage medium
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202110914151.8,申请日为2021年08月10日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with application number 202110914151.8 and a filing date of August 10, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated by reference into this application.
技术领域technical field
本申请实施例涉及但不限于计算机网络技术领域,尤其涉及一种资源共享方法及微前端系统、应用、计算机可读存储介质。Embodiments of the present application relate to but are not limited to the technical field of computer networks, and in particular, relate to a resource sharing method, a micro front-end system, an application, and a computer-readable storage medium.
背景技术Background technique
目前,在前端领域内,单页面应用是广泛受到关注及使用的一种项目形态,但随着时间的推移以及应用功能的丰富,单页面应用的单一性变得越来越差且越来越难以维护,往往是改动其一处而影响单页面应用全身,由此带来的发版成本也越来越高。针对此问题,业界提出了微服务概念,即,将这些庞大的应用进行拆分并随之解耦,使得每个模块可以单独进行维护和部署,从而提升了开发效率。微服务概念也随之应用到前端领域,即微前端,其核心思想为将网络应用由单一的单体应用转变为多个小型前端应用聚合为一的多个应用。At present, in the front-end field, single-page applications are widely concerned and used as a project form, but with the passage of time and the enrichment of application functions, the single-page applications become less and less single and more and more Difficult to maintain, often changing one of them will affect the whole single page application, and the resulting cost of publishing is getting higher and higher. In response to this problem, the industry has proposed the concept of microservices, that is, to split and decouple these huge applications, so that each module can be maintained and deployed independently, thereby improving development efficiency. The concept of microservices is also applied to the front-end field, that is, the micro-frontend. Its core idea is to transform the network application from a single single application to multiple applications that aggregate multiple small front-end applications into one.
微前端技术区别于服务端技术,虽然各个前端应用经过拆分实现了独立开发、独立运行和独立部署,但在展示给用户时仍需要在浏览器进行一次页面级整合,在整合后于同一个浏览器加载时,会存在引用大量重复的静态依赖资源,这种共用的基础资源存在重复打包、占用存储空间以及基础库代码复用率不高等问题,在运行时不仅浪费网络带宽,还增加了访问的响应时间。为此,前端领域提出了将重复的网络资源进行共享,以缓解上述问题,一些情形下,主要通过将已请求的共享资源存放于某网络节点的缓存,在每次资源请求时进行判断,从而选择从缓存或原始资源地址访问,其缺点是增加了资源请求的计算复杂度,同时增加了管理缓存资源的复杂程度,例如,当涉及到多次资源请求,则可能需要同时管理大量的缓存资源,造成访问的响应时间延长,并且,该方式无法排除出现重复请求的情况,仍然可能浪费网络带宽。Micro front-end technology is different from server-side technology. Although each front-end application has been split to achieve independent development, independent operation and independent deployment, it still needs to be integrated at the browser level when it is displayed to users. When the browser loads, it will refer to a large number of repeated static dependent resources. This shared basic resource has problems such as repeated packaging, storage space occupation, and low reuse rate of basic library code. It not only wastes network bandwidth at runtime, but also increases Access response time. For this reason, the front-end field proposes to share duplicate network resources to alleviate the above problems. In some cases, it mainly stores the requested shared resources in the cache of a network node and makes a judgment every time a resource is requested, thereby Choosing to access from the cache or the original resource address has the disadvantage 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 , causing the response time of the access to be extended, and this method cannot rule out the occurrence of repeated requests, which may still waste network bandwidth.
发明内容Contents of the invention
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。The following is an overview of the topics described in detail in this article. This summary is not intended to limit the scope of the claims.
本申请实施例提供了一种资源共享方法及微前端系统、应用、计算机可读存储介质。Embodiments of the present application provide a resource sharing method, a micro front-end system, an application, and a computer-readable storage medium.
第一方面,本申请实施例提供了一种资源共享方法,应用于微前端系统,所述微前端系统包括第一应用、第二应用和资源管理装置,所述第一应用包括被设置为加载备用共享资源的资源加载装置,所述资源共享方法包括:所述第二应用向所述第一应用发送注册信息,所述注册信息包括资源信息,所述资源信息用于表征所述第二应用所需调用的目标共享资源的特征;所述资源管理装置接收由所述第一应用发送的所述资源信息,并根据所述资源信息和所述备用共享资源确定针对所述目标共享资源的加载策略;所述第一应用接收由所述资源管理装置发送的所述加载策略,并根据所述加载策略更新所述资源加载装置;所述第二应用从更新后的所述资源加载装置中调用所述目标共享资源。In the first aspect, the embodiment of the present application provides a resource sharing method, which is applied to a micro front-end system, and the micro front-end system includes a first application, a second application, and a resource management device, and the first application includes a A resource loading device for standby shared resources, the resource sharing method includes: the second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the second application The characteristics of the target shared resource to be called; the resource management device receives the resource information sent by the first application, and determines the loading of the target shared resource according to the resource information and the standby shared resource strategy; the first application receives the loading strategy sent by the resource management device, and updates the resource loading device according to the loading strategy; the second application calls from the updated resource loading device The objects share resources.
第二方面,本申请实施例还提供了一种资源共享方法,应用于微前端系统中的第一应用,所述第一应用包括被设置为加载备用共享资源的资源加载装置,所述微前端系统还包括第二应用和资源管理装置,所述资源共享方法包括:获取由所述第二应用发送的注册信息,所述注册信息包括资源信息,所述资源信息用于表征所述第二应用所需调用的目标共享资源的特征;向资源管理装置发送所述资源信息,以使所述资源管理装置根据所述资源信息和所述备用共享资源确定针对所述目标共享资源的加载策略;接收由所述资源管理装置发送的所述加载策略,并 根据所述加载策略更新所述资源加载装置,以使所述第二应用从更新后的所述资源加载装置中调用所述目标共享资源。In the second aspect, the embodiment of the present application also provides a resource sharing method, which is applied to the first application in the micro front end system, and the first application includes a resource loading device configured to load a spare shared resource, and the micro front end The 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, the registration information including resource information, and the resource information is used to characterize the second application The characteristics of the target shared resource to be called; sending the resource information to the resource management device, so that the resource management device determines the loading strategy for the target shared resource according to the resource information and the standby shared resource; receiving The loading strategy sent by the resource management device, and updating the resource loading device according to the loading policy, so that the second application calls the target shared resource from the updated resource loading device.
第三方面,本申请实施例还提供了一种资源共享方法,应用于微前端系统中的第二应用,所述微前端系统还包括第一应用和资源管理装置,所述第一应用包括被设置为加载备用共享资源的资源加载装置,所述资源共享方法包括:向所述第一应用发送注册信息,以使所述第一应用向所述资源管理装置发送资源信息,并且使得所述资源管理装置根据所述资源信息和所述备用共享资源确定针对目标共享资源的加载策略,其中,所述注册信息包括资源信息,所述资源信息用于表征所述第二应用所需调用的所述目标共享资源的特征;从更新后的所述资源加载装置中调用所述目标共享资源,更新后的所述资源加载装置为由所述第一应用根据由所述资源管理装置发送的所述加载策略而确定。In the third aspect, the embodiment of the present application also provides a resource sharing method, which is applied to the second application in the micro front end system, and the micro front end system also includes a first application and a resource management device, and the first application includes the A resource loading device configured to load standby shared resources, 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 makes the resource The management device determines a loading strategy for the target shared resource according to the resource information and the backup shared resource, wherein the registration information includes resource information, and the resource information is used to characterize the The characteristics of the target shared resource; the target shared resource is called from the updated resource loading device, and the updated resource loading device is the first application according to the loading sent by the resource management device. determined by the strategy.
第四方面,本申请实施例还提供了一种微前端系统,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上所述第一方面的资源共享方法。In the fourth aspect, the embodiment of the present application also provides a micro front-end system, including: a memory, a processor, and a computer program stored on the memory and operable on the processor, and the processor implements the computer program when executing the computer program. The resource sharing method of the first aspect as mentioned above.
第五方面,本申请实施例还提供了一种网络设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现如上所述第二方面的资源共享方法,或者,实现如上所述第三方面的资源共享方法。In the fifth aspect, the embodiment of the present application also provides a network device, including: a memory, a processor, and a computer program stored on the memory and operable on the processor. When the processor executes the computer program, the above-mentioned The resource sharing method in the second aspect, or, implement the resource sharing method in the third aspect as described above.
第六方面,本申请实施例还提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行如上所述第一方面的资源共享方法,或者,执行如上所述第二方面的资源共享方法,或者,执行如上所述第三方面的资源共享方法。In the sixth aspect, the embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to execute the resource sharing method in the first aspect as described above, or to execute the above-mentioned The resource sharing method in the second aspect, or execute the resource sharing method in the third aspect as described above.
本申请的其它特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过实施本申请而了解。本申请的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Additional features and advantages of the application will be set forth in the description which follows, and, in part, will be obvious from the description, or may be learned by practice of the application. The objectives and other advantages of the application will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
附图说明Description of drawings
附图用来提供对本申请技术方案的进一步理解,并且构成说明书的一部分,与本申请的实施例一起用于解释本申请的技术方案,并不构成对本申请技术方案的限制。The accompanying drawings are used to provide a further understanding of the technical solution of the present application, and constitute a part of the specification, and are used together with the embodiments of the present application to explain the technical solution of the present application, and do not constitute a limitation to the technical solution of the present application.
图1是本申请一个实施例提供的用于执行资源共享方法的微前端系统的示意图;FIG. 1 is a schematic diagram of a micro front-end system for performing a resource sharing method provided by an embodiment of the present application;
图2是本申请一个实施例提供的菜单模块的页面示意图;Fig. 2 is a schematic diagram of a page of a menu module provided by an embodiment of the present application;
图3是本申请一个实施例提供的资源共享方法的流程图;FIG. 3 is a flowchart of a resource sharing method provided by an embodiment of the present application;
图4是本申请一个实施例提供的资源共享方法中的资源管理装置确定加载策略的流程图;FIG. 4 is a flow chart of determining a loading policy by a resource management device in a resource sharing method provided by an embodiment of the present application;
图5是本申请另一个实施例提供的资源共享方法中的资源管理装置确定加载策略的流程图;FIG. 5 is a flow chart of determining a loading policy by a resource management device in a resource sharing method provided by another embodiment of the present application;
图6是本申请一个实施例提供的资源共享方法中的第一应用更新资源加载装置的流程图;Fig. 6 is a flow chart of the first application update resource loading device in the resource sharing method provided by an embodiment of the present application;
图7是本申请一个实施例提供的资源共享方法中的第二应用调用目标共享资源之后的流程图;FIG. 7 is a flow chart after the second application calls the target shared resource in the resource sharing method provided by an embodiment of the present application;
图8是本申请一个实施例提供的第一应用的页面示意图;Fig. 8 is a schematic diagram of the page of the first application provided by an embodiment of the present application;
图9是本申请另一个实施例提供的微前端系统的示意图;FIG. 9 is a schematic diagram of a micro front-end system provided by another embodiment of the present application;
图10是图9所示实施例所提供的微前端系统执行资源共享方法的流程图;Fig. 10 is a flow chart of the resource sharing method performed by the micro front-end system provided by the embodiment shown in Fig. 9;
图11是本申请另一个实施例提供的资源共享方法的流程图;FIG. 11 is a flowchart of a resource sharing method provided by another embodiment of the present application;
图12是本申请一个实施例提供的资源共享方法中更新资源加载装置的流程图;Fig. 12 is a flowchart of updating a resource loading device in a resource sharing method provided by an embodiment of the present application;
图13是本申请另一个实施例提供的资源共享方法的流程图;FIG. 13 is a flowchart of a resource sharing method provided by another embodiment of the present application;
图14是本申请另一个实施例提供的微前端系统的示意图;Fig. 14 is a schematic diagram of a micro front-end system provided by another embodiment of the present application;
图15是本申请一个实施例提供的一种网络设备的示意图;Fig. 15 is a schematic diagram of a network device provided by an embodiment of the present application;
图16是本申请另一个实施例提供的一种网络设备的示意图。Fig. 16 is a schematic diagram of a network device provided by another embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请 进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solutions and advantages of the application clearer, the application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, not to limit the present application.
需要注意的是,虽然在装置示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置中的模块划分,或流程图中的顺序执行所示出或描述的步骤。说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。It should be noted that although the functional modules are divided in the schematic diagram of the device, and the logical sequence is shown in the flowchart, in some cases, it can be executed in a different order than the module division in the device or the flowchart in the flowchart. steps shown or described. The terms "first", "second" and the like in the specification and claims and the above drawings are used to distinguish similar objects, and not necessarily used to describe a specific sequence or sequence.
本申请提供了一种资源共享方法及微前端系统、应用、计算机可读存储介质,在微前端系统中,第一应用通过收集第二应用的注册信息而使得资源管理装置确定加载策略,并且根据加载策略更新资源加载装置,使得资源加载装置能够按需动态地引入第二应用所需调用的目标共享资源,由于在微前端系统中的第一应用和第二应用在同一页面加载,因此可供第二应用直接从资源加载装置调用目标共享资源,相比于一些情形,无需多次地进行地址访问或者缓存调用资源,因此能够在节省网络带宽、缩短响应延时的情况下进行资源共享,有利于提升微前端系统针对资源共享的执行效率。The present application provides a resource sharing method, a micro-frontend system, an application, and a computer-readable storage medium. In the micro-frontend system, the first application collects the registration information of the second application so that the resource management device determines the loading strategy, and according to The loading strategy updates the resource loading device, so that the resource loading device can dynamically introduce the target shared resources that the second application needs to call as needed. Since the first application and the second application in the micro front-end system are loaded on the same page, it is available for The second application directly calls the target shared resource from the resource loading device. Compared with some situations, it does not need to perform address access or cache call resource multiple times, so resource sharing can be performed while saving network bandwidth and shortening response delay. It is beneficial to improve the execution efficiency of the micro front-end system for resource sharing.
下面结合附图,对本申请实施例作进一步阐述。The embodiments of the present application will be further described below in conjunction with the accompanying drawings.
如图1所示,图1是本申请一个实施例提供的用于执行资源共享方法的微前端系统400的示意图。As shown in FIG. 1 , FIG. 1 is a schematic diagram of a micro front-end system 400 for performing a resource sharing method provided by an embodiment of the present application.
在图1的示例中,该微前端系统400包括但不限于:第一应用100、第二应用200和资源管理装置300,第一应用100可以包括但不限于为被设置为加载备用共享资源的资源加载装置110。在另一个实施例中,微前端系统400还可以包括共享资源库,其中,共享资源库用于存储共享资源,所存储的共享资源可以是备用贡献资源,还可以是其它类型或形式的共享资源,共享资源库可以但不限于为独立运行的微应用,用于负责共享资源的存储和版本管理。In the example of FIG. 1 , the micro frontend system 400 includes, but is not limited to: a first application 100, a second application 200, and a resource management device 300. The first application 100 may include, but is not limited to, the Resource loading means 110. In another embodiment, the micro front end system 400 may also include a shared resource library, where the shared resource library is used to store shared resources, and the stored shared resources may be spare contribution resources, or other types or forms of shared resources , the shared resource library can be, but not limited to, a micro-application that runs independently, and is responsible for storage and version management of shared resources.
在一实施例中,微前端系统400可以但不限于基于微服务而构建,能够实现微前端的相关功能,在该微前端系统400中,第一应用100与第二应用200互为从属关系,其中,第一应用100作为主应用,第二应用200作为子应用,两者之间以及资源管理装置300通过配合交互能够实现微前端系统400的正常功能执行,需要说明的是,第二应用200可以设置为多个,在这种情况下,每个第二应用200为对应于第一应用100的子应用,即,每个第二应用200配合第一应用100、资源管理装置300也能够实现微前端系统400的正常功能执行,因此,本实施例并未也不需要限制第二应用200的具体数量。In one embodiment, the micro-frontend system 400 can be constructed based on micro-services, but not limited to, and can realize related functions of the micro-frontend. In the micro-frontend system 400, the first application 100 and the second application 200 are mutually subordinate, Among them, the first application 100 serves as the main application, and the second application 200 serves as the sub-application, and the normal function execution of the micro front-end system 400 can be realized through cooperation and interaction between the two and the resource management device 300. It should be noted that the second application 200 It can be set to multiple, in this case, each second application 200 is a sub-application corresponding to the first application 100, that is, each second application 200 can also realize The normal function of the micro frontend system 400 is executed, therefore, this embodiment does not and does not need to limit the specific number of the second applications 200 .
在一实施例中,第一应用100可以是终端最终访问的微应用,即,无论终端涉及访问多少个应用,但以终端最终确认访问的应用作为第一应用100,使得所确定的第一应用100能够较好地匹配网络条件下的路由规则,以便于更准确可靠地将在微前端所拆分出的一个或多个第二应用200进行集成整合,从而配合实现一个或多个第二应用200的加载展示、通信以及资源共享,换言之,在微前端系统400中,第一应用100与第二应用200集成于同一超文本标记语言(Hyper Text Markup Language,HTML)页面上,因此,第二应用200可以共享第一应用100的资源池,即,不仅第一应用100能够从资源加载装置110调用相应的备用共享资源,而且第二应用200也能够从资源加载装置110调用相应的备用共享资源。In an embodiment, the first application 100 may be the micro-application that the terminal finally accesses, that is, no matter how many applications the terminal accesses, the application that the terminal finally confirms to access is used as the first application 100, so that the determined first application 100 can better match the routing rules under network conditions, so as to more accurately and reliably integrate one or more second applications 200 split from the micro front end, so as to cooperate to realize one or more second applications 200's loading display, communication and resource sharing, 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 (Hyper Text Markup Language, HTML) page, therefore, the second The application 200 can share the resource pool of the first application 100, that is, not only the first application 100 can call the corresponding standby shared resource from the resource loading device 110, but the second application 200 can also call the corresponding standby shared resource from the resource loading device 110 .
在一实施例中,访问第一应用100的终端数量不限制,其可以设置为多个,各个终端均可以称为接入终端、用户设备(User Equipment,UE)、用户单元、用户站、移动站、移动台、远方站、远程终端、移动设备、用户终端、无线通信设备、用户代理或用户装置。例如,各个终端均可以是蜂窝电话、无绳电话、会话启动协议(Session Initiation Protocol,SIP)电话、无线本地环路(Wireless Local Loop,WLL)站、个人数字处理(Personal Digital Assistant,PDA)、具有无线通信功能的手持设备、计算设备或连接到无线调制解调器的其它处理设备、车载设备、可穿戴设备、5G网络或者未来5G以上网络中的终端设备等,本实施例对此并不作具体限定。In one embodiment, the number of terminals accessing the first application 100 is not limited, it can be set to multiple, and each terminal can be called an access terminal, user equipment (User Equipment, UE), user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, wireless communication device, user agent, or user device. 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 devices with wireless communication functions, computing devices or other processing devices connected to wireless modems, vehicle-mounted devices, wearable devices, 5G networks or terminal devices in future 5G or higher networks, etc., are not specifically limited in this embodiment.
在一实施例中,第二应用200可以但不限于为按内部功能模块的划分可以独立开发、独立部署且具有一定功能职责的前端微应用,第二应用200既可以独立运行,也可以集成到第一应 用100页面上运行,本申请实施例主要是针对第二应用200集成到第一应用100页面上运行的方式而进行资源共享的,本领域技术人员可以根据实际场景选择第二应用200的运行方式,这并未限定。In one embodiment, the second application 200 can be, but not limited to, a front-end micro-application that can be independently developed and deployed independently according to the division of internal functional modules and has certain functional responsibilities. The second application 200 can run independently or be integrated into Running on the page of the first application 100, the embodiment of the present application is mainly aimed at resource sharing by integrating the second application 200 into running on the page of the first application 100, those skilled in the art can select the second application 200 according to the actual scene The mode of operation is not limited.
在一实施例中,第二应用200内部可以集成各种类型的功能模块,以菜单形式进行呈现,例如,第二应用200包括但不限于有功能模块、资源模块和注册模块等,上述各个模块以菜单形式排列于第二应用200页面上,其中,功能模块可以体现第二应用200自身的生命周期函数的情况并将其向外部进行展示,资源模块被设置为引入及管理与第二应用200匹配的共享资源,注册模块可以适用于第二应用200在集成时的情形,可以将第二应用200内部的相关信息注册到第一应用100,同时具备监听菜单以及接收与菜单相关的信息定义文件(例如,可以为标识信息文件、资源信息文件以及序号信息文件等)的功能,使得终端能够清楚菜单可能出现的变化情况,可以理解地是,注册模块实现消息注册及接收的方式并未限定,本领域技术人员可以根据实际场景进行设定。In an embodiment, various types of functional modules can be integrated inside the second application 200 and presented in the form of menus. For example, the second application 200 includes but not limited to functional modules, resource modules, and registration modules. Arranged on the page of the second application 200 in the form of a menu, wherein the functional modules can reflect the situation of the life cycle function of the second application 200 itself and display it to the outside, and the resource module is set to be imported and managed with the second application 200 Matching shared resources, the registration module can be applied to the situation when the second application 200 is integrated, can register relevant information inside the second application 200 to the first application 100, and can monitor menus and receive menu-related information definition files (For example, it can be an identification information file, a resource information file, and a serial number information file, etc.), so that the terminal can know the possible changes in the menu. It can be understood that the way the registration module implements message registration and reception is not limited. Those skilled in the art can make settings according to actual scenarios.
在一实施例中,资源加载装置110作为资源池进行提供,可以容纳不同的共享资源作为备用,并具有持续更新的能力,即,在第一应用100的作用下能够持续地引入新的共享资源,达到共享资源及时更新的效果,需要说明的是,资源加载装置110也可以作为独立运行的微应用进行设置,即,资源加载装置110与第一应用100之间是区分的,这并不会影响到资源加载装置110的功能执行;此外,第一应用100内部还可以集成其它类型的模块,例如,第一应用100还包括但不限于有路由加载模块、菜单模块和文档对象模型(Document Object Model,DOM)容器等,其中,路由加载模块被设置为响应路由切换而触发加载对应的第二应用200,从而展示第二应用200的界面元素到DOM容器,菜单模块负责接收并展示来自第二应用200的注册信息,同时可以缓存与第二应用200对应的一个或多个共享资源的内容信息,DOM容器作为一种HTML容器,可以用于展示第二应用200的界面元素,使得加载第二应用200的可视化程度变得更高。In one embodiment, the resource loading device 110 is provided as a resource pool, which can accommodate different shared resources as backup, and has the capability of continuous updating, that is, under the action of the first application 100, new shared resources can be continuously introduced. , to achieve the effect of updating shared resources in a timely manner. It should be noted that the resource loading device 110 can also be set as an independently running micro-application, that is, the resource loading device 110 is distinguished from the first application 100, which does not affect the function execution of the resource loading device 110; in addition, other types of modules can also be integrated inside the first application 100, for example, the first application 100 also includes but is not limited to a routing loading module, a menu module and a document object model (Document Object Model, DOM) container, etc., wherein, the route loading module is set to respond to route switching and trigger the loading of the corresponding second application 200, thereby displaying the interface elements of the second application 200 to the DOM container, and the menu module is responsible for receiving and displaying information from the second application The registration information of the application 200 can cache the content information of one or more shared resources corresponding to the second application 200 at the same time, and the DOM container, as a kind of HTML container, can be used to display the interface elements of the second application 200, so that the second The degree of visualization of the application 200 becomes higher.
可以理解地是,第一应用100和第二应用200内部集成多个功能模块的类型及数量还可以有更多种,这并未限制;并且,在第一应用100和第二应用200内部集成多个功能模块的目的在于实现功能区分,即,由相应的功能模块执行相应的功能,这大大降低了功能执行出现错误的几率,且更方便于管控,在出现问题时便于更直观地找出与问题对应的功能模块,从而便于对相应的功能模块进行调整或更新。It can be understood that there may be more types and quantities of multiple function modules integrated in the first application 100 and the second application 200, which is not limited; The purpose of multiple functional modules is to achieve functional differentiation, that is, the corresponding functional modules perform corresponding functions, which greatly reduces the probability of errors in function execution, and is more convenient for management and control, and it is easier to find out more intuitively when problems occur The functional modules corresponding to the problems, so that the corresponding functional modules can be easily adjusted or updated.
示例一:Example one:
如图2所示,图2给出了以表格所呈现的菜单模块的一种形式,从图2中可以看出,与第二应用200对应的各个属性的类型及含义是一一对应确定的,例如,ID对应于string类型,为唯一标识,mfaHash体现了触发第二应用200加载的路由规则,同时也作为第二应用200的全局唯一名称;并且,若属性还存在相关的子属性,也一并示出,例如,Share Component体现共享资源列表,第一个子属性Component Name体现共享资源名称,第二个子属性Component Version体现共享资源版本,因此,通过图2中示出的菜单模块可以准确获知有关第二应用200的注册信息。As shown in FIG. 2, FIG. 2 shows a form of a menu module presented in a table. It can be seen from FIG. 2 that the types and meanings of the attributes corresponding to the second application 200 are determined in one-to-one correspondence. For example, the ID corresponds to the string type and is a unique identifier. mfaHash embodies the routing rule that triggers the loading of the second application 200, and also serves as the globally unique name of the second application 200; Shown together, for example, Share Component embodies the shared resource list, the first subattribute Component Name embodies the name of the shared resource, and the second subattribute Component Version embodies the shared resource version, therefore, the menu module shown in Figure 2 can accurately The registration information about the second application 200 is obtained.
在图2中,针对各个属性,ID表示唯一标识,name分为zh name和en name,分别表示中文名称和英文名称,parentid表示父菜单标识,order表示菜单排序序号,href表示统一资源定位器(Uniform Resource Locator,URL)地址,mfaHash表示触发加载的哈希名称,Share Component分为Component Name和Component Version,分别表示共享资源名称和共享资源版本,group表示其它扩展字段;针对各个类型,string表示字符串类型,int表示整数类型,object表示相关的变量和方法的软件集类型。In Figure 2, for each attribute, ID represents a unique identifier, name is divided into zh name and en name, representing the Chinese name and English name respectively, parentid represents the parent menu identification, order represents the menu sorting number, and href represents the uniform resource locator ( Uniform Resource Locator, URL) address, mfaHash indicates the hash name that triggers loading, Share Component is divided into Component Name and Component Version, which respectively indicate the shared resource name and shared resource version, group indicates other extended fields; for each type, string indicates characters String type, int means integer type, and object means software set type of related variables and methods.
微前端系统400中的第一应用100和第二应用200均可以分别包括有存储器和处理器,其中,存储器和处理器可以通过总线或者其他方式连接。Both the first application 100 and the second application 200 in the micro-frontend system 400 may respectively include a memory and a processor, wherein the memory and the processor may be connected through a bus or in other ways.
存储器作为一种非暂态计算机可读存储介质,可被设置为存储非暂态软件程序以及非暂态性计算机可执行程序。此外,存储器可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存 储器可包括相对于处理器远程设置的存储器,这些远程存储器可以通过网络连接至该处理器。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。As a non-transitory computer-readable storage medium, memory can be configured to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory may include memory located remotely from the processor, which remote memory may be connected to the processor through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
本申请实施例描述的微前端系统400以及应用场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域技术人员可知,随着微前端系统400的演变和新应用场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。The micro front-end system 400 and the application scenarios described in the embodiment of the present application are to illustrate the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation to the technical solutions provided in the embodiments of the present application. Those skilled in the art know that as With the evolution of the micro front-end system 400 and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
本领域技术人员可以理解的是,图1中示出的微前端系统400并不构成对本申请实施例的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the micro front end system 400 shown in FIG. layout of the components.
在图1所示的微前端系统400中,第一应用100和第二应用200可以分别调用其储存的资源共享程序,以执行资源共享方法。In the micro-frontend system 400 shown in FIG. 1 , the first application 100 and the second application 200 can respectively call their stored resource sharing programs to execute the resource sharing method.
基于上述微前端系统400的结构,提出本申请的资源共享方法的各个实施例。Based on the above structure of the micro front end system 400, various embodiments of the resource sharing method of the present application are proposed.
如图3所示,图3是本申请一个实施例提供的资源共享方法的流程图,可以但不限于应用于如图1实施例所示的微前端系统,该资源共享方法包括但不限于步骤S100至S400。As shown in Figure 3, Figure 3 is a flow chart of a resource sharing method provided by an embodiment of the present application, which can be but not limited to be applied to the micro front-end system shown in the embodiment of Figure 1, the resource sharing method includes but is not limited to the steps S100 to S400.
步骤S100,第二应用向第一应用发送注册信息,注册信息包括资源信息,资源信息用于表征第二应用所需调用的目标共享资源的特征。Step S100, the second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call.
在一实施例中,由于注册信息能够表征第二应用内部各个模块或装置的特征情况,例如,注册信息包括有资源信息,即公开了第二应用所需调用的目标共享资源的特征,因此,第二应用通过向第一应用发送注册信息,则可以使得第一应用准确地获知第二应用的内部情况,并以之作为交互的基础,便于后续为加载第二应用作为相应的参考条件。In an embodiment, because the registration information can represent the characteristics of each module or device inside the second application, for example, the registration information includes resource information, which discloses the characteristics of the target shared resource that the second application needs to call, therefore, By sending the registration information to the first application, the second application can make the first application accurately know the internal situation of the second application, and use it as a basis for interaction, so as to facilitate subsequent loading of the second application as a corresponding reference condition.
在一实施例中,第二应用采用模型驱动的消息中间件方式向第一应用发送注册信息,即,基于模型驱动规范下的消息中间件方式进行传送,信息传输过程较为稳定,不容易出现注册信息丢失的情况,可以保证具有良好的发送效率。In one embodiment, the second application uses the model-driven message middleware method to send registration information to the first application, that is, the information is transmitted based on the model-driven message middleware method, the information transmission process is relatively stable, and registration information is not easy to occur. In the case of information loss, good sending efficiency can be guaranteed.
需要说明的是,注册信息的种类可以为多种,例如,参照图2中所示出的种类,本领域技术人员可以根据实际场景进行选择,本实施例并未限制。It should be noted that there may be various types of registration information. For example, referring to the types shown in FIG. 2 , those skilled in the art may select according to actual scenarios, which is not limited in this embodiment.
步骤S200,资源管理装置接收由第一应用发送的资源信息,并根据资源信息和备用共享资源确定针对目标共享资源的加载策略。In step S200, the resource management device receives the resource information sent by the first application, and determines a loading strategy for the target shared resource according to the resource information and the standby shared resource.
在一实施例中,资源管理装置可以作为独立运行的微应用,对共享资源进行运行时管理,维护当前已加载的备用共享资源,并且根据加载策略按需动态构建新资源访问地址并引入到第一应用,即,资源管理装置通过为第一应用确定加载策略,可以为第一应用更新资源加载装置打下基础,以使第一应用根据加载策略执行后续相应操作。In one embodiment, the resource management device can be used as an independently running micro-application to manage the shared resources at runtime, maintain the currently loaded standby shared resources, and dynamically construct new resource access addresses as needed according to the loading strategy and introduce them to the first An application, that is, by determining the loading policy for the first application, the resource management device can lay a foundation for the first application to update the resource loading device, so that the first application performs subsequent corresponding operations according to the loading policy.
需要说明的是,在一定场景下,资源管理装置也可以集成于第一应用内进行使用,这并未限制。It should be noted that, in a certain scenario, the resource management device may also be integrated into the first application for use, which is not limited.
如图4所示,步骤S200中“根据资源信息和备用共享资源确定针对目标共享资源的加载策略”包括但不限于步骤S210至S220。As shown in FIG. 4 , "determining a loading strategy for the target shared resource according to the resource information and the standby shared resource" in step S200 includes but is not limited to steps S210 to S220.
步骤S210,资源管理装置根据资源信息和备用共享资源确定目标共享资源在资源加载装置的加载情况;Step S210, the resource management device determines the loading status of the target shared resource in the resource loading device according to the resource information and the backup shared resource;
步骤S220,资源管理装置根据加载情况确定针对目标共享资源的加载策略。In step S220, the resource management device determines a loading strategy for the target shared resource according to the loading situation.
在一实施例中,由于资源信息用于表征第二应用所需调用的目标共享资源的特征,因此,将该资源信息与备用共享资源配合,可以确定资源信息所对应的目标共享资源在资源加载装置内的实际情况,基于此,资源管理装置才能够根据加载情况确定准确可靠的加载策略。In an embodiment, since the resource information is used to characterize the characteristics of the target shared resource to be invoked by the second application, by coordinating the resource information with the standby shared resource, it can be determined that the target shared resource corresponding to the resource information is Based on the actual situation in the device, the resource management device can determine an accurate and reliable loading strategy according to the loading situation.
具体地,如图5所示,步骤S220包括但不限于步骤S221。Specifically, as shown in FIG. 5, step S220 includes but is not limited to step S221.
步骤S221,在目标共享资源未加载于资源加载装置的情况下,资源管理装置根据目标共享资源构建与目标共享资源对应的目标访问地址,并将目标访问地址嵌入到第一应用。Step S221, if 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 one embodiment, if the target shared resource is loaded on the resource loading device, it means that the backup shared resource in the resource loading device already contains the target shared resource, so there is no need to adjust the backup shared resource in the resource loading device, and you can directly Applying the resource loading device, this is a loading strategy 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 means that the backup shared resource in the resource loading device does not include the target shared resource, Therefore, it is necessary to adjust the spare shared resources in the resource loading device. Therefore, the resource management device constructs the 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, equivalent to The target shared resource corresponding to the target access address can be introduced into the first application, so that the first application can correspondingly update the resource loading device, which is the loading strategy of the target shared resource in another situation.
可以理解地是,目标访问地址与目标共享资源对应,因此,将目标访问地址嵌入到第一应用,即相当于将目标共享资源引入到第一应用,但这并非是唯一限定的,也可以采用其他表现形式替代访问地址,只需保证所替代的表现形式与目标共享资源相关即可。此外,加载策略不限于仅关联于目标共享资源在资源加载装置上的加载情况,本领域技术人员还可以根据具体应用场景相应设置加载策略,本实施例并未限制。It can be understood that the target access address corresponds to the target shared resource. Therefore, embedding the target access address into the first application is equivalent to introducing the target shared resource into the first application. Other forms of expression replace the access address, as long as the replaced form of expression is related to the target shared resource. In addition, the loading policy is not limited to only being related to the loading situation of the target shared resource on the resource loading device, and those skilled in the art can also set the loading policy according to specific application scenarios, which is not limited in this embodiment.
步骤S300,第一应用接收由资源管理装置发送的加载策略,并根据加载策略更新资源加载装置。Step S300, the first application receives the loading policy sent by the resource management device, and updates the resource loading device according to the loading policy.
在一实施例中,第一应用根据加载策略更新资源加载装置,使得资源加载装置能够按需动态地引入第二应用所需调用的目标共享资源,因此,更新后的资源管理装置中的备用共享资源包括目标共享资源,能够符合加载需求。In one embodiment, the first application updates the resource loading device according to the loading strategy, so that the resource loading device can dynamically introduce the target shared resources that the second application needs to call as needed. Therefore, the backup shared resources in the updated resource management device Resources, including target shared resources, are able to meet loading requirements.
具体地,如图6所示,步骤S300包括但不限于步骤S310。Specifically, as shown in FIG. 6, step S300 includes but is not limited to step S310.
步骤S310,第一应用根据目标访问地址从共享资源库中引入目标共享资源,并将目标共享资源发送至资源加载装置。Step S310, the first application imports 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 one embodiment, since the target access address corresponds to the target shared resource, the relevant information of the target shared resource can be determined through the target access address, so that the target shared resource can be imported from the shared resource library only through the target access address As far as the resource loading device is concerned, it can be seen that the loading strategy can realize the introduction of shared resources only depending on the network access address, without consuming a large amount of network resources, which is beneficial to reduce network costs.
步骤S400,第二应用从更新后的资源加载装置中调用目标共享资源。Step S400, the second application invokes the target shared resource from the updated resource loading device.
在一实施例中,资源加载装置按需动态地引入第二应用所需调用的目标共享资源,由于在微前端系统中的第一应用和第二应用在同一页面加载,因此可供第二应用直接从资源加载装置调用目标共享资源,相比于一些情形,无需多次地进行地址访问或者缓存调用资源,因此能够在节省网络带宽、缩短响应延时的情况下进行资源共享,有利于提升微前端系统针对资源共享的执行效率。In one embodiment, the resource loading device dynamically imports the target shared resources that the second application needs to call as needed. Since the first application and the second application in the micro frontend system are loaded on the same page, they can be used by the second application Directly call the target shared resource from the resource loading device. Compared with some situations, there is no need to perform multiple address access or cache call resources. Therefore, resource sharing can be carried out while saving network bandwidth and shortening response delay, which is conducive to improving micro The execution efficiency of the front-end system for resource sharing.
在图7的示例中,步骤S400之后,还包括但不限于步骤S500。In the example of FIG. 7 , after step S400 , step S500 is also included but not limited to.
步骤S500,第一应用展示第二应用的界面元素,界面元素对应于目标共享资源。In step S500, the first application displays interface elements of the second application, and the interface elements correspond to target shared resources.
在一实施例中,通过在第一应用上集成化地展示第二应用的界面元素,可以用于展示第二应用的加载情况,使得加载第二应用的可视化程度变得更高,对于终端而言,能够更加直观地了解第二应用的加载情况,从而能够满足终端的应用需求。In an embodiment, by displaying the interface elements of the second application integratedly on the first application, it can be used to display the loading status of the second application, so that the visibility of loading the second application becomes higher. For the terminal In other words, it is possible to understand the loading situation of the second application more intuitively, so as to meet the application requirements of the terminal.
需要说明的是,第二应用可以为多个,每个第二应用与相关部件执行上述各实施例的步骤互不影响,因此,由于各个应用在同一页面加载,所以所需的组件资源在运行时可以只加载一次,即可实现全局共享访问,达到节省网络带宽的效果,并且提高访问性能;在这一过程中,无论第二应用设置为多少个,资源共享均由第一应用实现统一管理,即使不同的第二应用的注册信息也可能是变化的,但第一应用仍然会根据加载情况实现动态化地按需引入,使得第二应用直接调用所需的目标共享资源,因此,本实施例的微前端系统实现了对共享资源的“一次引入,多次使用”,简洁可靠且效率更高。It should be noted that there may be multiple second applications, and each second application and related components execute the steps of the above embodiments independently of each other. Therefore, since each application is loaded on the same page, the required component resources are running It can be loaded only once to achieve global shared access, saving network bandwidth and improving access performance; in this process, no matter how many second applications are set, resource sharing is managed by the first application in a unified manner , even though the registration information of different second applications may change, the first application will still implement dynamic on-demand import according to the loading situation, so that the second application can directly call the required target shared resources. Therefore, this implementation The micro-frontend system of the example realizes "one-time introduction, multiple use" of shared resources, which is simple, reliable and more efficient.
以下继续给出具体示例以说明上述各实施例的基本原理。Specific examples are given below to illustrate the basic principles of the above-mentioned embodiments.
示例二:Example two:
如图8所示,图8是本申请一个实施例提供的第一应用的页面示意图。As shown in FIG. 8 , FIG. 8 is a schematic diagram of a page of a first application provided by an embodiment of the present application.
如图8所示,第二应用的菜单区和模块菜单区均集成于第一应用上,同时第一应用上还集成有自身的功能菜单区,具体地,呈现给用户的页面是由1个portal主应用(即第一应用)和若干个独立部署的子应用(即第二应用)构成。第一应用菜单区由各个第二应用通过菜单注册 动态组合而成,菜单模型信息中包含了第二应用的资源信息,第二应用内容展示区设置于第一应用内部的界面元素展示容器,可以采用一个DOM容器,对于第一应用而言,根据路由地址变化而动态地匹配并加载对应的第二应用,实现将其渲染到一个DOM容器上,从而展示其界面元素,图8中显示了一个第二应用的模块菜单区也同时渲染到对应的DOM容器上,针对不同的第二应用(即如图8所示的第二应用1、第二应用2、第二应用3、第二应用4和第二应用5),通过第一应用使得各个第二应用在加载后能够单独运行在不同的DOM容器中,彼此隔离,从而使得各个功能模块之间的耦合性大大降低,可以看出,如图8所示的集成展示方式确保了第一应用和第二应用均具有良好的展示空间,且各个第二应用之间互不影响,从而提升了对于第二应用的渲染展示效果。As shown in Figure 8, the menu area and the module menu area of the second application are integrated into the first application, and the first application also integrates its own function menu area. Specifically, the page presented to the user is composed of a Portal main application (namely the first application) and several independently deployed sub-applications (namely the second application). The first application menu area is dynamically combined by each second application through menu registration. The menu model information includes the resource information of the second application. The second application content display area is set in the interface element display container inside the first application, which can Using a DOM container, for the first application, dynamically match and load the corresponding second application according to the change of the routing address, and render it to a DOM container to display its interface elements, as shown in Figure 8 The module menu area of the second application is also rendered to the corresponding DOM container at the same time. and the second application 5), through the first application, each second application can run independently in different DOM containers after being loaded, and be isolated from each other, so that the coupling between the various functional modules is greatly reduced. It can be seen that, as The integrated display method shown in FIG. 8 ensures that both the first application and the second application have a good display space, and the second applications do not affect each other, thereby improving the rendering and display effect of the second application.
示例三:Example three:
如图9所示,图9是本申请另一个实施例提供的微前端系统的示意图。As shown in FIG. 9 , FIG. 9 is a schematic diagram of a micro front-end system provided by another embodiment of the present application.
如图10所示,图10是图9所示的微前端系统执行资源共享方法的流程图。As shown in FIG. 10 , FIG. 10 is a flow chart of the resource sharing method performed by the micro front-end system shown in FIG. 9 .
在图9的示例中,第二应用包括两个,分别为第二应用1和第二应用2,由于第二应用1与第二应用2的工作原理是相同的,为了避免冗余,以下仅以其中一个进行说明,参照图9和图10,给出该微前端系统的一种具体运行方式的实施例。In the example in FIG. 9 , the second application includes two, respectively, the second application 1 and the second application 2. Since the second application 1 and the second application 2 work on the same principle, in order to avoid redundancy, only One of them is used for illustration, referring to FIG. 9 and FIG. 10 , an embodiment of a specific operation mode of the micro front-end system is given.
首先,提取第二应用1中的共享资源组件,该共享资源组件包括但不限于目标共享资源的组件,相比于传统技术中的将该共享资源组件打包到工程模块中进行单独部署的情况,或者,将共享资源组件存放于第三方公共共享资源库以进行各自引用的情况,本实施例选择将提取后的共享资源组件统一存放在共享资源库中,提供类似内容分发网络(Content Delivery Network,CDN)的共享访问,可以减少共享资源组件编译后的代码体积。First, the shared resource component in the second application 1 is extracted, the shared resource component includes but not limited to the component of the target shared resource. Compared with the situation in the traditional technology that the shared resource component is packaged into an engineering module for separate deployment, Alternatively, in the case of storing the shared resource components in a third-party public shared resource library for their respective references, this embodiment chooses to uniformly store the extracted shared resource components in the shared resource library to provide a similar Content Delivery Network (Content Delivery Network, CDN) shared access can reduce the code volume of compiled shared resource components.
其次,在获取共享资源库地址后,资源模块可以将共享资源组件默认引入到第二应用1的主页HTML的head标签中,并挂载在window全局对象,确保第二应用1在独立访问场景中运行正常,其中,第二应用1在引入的标签中可以加上ignore属性,以之作为区分标识,即,当在微前端系统环境中加载第二应用1时,经过第一应用的分析则会忽略加载带有ignore属性的资源,而在独立访问时的第二应用1本身可以通过资源模块正常加载该组件资源。Secondly, after obtaining the address of the shared resource library, the resource module can import the shared resource component into the head tag of the home page HTML of the second application 1 by default, and mount it in the window global object to ensure that the second application 1 is in the independent access scenario It is running normally, and the second application 1 can add the ignore attribute in the imported tag as a distinguishing mark, that is, when the second application 1 is loaded in the micro-frontend system environment, after the analysis of the first application, it will The loading of the resources with the ignore attribute is ignored, and the second application 1 itself can normally load the component resources through the resource module during independent access.
其次,第二应用1通过注册模块向第一应用注册资源信息,第一应用通过菜单模块动态集成第二应用1页面,即,菜单模块接收来自第二应用1的注册信息,对菜单树节点进行转换,从而将注册信息转换为界面元素以显示在门户单元,同时将相应的资源信息进行缓存备用;Secondly, the second application 1 registers resource information with the first application through the registration module, and the first application dynamically integrates the pages of the second application 1 through the menu module, that is, the menu module receives the registration information from the second application 1 and performs Conversion, so that the registration information is converted into interface elements to be displayed on the portal unit, and the corresponding resource information is cached for backup;
其中,菜单信息采用模型驱动的消息中间件方式由第二应用1注册到第一应用,菜单信息包括第二应用1的唯一ID、显示的中英文名称、IP地址和共享资源列表等,其中,可以由注册模块通过消息中间件将第二应用1的相关信息注册到第一应用,具体采用以集群方式部署的消息中间件,负责用于接收菜单相关的消息,并通知监听菜单变化的消息终端,在本实施例中,使用kafka集群实现消息的分布式发布和订阅。Among them, the menu information is registered from the second application 1 to the first application by adopting a model-driven message middleware method, and the menu information includes the unique ID of the second application 1, the displayed Chinese and English names, the IP address and the list of shared resources, etc., wherein, The registration module can register the relevant information of the second application 1 to the first application through the message middleware. Specifically, the message middleware deployed in a cluster mode is used to receive menu-related messages and notify the message terminals that monitor menu changes. , in this embodiment, a kafka cluster is used to implement distributed publication and subscription of messages.
其次,当用户或终端点击第二应用1菜单,则触发第二应用1页面加载流程,开始对第二应用1的资源加载方式进行判断,即,第二应用1通过功能模块实现业务功能的脚本和样式,从而向第一应用暴露必要的生命周期函数,使得第一应用在微前端系统下对其进行识别,并在该生命周期函数的基础上,判断该注册信息是否注册有资源信息,若未注册,则直接加载目标共享资源并进行容器隔离,反之,若已经注册,则将注册的资源信息发送到资源管理装置进行下一步处理。Secondly, when the user or terminal clicks on the menu of the second application 1, the page loading process of the second application 1 is triggered, and the resource loading method of the second application 1 is judged, that is, the script of the second application 1 to realize the business function through the function module and style, so as to expose the necessary life cycle function to the first application, so that the first application can identify it under the micro front-end system, and judge whether the registration information has resource information registered on the basis of the life cycle function, if If it is not registered, it will directly load the target shared resource and perform container isolation. On the contrary, if it has been registered, it will send the registered resource information to the resource management device for further processing.
其次,在第二应用1页面的生命周期内,资源管理装置将接收到的资源信息与资源加载装置中的备用共享资源进行对比,若资源信息对应的目标共享资源已被加载,则直接返回资源信息,不对其做处理,反之,若资源信息对应的目标共享资源并未被加载,则由资源加载装置动态构建目标共享资源对应的目标访问地址,并将地址返回给第一应用的当前HTML,由当前HTML的head标签引入。Secondly, within the life cycle of the second application 1 page, the resource management device compares the received resource information with the spare shared resource in the resource loading device, and if the target shared resource corresponding to the resource information has been loaded, directly returns the resource Information, do not process it, otherwise, if the target shared resource corresponding to the resource information has not been loaded, then the target access address corresponding to the target shared resource is dynamically constructed by the resource loading device, and the address is returned to the current HTML of the first application, Introduced by the head tag of the current HTML.
其次,第一应用根据地址从共享资源库请求并引入目标共享资源,挂载到window全局对象以供第二应用1直接调用。Secondly, the first application requests and imports the target shared resource from the shared resource library according to the address, and mounts it to the window global object for direct calling by the second application 1 .
最后,将第二应用1的界面元素展示到第一应用的DOM容器,完成第二应用1的页面渲染。Finally, the interface elements of the second application 1 are displayed in the DOM container of the first application, and the page rendering of the second application 1 is completed.
如图11所示,图11是本申请另一个实施例提供的资源共享方法的流程图,可以但不限于应用于如图1实施例所示的微前端系统中的第一应用,该资源共享方法包括但不限于步骤S600至S800。As shown in Figure 11, Figure 11 is a flow chart of a resource sharing method provided by another embodiment of the present application, which can be but not limited to be applied to the first application in the micro front-end system shown in the embodiment of Figure 1, the resource sharing The method includes but not limited to steps S600 to S800.
步骤S600,获取由第二应用发送的注册信息,注册信息包括资源信息,资源信息用于表征第二应用所需调用的目标共享资源的特征;Step S600, obtaining the registration information sent by the second application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
步骤S700,向资源管理装置发送资源信息,以使资源管理装置根据资源信息和备用共享资源确定针对目标共享资源的加载策略;Step S700, sending resource information to the 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 backup shared resource;
步骤S800,接收由资源管理装置发送的加载策略,并根据加载策略更新资源加载装置,以使第二应用从更新后的资源加载装置中调用目标共享资源。Step S800, receiving the loading policy sent by the resource management device, and updating the resource loading device according to the loading policy, so that the second application calls the target shared resource from the updated resource loading device.
在一实施例中,通过收集第二应用的注册信息而使得资源管理装置确定加载策略,并且根据加载策略更新资源加载装置,使得资源加载装置能够按需动态地引入第二应用所需调用的目标共享资源,由于在微前端系统中的第一应用和第二应用在同一页面加载,因此可供第二应用直接从资源加载装置调用目标共享资源,相比于一些情形,无需多次地进行地址访问或者缓存调用资源,因此能够在节省网络带宽、缩短响应延时的情况下进行资源共享,有利于提升微前端系统针对资源共享的执行效率。In one embodiment, the resource management device determines 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 that the second application needs to call Shared resources, since the first application and the second application are loaded on the same page in the micro-frontend system, the second application can directly call the target shared resource from the resource loading device. Compared with some situations, there is no need to address multiple times Access or cache call resources, so resource sharing can be performed while saving network bandwidth and shortening response delay, which is conducive to improving the execution efficiency of the micro front-end system for resource sharing.
具体地,如图12所示,步骤S800中的“根据加载策略更新资源加载装置”包括但不限于步骤S810。Specifically, as shown in FIG. 12 , the "update resource loading device according to the loading strategy" in step S800 includes but is not limited to step S810.
步骤S810,在目标共享资源未加载于资源加载装置的情况下,根据加载策略从共享资源库中引入目标共享资源至资源加载装置。Step S810, if the target shared resource is not loaded in the resource loading device, import the target shared resource from the shared resource library to the resource loading device according to the loading strategy.
值得注意的是,由于本实施例中的资源共享方法与上述各实施例中的资源共享方法属于同一发明构思,区别仅在于本实施例中的资源共享方法的执行主体为微前端系统中的第一应用,上述各实施例中的资源共享方法的执行主体为微前端系统,因此本实施例中的资源共享方法的具体实施方式,可以参照上述各实施例中的资源共享方法的具体实施例,为避免冗余,本实施例的资源共享方法的具体实施方式在此不再赘述。It should be noted that since the resource sharing method in this embodiment and the resource sharing methods in the above-mentioned embodiments belong to the same inventive concept, the only difference is that the execution subject of the resource sharing method in this embodiment is the first For an application, the execution subject of the resource sharing method in the above-mentioned embodiments is the micro front-end system, so the specific implementation manner of the resource sharing method in this embodiment can refer to the specific embodiments of the resource sharing method in the above-mentioned embodiments, In order to avoid redundancy, the specific implementation manner of the resource sharing method in this embodiment will not be repeated here.
如图13所示,图13是本申请另一个实施例提供的资源共享方法的流程图,可以但不限于应用于如图1实施例所示的微前端系统中的第二应用,该资源共享方法包括但不限于步骤S900至S1000。As shown in Figure 13, Figure 13 is a flowchart of a resource sharing method provided by another embodiment of the present application, which can be but not limited to be applied to the second application in the micro front-end system shown in the embodiment of Figure 1, the resource sharing The method includes but not limited to steps S900 to S1000.
步骤S900,向第一应用发送注册信息,以使第一应用向资源管理装置发送资源信息,并且使得资源管理装置根据资源信息和备用共享资源确定针对目标共享资源的加载策略,其中,注册信息包括资源信息,资源信息用于表征第二应用所需调用的目标共享资源的特征;Step S900, sending registration information to the first application, so that the first application sends resource information to the resource management device, and makes the resource management device determine a loading policy for the target shared resource according to the resource information and the backup shared resource, wherein the registration information includes Resource information, the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
步骤S1000,从更新后的资源加载装置中调用目标共享资源,更新后的资源加载装置为由第一应用根据由资源管理装置发送的加载策略而确定。Step S1000, call the target shared resource from the updated resource loading device, the updated resource loading device is determined by the first application according to the loading strategy sent by the resource management device.
在一实施例中,通过向第一应用发送注册信息而使得资源管理装置确定加载策略,并且使得第一应用根据加载策略更新资源加载装置,促使资源加载装置能够按需动态地引入第二应用所需调用的目标共享资源,由于在微前端系统中的第一应用和第二应用在同一页面加载,因此可以直接从资源加载装置调用目标共享资源,相比于一些情形,无需多次地进行地址访问或者缓存调用资源,因此能够在节省网络带宽、缩短响应延时的情况下进行资源共享,有利于提升微前端系统针对资源共享的执行效率。In one embodiment, the resource management device determines the loading policy by sending the registration information to the first application, and makes the first application update the resource loading device according to the loading policy, so that the resource loading device can dynamically import the resource loaded by the second application as needed. The target shared resource that needs to be called, because the first application and the second application in the micro front-end system are loaded on the same page, so the target shared resource can be called directly from the resource loading device. Access or cache call resources, so resource sharing can be performed while saving network bandwidth and shortening response delay, which is conducive to improving the execution efficiency of the micro front-end system for resource sharing.
具体地,步骤S900中的“向第一应用发送注册信息”包括但不限于步骤S910。Specifically, "sending registration information to the first application" in step S900 includes but is not limited to step S910.
步骤S910,采用模型驱动的消息中间件方式向第一应用发送注册信息。In step S910, the registration information is sent to the first application in a model-driven message middleware manner.
具体地,步骤S1000之后还包括但不限于步骤S1100。Specifically, step S1100 is also included after step S1000.
步骤S1100,在第一应用上展示界面元素,界面元素对应于目标共享资源。Step S1100, display interface elements on the first application, where the interface elements correspond to target shared resources.
值得注意的是,由于本实施例中的资源共享方法与上述各实施例中的资源共享方法属于同一发明构思,区别仅在于本实施例中的资源共享方法的执行主体为微前端系统中的第二应用,上述各实施例中的资源共享方法的执行主体为微前端系统,因此本实施例中的资源共享方法的 具体实施方式,可以参照上述各实施例中的资源共享方法的具体实施例,为避免冗余,本实施例的资源共享方法的具体实施方式在此不再赘述。It should be noted that since the resource sharing method in this embodiment and the resource sharing methods in the above-mentioned embodiments belong to the same inventive concept, the only difference is that the execution subject of the resource sharing method in this embodiment is the first Two applications, the execution subject of the resource sharing method in the above-mentioned embodiments is the micro front-end system, so the specific implementation manner of the resource sharing method in this embodiment can refer to the specific embodiments of the resource sharing method in the above-mentioned embodiments, In order to avoid redundancy, the specific implementation manner of the resource sharing method in this embodiment will not be repeated here.
另外,参照图14,本申请的一个实施例还提供了一种微前端系统,该微前端系统包括:第一存储器、第一处理器及存储在第一存储器上并可在第一处理器上运行的计算机程序。In addition, referring to FIG. 14 , an embodiment of the present application also provides a micro front-end system, the micro front-end system includes: a first memory, a first processor, and a A computer program that runs.
第一处理器和第一存储器可以通过第一总线或者其他方式连接。The first processor and the first memory may be connected through a first bus or in other ways.
需要说明的是,本实施例中的服务器,可以应用为例如图1所示实施例中的微前端系统,本实施例中的微前端系统能够构成例如图1所示实施例中的微前端系统的一部分,这些实施例均属于相同的发明构思,因此这些实施例具有相同的实现原理以及技术效果,此处不再详述。It should be noted that the server in this embodiment can be applied, for example, to the micro front-end system in the embodiment shown in FIG. These embodiments all belong to the same inventive concept, so these embodiments have the same implementation principle and technical effect, and will not be described in detail here.
实现上述实施例的资源共享方法所需的非暂态软件程序以及指令存储在第一存储器中,当被第一处理器执行时,执行上述各实施例的资源共享方法,例如,执行以上描述的图3中的方法步骤S100至S400、图4中的方法步骤S210至S220、图5中的方法步骤S221、图6中的方法步骤S310或图7中的方法步骤S500。The non-transitory software programs and instructions required to realize the resource sharing method of the above-mentioned embodiments are stored in the first memory, and when executed by the first processor, the resource sharing methods of the above-mentioned embodiments are executed, for example, 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 .
另外,参照图15,本申请的一个实施例还提供了一种网络设备,该网络设备包括:第二存储器、第二处理器及存储在第二存储器上并可在第二处理器上运行的计算机程序。In addition, referring to FIG. 15 , an embodiment of the present application also provides a network device, which includes: a second memory, a second processor, and a program stored in the second memory and operable on the second processor. Computer program.
第二处理器和第二存储器可以通过第二总线或者其他方式连接。The second processor and the second memory may be connected through a second bus or in other ways.
需要说明的是,本实施例中的网络设备,可以应用为例如图1所示实施例中的微前端系统,本实施例中的网络设备能够构成例如图1所示实施例中的微前端系统的一部分,这些实施例均属于相同的发明构思,因此这些实施例具有相同的实现原理以及技术效果,此处不再详述。It should be noted that, the network device in this embodiment can be applied, for example, to the micro front-end system in the embodiment shown in Figure 1, and the network device in this embodiment can constitute, for example, the micro front-end system in the embodiment shown in Figure 1 These embodiments all belong to the same inventive concept, so these embodiments have the same implementation principle and technical effect, and will not be described in detail here.
实现上述实施例的资源共享方法所需的非暂态软件程序以及指令存储在第二存储器中,当被第二处理器执行时,执行上述各实施例的资源共享方法,例如,执行以上描述的图11中的方法步骤S600至S800或图12中的方法步骤S810。The non-transitory software programs and instructions required to realize the resource sharing method of the above-mentioned embodiments are stored in the second memory, and when executed by the second processor, the resource sharing methods of the above-mentioned embodiments are executed, for example, the above-described Method steps S600 to S800 in FIG. 11 or method step S810 in FIG. 12 .
另外,参照图16,本申请的一个实施例还提供了一种网络设备,该网络设备包括:第三存储器、第三处理器及存储在第三存储器上并可在第三处理器上运行的计算机程序。In addition, referring to FIG. 16 , an embodiment of the present application also provides a network device, the network device includes: a third memory, a third processor, and a program stored in the third memory and operable on the third processor Computer program.
第三处理器和第三存储器可以通过第三总线或者其他方式连接。The third processor and the third memory may be connected through a third bus or in other ways.
需要说明的是,本实施例中的网络设备,可以应用为例如图1所示实施例中的微前端系统,本实施例中的网络设备能够构成例如图1所示实施例中的微前端系统的一部分,这些实施例均属于相同的发明构思,因此这些实施例具有相同的实现原理以及技术效果,此处不再详述。It should be noted that, the network device in this embodiment can be applied, for example, to the micro front-end system in the embodiment shown in Figure 1, and the network device in this embodiment can constitute, for example, the micro front-end system in the embodiment shown in Figure 1 These embodiments all belong to the same inventive concept, so these embodiments have the same implementation principle and technical effect, and will not be described in detail here.
实现上述实施例的资源共享方法所需的非暂态软件程序以及指令存储在第三存储器中,当被第三处理器执行时,执行上述各实施例的资源共享方法,例如,执行以上描述的图13中的方法步骤S900至S1000、方法步骤S910或方法步骤S1100。The non-transitory software programs and instructions required to realize the resource sharing method of the above-mentioned embodiments are stored in the third memory, and when executed by the third processor, the resource sharing methods of the above-mentioned embodiments are executed, for example, the above-described Method steps S900 to S1000, method step S910 or method step S1100 in FIG. 13 .
以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
此外,本申请的一个实施例还提供了一种计算机可读存储介质,该计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个第一处理器、第二处理器、第三处理器或控制器执行,例如,被上述设备实施例中的一个第一处理器、第二处理器或第三处理器执行,可使得上述第一处理器、第二处理器或第三处理器执行上述实施例中的资源共享方法,例如,执行以上描述的图3中的方法步骤S100至S400、图4中的方法步骤S210至S220、图5中的方法步骤S221、图6中的方法步骤S310、图7中的方法步骤S500、图11中的方法步骤S600至S800、图12中的方法步骤S810、图13中的方法步骤S900至S1000、方法步骤S910或方法步骤S1100。In addition, an embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by a first processor, a second processor, and a second processor. Execution by three processors or controllers, for example, being executed by a first processor, a second processor or a third processor in the above-mentioned device embodiment, may cause the above-mentioned first processor, second processor or third processing The device executes the resource sharing method in the above embodiment, for example, executes the method steps S100 to S400 in FIG. 3 described above, the method steps S210 to S220 in FIG. 4 , the method step S221 in FIG. 5 , and the method in FIG. 6 Step S310, method step S500 in FIG. 7, method step S600 to S800 in FIG. 11, method step S810 in FIG. 12, method step S900 to S1000 in FIG. 13, method step S910 or method step S1100.
本申请实施例包括:资源共享方法,应用于微前端系统,微前端系统包括第一应用、第二应用和资源管理装置,第一应用包括被设置为加载备用共享资源的资源加载装置,资源共享方法包括:第二应用向第一应用发送注册信息,注册信息包括资源信息,资源信息用于表征第二应用所需调用的目标共享资源的特征;资源管理装置接收由第一应用发送的资源信息,并根据资源信息和备用共享资源确定针对目标共享资源的加载策略;第一应用接收由资源管理装置发 送的加载策略,并根据加载策略更新资源加载装置;第二应用从更新后的资源加载装置中调用目标共享资源。根据本申请实施例提供的方案,在微前端系统中,第一应用通过收集第二应用的注册信息而使得资源管理装置确定加载策略,并且根据加载策略更新资源加载装置,使得资源加载装置能够按需动态地引入第二应用所需调用的目标共享资源,由于在微前端系统中的第一应用和第二应用在同一页面加载,因此可供第二应用直接从资源加载装置调用目标共享资源,相比于一些情形,无需多次地进行地址访问或者缓存调用资源,因此能够在节省网络带宽、缩短响应延时的情况下进行资源共享,有利于提升微前端系统针对资源共享的执行效率。The embodiment of the present application includes: a resource sharing method applied to a micro front-end system, 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 configured to load a backup shared resource, and the resource sharing The method includes: the second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call; the resource management device receives the resource information sent by the first application , and determine the loading strategy for 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; the second application loads the device from the updated resource Invoking the target shared resource. According to the solution provided by the embodiment of the present application, in the micro front-end system, the first application collects the registration information of the second application so that the resource management device determines the loading strategy, and updates the resource loading device according to the loading strategy, so that the resource loading device can press It is necessary to dynamically introduce the target shared resource that the second application needs to call. Since the first application and the second application in the micro-frontend system are loaded on the same page, the second application can directly call the target shared resource from the resource loading device. Compared with some situations, there is no need to perform address access or cache call resources multiple times, so resource sharing can be performed while saving network bandwidth and shortening response delay, which is conducive to improving the execution efficiency of the micro front-end system for resource sharing.
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、系统可以被实施为软件、固件、硬件及其适当的组合。某些物理组件或所有物理组件可以被实施为由处理器,如中央处理器、数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于RAM、ROM、EEPROM、闪存或其他存储器技术、CD-ROM、数字多功能盘(DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。Those skilled in the art can understand that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware and an appropriate combination 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). As known to those of ordinary skill in the art, the term computer storage media includes both volatile and nonvolatile media implemented in any method or technology for storage of information, such as computer readable instructions, data structures, program modules, or other data. permanent, removable and non-removable media. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cartridges, tape, magnetic disk storage or other magnetic storage devices, or can Any other medium used to store desired information and which can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, 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 may include any information delivery media .
以上是对本申请的若干实施方式进行的具体说明,但本申请并不局限于上述实施方式,熟悉本领域的技术人员在不违背本申请精神的前提下还可作出种种的等同变形或替换,这些等同的变形或替换均包含在本申请权利要求所限定的范围内。The above is a specific description of several implementations of the present application, but the application is not limited to the above-mentioned implementations. Those skilled in the art can also make various equivalent deformations or replacements without violating the spirit of the application. Equivalent modifications or replacements are all within the scope defined by the claims of the present application.

Claims (14)

  1. 一种资源共享方法,应用于微前端系统,所述微前端系统包括第一应用、第二应用和资源管理装置,所述第一应用包括被设置为加载备用共享资源的资源加载装置,所述资源共享方法包括:A resource sharing method, applied to a micro front-end system, 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 configured to load a backup shared resource, the Resource sharing methods include:
    所述第二应用向所述第一应用发送注册信息,所述注册信息包括资源信息,所述资源信息用于表征所述第二应用所需调用的目标共享资源的特征;The second application sends registration information to the first application, the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
    所述资源管理装置接收由所述第一应用发送的所述资源信息,并根据所述资源信息和所述备用共享资源确定针对所述目标共享资源的加载策略;The resource management device receives the resource information sent by the first application, and determines a loading strategy for the target shared resource according to the resource information and the standby shared resource;
    所述第一应用接收由所述资源管理装置发送的所述加载策略,并根据所述加载策略更新所述资源加载装置;The first application receives the loading policy sent by the resource management device, and updates the resource loading device according to the loading policy;
    所述第二应用从更新后的所述资源加载装置中调用所述目标共享资源。The second application invokes the target shared resource from the updated resource loading device.
  2. 根据权利要求1所述的资源共享方法,其中,所述资源管理装置根据所述资源信息和所述备用共享资源确定针对所述目标共享资源的加载策略,包括:The resource sharing method according to claim 1, wherein the resource management device determines a loading strategy for the target shared resource according to the resource information and the standby shared resource, comprising:
    所述资源管理装置根据所述资源信息和所述备用共享资源确定所述目标共享资源在所述资源加载装置的加载情况;The resource management device determines the loading status of the target shared resource in the resource loading device according to the resource information and the standby shared resource;
    所述资源管理装置根据所述加载情况确定针对所述目标共享资源的加载策略。The resource management device determines a loading strategy for the target shared resource according to the loading situation.
  3. 根据权利要求2所述的资源共享方法,其中,所述资源管理装置根据所述加载情况确定针对所述目标共享资源的加载策略,包括:The resource sharing method according to claim 2, wherein the resource management device determines a loading strategy for the target shared resource according to the loading situation, comprising:
    在所述目标共享资源未加载于所述资源加载装置的情况下,所述资源管理装置根据所述目标共享资源构建与所述目标共享资源对应的目标访问地址,并将所述目标访问地址嵌入到所述第一应用。In the 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 to the first application.
  4. 根据权利要求3所述的资源共享方法,其中,所述微前端系统还包括用于存储共享资源的共享资源库;The resource sharing method according to claim 3, wherein the micro front end system further comprises a shared resource library for storing shared resources;
    所述第一应用根据所述加载策略更新所述资源加载装置,包括:The first application updating the resource loading device according to the loading strategy includes:
    所述第一应用根据所述目标访问地址从所述共享资源库中引入所述目标共享资源,并将所述目标共享资源发送至所述资源加载装置。The first application imports 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. 根据权利要求1所述的资源共享方法,其中,所述第二应用向所述第一应用发送注册信息,包括:The resource sharing method according to claim 1, wherein the second application sends registration information to the first application, comprising:
    所述第二应用采用模型驱动的消息中间件方式向所述第一应用发送注册信息。The second application sends registration information to the first application in a model-driven message middleware manner.
  6. 根据权利要求1所述的资源共享方法,其中,所述第二应用从更新后的所述资源加载装置中调用所述目标共享资源之后,还包括:The resource sharing method according to claim 1, wherein, after the second application invokes 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 includes a resource loading device configured to load a spare shared resource, the micro front end system further includes a second application and a resource management device, The resource sharing method includes:
    获取由所述第二应用发送的注册信息,所述注册信息包括资源信息,所述资源信息用于表征所述第二应用所需调用的目标共享资源的特征;Acquire registration information sent by the second application, where the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
    向资源管理装置发送所述资源信息,以使所述资源管理装置根据所述资源信息和所述备用共享资源确定针对所述目标共享资源的加载策略;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;
    接收由所述资源管理装置发送的所述加载策略,并根据所述加载策略更新所述资源加载装置,以使所述第二应用从更新后的所述资源加载装置中调用所述目标共享资源。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. 根据权利要求7所述的资源共享方法,其中,所述微前端系统还包括用于存储共享资源的共享资源库;The resource sharing method according to claim 7, wherein the micro front end system further comprises a shared resource library for storing shared resources;
    所述根据所述加载策略更新所述资源加载装置,包括:The updating the resource loading device according to the loading strategy includes:
    在所述目标共享资源未加载于所述资源加载装置的情况下,根据所述加载策略从所述共享 资源库中引入所述目标共享资源至所述资源加载装置。In the case that the target shared resource is not loaded in the resource loading device, import 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 also includes a first application and a resource management device, the first application includes a resource loading device configured to load a standby shared resource, 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 makes the resource management device determine the target shared resource according to the resource information and the standby shared resource The loading policy, wherein the registration information includes resource information, and the resource information is used to characterize the characteristics of the target shared resource that the second application needs to call;
    从更新后的所述资源加载装置中调用所述目标共享资源,更新后的所述资源加载装置为由所述第一应用根据由所述资源管理装置发送的所述加载策略而确定。calling the target shared resource from the updated resource loading means determined by the first application according to the loading policy sent by the resource management means.
  10. 根据权利要求9所述的资源共享方法,其中,所述向所述第一应用发送注册信息,包括:The resource sharing method according to claim 9, wherein the sending registration information to the first application comprises:
    采用模型驱动的消息中间件方式向所述第一应用发送注册信息。The registration information is sent to the first application in a model-driven message middleware manner.
  11. 根据权利要求9所述的资源共享方法,其中,所述从更新后的所述资源加载装置中调用所述目标共享资源,还包括:The resource sharing method according to claim 9, wherein the calling the target shared resource from the updated resource loading device further comprises:
    在所述第一应用上展示界面元素,所述界面元素对应于所述目标共享资源。Displaying an interface element on the first application, the interface element corresponding to the target shared resource.
  12. 一种微前端系统,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现如权利要求1至6中任意一项所述的资源共享方法。A micro front end system, comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein, when the processor executes the computer program, any one of claims 1 to 6 is realized. The resource sharing method described in the item.
  13. 一种网络设备,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述处理器执行所述计算机程序时实现如权利要求7或8中所述的资源共享方法,或者,实现如权利要求9至11中任意一项所述的资源共享方法。A network device, comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor, wherein, when the processor executes the computer program, the method described in claim 7 or 8 is realized A resource sharing method, or implement the resource sharing method according to any one of claims 9-11.
  14. 一种计算机可读存储介质,存储有计算机可执行指令,其中,所述计算机可执行指令用于执行权利要求1至6中任意一项所述的资源共享方法,或者,执行权利要求7或8所述的资源共享方法,或者,执行权利要求9至11中任意一项所述的资源共享方法。A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the resource sharing method according to any one of claims 1 to 6, or to execute claim 7 or 8 The resource sharing method, or execute the resource sharing method described in any one of claims 9 to 11.
PCT/CN2022/093303 2021-08-10 2022-05-17 Resource sharing methods and micro-front-end system, application, and computer-readable storage medium WO2023016019A1 (en)

Applications Claiming Priority (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
CN202110914151.8 2021-08-10

Publications (1)

Publication Number Publication Date
WO2023016019A1 true WO2023016019A1 (en) 2023-02-16

Family

ID=85199807

Family Applications (1)

Application Number Title Priority Date Filing Date
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

Country Status (2)

Country Link
CN (1) CN115842733A (en)
WO (1) WO2023016019A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
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
CN111737032A (en) * 2020-07-27 2020-10-02 腾讯科技(深圳)有限公司 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
CN112988153A (en) * 2021-03-17 2021-06-18 薪得付信息技术(上海)有限公司 Data processing method and framework based on micro front end

Patent Citations (4)

* Cited by examiner, † Cited by third party
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
CN111737032A (en) * 2020-07-27 2020-10-02 腾讯科技(深圳)有限公司 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
CN112988153A (en) * 2021-03-17 2021-06-18 薪得付信息技术(上海)有限公司 Data processing method and framework based on micro front end

Also Published As

Publication number Publication date
CN115842733A (en) 2023-03-24

Similar Documents

Publication Publication Date Title
CN108228282B (en) Method and device for loading website page
KR100819021B1 (en) Method and apparatus for enabling associated portlets of a web portal to collaborate for synchronized content display
KR100843828B1 (en) Method and apparatus for managing a collection of portlets in a portal server
US10880391B2 (en) Method and apparatus for relaying session information from a portal server
US7870482B2 (en) Web browser extension for simplified utilization of web services
CN110636093B (en) Microservice registration and discovery method, microservice registration and discovery device, storage medium and microservice system
US20060235935A1 (en) Method and apparatus for using business rules or user roles for selecting portlets in a web portal
US20090313645A1 (en) Dynamic device profile interfaces
Malandrino et al. MIMOSA: context-aware adaptation for ubiquitous web access
US20040267900A1 (en) Dynamic mobile device characterization
CN101944032A (en) Microware updating method, client, server and system
WO2023016019A1 (en) Resource sharing methods and micro-front-end system, application, and computer-readable storage medium
CN111666074B (en) Web application customization method, related device and system
CN103793459B (en) Webpage opening method and device
US20080133586A1 (en) Ontology-based modification of structured representations of properties
CN112597423B (en) Webpage content display method, terminal and server
CN112765503A (en) Static processing method and device for page loading data
CN112925998B (en) Interface data processing method, device and system, electronic equipment and storage medium
CN117390326A (en) Page management method, device, equipment and storage medium
CN115827105A (en) Micro front end architecture based method for dynamically loading main and sub applications
CN116701520A (en) Page display method, device, server and storage medium
CN117873754A (en) Generalized calling method, device, equipment and medium
CN114691702A (en) Intercommunication method and device for client Web program and cloud database and terminal equipment
CN114528510A (en) Webpage data processing method and device, electronic equipment and medium
CN116560777A (en) Page display method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22855006

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE