CN115617417A - Micro front-end architecture sub-application management method, device, equipment and storage medium - Google Patents
Micro front-end architecture sub-application management method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN115617417A CN115617417A CN202211260235.5A CN202211260235A CN115617417A CN 115617417 A CN115617417 A CN 115617417A CN 202211260235 A CN202211260235 A CN 202211260235A CN 115617417 A CN115617417 A CN 115617417A
- Authority
- CN
- China
- Prior art keywords
- sub
- application
- configuration information
- target
- interface request
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000007726 management method Methods 0.000 title claims abstract description 40
- 230000003213 activating effect Effects 0.000 claims abstract description 15
- 230000000977 initiatory effect Effects 0.000 claims abstract description 10
- 238000000034 method Methods 0.000 claims description 43
- 238000004590 computer program Methods 0.000 claims description 17
- 230000004913 activation Effects 0.000 claims description 10
- 230000000007 visual effect Effects 0.000 claims description 3
- 230000002085 persistent effect Effects 0.000 claims description 2
- 238000011161 development Methods 0.000 abstract description 15
- 238000012423 maintenance Methods 0.000 abstract description 8
- 238000012545 processing Methods 0.000 description 14
- 238000004891 communication Methods 0.000 description 6
- 238000012800 visualization Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 4
- 239000002071 nanotube Substances 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 230000003068 static effect Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 238000013473 artificial intelligence Methods 0.000 description 2
- 238000004422 calculation algorithm Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 230000002688 persistence Effects 0.000 description 2
- 244000035744 Hura crepitans Species 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000002955 isolation Methods 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- 239000004575 stone Substances 0.000 description 1
- 230000001052 transient effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/30—Authentication, i.e. establishing the identity or authorisation of security principals
- G06F21/44—Program or device authentication
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4482—Procedural
- G06F9/4484—Executing subprograms
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Computer Hardware Design (AREA)
- Stored Programmes (AREA)
Abstract
The application discloses a micro front-end architecture sub-application management method, a device, equipment and a storage medium, which are applied to main application, relate to the technical field of micro front-end and comprise the following steps: reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information; activating the corresponding sub-application based on the browser access address and the sub-application name contained in the configuration information; when detecting that the interface request exists, determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request; and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server. By dynamically reading the configuration information during the initialization of the main application and carrying out operations such as loading or interface forwarding of the sub-application according to the configuration information, a large amount of development codes or configuration files do not need to be developed, and only by simple configuration, the development and maintenance efficiency is improved, and the robustness and the manageability of the micro front-end architecture are enhanced.
Description
Technical Field
The present invention relates to the field of micro front end technologies, and in particular, to a micro front end architecture sub-application management method, apparatus, device, and storage medium.
Background
With the recent increasing demand of people on software service systems and the increasing complexity of the Web application at the browser end, the Web application gradually becomes a very large "megastone application", which is not only very troublesome to develop and maintain, but also very poor in operation performance, and a micro front-end architecture is developed accordingly. The micro front end is a micro service architecture of the Web front end, and converts a single Web application into a plurality of small front end applications which are aggregated into one application. Each front-end application can be independently operated, independently developed and independently deployed, so that decoupling among modules of a front-end page is achieved. While qaankun is a micro front end solution that is currently more mature and commonly used. In the prior art, in order to implement the master application hosting the sub-applications, the service IP addresses, ports, and service names of the respective sub-applications are generally configured in the master application, and in order to meet the requirements of different sub-applications for forwarding requests to different target services, personalized development is often required at the server end of the master application. A large amount of repeated development work is required for each new-promoter application, and the work is tedious and the efficiency is extremely low.
In summary, how to manage a new sub-application only by simple configuration without developing a large amount of codes or changing configuration files is a technical problem to be solved in the field of management, development and maintenance efficiency of managing sub-applications.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, an apparatus, a device, and a storage medium for managing a sub-application in a micro-front-end architecture, which can manage a new sub-application only by simple configuration, and do not need to develop a large amount of codes or change configuration files, thereby improving management efficiency, development efficiency, and maintenance efficiency of managing the sub-application. The specific scheme is as follows:
in a first aspect, the present application discloses a micro front-end architecture sub-application management method, applied to a main application, including:
reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information;
activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information;
when detecting that the interface request exists, determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request;
and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server.
Optionally, before reading the configuration information for managing the sub-application, the method further includes:
the configuration information comprises the name of the sub-application, the IP of the sub-application, the port of the sub-application, the forwarding rule of the interface request, the matching of keywords and the address parameter of the server.
Optionally, the activating the corresponding sub-application based on the browser access address and the sub-application name included in the configuration information includes:
and inquiring corresponding sub-application IP and sub-application port based on the browser access address and the sub-application name contained in the configuration information, and activating the corresponding sub-application based on the sub-application IP and the sub-application port.
Optionally, before determining, from the activated sub-applications, a target sub-application that initiates the interface request based on the header information of the interface request, the method further includes:
and intercepting and authenticating the interface request by using the service end of the main application to obtain the successfully authenticated interface request.
Optionally, the determining, by using the configuration information, a target server corresponding to the target sub-application and forwarding the interface request to the target server includes:
and determining a forwarding rule corresponding to the target sub-application by using the configuration information, and forwarding the interface request to a target server corresponding to the target sub-application based on the forwarding rule.
Optionally, after determining the forwarding rule corresponding to the target sub-application by using the configuration information, the method further includes:
and if the forwarding rule corresponding to the target sub-application is determined to be self-defined forwarding, displaying the server address parameter of the corresponding target server in the visual sub-application page.
Optionally, the method for managing a sub-application of a micro front-end architecture further includes:
and storing the configuration information into a preset local database and/or a physical memory in a persistent manner so that the main application can read the configuration information through a preset information interface.
In a second aspect, the present application discloses a micro front-end architecture sub-application management device, applied to a main application, including:
the sub-application mounting module is used for reading configuration information used for managing the sub-applications and mounting the corresponding sub-applications based on the configuration information;
the sub-application activation module is used for activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information;
the application determining module is used for determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request when the interface request is detected to exist;
and the request forwarding module is used for determining a target server corresponding to the target sub-application by using the configuration information and forwarding the interface request to the target server.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the micro front-end architecture sub-application management method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the steps of the micro front-end architecture sub-application management method disclosed above.
Therefore, the application discloses a micro front-end architecture sub-application management method, which is applied to main applications and comprises the following steps: reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information; activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information; when detecting that the interface request exists, determining a target sub-application which initiates the interface request from the activated sub-applications based on the header information of the interface request; and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server. Therefore, the configuration information is dynamically read when the main application is initialized, and operations such as loading or interface forwarding of the sub-application are performed according to the configuration information, that is, the dynamic management of the sub-application is completed. By the method, management of the new sub-applications can be completed only by simple configuration without developing a large amount of codes or changing configuration files. The method is convenient and quick, greatly improves the development and maintenance efficiency, enhances the robustness of the micro front-end architecture, and improves the nanotube capacity of the micro front-end architecture.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart of a micro front end architecture sub-application management method disclosed in the present application;
FIG. 2 is a flow chart of a particular micro-front-end architecture sub-application management method disclosed herein;
FIG. 3 is a flowchart of a method for managing sub-applications of a master application in a micro front-end architecture based on qiankun disclosed in the present application;
FIG. 4 is a schematic structural diagram of a micro-front-end architecture sub-application management device disclosed in the present application;
fig. 5 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
With the recent more diversified demands of people on software service systems and the more complicated Web application at the browser end, the Web application gradually becomes a very large 'huge stone application', not only is the development and maintenance very troublesome, but also the running performance is very poor, and a micro front-end architecture is developed accordingly. The micro front end is a micro service architecture of the Web front end, and converts a single Web application into a plurality of small front end applications which are aggregated into one application. Each front-end application can be independently operated, independently developed and independently deployed, so that decoupling among modules of a front-end page is achieved. While qaankun is a micro front end solution that is currently more mature and commonly used. In the prior art, in order to implement the master application hosting the sub-applications, the service IP addresses, ports, and service names of the respective sub-applications are generally configured in the master application, and in order to meet the requirements of different sub-applications for forwarding requests to different target services, personalized development is often required at the server end of the master application. A large amount of repeated development work is required for each new-promoter application, and the work is tedious and the efficiency is extremely low.
Therefore, the micro front-end architecture sub-application management scheme is provided, new sub-applications can be managed only through simple configuration, a large amount of codes do not need to be developed or configuration files do not need to be changed, and management efficiency and development and maintenance efficiency of the sub-applications are improved.
Referring to fig. 1, an embodiment of the present invention discloses a micro front-end architecture sub-application management method, applied to a main application, including:
step S11: and reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information.
In this embodiment, the configuration information is persistently stored in a preset local database and/or a physical memory, so that the main application can read the configuration information through a preset information interface. It can be understood that all the key information of the sub-application is visually collected and persisted, and is prepared for subsequent management of the sub-application by using the configuration information, and then the configuration information for managing the sub-application is read from the configuration data set in the preset local database or the physical memory, and it should be noted that, when the configuration information in the configuration data set is read, all the configuration data sets are generally read through the interface when the main application is initialized, and the configuration information is cached in the main application. After the configuration information for managing the sub-applications is read, the mounting of all the sub-applications in the configuration data set is completed, and it can be understood that the mounting of the sub-applications, that is, the sub-applications perform a "registration" with the main application, and record information such as names, addresses, loaded containers, and activation rules in the main application. The sub-applications, i.e. the applications other than the main application, are referred to as sub-applications, and the sub-applications can be thought of as components of the main application, which are activated or destroyed according to the logic of the main application to provide specific service functions.
In this embodiment, before reading the configuration information for managing the sub-application, the method further includes: the configuration information comprises the name of the sub-application, the IP of the sub-application, the port of the sub-application, the forwarding rule of the interface request, the matching of keywords and the address parameter of the server. It can be understood that a visualized parameter configuration page is developed, which includes, but is not limited to, the following parameters: the method comprises the following steps of sub-application name, sub-application IP, sub-application port, request forwarding rule, keyword matching and target service address, wherein the request forwarding rule comprises the following steps: three options of no forwarding, default forwarding and custom forwarding are provided; the keyword matching specifically includes that a path of a sub application initiating request carries the keyword, and the keyword matching displays the parameter information only when the request forwarding rule selects 'custom forwarding'; the target service address is the target server address of the sub-application originating the request, and this parameter information is displayed only when the request forwarding rule selects "custom forwarding". Therefore, the parameter configuration is saved to a database or a physical storage through an interface by a front-end developer in a visualization page, and the configuration data of all the sub-applications form a data set.
Step S12: and activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information.
In this embodiment, the corresponding sub-application is activated according to the browser access address and the sub-application name in the configuration data set, that is, the main application controls which sub-application is activated according to the sub-application name in the browser access address, that is, the page of the sub-application and other static resources are read into the page, and the display of the sub-application page is completed. The rest sub-applications are in an inactive state, and all pages or static resources cannot be loaded in the pages. Specifically, a corresponding sub-application IP and a sub-application port are queried based on a browser access address and a sub-application name included in the configuration information, and the corresponding sub-application is activated based on the sub-application IP and the sub-application port. The main application accesses the name of the sub-application in the address through the browser, finds the corresponding IP address and port of the sub-application by combining the configuration data set, and completes activation of the sub-application.
Step S13: when detecting that the interface request exists, determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request.
In this embodiment, when a page of a sub-application requests an API interface, which sub-application the request originates from is identified according to a referrer in the request header, and the sub-application from which the request originates is determined as a target sub-application from among the activated sub-applications.
Step S14: and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server.
In this embodiment, the forwarding rule in the configuration information is used to determine the target server corresponding to the target sub-application, and the page request of the sub-application is forwarded to the target server for processing, it can be understood that since there may be multiple servers, the forwarding rule is predefined in the configuration information, and the target server corresponding to the sub-application is determined, so that the page request from the sub-application is accurately forwarded to the corresponding target server.
Therefore, the application discloses a micro front-end architecture sub-application management method, which is applied to main applications and comprises the following steps: reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information; activating the corresponding sub-application based on the browser access address and the sub-application name contained in the configuration information; when detecting that the interface request exists, determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request; and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server. Therefore, the configuration information is dynamically read when the main application is initialized, and operations such as loading or interface forwarding of the sub-application are performed according to the configuration information, that is, the dynamic management of the sub-application is completed. By the method, management of the new sub-applications can be completed only by simple configuration without developing a large amount of codes or changing configuration files. The method is convenient and quick, greatly improves the development and maintenance efficiency, enhances the robustness of the micro front-end architecture, and improves the nanotube capacity of the micro front-end architecture.
Referring to fig. 2, the embodiment of the present invention discloses a specific micro-front-end framework sub-application management method, and compared with the previous embodiment, the present embodiment further describes and optimizes the technical solution. Specifically, the method comprises the following steps:
step S21: and reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information.
Step S22: and activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information.
For a more detailed processing procedure in steps S21 and S22, please refer to the content of the foregoing disclosed embodiments, which is not described herein again.
Step S23: when detecting that the interface request exists, utilizing the service end of the main application to intercept and authenticate the interface request so as to obtain the successfully authenticated interface request.
In this embodiment, when the page of the sub-application requests the API interface, the server of the main application sets a request interceptor through a code, to intercept the page requests of all the sub-applications, and perform uniform interception and authentication on the interface requests of the page. It can be understood that, since the Web applications both have a server side and a browser side, the main application server side, that is, the server side of the Web application, mainly intercepts the request information of the application, and performs service processing such as authentication information assembly, black and white lists, and the like to obtain an interface request after authentication is successful.
Step S24: and determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request.
In this embodiment, the header information of the interface request successfully authenticated is obtained, and it is determined that the interface request is from a certain activated sub-application according to the header information, for example: the method comprises the steps of identifying which sub-application a request originates from according to a referrer in a request header, wherein the referrer is a part of the header, and when a browser sends a request to a Web server, the browser is generally provided with the referrer to indicate a link from which to a current webpage, and the server can obtain some information for processing, wherein the format is URL. In other words, with referrer, the current web page can check where the visitor came from, which is also often used to deal with fake cross-web requests. When a visitor accesses a web page, refer is the URL of the previous web page. If the picture is a picture, the picture is usually referred to as a webpage. The referrer is included in the interface request when the web browser is directed to the web server.
Step S25: and determining a forwarding rule corresponding to the target sub-application by using the configuration information, and forwarding the interface request to a target server corresponding to the target sub-application based on the forwarding rule.
In this embodiment, the forwarding rule corresponding to the target sub-application is determined by using the configuration information, and it can be understood that if a keyword carried in a request path initiated by the sub-application can be matched with a keyword corresponding to "custom forwarding" in the request forwarding rule, the forwarding rule corresponding to the target sub-application is determined to be custom forwarding. Correspondingly, the server address parameter of the corresponding target server is displayed in the visualization sub-application page. Forwarding the interface request to a target server corresponding to the server address parameter according to the service address parameter, and if the forwarding rule corresponding to the target sub-application is determined to be the default forwarding, forwarding the interface request to the corresponding target server based on the default forwarding rule; and if the forwarding rule corresponding to the target sub-application is determined not to be forwarded, stopping forwarding the interface request to any server.
Referring to fig. 3, a process of dynamic nanotube application of a main application in a micro-front-end architecture based on qaankun includes: the method comprises the following steps of sub-application parameter configuration, configuration persistence, configuration reading, sub-application loading and interface forwarding, and specifically comprises the following steps: first, a visualization page is developed, and the design includes, but is not limited to, the following configuration parameters: the method comprises the following steps of (1) sub-application name, sub-application IP, sub-application port, request forwarding rule, matching keyword and target service address; secondly, according to the formats of the different configuration information, the configuration data of the sub-applications are durably stored in a database or physical storage, and configuration data sets of all the sub-applications are formed in the database or the physical storage; secondly, when the main application is initialized, namely a system page is loaded for the first time, reading the configuration data set, caching in the main application, and simultaneously mounting all the sub-applications in the configuration data set; according to the name of the sub-application in the browser access address, the IP address and the port of the corresponding sub-application are searched in the configuration data set, the corresponding sub-application is activated, and the page of the sub-application is displayed, for example: the sub-application pages are activated, and the inactivated sub-application pages are not displayed in the system page; when the activated page of the sub-application requests an API interface, the server end of the main application intercepts the page, identifies which sub-application the request comes from according to the referrer in the request header, searches the corresponding forwarding rule in the configuration data, and forwards the request to the corresponding target server according to the forwarding rule. Wherein the qaankun is specifically a micro front end framework available for production, and has the capability required by micro front end systems such as js sandbox, style isolation, preloading and the like. The qaankun can be used for any js framework, and the micro application access is as simple as embedding an iframe system. The micro front end is specifically Web front end micro-servitization, namely the front end service is split according to a business module or other rules, and each application is independently developed, independently deployed and independently released. The main application is a basic project among a plurality of applications in the micro front end architecture, and other applications are registered in the main application, and the main application controls which project is to be activated according to the link address. Only the overall control functions are provided and no specific service functions are provided.
Therefore, the interface requests initiated by all activated sub-applications are processed in a unified mode through the main application server end, the interface requests are intercepted and the like, the main application server end directly correspondingly forwards the interface requests to the target server according to the forwarding rules in the pre-loaded configuration information in a unified mode, personalized development of the main application server end is not needed, repeated development work is reduced, work is simplified, and efficiency is improved.
Referring to fig. 4, an embodiment of the present invention discloses a specific micro front end architecture sub-application management device, which is applied to a main application, and includes:
the sub-application mounting module 11 is configured to read configuration information for managing the sub-applications, and mount the corresponding sub-applications based on the configuration information;
a sub-application activation module 12, configured to activate a corresponding sub-application based on the browser access address and the sub-application name included in the configuration information;
an application determining module 13, configured to determine, when it is detected that there is an interface request, a target sub-application that initiates the interface request from among the activated sub-applications based on header information of the interface request;
a request forwarding module 14, configured to determine, by using the configuration information, a target server corresponding to the target sub-application, and forward the interface request to the target server.
The sub-application mounting module 11 is specifically configured to persistently store the configuration information to a preset local database and/or a physical memory, so that the main application reads the configuration information through a preset information interface. It can be understood that all the key information of the sub-application is visually collected and persisted, and is prepared for subsequent management of the sub-application by using the configuration information, and then the configuration information for managing the sub-application is read from the configuration data set in the preset local database or the physical memory, and it should be noted that, when the configuration information in the configuration data set is read, all the configuration data sets are generally read through the interface when the main application is initialized, and the configuration information is cached in the main application. After the configuration information for managing the sub-applications is read, the mounting of all the sub-applications in the configuration data set is completed, and it can be understood that the mounting of the sub-applications, that is, the sub-applications perform a "registration" with the main application, and record information such as names, addresses, loaded containers, and activation rules in the main application. The sub-applications, i.e. the applications other than the main application, are referred to as sub-applications, and the sub-applications can be thought of as components of the main application, which are activated or destroyed according to the logic of the main application to provide specific service functions. Before reading the configuration information for managing the sub-application, the method further includes: the configuration information comprises sub application names, sub application IPs, sub application ports, interface request forwarding rules, keyword matching and server address parameters. It can be understood that a visualized parameter configuration page is developed, which includes, but is not limited to, the following parameters: the method comprises the following steps of sub-application name, sub-application IP, sub-application port, request forwarding rule, keyword matching and target service address, wherein the request forwarding rule comprises the following steps: three options of no forwarding, default forwarding and custom forwarding are provided; the keyword matching specifically includes that a path of a sub application initiating request carries the keyword, and the keyword matching displays the parameter information only when the request forwarding rule selects 'custom forwarding'; the target service address is the target server address of the sub-application originating the request, and this parameter information is displayed only when the request forwarding rule selects "custom forwarding". Therefore, the parameter configuration is saved to a database or a physical storage through an interface by a front-end developer in a visualization page, and the configuration data of all the sub-applications form a data set.
The sub-application activation module 12 is specifically configured to activate the corresponding sub-application according to the browser access address and the sub-application name in the configuration data set, that is, the main application controls which sub-application is activated according to the sub-application name in the browser access address, that is, the page of the sub-application and other static resources are read into the page, and the display of the sub-application page is completed. The rest sub-applications are in an inactive state, and all pages or static resources cannot be loaded in the pages. Specifically, a corresponding sub-application IP and a sub-application port are queried based on a browser access address and a sub-application name included in the configuration information, and the corresponding sub-application is activated based on the sub-application IP and the sub-application port. The main application accesses the name of the sub-application in the address through the browser, finds the corresponding IP address and port of the sub-application by combining the configuration data set, and completes activation of the sub-application.
The application determining module 13 is specifically configured to, when a page of a sub-application requests an API interface, set a request interceptor by a code at a server side of the main application, and configured to intercept the page requests of all the sub-applications, and perform uniform interception and authentication on the interface requests of the page. It can be understood that, because Web applications both have a server side and a browser side, the main application server side, that is, the server side of the Web application, mainly intercepts the request information of the application, and performs service processing such as authentication information assembly, black and white lists, and the like to obtain an interface request after authentication is successful.
The request forwarding module 14 is specifically configured to obtain header information of the interface request successfully authenticated, and determine, according to the header information, that the interface request is from a certain activated sub-application, for example: the method comprises the steps of identifying which sub-application a request originates from according to a referrer in a request header, wherein the referrer is a part of the header, and when a browser sends a request to a Web server, the browser is generally provided with the referrer to indicate a link from which to a current webpage, and the server can obtain some information for processing, wherein the format is URL. In other words, with referrer, the current web page can check where the visitor came from, which is also often used to deal with fake cross-web requests. When the visitor accesses a web page, refer is the URL of the previous web page. If the picture is a picture, the picture is usually referred to as a webpage. The referrer is included in the interface request when the web browser is directed to the web server. And determining a forwarding rule corresponding to the target sub-application by using the configuration information, wherein if the keyword carried in the request path initiated by the sub-application can be matched with the keyword corresponding to the 'custom forwarding' in the request forwarding rule, the forwarding rule corresponding to the target sub-application is determined to be custom forwarding. Correspondingly, the server address parameter of the corresponding target server is displayed in the visualization sub application page. Forwarding the interface request to a target server corresponding to the server address parameter according to the service address parameter, and if the forwarding rule corresponding to the target sub-application is determined to be the default forwarding, forwarding the interface request to the corresponding target server based on the default forwarding rule; and if the forwarding rule corresponding to the target sub-application is determined not to be forwarded, stopping forwarding the interface request to any server.
Therefore, the application discloses a micro front-end architecture sub-application management method, which is applied to main applications and comprises the following steps: reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information; activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information; when detecting that the interface request exists, determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request; and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server. Therefore, the configuration information is dynamically read when the main application is initialized, and operations such as loading or interface forwarding of the sub-application are performed according to the configuration information, that is, the dynamic management of the sub-application is completed. By the method, management of the new sub-applications can be completed only by simple configuration without developing a large amount of codes or changing configuration files. The method is convenient and quick, greatly improves the development and maintenance efficiency, enhances the robustness of the micro front-end architecture, and improves the nanotube capacity of the micro front-end architecture.
In some embodiments, the micro front-end architecture sub-application management device may specifically include:
and the information configuration unit is used for configuring configuration information comprising the name of the sub-application, the IP of the sub-application, a port of the sub-application, an interface request forwarding rule, keyword matching and server address parameters.
In some specific embodiments, the sub-application activation module 12 may specifically include:
and the application activation unit is used for inquiring the corresponding sub-application IP and the sub-application port based on the browser access address and the sub-application name contained in the configuration information, and activating the corresponding sub-application based on the sub-application IP and the sub-application port.
In some embodiments, the micro front-end architecture sub-application management device may specifically include:
and the request authentication unit is used for intercepting and authenticating the interface request by using the service end of the main application so as to obtain the successfully authenticated interface request.
In some specific embodiments, the request forwarding module 14 may specifically include:
and the rule determining submodule is used for determining a forwarding rule corresponding to the target sub-application by using the configuration information, and forwarding the interface request to a target server corresponding to the target sub-application based on the forwarding rule.
In some embodiments, the rule determining sub-module may specifically include:
and the parameter determining unit is used for displaying the server address parameter of the corresponding target server in the visual sub-application page if the forwarding rule corresponding to the target sub-application is determined to be self-defined forwarding.
In some embodiments, the micro front-end architecture sub-application management device may specifically include:
and the information persistence unit is used for persistently storing the configuration information to a preset local database and/or a physical memory so that the main application can read the configuration information through a preset information interface.
Further, an electronic device is disclosed in the embodiments of the present application, and fig. 5 is a block diagram of the electronic device 20 according to an exemplary embodiment, which should not be construed as limiting the scope of the application.
Fig. 5 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present disclosure. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, and the computer program is loaded and executed by the processor 21 to implement relevant steps in the micro front-end architecture sub-application management method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to obtain external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
In addition, the storage 22 is used as a carrier for resource storage, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage manner may be a transient storage or a permanent storage.
The operating system 221 is configured to manage and control each hardware device and the computer program 222 on the electronic device 20, so as to implement the operation and processing of the mass data 223 in the memory 22 by the processor 21, and may be Windows Server, netware, unix, linux, or the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the micro front-end architecture sub-application management method executed by the electronic device 20 disclosed in any of the foregoing embodiments. The data 223 may include data received by the electronic device and transmitted from an external device, or may include data collected by the input/output interface 25 itself.
Further, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the micro front-end architecture sub-application management method disclosed above. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, which are not described herein again.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed in the embodiment corresponds to the method disclosed in the embodiment, so that the description is simple, and the relevant points can be referred to the description of the method part.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application. The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
The method, the apparatus, the device and the storage medium for managing the micro front-end architecture sub-application provided by the present invention are described in detail above, and a specific example is applied in the present document to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, the specific embodiments and the application range may be changed, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (10)
1. A management method for a micro front-end architecture sub-application is applied to a main application, and comprises the following steps:
reading configuration information for managing the sub-applications, and mounting the corresponding sub-applications based on the configuration information;
activating the corresponding sub-application based on the browser access address and the sub-application name contained in the configuration information;
when detecting that the interface request exists, determining a target sub-application which initiates the interface request from the activated sub-applications based on the header information of the interface request;
and determining a target server corresponding to the target sub-application by using the configuration information, and forwarding the interface request to the target server.
2. The method according to claim 1, wherein before reading the configuration information for managing the sub-application, the method further comprises:
the configuration information comprises the name of the sub-application, the IP of the sub-application, the port of the sub-application, the forwarding rule of the interface request, the matching of keywords and the address parameter of the server.
3. The method according to claim 1, wherein activating the corresponding sub-application based on the browser access address and the sub-application name included in the configuration information comprises:
and inquiring corresponding sub-application IP and sub-application port based on the browser access address and the sub-application name contained in the configuration information, and activating the corresponding sub-application based on the sub-application IP and the sub-application port.
4. The method according to claim 1, wherein before determining a target sub-application from among the active sub-applications that initiates the interface request based on the header information of the interface request, the method further comprises:
and intercepting and authenticating the interface request by using the service end of the main application to obtain the successfully authenticated interface request.
5. The method according to claim 1, wherein the determining a target server corresponding to the target sub-application by using the configuration information and forwarding the interface request to the target server comprises:
and determining a forwarding rule corresponding to the target sub-application by using the configuration information, and forwarding the interface request to a target server corresponding to the target sub-application based on the forwarding rule.
6. The method according to claim 5, wherein after determining the forwarding rule corresponding to the target sub-application by using the configuration information, the method further comprises:
and if the forwarding rule corresponding to the target sub-application is determined to be self-defined forwarding, displaying the server address parameter of the corresponding target server in the visual sub-application page.
7. The micro front-end architecture sub-application management method according to any one of claims 1 to 6, further comprising:
and storing the configuration information into a preset local database and/or a physical memory in a persistent manner so that the main application can read the configuration information through a preset information interface.
8. A micro front-end architecture sub-application management device is applied to a main application, and comprises the following components:
the sub-application mounting module is used for reading configuration information used for managing the sub-applications and mounting the corresponding sub-applications based on the configuration information;
the sub-application activation module is used for activating the corresponding sub-application based on the browser access address and the name of the sub-application contained in the configuration information;
the application determining module is used for determining a target sub-application for initiating the interface request from the activated sub-applications based on the header information of the interface request when the interface request is detected to exist;
and the request forwarding module is used for determining a target server corresponding to the target sub-application by using the configuration information and forwarding the interface request to the target server.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing said computer program for implementing the steps of the micro front-end architecture sub-application management method according to any of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the steps of the micro front-end architecture sub-application management method of any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211260235.5A CN115617417A (en) | 2022-10-14 | 2022-10-14 | Micro front-end architecture sub-application management method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211260235.5A CN115617417A (en) | 2022-10-14 | 2022-10-14 | Micro front-end architecture sub-application management method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115617417A true CN115617417A (en) | 2023-01-17 |
Family
ID=84861974
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211260235.5A Pending CN115617417A (en) | 2022-10-14 | 2022-10-14 | Micro front-end architecture sub-application management method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115617417A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116360779A (en) * | 2023-06-02 | 2023-06-30 | 杭州比智科技有限公司 | Method for constructing micro front end base based on qiankun in Vue CLI application |
-
2022
- 2022-10-14 CN CN202211260235.5A patent/CN115617417A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116360779A (en) * | 2023-06-02 | 2023-06-30 | 杭州比智科技有限公司 | Method for constructing micro front end base based on qiankun in Vue CLI application |
CN116360779B (en) * | 2023-06-02 | 2023-08-15 | 杭州比智科技有限公司 | Method for constructing micro front end base based on qiankun in Vue CLI application |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10623476B2 (en) | Endpoint management system providing an application programming interface proxy service | |
US10356156B2 (en) | Method and device for loading webpage | |
US20090327460A1 (en) | Application Request Routing and Load Balancing | |
US8554980B2 (en) | Triggered notification | |
CN113452780B (en) | Access request processing method, device, equipment and medium for client | |
CN113765980A (en) | Current limiting method, device, system, server and storage medium | |
CN109284466B (en) | Method, apparatus and storage medium for enabling web page access in blockchain | |
CN111510330B (en) | Interface management device, method and storage medium | |
CN113315706B (en) | Private cloud flow control method, device and system | |
US11765112B2 (en) | Context driven dynamic actions embedded in messages | |
CN111767089A (en) | Method, device and equipment for loading file and storage medium | |
US20230328147A1 (en) | Smart notification system | |
CN115617417A (en) | Micro front-end architecture sub-application management method, device, equipment and storage medium | |
CN113162944B (en) | Network communication method, device and equipment for security operation platform and security component | |
CN114285659A (en) | Reverse proxy method, device, equipment and storage medium | |
WO2022090847A1 (en) | Handling deferrable network requests | |
US10135728B2 (en) | Partial switching of network traffic | |
CN112948733B (en) | Interface maintenance method, device, computing equipment and medium | |
US20220086215A1 (en) | Web Client with Response Latency Awareness | |
CN114301872A (en) | Domain name based access method and device, electronic equipment and storage medium | |
CN115516842A (en) | Orchestration broker service | |
CN113765972A (en) | Data request response method, device, system, server and storage medium | |
US20200228517A1 (en) | Secure Cloud Computing | |
US12032647B2 (en) | Tenant network for rewriting of code included in a web page | |
CN112988385A (en) | Request processing method, device, system, storage medium and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |