Front-end microservice method, device and electronic device based on dynamic routing

Through dynamic routing injection and permission management, the problems of slow page loading speed and weak permission control in the front-end microservice architecture are solved, efficient page rendering and resource management are achieved, and user experience and system performance are improved.

CN114357327BActive Publication Date: 2025-01-07BIG DATA RES INST INST OF COMPUTING TECH CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111448265.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2025-01-07
Estimated Expiration
2041-11-30

AI Technical Summary

Technical Problem

The existing front-end microservice architecture has problems such as slow page loading speed, weak permission control, poor reusability and high development costs, resulting in poor user experience and waste of resources.

Method used

Adopting a front-end microservice method based on dynamic routing, dynamically discovering the routing files of the child application, generating the parent application routing files, and controlling the permissions based on the user's permission routing list. The child application inherits the baseApplication base class of the parent application to realize the rendering interface and Lifecycle function, implements dynamic routing injection and permission management, and supports page uninstallation and re-rendering without refreshing.

Benefits of technology

It improves page loading speed and fluency, realizes flexible permission control, reduces resource waste and development costs, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114357327B_ABST
    Figure CN114357327B_ABST
Patent Text Reader

Abstract

The present application relates to a front-end microservice method, device and electronic device based on dynamic routing, which is applied to the field of front-end development technology. The method includes: dynamically discovering the routing file of a sub-application, generating the parent application routing file of the parent application according to the routing file of at least one sub-application when the routing file of at least one sub-application is retrieved, and obtaining the user's permission routing list when receiving the user's access request. If it is determined that the user has access rights according to the parent application routing file and the permission routing list, the current access sub-application is determined according to the access request, and the resource package of the current access sub-application is executed and rendered to display the content of the current access sub-application, wherein the current access sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control the life cycle function. The present application can realize dynamic injection and permission control of routing, and can improve the loading speed of pages.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of front-end development technology, and in particular to a front-end microservice method, device and electronic device based on dynamic routing. More specifically, it is a microservice method for permission control and rapid integration of sub-applications based on dynamic routing. Background Art

[0002] With the rapid development of the front-end, various front-end frameworks have sprung up, such as React, Vue, Angular and other front-end frameworks. Front-end frameworks emerge in an endless stream, and versions are constantly iterating. It is inevitable that there will be problems such as inconsistent front-end project technology stacks and inconsistent framework versions. In order to solve this problem, developers and project managers have come up with the idea of ​​concentrating multiple different services on a large platform and opening them to the outside world. At the same time, they also realize that aggregation has become a new technological trend. Therefore, the front-end microservice architecture has gradually come into people's sight and has become a hot topic of current research. Summary of the invention

[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a front-end microservice method, device and electronic device based on dynamic routing.

[0004] According to a first aspect of the present application, a front-end microservice method based on dynamic routing is provided, the method comprising:

[0005] Dynamically discover the routing files of sub-applications;

[0006] In the case where at least one sub-application routing file is retrieved, generating a parent application routing file of the parent application according to the at least one sub-application routing file;

[0007] Upon receiving an access request from a user, obtaining a permission routing list of the user;

[0008] If it is determined according to the parent application routing file and the permission routing list that the user has access rights, determining the current access sub-application according to the access request;

[0009] The resource package of the currently accessed sub-application is executed and rendered to display the content of the currently accessed sub-application, wherein the currently accessed sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control lifecycle functions.

[0010] According to a second aspect of the present application, a front-end microservice device based on dynamic routing is provided, the device comprising:

[0011] Route discovery module, used to dynamically discover the route files of sub-applications;

[0012] A generation module, configured to generate a parent application routing file of a parent application according to the routing file of the at least one sub-application when the routing file of the at least one sub-application is retrieved;

[0013] The permission acquisition module is used to obtain the permission routing list of the user when receiving the access request of the user;

[0014] A determination module, configured to determine a currently accessed sub-application according to the access request if it is determined according to the parent application routing file and the permission routing list that the user has access rights;

[0015] A rendering module is used to execute the resource package of the currently accessed sub-application and render it to display the content of the currently accessed sub-application, wherein the currently accessed sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control life cycle functions.

[0016] According to a third aspect of the present application, an electronic device is provided, comprising: a processor, the processor being used to execute a computer program stored in a memory, the computer program implementing the dynamic routing-based front-end microservice method described in the first aspect when executed by the processor.

[0017] According to a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the front-end microservice method based on dynamic routing described in the first aspect is implemented.

[0018] According to a fifth aspect of the present application, a computer program product is provided. When the computer program product is run on a computer, the computer is enabled to execute the front-end microservice method based on dynamic routing described in the first aspect.

[0019] Compared with the prior art, the technical solution provided by the embodiments of the present application has the following advantages:

[0020] By dynamically discovering the routing file of the sub-application, when at least one routing file of the sub-application is retrieved, the parent application routing file of the parent application is generated according to the routing file of at least one sub-application, and when receiving the user's access request, the user's permission routing list is obtained. If it is determined that the user has access rights according to the parent application routing file and the permission routing list, the current access sub-application is determined according to the access request, and the resource package of the current access sub-application is executed and rendered to display the content of the current access sub-application, wherein the current access sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control the life cycle function. The above technical solution is adopted, and the dynamic routing injection is realized by dynamically discovering the routing file of the sub-application and generating the parent application routing file, and by obtaining the user's permission routing list, the parent application routing file is compared with the permission routing list, and subsequent operations are performed when it is determined that the user has access rights, so as to realize the permission control of the route. In addition, the sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control the life cycle function, so that the page can complete the unloading and re-rendering of the Document Object Model (DOM) without refreshing, thereby improving the loading speed of the page and improving the fluency of the page loading. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0023] Figure 1 A schematic diagram of a process flow of a front-end microservice method based on dynamic routing provided in an embodiment of the present application;

[0024] Figure 2 An example diagram of a system architecture provided for an embodiment of the present application;

[0025] Figure 3 A schematic diagram of a permission control process provided by an embodiment of the present application;

[0026] Figure 4 A schematic diagram of the structure of a front-end microservice device based on dynamic routing provided in one embodiment of the present application;

[0027] Figure 5A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0028] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.

[0029] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.

[0030] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0031] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0032] Before introducing the front-end microservice method, device and electronic device based on dynamic routing provided by the present application, the professional terms that may be involved in the embodiments of the present application are explained as follows:

[0033] Front-end microservices: generally refers to a concept of centralizing multiple different services on a large platform and opening them to the outside world. Its characteristics include independent operation, independent development, and independent deployment.

[0034] Routing: A method by which the client browser can render different view pages based on different Uniform Resource Locators (URLs) without relying on the server.

[0035] Rendering: Generally, it is a process of creating a DOM tree, creating a style sheet, creating a render tree, layout, and drawing a page on the front end.

[0036] Lifecycle function: generally refers to the process in the front-end framework from object creation to destruction, which will go through a series of executive functions, in which events are added to each time point.

[0037] Universal Module Definition (UMD): A specification for front-end modularization.

[0038] baseApplication: An application instance designed according to object-oriented design. It is mainly used to standardize rendering interfaces. When a child application is injected into a parent application, it must be injected with an application instance inherited from the baseApplication base class.

[0039] At present, in the related technologies, the implementation scheme of front-end microservices is usually implemented by using the href (abbreviation of Hypertext Reference) attribute of the ifream tag. The advantages of this implementation method are fast and convenient, but it also has certain disadvantages, including:

[0040] (1) The ifream tag will block the page loading speed, causing the page to freeze and poor user experience;

[0041] (2) Weak permission control, which makes it impossible to grant permissions to different users to allow them to access specific business modules of the platform, while prohibiting them from accessing business modules without permission;

[0042] (3) Poor reusability and high development costs put enormous pressure on the server and waste social resources.

[0043] The above problems will lead to the fact that in many project requirements, users and projects cannot be satisfied, and repeated development is required, resulting in a huge waste of development resources; and the project operation performance is poor, energy consumption increases, and it will also cause a huge waste of server resources.

[0044] This application aims at some problems that have arisen in the current front-end microservice architecture, and provides a method for light coupling, high reuse, independence, and rapid integration of the front-end microservice architecture. First, a routing file script is created in each sub-application, and through dynamic routing injection, after the parent application receives the route, it is compared with the permission route list returned by the backend, and the parent application filters the routes without permission, thereby realizing the permission control of the route. In addition, by establishing a baseApplication base class, the sub-application inherits the method of the baseApplication base class in the entry file to control the life cycle function of each sub-application, so that the page can complete the unloading and re-rendering of the DOM without refreshing. Finally, through the UMD packaging method of webpack, the loading and scheduling of the configuration script can be quickly integrated with multiple sub-applications, and finally a plug-in architecture solution is formed. The solution of this application can prevent repeated development, flexibly control permissions, improve user experience, and reduce resource waste and energy consumption.

[0045] Figure 1 This is a flow chart of a front-end microservice method based on dynamic routing provided in an embodiment of the present application. The method can be executed by a front-end microservice device based on dynamic routing provided in an embodiment of the present application, wherein the device can be implemented by software and / or hardware and can generally be integrated in electronic devices such as computers. Figure 1 As shown, the front-end microservice method based on dynamic routing may include the following steps:

[0046] Step 101, dynamically discover the routing file of the sub-application.

[0047] In the embodiment of the present application, a parent application product and at least one sub-application may be created, such as innovative sub-application A and sub-application B. For example, Figure 2 This is an example diagram of a system architecture provided in an embodiment of the present application, such as Figure 2 As shown, the system includes a parent application and multiple sub-applications, namely sub-application A, sub-application B, sub-application C and sub-application D. Each sub-application corresponds to a routing file and an access path. The front-end microservice method based on dynamic routing provided in the embodiment of the present application can be executed by the parent application. The parent application dynamically discovers the routing files of each sub-application, generates a parent application routing file, and implements permission control.

[0048] Among them, the routing files of the sub-applications can be pre-defined, and the routing files of each sub-application can be saved in its own root directory.

[0049] For example, the routing file of the sub-application can be defined in the following format:

[0050]

[0051]

[0052] Among them, "app / a" is the path name of sub-application A. The above example only uses sub-application A as an example. In actual applications, it can be flexibly set according to needs.

[0053] In an embodiment of the present application, for the routing file of the defined sub-application, the routing file name and file location can also be defined. It is recommended that the routing file name be consistent, similar to file names such as pkg-router.js or pkg-router.json, and the file path is recommended to be placed in the root directory of the sub-application.

[0054] Step 102: When at least one sub-application routing file is retrieved, a parent application routing file of the parent application is generated according to the at least one sub-application routing file.

[0055] In an embodiment of the present application, the parent application dynamically retrieves and discovers the routing file of the child application. When retrieving the routing file of at least one child application, the parent application adds corresponding prefixes to different sub-applications, such as app / a, app / b, etc., and generates the parent application routing file of the parent application based on the routing file of at least one child application.

[0056] In an optional implementation of the present application, when generating a parent application routing file of a parent application based on a routing file of at least one sub-application, the routing file of the at least one sub-application can be read from the root directory of the at least one sub-application, and then the parent application routing file can be generated according to preset rules based on the routing file of the at least one sub-application.

[0057] Exemplarily, the node service of webpack can be used to read the routing file corresponding to the sub-application from the root directory of the discovered sub-application, and then generate the parent application routing file according to preset rules.

[0058] The preset rule may be a routing file format pre-defined for the parent application.

[0059] Exemplarily, the predefined routing file format is as follows:

[0060]

[0061] Thus, according to the read routing file of the sub-application and in accordance with the above routing file format, a parent application routing file can be generated.

[0062] Step 103: upon receiving an access request from a user, obtaining a permission routing list of the user.

[0063] In an embodiment of the present application, when a user accesses any sub-application in the system, the parent application will receive the user's access request to access the sub-application. At this time, the parent application can obtain the user's permission routing list for accessing the sub-application from the background.

[0064] The permission routing list records the business modules that the current user can access, that is, the business modules that the user has permission to access. For example, user A can access the "Personal Center" page of sub-application A, but cannot access the "Transaction Record" page of sub-application A, can access the "Historical Evaluation" page of sub-application B, but cannot access the "Payment History" page of sub-application B.

[0065] For example, the permission routing list of user A can be defined as follows:

[0066]

[0067]

[0068] Step 104: If it is determined according to the parent application routing file and the permission routing list that the user has access rights, the currently accessed sub-application is determined according to the access request.

[0069] In an embodiment of the present application, after the parent application obtains the user's permission routing list, it can compare the obtained permission routing list with the parent application routing file to determine whether the user has access rights. When it is determined that the user has access rights based on the parent application routing file and the permission routing list, the current access sub-application can be determined based on the received access request.

[0070] Exemplarily, the path attribute in the parent application routing list and the path attribute in the obtained user's permission routing list can be compared to see if they are consistent. If they are inconsistent, it is determined that the user does not have access rights. If they are consistent, it can be determined that the user has access rights, and the specific business module to which the user has access rights can be further determined based on the able attribute in the obtained permission routing list.

[0071] Exemplarily, the access request may include a request path, and the sub-application to which the path to be routed corresponds is determined based on the first segment path name of the request path, and the sub-application is the currently accessed sub-application. For example, if the first segment path name of the request path / a / b is a, it can be determined that the currently accessed sub-application is sub-application a.

[0072] In an optional implementation of the present application, if it is determined based on the parent application routing file and the permission routing list that the user does not have access rights, a no-authority-access page is displayed, where the no-authority-access page is used to prompt the user that the user does not have access rights.

[0073] For example, Figure 3 A flowchart of permission control provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, when user 1 accesses sub-application A in the system, the parent application obtains the user's permission routing list and determines whether user 1 has access rights based on the parent application routing file and the permission routing list. If it is determined that user 1 does not have permission to access sub-application A, the user is directed to the unauthorized access page, which displays a prompt message "Sorry, you cannot access" to prompt user 1 that he does not have permission to access the current sub-application A; if it is determined that user 1 has permission to access sub-application A, the script of sub-application A can be loaded to enter sub-application A, and a prompt message "Hello, welcome to sub-application A" is displayed to prompt user 1 that he has entered sub-application A.

[0074] It can be seen that the solution provided in the embodiment of the present application can control the user's access rights to the page according to the user's role. This method provides developers with a more practical system integration method. In today's rapidly developing society, it can better and faster integrate projects and complete the transformation to digitalization and informatization.

[0075] Step 105 , execute the resource package of the currently accessed sub-application and render it to display the content of the currently accessed sub-application, wherein the currently accessed sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control lifecycle functions.

[0076] In the embodiment of the present application, after determining the currently accessed sub-application, the parent application can load and execute the resource package of the currently accessed sub-application, and render the application view to display the content of the currently accessed sub-application. When rendering, the parent application creates a baseApplication base class, and the currently accessed sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control its own life cycle function.

[0077] For example, the baseApplication base class can be defined as follows:

[0078]

[0079] Furthermore, the current example of accessing a sub-application (taking the React version as an example) that inherits baseApplication is as follows:

[0080]

[0081]

[0082] In the current front-end microservice architecture solution, the ifream tag will block the loading speed of the page and bring pressure to the server. In addition, the maintenance of each sub-application will be cumbersome and waste server resources. The solution provided by this application is that the parent application defines the baseApplication base class, the sub-application inherits the baseApplication base class, and customizes the rendering interface of the sub-application. It can realize the front-end microservice architecture with high cohesion and light coupling, and reduce the waste of social resources.

[0083] The front-end microservice method based on dynamic routing of this embodiment dynamically discovers the routing file of the sub-application, generates the parent application routing file of the parent application according to the routing file of at least one sub-application when the routing file of at least one sub-application is retrieved, and obtains the user's permission routing list when receiving the user's access request. If it is determined that the user has access rights according to the parent application routing file and the permission routing list, the current access sub-application is determined according to the access request, and the resource package of the current access sub-application is loaded and executed and rendered to display the content of the current access sub-application, wherein the current access sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control the life cycle function. The above technical solution is adopted to realize dynamic routing injection by dynamically discovering the routing file of the sub-application and generating the parent application routing file, and by obtaining the user's permission routing list, the parent application routing file is compared with the permission routing list, and subsequent operations are performed when it is determined that the user has access rights, so as to realize the permission control of the routing. In addition, the sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control the life cycle function, so that the page can complete the unloading and re-rendering of the DOM without refreshing, thereby improving the loading speed of the page and improving the fluency of the page loading. Compared with the current front-end microservice architecture solution, which cannot meet the needs of users and projects and requires flexible control of routing permissions in projects, the solution of this application provides a combination of permission layer and dynamic routing, which can quickly integrate sub-applications.

[0084] In an optional implementation of the present application, after determining the currently accessed sub-application, it is also possible to determine whether the routing information of the currently accessed sub-application has been injected based on the parent application routing file; if the routing information of the currently accessed sub-application has not been injected, the currently accessed sub-application is dynamically loaded as a resource package.

[0085] In the embodiment of the present application, after determining the currently accessed sub-application, it is possible to determine whether the routing information of the currently accessed sub-application has been injected according to the parent application routing file. Specifically, it is possible to query whether the parent application routing file contains the path name of the currently accessed sub-application according to the path name of the currently accessed sub-application. If it does, it indicates that the currently accessed sub-application has been injected with routing information. At this time, the resource package of the currently accessed sub-application can be directly executed and rendered; if the parent application routing file does not contain the path name of the currently accessed sub-application, it can be determined that the routing information of the currently accessed sub-application has not been injected. At this time, the resource package of the currently accessed sub-application can be dynamically loaded, and after the js script resource package is executed, the subsequent rendering logic can be continued.

[0086] Exemplarily, when dynamically loading the resource bundle of the currently accessed sub-application, it can be implemented by using link and script tags to dynamically insert the resource bundle address under the head and body tags respectively.

[0087] In an embodiment of the present application, after determining the currently accessed sub-application, it is determined whether the routing information of the currently accessed sub-application has been injected according to the parent application routing file, and when the routing information of the currently accessed sub-application has not been injected, the resource package of the currently accessed sub-application is dynamically loaded. Thus, the resource package of the currently accessed sub-application is dynamically loaded in a timely manner, the waiting time is reduced, the speed at which users access sub-applications is increased, and the user experience is improved.

[0088] In an optional implementation manner of the present application, the method further includes:

[0089] Determining a resource path of the at least one sub-application according to the routing file of the at least one sub-application;

[0090] Loading a resource package of the at least one sub-application according to the resource path of the at least one sub-application;

[0091] Execute the resource package of the at least one sub-application and render it, wherein the at least one sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control life cycle functions;

[0092] The at least one sub-application is packaged using a common module definition specification.

[0093] In the embodiment of the present application, the routing file of each sub-application contains the resource path of the sub-application. The parent application can determine the resource path corresponding to each sub-application from the routing file based on the routing file of each sub-application in at least one sub-application found, and then load the resource package of each sub-application according to the resource path corresponding to each sub-application, and then execute the resource package of each sub-application and render it. Among them, each sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control the life cycle function. Afterwards, the parent application can package using the UMD specification packaging method according to the parameters of the configured packaging tool to complete the integration of each sub-application.

[0094] Among them, the parameters of the packaging tool can be configured by the developer to configure the loading and scheduling of the scripts.

[0095] In an embodiment of the present application, by determining the resource path of at least one sub-application according to the routing file of at least one sub-application, loading the resource package of at least one sub-application according to the resource path of at least one sub-application, and then executing and rendering the resource package of at least one sub-application, at least one sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control life cycle functions, and finally, the at least one sub-application is packaged using a general module definition specification. Thus, multiple sub-applications can be quickly integrated, and multiple sub-applications inherit the baseApplication base class of the parent application to define the rendering interface and control the life cycle functions. Each sub-application can be independently deployed and run, and has strong reusability. Developers do not need to reinvent the wheel, which can reduce the waste of social resources.

[0096] Corresponding to the above method embodiment, the embodiment of the present application also provides a front-end microservice device based on dynamic routing.

[0097] Figure 4 A schematic diagram of the structure of a front-end microservice device based on dynamic routing provided in one embodiment of the present application. The front-end microservice device based on dynamic routing can be implemented using software and / or hardware and can generally be integrated into electronic devices such as computers.

[0098] like Figure 4 As shown, the front-end microservice device 40 based on dynamic routing may include: a routing discovery module 410, a generation module 420, a permission acquisition module 430, a determination module 440 and a rendering module 450.

[0099] Wherein, the routing discovery module 410 is used to dynamically discover the routing file of the sub-application;

[0100] A generating module 420, configured to generate a parent application routing file of a parent application according to the routing file of the at least one sub-application when the routing file of the at least one sub-application is retrieved;

[0101] The permission acquisition module 430 is used to acquire the permission routing list of the user when receiving the access request of the user;

[0102] A determination module 440 is configured to determine a currently accessed sub-application according to the access request if it is determined according to the parent application routing file and the permission routing list that the user has access rights;

[0103] The rendering module 450 is used to execute the resource package of the currently accessed sub-application and render it to display the content of the currently accessed sub-application, wherein the currently accessed sub-application inherits the baseApplication base class of the parent application to define the rendering interface and control life cycle functions.

[0104] Optionally, the front-end microservice device 40 based on dynamic routing further includes:

[0105] A judgment module, used to judge whether the routing information of the currently accessed sub-application has been injected according to the routing file of the parent application;

[0106] The dynamic loading module is used to dynamically load the resource package of the currently accessed sub-application if the routing information of the currently accessed sub-application is not injected.

[0107] Optionally, the generating module 420 is further configured to:

[0108] Reading a routing file of the at least one sub-application from a root directory of the at least one sub-application;

[0109] The parent application routing file is generated according to the routing file of the at least one sub-application and according to preset rules.

[0110] Optionally, the front-end microservice device 40 based on dynamic routing further includes:

[0111] The prompt module is used to guide the user to a no-authority-access page if it is determined that the user does not have access rights according to the parent application routing file and the permission routing list. The no-authority-access page is used to prompt the user that the user does not have access rights.

[0112] Optionally, the front-end microservice device 40 based on dynamic routing further includes:

[0113] A resource path determination module, configured to determine a resource path of the at least one sub-application according to a routing file of the at least one sub-application;

[0114] A resource loading module, configured to load a resource package of the at least one sub-application according to a resource path of the at least one sub-application;

[0115] An execution and rendering module, used to execute the resource package of the at least one sub-application and render it, wherein the at least one sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control lifecycle functions;

[0116] The packaging module is used to package the at least one sub-application using a general module definition specification.

[0117] The front-end microservice device based on dynamic routing provided in the embodiment of the present application can execute any front-end microservice method based on dynamic routing that can be applied to electronic devices such as computers provided in the embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method. Contents not fully described in the embodiment of the device of the present application can refer to the description in any method embodiment of the present application.

[0118] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0119] In an exemplary embodiment of the present application, an electronic device is also provided, comprising: a processor, wherein the processor is used to execute a computer program stored in a memory, and when the computer program is executed by the processor, the steps of the front-end microservice method based on dynamic routing as described in the above embodiment are implemented.

[0120] Figure 5 This is a schematic diagram of a structure of an electronic device provided in an embodiment of the present application. It should be noted that: Figure 5 The electronic device 500 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0121] like Figure 5As shown, electronic device 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In RAM 503, various programs and data required for system operation are also stored. Central processing unit 501, ROM 502 and RAM 503 are connected to each other via a bus 504. Input / output (I / O) interface 505 is also connected to bus 504.

[0122] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a local area network (LAN) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.

[0123] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication part 509, and / or installed from a removable medium 511. When the computer program is executed by the central processing unit 501, various functions defined in the device of the present application are executed.

[0124] In an embodiment of the present application, a computer-readable storage medium is further provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the front-end microservice method based on dynamic routing described in the above embodiment are implemented.

[0125] It should be noted that the computer-readable storage medium shown in the present application may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, radio frequency, etc., or any suitable combination of the above.

[0126] In an embodiment of the present application, a computer program product is also provided. When the computer program product is run on a computer, the computer is enabled to execute the steps of the front-end microservice method based on dynamic routing described in the above embodiment.

[0127] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0128] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A front-end microservice method based on dynamic routing, characterized in that: The method comprises: Dynamically discover the routing files of sub-applications; In the case where at least one sub-application routing file is retrieved, generating a parent application routing file of the parent application according to the at least one sub-application routing file; Upon receiving an access request from a user, obtaining a permission routing list of the user; If it is determined according to the parent application routing file and the permission routing list that the user has access rights, determining the current access sub-application according to the access request; The resource package of the currently accessed sub-application is executed and rendered to display the content of the currently accessed sub-application, wherein the currently accessed sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control lifecycle functions.

2. According to the front-end microservice method based on dynamic routing according to claim 1, it is characterized in that: The method further comprises: According to the parent application routing file, determine whether the routing information of the currently accessed sub-application has been injected; If the routing information of the currently accessed sub-application is not injected, the resource package of the currently accessed sub-application is dynamically loaded.

3. The front-end microservice method based on dynamic routing according to claim 1, characterized in that: Generating a parent application routing file of a parent application according to the routing file of the at least one sub-application includes: Reading a routing file of the at least one sub-application from a root directory of the at least one sub-application; The parent application routing file is generated according to the routing file of the at least one sub-application and according to preset rules.

4. The front-end microservice method based on dynamic routing according to claim 1, characterized in that: The method further comprises: If it is determined according to the parent application routing file and the permission routing list that the user does not have access rights, the user is directed to a no-authority-access page, where the no-authority-access page is used to prompt the user that the user does not have access rights.

5. The front-end microservice method based on dynamic routing according to any one of claims 1 to 4, characterized in that: The method further comprises: Determining a resource path of the at least one sub-application according to the routing file of the at least one sub-application; Loading a resource package of the at least one sub-application according to the resource path of the at least one sub-application; Execute the resource package of the at least one sub-application and render it, wherein the at least one sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control life cycle functions; The at least one sub-application is packaged using a common module definition specification.

6. A front-end microservice device based on dynamic routing, characterized in that: The device comprises: Route discovery module, used to dynamically discover the route files of sub-applications; A generation module, configured to generate a parent application routing file of a parent application according to the routing file of the at least one sub-application when the routing file of the at least one sub-application is retrieved; The permission acquisition module is used to obtain the permission routing list of the user when receiving the access request of the user; A determination module, configured to determine a currently accessed sub-application according to the access request if it is determined according to the parent application routing file and the permission routing list that the user has access rights; A rendering module is used to execute the resource package of the currently accessed sub-application and render it to display the content of the currently accessed sub-application, wherein the currently accessed sub-application inherits the baseApplication base class of the parent application to define a rendering interface and control life cycle functions.

7. The front-end microservice device based on dynamic routing according to claim 6, characterized in that: The device also includes: A judgment module, used to judge whether the routing information of the currently accessed sub-application has been injected according to the routing file of the parent application; The dynamic loading module is used to dynamically load the resource package of the currently accessed sub-application if the routing information of the currently accessed sub-application is not injected.

8. The front-end microservice device based on dynamic routing according to claim 6, characterized in that: The device also includes: The prompt module is used to guide the user to a no-authority-access page if it is determined that the user does not have access rights according to the parent application routing file and the permission routing list. The no-authority-access page is used to prompt the user that the user does not have access rights.

9. An electronic device, characterized in that: include: A processor, wherein the processor is used to execute a computer program stored in a memory, and when the computer program is executed by the processor, the steps of the front-end microservice method based on dynamic routing are implemented as described in any one of claims 1 to 5.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the front-end microservice method based on dynamic routing are implemented as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Sub-application access method and device, electronic equipment and readable storage medium

    CN111666585A

  • Page generation method and device

    CN111949342A