Multi-system micro-front-end dynamic integration method and device, electronic equipment and storage medium
By using a multi-system micro-frontend integration method, deploying base applications and configuring sandbox mechanisms, frontend plugins, and caching strategies, and generating time-limited user tokens using a unified authentication service, combined with a dual verification mechanism, the problems of scattered entry points, low data utilization, and weak performance in traditional system integration are solved, achieving efficient integration and stable operation of multiple systems.
Patent Information
- Application Number
- CN202511126291.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-11-28
AI Technical Summary
Traditional system integration solutions suffer from problems such as fragmented entry points, low data utilization, and weak performance. In particular, in multi-system integration, the user experience is poor, the communication efficiency between systems is low, and the access control is fragmented.
By adopting a multi-system micro-frontend integration approach, deploying a base application and configuring a sandbox mechanism, frontend plugins, and caching strategies, and using a unified authentication service to generate time-limited user tokens, combined with a dual verification mechanism, we can achieve secure loading and state management of sub-applications and optimize resource loading efficiency.
It improved system performance and user experience, solved the problem of fragmented access control, achieved efficient integration and stable operation of multiple systems, and ensured the continuity and security of user access.
Smart Images

Figure CN121029252A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, can be applied to the field of science and technology finance, and particularly relates to a multi-system micro-frontend dynamic integration method and device, electronic equipment and a storage medium. BACKGROUND
[0002] In the current informationization and digitization construction process, many fields generally adopt a "vertical shaft type" development mode in the initial stage of application system construction due to the independence and urgency of business requirements. In the selection of system integration technology, the iframe nested integration method becomes the common choice of many developers due to its low invasiveness and simple implementation process. This method places different application systems in independent spaces and runs separately, which meets the demand of quickly integrating systems in the short term to a certain extent. However, with the continuous expansion of business scale and the increasing expectations of users for system interaction and efficiency, the limitations of the iframe nested integration method become increasingly obvious. In terms of user application experience, the scattered service entry makes users have to frequently switch system entries when operating, and the operation process is complicated and lacks coherence. For new users, the adaptation cost is high. From the overall system, the processes and services between systems are seriously fragmented, and cannot form an efficient and coordinated organic whole, thereby hindering the smooth progress of the business process. In terms of data utilization, due to the lack of data sharing mechanism between systems, data is scattered in each independent system and cannot be centrally integrated and deeply analyzed, so that data cannot be effectively converted into decision basis. In terms of running efficiency, the iframe nested integration method also has performance bottlenecks, which will produce large performance overhead, and the communication between systems is difficult, the information interaction efficiency is low, and the collaborative work ability between systems is seriously restricted. In addition, the styles of each system are independent, which leads to the lack of consistency and coordination of system visual effects, and reduces the user experience. SUMMARY
[0003] The technical problem solved by the embodiments of the present application is the scattered entry, low data utilization rate and weak performance of the traditional system integration scheme.
[0004] To solve the above technical problems, the first technical solution adopted by the embodiments of the present application is to provide a multi-system micro-frontend integration method, comprising: deploying a base application based on a micro-frontend framework, configuring a sandbox mechanism and a front-end plug-in of the base application, initializing a cache strategy of the base application, and obtaining a target system to be integrated as a sub-application, and opening a state refresh interface of the sub-application; when a user logs in the base application and accesses the sub-application, a deployed unified authentication service is called to generate a user token with a time limit, and the user token is returned to the sub-application; the sub-application obtains an access token from the unified authentication service according to user information and a key pair, and verifies the validity of the access token and the user token through the unified authentication service, wherein the user information is user data saved after successful login, and the key pair is obtained from the unified authentication service in advance; if the access token is valid, the base application loads the sub-application using the sandbox mechanism and the front-end plug-in.
[0005] Optionally, after the step of loading the sub-application using the sandbox mechanism and the front-end plug-in in the base application if the access token is valid, the method further comprises: when the sub-application is successfully loaded, registering a login state of the user to the base application through the sub-application, and periodically detecting and renewing the login state in the base application according to the state refresh interface and the cache strategy; or, when the sub-application is successfully loaded and the user switches between different sub-applications, verifying the validity of the access token and the user token through the unified authentication service, and periodically detecting and renewing the login state in the base application according to the state refresh interface and the cache strategy.
[0006] Optionally, the step of calling the deployed unified authentication service to generate a user token with a time limit and returning the user token to the sub-application when the user logs in the base application and accesses the sub-application comprises: when the user logs in the base application and accesses the sub-application, calling a user token generation interface of the deployed unified authentication service through the base application; obtaining the user token returned by the user token generation interface, wherein the user token is generated by a preset token generation algorithm, and the user token is provided with a time limit and a one-time use limit; and returning the generated user token to the sub-application.
[0007] Optionally, the step of obtaining an access token from the unified authentication service by the sub-application using the logged-in user information and the pre-acquired key from the unified authentication service, and verifying the validity of the access token and the user token by the unified authentication service, comprises: obtaining a key pair from the unified authentication service after the sub-application is started, wherein the key pair comprises a corresponding public key and a private key; initiating an access token request to the unified authentication service by the sub-application using the logged-in user information, the public key and the private key; returning the access token generated by a preset access token generation algorithm to the cache of the sub-application when the unified authentication service verifies that the user information, the public key and the private key are passed, wherein the access token is provided with a cache time limit; calling an authentication service authorization interface of the unified authentication service by the sub-application using the user information, the access token and the user token; and receiving the verification result of the validity of the user information, the access token and the user token returned by the authentication service authorization interface.
[0008] Optionally, the step of loading the sub-application by the base application using the sandbox mechanism and the front-end plug-in if the access token is valid, comprises: creating an independent sandbox running environment for the sub-application by the base application using the sandbox mechanism if the access token is valid, and hiding the custom front-end library variables of the sub-application; analyzing the cascading style sheet of the sub-application using the front-end plug-in, adding a target prefix and / or a scope identifier to the cascading style sheet to limit the style of the sub-application within the sandbox element; injecting a global style reset file into the sub-application to unify the appearance style of the front-end basic elements of the sub-application, and replacing the custom component style of the sub-application with a preset unified component style; and clearing the style data of the sub-application stored in the sandbox running environment when the sub-application is unloaded.
[0009] Optionally, the step of registering the login state of the user by the sub-application to the base application, and periodically detecting and renewing the login state by the base application according to the state refresh interface and the cache strategy, comprises: registering the login state information of the user to the base application by an event binding mechanism when the sub-application is loaded; sending a state verification request to the sub-application by the base application using the state refresh interface according to a preset detection period to obtain the remaining validity period of the current login state information; and calling the state refresh interface to update the login state information when it is detected that the remaining validity period of the login state information is lower than a preset threshold, and updating the cache of the login state information at the same time.
[0010] Optionally, after the step of calling the state refresh interface to update the login state information while updating the cache of the login state information, the method further comprises: if the state refresh fails, triggering a timeout retry mechanism of the base application, and if the retry fails, marking the state of the sub-application as abnormal; when the user logs out of the base application or the sub-application is uninstalled, removing the login state information and the cache data corresponding to the login state information through the base application; and if the user accesses the sub-application whose state is marked as abnormal again, re-executing a unified authentication process through the base application to obtain new valid login state information.
[0011] Optionally, after the step of registering the login state of the user by the sub-application to the base application and periodically detecting and renewing the login state by the base application according to the state refresh interface and the cache strategy, the method further comprises: after the sub-application is successfully loaded, caching resource files and configuration information of the sub-application by the base application and recording an access weight value and a cache duration of the sub-application; when the user accesses the sub-application, checking whether there is valid resource in the cache by the base application, if there is and the cache duration has not exceeded a cache duration threshold, loading the resources of the sub-application from the cache, if there is not or the cache duration has expired, re-obtaining corresponding resources from the sub-application; traversing a cache list according to a preset period by the base application, performing weighted calculation according to the access weight value and the cache duration, and removing the cache of the sub-application with the smallest weighted weight; when the resources of the sub-application are continuously accessed for a preset number of times, marking the corresponding resources as hot resources, prolonging the cache duration of the hot resources, and improving the access weight of the hot resources.
[0012] To solve the above technical problems, a second technical solution adopted by the embodiments of the present application is to provide a multi-system micro front-end integration device, comprising: an application initialization module, configured to deploy a base application based on a micro front-end framework, configure a sandbox mechanism and a front-end plug-in of the base application, initialize a cache strategy of the base application, and obtain a target system to be integrated as a sub-application and open a state refresh interface of the sub-application; a user token acquisition module, configured to, when a user logs in the base application and accesses the sub-application, call a deployed unified authentication service to generate a user token with a time limit, and return the user token to the sub-application; an access token acquisition module, configured to, through the sub-application, acquire an access token from the unified authentication service according to user information and a key pair, and verify the validity of the access token and the user token through the unified authentication service, wherein the user information is user data saved after successful login, and the key pair is obtained from the unified authentication service in advance; and a sub-application loading module, configured to, if the access token is valid, load the sub-application by the base application using the sandbox mechanism and the front-end plug-in.
[0013] To solve the above technical problems, a third technical solution adopted by the embodiments of the present application is to provide an electronic device, comprising: at least one processor; and a memory in communication connection with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the multi-system micro front-end integration method as described above.
[0014] Differently from the related art, the multi-system micro front-end integration method provided by the present application effectively isolates the code and style interference between the sub-applications and the base application by deploying the base application and configuring the sandbox mechanism, the front-end plug-in and the cache strategy, optimizes the system performance, and improves the resource loading efficiency. The security and legality of the sub-application access are enhanced by generating a user token with time limit by the unified authentication service and combining the "user token + access token" double verification mechanism, the tedious operation of repeated login in the traditional system is avoided, and the problem of scattered permission management is solved. When the sub-application is loaded, the sandbox mechanism and the front-end plug-in are used to ensure that the sub-application runs stably, safely and uniformly in style. The effective management and synchronization of the login state are realized by registering the login state of the sub-application to the base application and regularly detecting the renewal, and the coherence of user access is ensured. The flexibility and security of communication are ensured by the bidirectional data communication realized based on the browser native mechanism. Overall, the user experience and system management efficiency are improved, and efficient integration and stable operation of multiple systems are realized. BRIEF DESCRIPTION OF DRAWINGS
[0015] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, which are schematic and not intended to be limiting of the embodiments, and in which like reference numerals designate similar items in the figures, in which: the drawings do not limit the proportion.
[0016] Figure 1 is a schematic diagram of a running environment of the multi-system micro front-end integration method provided by the embodiments of the present application.
[0017] Figure 2 is a schematic diagram of an execution flow of the multi-system micro front-end integration method provided by the embodiments of the present application.
[0018] Figure 3 is an example diagram of an execution flow of application and issuance of keys in the multi-system micro front-end integration method provided by the embodiments of the present application.
[0019] Figure 4 is an example diagram of an execution flow of unified authentication in the multi-system micro front-end integration method provided by the embodiments of the present application.
[0020] Figure 5This is an example diagram of the execution flow for unified adaptation of sub-application styles in the multi-system micro-frontend integration method provided in this application embodiment.
[0021] Figure 6 This is an example diagram of the execution flow of sub-application state management in the multi-system micro-frontend integration method provided in this application embodiment.
[0022] Figure 7 This is another example of the execution flow diagram for sub-application state management in the multi-system micro-frontend integration method provided in this application embodiment.
[0023] Figure 8 This is an example diagram of the sub-application caching workflow in the multi-system micro-frontend integration method provided in this application embodiment.
[0024] Figure 9 This is a flowchart illustrating the data communication process between the base application and sub-applications in the multi-system micro-frontend integration method provided in this application embodiment.
[0025] Figure 10 This is a schematic diagram of the system structure of the multi-system micro-frontend integration device provided in the embodiments of this application.
[0026] Figure 11 This is a schematic diagram of the hardware structure of an electronic device that performs a multi-system micro-frontend integration method according to an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0028] It should be noted that, unless there is a conflict, the various features in the embodiments of this application can be combined with each other, and all are within the protection scope of this application. Furthermore, although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a different module division or in a different order than that shown in the device schematic diagram or the flowchart.
[0029] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items.
[0030] To facilitate understanding of this embodiment, a multi-system micro-frontend integration method disclosed in this application will first be described in detail. Please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a schematic diagram of the operating environment of the multi-system micro-frontend integration method provided in the embodiments of this application, such as... Figure 1 As shown, the execution subject of the multi-system micro-frontend integration method provided in this application embodiment is generally an electronic device with a certain computing power, such as a computer device. In some possible implementations, this multi-system micro-frontend integration method can be implemented by the processor calling computer-readable instructions stored in the memory. Figure 1 The computer equipment mentioned can be a server. A server can be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. This can be understood as... Figure 1 The number of computer devices shown is merely illustrative and can be expanded in any number according to actual needs.
[0031] Please continue reading. Figure 2 , Figure 2 This is a schematic diagram of the execution flow of the multi-system micro-frontend integration method provided in the embodiments of this application, such as... Figure 2 As shown, it includes the following steps S1 to S4.
[0032] S1. Deploy the base application based on the micro-frontend framework, configure the sandbox mechanism and frontend plugins of the base application, initialize the caching strategy of the base application, obtain the target system to be integrated as a sub-application, and open the status refresh interface of the sub-application.
[0033] When integrating multiple system micro-frontends, it is necessary to consider aspects such as unified authentication of sub-applications, data communication between sub-applications and base applications, state management of sub-applications, unified style adaptation between sub-applications and base applications, as well as caching and performance optimization. Therefore, it is necessary to consider the front-end and back-end technology stacks, technical frameworks, technical architectures, authentication methods, token management mechanisms, compilation and building methods, and resources available for modification of the sub-applications being integrated.
[0034] As examples, step S1 can utilize a micro-app micro-frontend framework. This framework's core features include sandbox isolation, low-intrusion integration, and support for mainstream frontend frameworks such as Vue and React. The base application serves as a unified entry point (e.g., a management portal), responsible for loading sub-applications, managing the authentication process, coordinating global state, and optimizing performance. Sandboxing isolates the JavaScript execution environment and CSS styles of the base and sub-applications, preventing sub-application code from polluting the base (e.g., global variable conflicts, style overriding). The micro-app sandbox is based on the browser's native Shadow DOM or Proxy, creating an independent scope for each sub-application. Frontend plugins can be used for unified style adaptation of sub-applications, employing Webpack / Vite plugins and supporting UI frameworks such as Element-UI, Element Plus, and Ant Design. The caching strategy aims to store sub-application resources (JS, CSS, static files, etc.) and access states, reducing repeated network requests and improving loading speed. Caching strategy rules can be based on access frequency (weight value) and duration to manage caching, removing infrequent cache entries, or marking hot resources (accessed multiple times consecutively) and extending cache duration. Sub-applications (such as project management systems, R&D delivery systems, and requirement management systems) need to expose state refresh interfaces (such as APIs for refreshing tokens) so that the base application can periodically verify and renew user login status. Furthermore, sub-applications only need to adapt the interfaces and retain the original authentication mechanisms (such as the original session / token management) to reduce the cost of sub-application transformation.
[0035] S2. When a user logs into the base application and accesses a sub-application, the deployed unified authentication service is invoked to generate a time-limited user token, which is then returned to the sub-application.
[0036] As an optional implementation, please refer to Figure 3 , Figure 3 This is an example diagram illustrating the execution flow of key application and issuance in the multi-system micro-frontend integration method provided in this application embodiment, as shown below. Figure 3 As shown, firstly, the sub-application administrator initiates an application to access the authentication service and fills in the relevant application information. Then, the authentication service administrator reviews the application information. Upon approval, the authentication service platform uses an algorithm to generate a KEY and a key, and authorizes the sub-application to access the authentication service's API interface. Next, the authentication service administrator registers and manages the key information and transfers the key to the sub-application. Finally, the sub-application receives the KEY and key issued by the authentication service, completing the access process.
[0037] As another optional implementation, step S2 may further include steps S21 to S23.
[0038] S21. When a user accesses a sub-application after logging into the base application, the user token generation interface of the deployed unified authentication service is called through the base application.
[0039] S22. Obtain the user token returned by the user token generation interface. The user token is generated by a preset token generation algorithm and has an expiration time limit and a one-time use limit.
[0040] For example, the validity period of a user token can be set to 5 minutes, after which it becomes unusable to prevent the risk of token leakage. Then, the user token generation algorithm can employ a combination of cryptographic algorithms (such as HMAC-SHA256) and random string generation to ensure unpredictability.
[0041] S23. Return the generated user token to the sub-application.
[0042] As an example, a company uses a technology management portal based on a micro-frontend framework as its base application, integrating multiple sub-applications such as a requirements management system, a project management system, and a research and development delivery system. After logging into the technology management portal, a user clicks to enter the project management system. At this point, the technology management portal backend, according to pre-defined communication rules, uses the HTTPS protocol to send a request to the deployed unified authentication service, calling its user token generation interface. Upon receiving the request, the unified authentication service verifies the legitimacy of the request source by checking the portal application's unique identifier (Client ID) and signature information. If correct, it uses the SHA256 hash algorithm, combined with the system timestamp, a random number, and the portal application key, to generate a user token (user_token) valid for 5 minutes and limited to single use, and returns it to the technology management portal backend. After obtaining the user token, the portal backend injects it into the project management system's frontend runtime environment through a custom event (e.g., microapp:token). The project management system frontend receives and temporarily stores the user token, preparing for subsequent operations such as requesting access tokens (access_token) and permission verification from the unified authentication service.
[0043] Through steps S21 to S23, a unified authentication service is invoked to generate a user token with an expiration date and single-use limit, which is then transmitted to the sub-application. This achieves a unified authentication process of "one-time authentication, seamless access across multiple systems," avoiding the cumbersome operation of repeated logins required by traditional "siloed" systems. Generating tokens using a preset algorithm and limiting their validity and number of uses enhances the security of the authentication process and reduces the risk of token leakage. Simultaneously, sub-application access is achieved in a low-intrusive manner, without requiring modification to the sub-application's original authentication mechanism, reducing the cost of cooperation with target systems, and ensuring compatibility with existing third-party systems. This effectively solves the pain points of fragmented system entry points and poor process integration, improving user operation efficiency and user experience.
[0044] S3. The sub-application obtains an access token from the unified authentication service based on the user information and key pair, and verifies the validity of the access token and user token through the unified authentication service. The user information is the user data saved after successful login, and the key pair is obtained in advance from the unified authentication service.
[0045] The technical purpose of step S3 is to ensure the security and legitimacy of sub-application access through a dual verification mechanism of "user token (user_token) + access token (access_token)," while being compatible with the original authentication system of the sub-application. Based on the user_token issued by the unified authentication service, the sub-application further applies for an access_token through its own key pair and user information, forming a secure link of "one-time application, dual verification" to avoid the risk of unauthorized access caused by the leakage of a single token.
[0046] As an optional implementation, step S3 may further include steps S31 to S35.
[0047] S31. When the sub-application starts, it obtains a key pair from the unified authentication service, wherein the key pair includes the corresponding public key and private key.
[0048] For example, when a sub-application connects to the unified authentication service, it needs to apply for and bind a unique public key and private key for asymmetric encrypted communication (such as the RSA algorithm). When the sub-application starts (e.g., during frontend initialization or backend service startup), it retrieves or verifies the assigned key pair from the unified authentication service via a secure channel (HTTPS) to ensure the key pair is bound to the sub-application's identity. The private key is stored securely on the sub-application's server (e.g., in an encrypted database or via a Key Management Service (KMS), while the public key can be publicly used for signature verification to prevent the key pair from being intercepted during transmission.
[0049] S32. The sub-application uses the logged-in user information, public key, and private key to initiate an access token request to the unified authentication service.
[0050] For example, the sub-application encapsulates the user's logged-in identity information (such as user ID and role), public key, and private key signature (generating a signature value by adding a timestamp to the user information using the private key) into a request body. It then sends a POST request to the unified authentication service's ` / api / app / getJwtToken` interface via HTTPS, ensuring data transmission is tamper-proof and secure. Step S32 above is equivalent to the sub-application "proving its identity" to the authentication service, verifying its legitimacy through private key signing and preventing request forgery.
[0051] S33. After the unified authentication service verifies the user information, public key and private key, it returns the access token generated by the preset access token generation algorithm to the cache of the sub-application. The access token has a cache time limit.
[0052] For example, the unified authentication service verifies the validity of user information (e.g., whether the user exists or has been frozen), the consistency of the public and private key signatures (verifying the request's legitimacy by decrypting the signature using the public key), and whether the user_token has been used or expired. After successful verification, an access_token is generated using a preset algorithm (e.g., HMAC-SHA256), containing information such as the user's permission scope and expiration time (e.g., 30 minutes), typically in JWT format (for easy parsing by sub-applications). Sub-applications store the access_token in a memory cache (e.g., Redis) or browser session storage, setting a cache time (e.g., slightly shorter than the token's expiration time) to reduce the pressure of repeated requests.
[0053] S34. Sub-applications use user information, access tokens, and user tokens to call the authentication service authorization interface of the unified authentication service.
[0054] For example, a sub-application combines user information, an access token (used to verify permissions), and a user token (used to verify the legitimacy of a single access) as request parameters and calls the ` / api / oauth / checkUserToken` interface of the unified authentication service. The authentication service uses the access token to resolve the user's role in the sub-application (e.g., "project manager," "regular employee," etc.) and matches it with the sub-application's resource access permissions (e.g., whether viewing project financial data is allowed). It also verifies whether the user token is bound to the current access token (i.e., whether the access token was generated by the corresponding user token) to prevent token reuse across sessions.
[0055] S35. Receive the validity verification results of user information and access token returned by the authentication service authorization interface.
[0056] For example, the authentication service returns a JSON-formatted result, including status (success / failure), code (error code), message (prompt message), and permission scope (e.g., permissions:["view","edit"]). In addition, if authentication is successful, the sub-application loads the corresponding resource (e.g., a report page in a project management system) and logs the access. If authentication fails (e.g., token expired, insufficient permissions), the sub-application redirects to the base application's login page or displays a permission denial message, while simultaneously triggering the base application to clear its invalid token cache. Repeated calls to the authentication interface are allowed, but the same user_token + access_token combination is only valid within its expiration period to prevent security vulnerabilities caused by repeated submissions.
[0057] As an example, a company's technology management portal integrates a code hosting system as a sub-application. When the code hosting system starts, it automatically obtains pre-assigned public and private keys from a unified authentication service (the public key is used for signature verification, and the private key is stored in a secure server environment). When a user accesses the code hosting system through the portal, the sub-application uses the user's logged-in identity information (e.g., employee ID, permission group), public key, and private key to sign the request and initiate an access token request to the unified authentication service. After the authentication service verifies the user information and key pair, it generates an access token (JWT format, valid for 30 minutes) containing the permission scope (e.g., code read / write permissions) and returns it to the sub-application's cache. Subsequently, the sub-application calls the authentication service's authorization interface with the user information, access token, and the previously obtained user token (a time-limited, single-use credential). After verifying the association and validity of the two tokens, the authentication service returns an access permission result, and the code hosting system loads the required code repository resources based on this.
[0058] Through steps S31 to S35, an asymmetric encryption key pair mechanism (public / private key) ensures the legitimacy of the sub-application's identity, preventing forged requests. By combining user information with the key pair for verification, precise binding between sub-application permissions and user identity is achieved. The access token caching mechanism reduces duplicate authentication requests, improving system response efficiency. The dual-token (user token + access token) association verification mechanism strengthens access control security, preventing unauthorized access risks caused by a single token leak. Simultaneously, this process is compatible with the sub-application's existing authentication system, requiring only interface adaptation for integration. This reduces the complexity of modifying existing systems and effectively solves the problems of fragmented permission management and cumbersome cross-system authentication in traditional integration solutions, improving security and user operation consistency in multi-system integration scenarios.
[0059] As an example, please refer to Figure 4 , Figure 4This is an example diagram of the execution flow of unified authentication in the multi-system micro-frontend integration method provided in this application embodiment, such as... Figure 4 As shown, after a user logs into the technology management portal, they click or access resources and services in its sub-applications. At this time, the portal's backend service requests a user_token with time and access limits from the authentication service. This token is generated by the authentication service using an algorithm. Upon receiving the user_token, the sub-application parses and verifies the request information, assembling the key, secret key, and user information into a message, and requests an access_token from the authentication service. The authentication service verifies the key and secret key and returns the result. The sub-application receives the access_token and reassembles it with the user_token, submitting it to the authentication service to verify the validity of the user_token. The authentication service returns the verification result. If the result is invalid, the technology management portal renders portal resources and loads an error page; if the result is valid, the sub-application calls system logic to authenticate user information and permissions. If authentication fails, the technology management portal renders an error page for the sub-application; if authentication succeeds, the sub-application loads system resources, and the technology management portal's base application successfully renders the sub-application resources.
[0060] S4. If the access token is valid, the base application uses a sandbox mechanism and a front-end plugin to load the sub-application.
[0061] Provided that the access token is valid, the sandbox mechanism and front-end plugins are used to ensure that the sub-applications are loaded and run stably, securely and with consistent styles in the base application, preventing code and style conflicts between the sub-applications and the base application, as well as between the sub-applications themselves.
[0062] As an optional implementation, step S4 may further include steps S41 to S44.
[0063] S41. If the access token is valid, the base application uses a sandbox mechanism to create an independent sandbox runtime environment for the sub-application and hides the sub-application's custom front-end library variables.
[0064] The sandbox mechanism utilizes browser features (such as Shadow DOM or JavaScript environment isolation implemented using proxies) to create an independent runtime space for sub-applications. Within this space, the JavaScript code execution environment of the sub-application is isolated from the base application and other sub-applications, preventing interference from global variables. For example, global variables defined in a sub-application will not "leak" into the scope of the base application or other sub-applications. Hiding custom front-end library variables in sub-applications further ensures that the sub-application's code does not accidentally couple with other parts, guaranteeing its independence and stability.
[0065] S42. Use a front-end plugin to analyze the Cascading Style Sheets (CSS) of the sub-application, and add target prefixes and / or scope identifiers to the CSS to restrict the styles of the sub-application to sandbox elements.
[0066] Front-end plugins (such as those developed using build tools like Webpack or Vite) perform in-depth analysis of Cascading Style Sheets (CSS). By adding target prefixes and scope identifiers, they can precisely limit the scope of styles applied to sub-applications. For example, a simple class name in a sub-application might conflict with class names in other sub-applications or the base application. Adding prefixes and scope identifiers is like giving these style rules unique "labels," ensuring they only apply within the sandbox elements corresponding to the sub-application. Even if different sub-applications or the base application have the same class name, it won't cause style confusion, achieving effective style isolation.
[0067] S43. Inject global style reset files into the sub-application to unify the appearance style of the basic front-end elements of the sub-application, and replace the custom component styles of the sub-application with preset unified component styles.
[0068] The global style reset file overrides the default styles of basic elements (such as body, div, p, etc.) in the sub-applications' front-end, ensuring that all sub-applications maintain a consistent basic appearance, such as setting uniform fonts, colors, and margins. Replacing custom component styles in sub-applications with preset uniform component styles achieves overall visual consistency. For example, replacing custom button styles in sub-applications with uniform button styles that match the entire system's style creates consistency and harmony in the user interface, improving user experience and facilitating overall interface maintenance and updates.
[0069] S44. When a sub-application is uninstalled, clear the style data of the sub-application stored in the sandbox runtime environment.
[0070] When a sub-application finishes use and is uninstalled, to prevent residual style data from affecting the loading of subsequent sub-applications or the normal operation of the base application, it is necessary to clear the sub-application style data stored in the sandbox runtime environment. This includes previously added prefixes, scope identifiers, and various custom style rules defined by the sub-application. This cleanup mechanism ensures the "cleanliness" of the sandbox runtime environment, preparing it for the next loading of sub-applications and preventing the accumulation of redundant and conflicting style data.
[0071] As an example, please refer to Figure 5 , Figure 5 This is an example diagram of the execution flow for unified adaptation of sub-application styles in the multi-system micro-frontend integration method provided in this application embodiment, such as... Figure 5As shown, firstly, the technology management portal is responsible for building the webpack and vite plugins, and then providing them to the sub-applications. Upon receiving the plugins, the sub-applications import them into their own webpack or vite tools. After importing the plugins, the sub-applications begin a series of style processing operations: First, they hide custom UI library variables to prevent style conflicts during application integration; second, they introduce unified style variables for the micro-applications, laying the foundation for the sub-applications to integrate with the overall style; third, during the build phase, they generate new theme styles based on the UI libraries used by the sub-applications, enabling them to better adapt to the overall system; fourth, they import the newly generated theme styles into the sub-applications for adaptation. Through these steps, the customization and integration of the sub-application styles are completed, achieving style uniformity and coordination between the sub-applications and the technology management portal.
[0072] Through steps S41 to S44, the sandbox mechanism creates an independent runtime environment for sub-applications and hides custom front-end library variables, effectively preventing code interference between sub-applications and the base application and other sub-applications, ensuring the independence and stability of code execution, and avoiding functional abnormalities caused by variable conflicts. Using front-end plugins to process cascading style sheets for sub-applications, adding target prefixes and scope identifiers, restricts styles to sandbox elements, avoiding style chaos and mutual overwriting, and achieving precise isolation of styles for each sub-application. Injecting global style reset files and replacing custom component styles unifies the appearance of basic front-end elements and component styles of sub-applications, improving the overall visual consistency and user experience of the system, and facilitating unified interface maintenance. When a sub-application is uninstalled, style data within the sandbox is cleared to prevent style residue from causing subsequent conflicts, ensuring a clean sandbox environment, providing a good foundation for subsequent sub-application loading, and ensuring the smoothness and stability of the entire micro-frontend architecture.
[0073] As an optional implementation, after step S4 above, the user's login status can also be managed, that is, the user login status can be managed, specifically including the following step S5.
[0074] S5. After the sub-application loads successfully, the user's login status is registered with the base application through the sub-application. The base application refreshes the interface and caching strategy according to the status, and periodically checks and renews the login status. Alternatively, after the sub-application loads successfully, when the user switches between different sub-applications, the validity of the access token and user token is verified through the unified authentication service. The base application refreshes the interface and caching strategy according to the status, and periodically checks and renews the login status.
[0075] Step S5 is the core step in achieving consistent management of user login status across applications, solving the technical problems of repeated logins and difficulty in status synchronization when users switch between different sub-applications in traditional "siloed" systems. After a sub-application loads successfully, it registers user login status information (such as user ID, token, and validity period) with the base application through an event binding mechanism, making the base application the global manager of login status. The base application periodically checks the remaining validity period of the login status by calling the status refresh interface opened by the sub-application according to a preset detection cycle. When the validity period is lower than a threshold, it automatically triggers status renewal and updates the cache, ensuring that users do not need to log in frequently. When a user switches between different sub-applications, the unified authentication service first verifies the validity of the access token and user token. The base application then simultaneously checks and renews the login status of the switched sub-application through the status refresh interface and caching strategy. This mechanism ensures access security through dual token verification and, with the centralized status management of the base application, achieves a smooth experience of "one-time login, seamless switching" for users across multiple sub-applications, while also being compatible with the original authentication system of the sub-applications, reducing the complexity of system modification.
[0076] As an optional implementation, step S5 may further include steps S51 to S53.
[0077] S51. After the sub-application is loaded, the user's login status information is registered with the base application through the event binding mechanism.
[0078] For example, when a sub-application finishes loading, it means it's ready to run normally. At this point, using an event binding mechanism (such as listening for a specific load completion event in JavaScript using `addEventListener`), the sub-application will send the user's login status information (such as user ID, login time, permission level, token, and other related data) to the base application for registration. This is similar to the sub-application "reporting" the current user's login status to the base application, allowing the base application to subsequently manage and monitor this login status, establishing an informational link between the two applications regarding the user's login status.
[0079] S52. The base application sends a status verification request to the sub-application using the status refresh interface according to the preset detection period to obtain the remaining validity period of the current login status information.
[0080] For example, the base application sends a status verification request to the sub-application via a pre-defined detection cycle (e.g., every 5 minutes, which can be flexibly adjusted according to actual business needs). Upon receiving the request, the sub-application checks the remaining validity period of the current user's login status information (e.g., the remaining validity period of the token) and returns this information to the base application. This allows the base application to monitor the validity of the user's login status in real time, providing a basis for subsequent renewal operations and ensuring the validity of the user's login status.
[0081] S53. When the remaining validity period of the login status information is detected to be lower than the preset threshold, the status refresh interface is called to update the login status information, and the cache of the login status information is updated at the same time.
[0082] For example, when the base application detects that the remaining validity period of the login status information is lower than a preset threshold (e.g., less than 20% of the initial validity period), to prevent inconvenience such as the user needing to log in again due to expired login status, the base application will call the status refresh interface to send a request to the sub-application to update the login status information. Upon receiving the request, the sub-application will interact with the authentication service (e.g., obtain a new token) to update the login status information and then return the updated information to the base application. Simultaneously, the base application will also update the data regarding this login status information in its local cache to ensure that the latest and valid login status information is used subsequently, maintaining the user's normal login status.
[0083] As another optional implementation, step S4 may further include steps S54 to S56.
[0084] S54. If the status refresh fails, the timeout retry mechanism of the base application is triggered. If the retry fails, the status of the sub-application is marked as abnormal.
[0085] For example, when attempting to update login status information, if the status refresh fails due to network failure, authentication service anomalies, or other reasons, the base application will trigger a timeout retry mechanism (e.g., setting a maximum of 3 retries, with a 2-second interval between each retrieval). This process provides the system with multiple opportunities to recover in the event of a possible temporary failure. If the retries still fail after multiple attempts, it indicates a problem with the login status of the current sub-application. The base application will then mark the sub-application's status as abnormal for subsequent targeted handling, such as notifying the user or conducting relevant troubleshooting.
[0086] S55. When a user exits the base application or uninstalls a sub-application, the login status information and the corresponding cached data are removed through the base application.
[0087] Specifically, when a user actively exits the base application or the sub-application is uninstalled, the current session between the user and that sub-application ends. At this time, the base application removes the previously registered login status information for that user within the sub-application and deletes the corresponding cached data. This is to ensure the accuracy and cleanliness of system data, avoid invalid login status information and cache consuming system resources, and prevent potential information confusion or other problems in the future.
[0088] S56. If a user revisits a sub-application whose status is marked as abnormal, the unified authentication process is re-executed through the base application to obtain new valid login status information.
[0089] For example, if a user attempts to access a sub-application that was previously marked as abnormal, it indicates that the user needs to continue using the sub-application. In this case, the base application will re-execute the unified authentication process (i.e., starting from obtaining the user_token and going through the complete authentication steps again), interacting with the authentication service to obtain new valid login status information. This allows the user to regain legitimate access permissions and use the sub-application's functions normally, ensuring user continuity and the normal operation of the system.
[0090] As an example, please refer to Figure 6 , Figure 6 This is an example diagram of the execution flow of sub-application state management in the multi-system micro-frontend integration method provided in this application embodiment, such as... Figure 6 As shown, when a user accesses sub-application resources and services within the base application, the sub-application verifies the user's information. If verification is successful, the sub-application transmits the user's status information to the base application. Upon receiving this information, the base application registers the user and incorporates it into a unified monitoring and management system. Subsequently, it periodically polls and checks the user's status information according to a set schedule. During the check, the base application determines whether the user's status information has reached a set threshold (e.g., a login status validity period threshold). If not, it continues periodic polling; if it has, the base application calls the user status refresh interface, requesting the sub-application to verify the user information and refresh the status. If the sub-application times out processing this request, the base application automatically triggers a retry mechanism. After the sub-application successfully verifies and refreshes the user's status, the base application updates the sub-application's user status information, completing the user status management process.
[0091] As another example, please refer to Figure 7 , Figure 7 This is another example of the execution flow diagram for sub-application state management in the multi-system micro-frontend integration method provided in this application embodiment, such as... Figure 7As shown, when a base application fails to refresh the user status of a sub-application, if the user continues to access the sub-application's resources and services, the sub-application will first verify the user's status. If the status is invalid, the verification fails, and the user's access is denied. Simultaneously, the sub-application sends the verification failure information back to the base application. Upon receiving this failure information, the base application removes the corresponding user status information from the sub-application and then re-initiates the request and loading process for the sub-application's resources. During this process, the sub-application submits an authentication request to the unified authentication service. After processing and completing the authentication, the unified authentication service returns the authentication result to the sub-application. Based on this result, the sub-application completes user verification and then transmits the user status information to the base application. Upon receiving this, the base application registers the sub-application and incorporates it into its unified monitoring and management. If any problems occur during the entire process, the base application will ultimately render an error page for the sub-application, thus fully presenting the entire process from the failed status refresh to the subsequent series of interactions, authentications, and result presentations.
[0092] Through steps S51 to S56, user login status information is registered via an event binding mechanism, ensuring accurate transmission and association of login status information between the base application and sub-applications, laying the foundation for subsequent management. A preset detection cycle periodically verifies the validity period of the login status, enabling timely monitoring of login status timeliness and early detection of potential expiration risks. When the validity period falls below a threshold, the login status information and cache are proactively updated, effectively preventing users from frequently re-login due to expired login status and improving user continuity. A timeout retry mechanism for failed status refreshes enhances the system's ability to handle temporary faults, and marking abnormal states facilitates subsequent troubleshooting. When a user logs out or a sub-application is uninstalled, the login status information and cache are removed, ensuring clean system data and avoiding resource consumption and information confusion. A unified authentication process is re-executed for sub-applications in abnormal states, ensuring users can access the system normally again, maintaining system stability and user smoothness, and comprehensively improving user experience and system management efficiency.
[0093] As a preferred embodiment, the method includes the following steps S61 to S64.
[0094] S61. After the sub-application is successfully loaded, the resource files and configuration information of the sub-application are cached through the base application, and the access weight value and cache duration of the application are recorded.
[0095] For example, when a sub-application loads successfully, the base application uses caching technology to store the sub-application's resource files (such as JavaScript, CSS files, images, etc.) and configuration information (such as route configuration, permission settings, etc.). Simultaneously, it records an access weight value (initially set to 1, increasing with each access) and cache duration (recording the cache entry time) for each sub-application, providing foundational data for subsequent cache management.
[0096] S62. When a user accesses a sub-application, the base application checks whether there are valid resources in the cache. If they exist and the cache duration threshold is not exceeded, the sub-application's resources are loaded from the cache. If they do not exist or the cache duration has expired, the corresponding resources are retrieved from the sub-application.
[0097] For example, when a user accesses a sub-application, the base application first checks if there is a corresponding valid resource in the cache. It checks if the cache exists and compares the current time with the cached time to determine if the cache duration threshold has been exceeded. If the cache exists and has not expired, the sub-application resource is loaded directly from the cache, reducing network requests; if the cache does not exist or has expired, the resource is retrieved again from the sub-application server to ensure the user receives the latest content.
[0098] S63. The base application iterates through the cache list according to a preset period, performs a weighted calculation based on the access weight value and cache duration, and removes the cache of the sub-application with the smallest weight.
[0099] For example, the base application iterates through the cache list at a set period (e.g., hourly) and performs a weighted calculation based on the access weight value and cache duration of each sub-application (e.g., weighted weight = access weight value × (1 + cache duration / maximum cache duration)). This calculation method assesses the importance of each cached item, then removes the sub-application cache with the lowest weight, freeing up cache space and ensuring that important and frequently used resources are retained in the cache.
[0100] S64. When a sub-application's resource is accessed a preset number of times consecutively, the corresponding resource is marked as a hot resource, and the cache duration of the hot resource is extended, as well as the access weight of the hot resource is increased.
[0101] For example, when a sub-application's resource is accessed consecutively a preset number of times (e.g., 5 times), the base application marks it as a hot resource. For hot resources, the cache duration is extended (e.g., set to several times that of ordinary resources) to increase their retention time in the cache; at the same time, the access weight is increased (set to a higher fixed value) to make them less likely to be evicted in cache management, thereby optimizing the loading performance of frequently accessed resources.
[0102] As an example, please refer to Figure 8 , Figure 8 This is an example diagram of the sub-application caching workflow in the multi-system micro-frontend integration method provided in this application embodiment, such as... Figure 8As shown, when a user clicks or accesses a sub-application resource, the base application first checks if the sub-application is cached. If cached, the sub-application directly responds to the user's request; if not cached, the base application requests the sub-application resource and service, the sub-application requests unified authentication from the authentication service, the authentication service verifies the user information and returns the resource, and the sub-application sends the information back to the base application for registration. Subsequently, the base application checks if the number of sub-application caches exceeds a threshold. If it does, it removes and unloads the sub-application cache with the lowest weight value, and then caches the sub-application resource; if it does not exceed the threshold, it caches directly. Finally, the base application periodically checks cache information through polling, removes caches exceeding the cache duration threshold, and calculates a weighted weight based on the sub-application weight and cache duration to achieve optimized cache management.
[0103] Through steps S61 to S64 above, after a sub-application is successfully loaded, its resource files and configuration information are cached, and access weight values and cache durations are recorded. This enables rapid resource retrieval and provides data support for subsequent cache management. When accessing a sub-application, resources are intelligently loaded based on cache validity, ensuring data timeliness while reducing network requests and latency. Weighted calculations based on access weight values and cache durations are performed at preset intervals, and low-weighted caches are removed, dynamically cleaning cache space and optimizing cache utilization. Identifying hot resources and extending their cache duration and increasing their access weights can specifically accelerate the loading of frequently accessed resources, improving overall system resource loading efficiency, optimizing user experience, and ensuring high system performance and stability.
[0104] As another preferred implementation, in the integrated architecture of the base application and sub-applications, bidirectional data communication is achieved through an event binding-listening pattern based on the browser's native CustomEvent mechanism. Specific application scenarios of this mechanism in this implementation include: sub-application status notification, where the sub-application sends a resource loading completion status to the base application by triggering a custom event (e.g., resourceLoaded); lifecycle management, where the sub-application notifies the base application to perform resource reclamation and status cleanup before uninstallation via an event (e.g., beforeUnload); and bidirectional data interaction, where cross-application data transfer is achieved by carrying custom data payloads (CustomEvent.detail) through events in specific business scenarios (e.g., form submission, permission verification). The aforementioned communication mechanism is based on a publish-subscribe pattern, ensuring communication security through event namespace isolation (e.g., the microapp: prefix), while supporting event bubbling and capturing mechanisms, providing a loosely coupled message passing solution for micro-frontend architectures.
[0105] As an example, please refer to Figure 9 , Figure 9This is a flowchart illustrating the data communication process between the base application and sub-applications in the multi-system micro-frontend integration method provided in this application embodiment. Figure 9 As shown, when a base application sends data to a child application, the base application sends data via `setData`, triggering a data change event. The child application listens for this event using `addDataListener` and executes data processing logic. When the child application is uninstalled, it removes the listener using `removeDataListener`. When a child application sends data to a base application, the child application sends data via `dispatch`, triggering an event. The base application listens for and processes the data using `addDataListener`. When the child application is uninstalled, the base application removes the listener. In a bidirectional data transfer scenario, the child application sends data via `dispatch`, triggering an event. The base application listens for and processes the data, returning a result. The child application processes the result data via `callback`. When the child application is uninstalled, the base application similarly removes the listener. This event binding-listener mechanism ensures flexible and efficient communication.
[0106] The multi-system micro-frontend integration method provided in this application, by deploying a base application based on a micro-frontend framework and configuring a sandbox mechanism, frontend plugins, and caching strategies, achieves low-intrusion integration of sub-applications, avoids code and style conflicts, and optimizes system performance. By leveraging a unified authentication service to generate time-limited user tokens and combining a "user token + access token" dual verification mechanism, the security and legitimacy of sub-application access are ensured, solving the problems of repeated logins and fragmented permission management in traditional systems. During the sub-application loading phase, a sandbox mechanism and frontend plugins ensure stable, secure, and style-consistent operation. Effective management and synchronization of login status are achieved by having sub-applications register their login status with the base application and periodically check for renewal. In cache management, resource loading efficiency is improved by recording access weight values and cache duration, intelligently loading resources, dynamically clearing the cache, and identifying hot resources. Bidirectional data communication is achieved through an event binding-listening mode based on the browser's native CustomEvent mechanism, ensuring the flexibility and security of communication between the base application and sub-applications. This method comprehensively improves user experience and system management efficiency, effectively solves pain points such as scattered system entry points and poor process integration, and achieves efficient integration and stable operation of multiple systems.
[0107] Please continue reading. Figure 10 , Figure 10 This is a schematic diagram of the system structure of the multi-system micro-frontend integration device provided in the embodiments of this application, such as... Figure 10 As shown, the multi-system micro-frontend integration device 10 includes: an application initialization module 101, a user token acquisition module 102, an access token acquisition module 103, a sub-application loading module 104, and a login status management module 105.
[0108] The application initialization module 101 is specifically used to deploy a base application based on a micro-frontend framework, configure the sandbox mechanism and frontend plugins of the base application, initialize the caching strategy of the base application, obtain the target system to be integrated as a sub-application, and open the status refresh interface of the sub-application.
[0109] The user token acquisition module 102 is specifically used to call the deployed unified authentication service to generate a time-limited user token when a user accesses the sub-application after logging into the base application, and then return the user token to the sub-application.
[0110] The access token acquisition module 103 is specifically used to obtain an access token from the unified authentication service through the sub-application based on user information and a key pair, and to verify the validity of the access token and the user token through the unified authentication service. The user information is user data saved after successful login, and the key pair is obtained in advance from the unified authentication service.
[0111] The sub-application loading module 104 is specifically used to load the sub-application in the base application using the sandbox mechanism and the front-end plugin if the access token is valid.
[0112] As an optional implementation, the multi-system micro-frontend integration device 100 further includes a login status management module. This module is used to register the user's login status with the base application through the sub-application after the sub-application has successfully loaded, and to periodically check and renew the login status in the base application according to the status refresh interface and the caching policy. Alternatively, when the sub-application has successfully loaded and the user switches between different sub-applications, the module verifies the validity of the access token and the user token through the unified authentication service, and periodically checks and renews the login status in the base application according to the status refresh interface and the caching policy.
[0113] As an optional implementation, the user token acquisition module 102 is specifically used to, when a user logs into the base application and accesses the sub-application, call the user token generation interface of the deployed unified authentication service through the base application; obtain the user token returned by the user token generation interface, wherein the user token is generated by a preset token generation algorithm, and the user token has an expiration time limit and a one-time use limit; and return the generated user token to the sub-application.
[0114] As an optional implementation, the access token acquisition module 103 is specifically used to: obtain a key pair from the unified authentication service after the sub-application starts, wherein the key pair includes a corresponding public key and a private key; initiate an access token request to the unified authentication service using the logged-in user information, the public key, and the private key; after the unified authentication service verifies the user information, the public key, and the private key, it returns the access token generated by a preset access token generation algorithm to the cache of the sub-application, wherein the access token has a cache time limit; call the authentication service authorization interface of the unified authentication service using the user information, the access token, and the user token; and receive the validity verification result of the user information, the access token, and the user token returned by the authentication service authorization interface.
[0115] As an optional implementation, the sub-application loading module 104 is specifically used to: if the access token is valid, create an independent sandbox runtime environment for the sub-application using the sandbox mechanism through the base application, and hide the sub-application's custom front-end library variables; analyze the sub-application's cascading style sheet using the front-end plugin, add target prefixes and / or scope identifiers to the cascading style sheet to restrict the sub-application's style to sandbox elements; inject a global style reset file into the sub-application to unify the appearance style of the sub-application's front-end basic elements, and replace the sub-application's custom component styles with preset unified component styles; and clear the sub-application's style data stored in the sandbox runtime environment when the sub-application is uninstalled.
[0116] As an optional implementation, the login status management module 105 is specifically used to register the user's login status information with the base application through an event binding mechanism after the sub-application is loaded; the base application sends a status verification request to the sub-application using the status refresh interface according to a preset detection period to obtain the remaining validity period of the current login status information; when the remaining validity period of the login status information is detected to be lower than a preset threshold, the status refresh interface is called to update the login status information, and the cache of the login status information is updated simultaneously.
[0117] As an optional implementation, the login status management module 105 is further configured to trigger the timeout retry mechanism of the base application if the status refresh fails, and mark the status of the sub-application as abnormal if the retry fails; when the user exits the base application or the sub-application is uninstalled, the login status information and the cached data corresponding to the login status information are removed through the base application; if the user accesses the sub-application whose status is marked as abnormal again, the unified authentication process is re-executed through the base application to obtain new valid login status information.
[0118] As an optional implementation, the multi-system micro-frontend integration device 100 further includes an application cache management module. Specifically, this module is used to cache the resource files and configuration information of the sub-application through the base application after the sub-application is successfully loaded, and record the application's access weight value and cache duration. When a user accesses the sub-application, the base application checks whether there are valid resources in the cache. If they exist and the cache duration threshold is not exceeded, the sub-application's resources are loaded from the cache. If they do not exist or the cache duration has expired, the corresponding resources are retrieved again from the sub-application. The base application iterates through the cache list according to a preset period, performs a weighted calculation based on the access weight value and the cache duration, and removes the cache of the sub-application with the lowest weight. When a sub-application's resource is accessed consecutively a preset number of times, the corresponding resource is marked as a hot resource, and the cache duration of the hot resource is extended, as well as the access weight of the hot resource is increased.
[0119] It should be noted that the above-described multi-system micro-frontend integration device can execute the multi-system micro-frontend integration method provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in the embodiments of the multi-system micro-frontend integration device can be found in the multi-system micro-frontend integration method provided in the embodiments of this application.
[0120] Figure 11 This is a schematic diagram of the hardware structure of the electronic device 110 for implementing the multi-system micro-frontend integration method provided in this application embodiment, as shown below. Figure 11 As shown, the electronic device 110 includes:
[0121] One or more processors 111 and memory 112, Figure 11 Take a processor 111 as an example.
[0122] Processor 111 and memory 112 can be connected via a bus or other means. Figure 11 Taking the example of a connection between China and Israel via a bus.
[0123] The memory 112, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the multi-system micro-frontend integration method in the embodiments of this application. The processor 111 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions, and modules stored in the memory 112, thereby realizing the multi-system micro-frontend integration method in the above-described method embodiments.
[0124] Memory 112 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the multi-system microfront-end integration device. Furthermore, memory 112 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some embodiments, memory 112 may optionally include memory remotely located relative to processor 111, and this remote memory may be connected to the multi-system microfront-end integration device via a network. Examples of such networks include, but are not limited to, the Internet, enterprise intranets, local area networks, mobile communication networks, and combinations thereof.
[0125] The one or more modules are stored in the memory 112. When executed by the one or more processors 111, they perform the multi-system micro-frontend integration method in any of the above method embodiments, for example, performing the above-described... Figure 2 Steps S1 to S5 in the method are implemented. Figure 10 The functions of modules 101-105 in the document.
[0126] The above-described product can perform the methods provided in the embodiments of this application, and has the corresponding functional modules and beneficial effects for performing the methods. Technical details not described in detail in this embodiment can be found in the methods provided in the embodiments of this application.
[0127] This application provides a non-volatile computer-readable storage medium storing computer-executable instructions that are executed by one or more processors, for example... Figure 11 One of the processors 111 can enable the one or more processors to execute the multi-system micro-frontend integration method in any of the above method embodiments, for example, to execute the above-described... Figure 2 Steps S1 to S5 in the method are implemented. Figure 10 The functions of modules 101-105 in the document.
[0128] This application provides a computer program product, which includes a computer program stored on a non-volatile computer-readable storage medium. The computer program includes program instructions, which, when executed by an electronic device, enable the electronic device to perform the multi-system micro-frontend integration method described in any of the above method embodiments, for example, to perform the above-described... Figure 2 Steps S1 to S5 in the method are implemented. Figure 10 The functions of modules 101-105 in the document.
[0129] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0130] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software and a general-purpose hardware platform, or of course, using hardware. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and not to limit them; under the concept of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of this application as described above, which are not provided in detail for the sake of brevity; although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A multi-system micro-frontend integration method, characterized in that, The method comprises the following steps: deploying a base application based on a micro-frontend framework, configuring a sandbox mechanism and a front-end plug-in of the base application, initializing a cache strategy of the base application, and obtaining a target system to be integrated as a sub-application, and opening a state refresh interface of the sub-application; when a user logs in the base application and accesses the sub-application, calling a deployed unified authentication service to generate a user token with a time limit, and returning the user token to the sub-application; obtaining an access token from the unified authentication service by the sub-application using user information and a key pair obtained from the unified authentication service in advance, and verifying the validity of the access token and the user token by the unified authentication service, wherein the user information is user data saved after successful login, and the key pair is obtained from the unified authentication service in advance; if the access token is valid, loading the sub-application in the base application using the sandbox mechanism and the front-end plug-in.
2. The multi-system micro-front end integration method of claim 1, wherein, After the step of loading the sub-application in the base application using the sandbox mechanism and the front-end plug-in if the access token is valid, the method further comprises the following steps: after the sub-application is successfully loaded, registering the login state of the user to the base application by the sub-application, and periodically detecting and renewing the login state in the base application according to the state refresh interface and the cache strategy; or, after the sub-application is successfully loaded, and when the user switches between different sub-applications, verifying the validity of the access token and the user token by the unified authentication service, and periodically detecting and renewing the login state in the base application according to the state refresh interface and the cache strategy.
3. The multi-system micro-front end integration method of claim 1, wherein, The step of calling a deployed unified authentication service to generate a user token with a time limit and returning the user token to the sub-application when a user logs in the base application and accesses the sub-application comprises the following steps: when a user logs in the base application and accesses the sub-application, calling a user token generation interface of the deployed unified authentication service by the base application; obtaining the user token returned by the user token generation interface, wherein the user token is generated by a preset token generation algorithm, and the user token is provided with a time limit and a one-time use limit; returning the generated user token to the sub-application.
4. The multi-system micro-front end integration method of claim 1, wherein, The step of obtaining an access token from the unified authentication service by the sub-application using user information after login and a key pair obtained from the unified authentication service in advance, and verifying the validity of the access token and the user token by the unified authentication service comprises the following steps: after the sub-application is started, obtaining a key pair from the unified authentication service, wherein the key pair includes a corresponding public key and a private key; using the user information after login, the public key and the private key by the sub-application to initiate an access token request to the unified authentication service; after the user information, the public key and the private key are verified by the unified authentication service, returning the access token generated by a preset access token generation algorithm to the cache of the sub-application, wherein the access token is provided with a cache time limit; calling, by the sub-application, an authentication service authorization interface of the uniform authentication service using the user information, the access token and the user token; receiving a result of checking validity of the user information, the access token and the user token returned by the authentication service authorization interface.
5. The multi-system micro-frontend integration method of claim 1, wherein, if the access token is valid, the step of loading the sub-application by the base application using the sandbox mechanism and the front-end plug-in includes: if the access token is valid, creating, by the base application, an independent sandbox running environment for the sub-application using the sandbox mechanism and hiding the custom front-end library variable of the sub-application; analyzing, by the front-end plug-in, Cascading Style Sheets (CSS) of the sub-application, adding a target prefix and / or a scope identifier to the CSS to limit the style of the sub-application within a sandbox element; injecting a global style reset file into the sub-application to unify the appearance style of front-end basic elements of the sub-application and replacing custom component styles of the sub-application with preset uniform component styles; when the sub-application is unloaded, clearing style data of the sub-application stored in the sandbox running environment.
6. The multi-system micro-frontend integration method of claim 2, wherein, the step of registering, by the sub-application, a login state of a user to the base application and refreshing an interface and a cache strategy according to the login state by the base application to periodically detect and renew the login state includes: after the sub-application is loaded, registering, by the base application, login state information of the user through an event binding mechanism; sending, by the base application, a state checking request to the sub-application using the state refreshing interface according to a preset detection period to obtain a remaining validity period of the login state information; when it is detected that the remaining validity period of the login state information is lower than a preset threshold, calling the state refreshing interface to update the login state information and updating a cache of the login state information.
7. The multi-system micro-frontend integration method of claim 5, wherein, after the step of calling the state refreshing interface to update the login state information and updating the cache of the login state information, the method further includes: if the state refreshing fails, triggering a timeout retry mechanism of the base application, and if the retry fails, marking the state of the sub-application as abnormal; when the user exits the base application or the sub-application is unloaded, removing, by the base application, the login state information and cache data corresponding to the login state information; if the user accesses the sub-application again whose state is marked as abnormal, re-executing, by the base application, a uniform authentication process to obtain new valid login state information.
8. The multi-system micro-front end integration method of claim 2, wherein, after the step of registering, by the sub-application, a login state of a user to the base application and refreshing an interface and a cache strategy according to the login state by the base application to periodically detect and renew the login state, the method further includes: after the sub-application is loaded successfully, caching, by the base application, resource files and configuration information of the sub-application and recording an access weight value and a cache duration of the sub-application. When a user accesses the sub-application, it is checked through the base application whether there is a valid resource in the cache, if there is and the cache duration threshold has not been exceeded, the resource of the sub-application is loaded from the cache, if there is not or the cache duration has expired, the corresponding resource is reacquired from the sub-application; The cache list is traversed by the base application according to a preset period, and a weighted calculation is performed according to the access weight value and the cache duration, and the cache of the sub-application with the smallest weighted weight is removed; When the resource of the sub-application is continuously accessed for a preset number of times, the corresponding resource is marked as a hot resource, the cache duration of the hot resource is extended, and the access weight of the hot resource is increased.
9. A multi-system micro-frontend integration device, comprising: Comprise: An application initialization module is configured to deploy a base application based on a micro-frontend framework, configure a sandbox mechanism and a front-end plug-in of the base application, initialize a cache strategy of the base application, and obtain a target system to be integrated as a sub-application, and open a state refreshing interface of the sub-application; A user token acquisition module is configured to, when a user accesses the sub-application after logging in the base application, call a deployed unified authentication service to generate a user token with a time limit, and return the user token to the sub-application; An access token acquisition module is configured to, through the sub-application, acquire an access token from the unified authentication service according to user information and a key pair, and verify the validity of the access token and the user token through the unified authentication service, wherein the user information is user data saved after successful login, and the key pair is preacquired from the unified authentication service; A sub-application loading module is configured to, if the access token is valid, load the sub-application in the base application using the sandbox mechanism and the front-end plug-in.
10. An electronic device, comprising: Comprise: At least one processor; And A memory connected in communication with the at least one processor; wherein The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the multi-system micro-frontend integration method of any one of claims 1-8.
Citation Information
Cited By
HTTP (Hyper Text Transport Protocol) multi-level automatic authentication data migration method and system based on multi-task scheduling
CN121691353A
An adaptive micro-frontend multi-system fusion method and system for electric power services
CN122348869A
