Dynamic route permission configuration method and device, computer device and storage medium

CN116389129BActive Publication Date: 2026-10-09PING AN BANK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310379916.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-07
Publication Date
2026-10-09
Estimated Expiration
2043-04-07

AI Technical Summary

Technical Problem

[0003]微服务场景下,路由匹配列表层级多、数据大,如果采用静态路由,需在路由匹配列表中将路由和组件进行一一映射,如果多级菜单,则会出现多个层级的嵌套,层级复杂不易维护

Benefits of technology

[0041] The dynamic routing permission configuration method provided in this application is applied to the front end. It retrieves multiple route menus configured in the backend from the database by encapsulating request functions and obtains a user identifier through a user login interface. Based on the user identifier, it iterates through the multiple route menus to determine the user permissions corresponding to the user identifier and caches the user permissions in the database. The corresponding target route menu is determined based on the user permissions. Corresponding route configuration information is generated based on the target route menu and the user permissions, and the route configuration information is added to the route instance. This application makes the code more concise and easier for staff to maintain by dynamically configuring route menus. When route configuration information changes, there is no need to manually modify the configuration items. This application can also generate different route menus for users with different roles and permissions, ensuring that users can only access route menus they have permission to access. It also eliminates the need to develop a separate route guard to prevent users from accessing pages they do not have permission to access by manually entering routes in the address bar, making permission control more flexible and convenient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116389129B_ABST
    Figure CN116389129B_ABST
Patent Text Reader

Abstract

The application relates to the field of electronic technology and discloses a dynamic route permission configuration method and device, computer equipment and a storage medium. The method is applied to a front end, a plurality of route menus configured by a back end are acquired from a database through encapsulation of a request function, and a user identifier is acquired through a user login interface; the plurality of route menus are traversed according to the user identifier, user permissions corresponding to the user identifier are determined, and the user permissions are cached in the database; a target route menu corresponding to the user permissions is determined; corresponding route configuration information is generated according to the target route menu and the user permissions, and the route configuration information is added to a route instance. The application dynamically configures the route menu, so that the code is more concise and more convenient for staff maintenance. Different route menus can be generated for users with different roles and different permissions, so that the permission control is more flexible and more convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic technology, and in particular to a dynamic routing permission configuration method, apparatus, computer device, and storage medium. Background Technology

[0002] In single-page rich application scenarios, adopting a front-end / back-end separation development model, front-end routing configuration is particularly important. Currently, industry standard routing configurations are all unified within the front-end code. Routing generally employs two methods: static loading and dynamic loading. Static loading involves the front-end writing all static routes, and after user login, the appropriate route is selected based on role permissions. Its core is front-end control of routing.

[0003] In microservice scenarios, route matching lists often have multiple levels and large amounts of data. If static routes are used, each route and component in the route matching list needs to be mapped one-to-one. With multi-level menus, this results in multiple nested levels, making the hierarchy complex and difficult to maintain. Furthermore, a separate set of route guard code needs to be developed to prevent users from directly accessing pages they don't have permission to access by entering a route. In this context, implementing dynamic route configuration becomes essential. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to overcome the shortcomings of the prior art and provide a dynamic routing permission configuration method, apparatus, computer equipment and storage medium that can be applied to fields such as fintech or other technical fields.

[0005] This invention provides the following technical solution:

[0006] In a first aspect, this disclosure provides a dynamic routing permission configuration method applied to a front-end, the method comprising:

[0007] The system retrieves multiple route menus configured in the backend from the database by encapsulating request functions, and obtains the user identifier through the user login interface.

[0008] The multiple routing menus are traversed according to the user identifier to determine the user permissions corresponding to the user identifier, and the user permissions are cached in the database;

[0009] The corresponding target route menu is determined based on the user permissions;

[0010] Generate corresponding route configuration information based on the target route menu and the user permissions, and add the route configuration information to the route instance.

[0011] Furthermore, each of the route menus includes the user identifier and the user permissions. After retrieving the multiple route menus configured by the backend from the database by encapsulating the request function, the method further includes:

[0012] The user permissions in each of the aforementioned route menus can be queried, added, edited, and deleted.

[0013] Further, the step of traversing the routing menu based on the user identifier includes:

[0014] Determine the target user identifier corresponding to the current user identifier in the routing menu;

[0015] Based on the target user identifier, the user permissions corresponding to the target user identifier are traversed, and it is determined whether the target user identifier has the corresponding user permissions.

[0016] If so, the corresponding user permissions will be retained.

[0017] Secondly, this disclosure provides a dynamic routing permission configuration method applied to a backend, the method comprising:

[0018] Retrieve multiple first-level route menus from the database, and filter out the first-level route menus that do not contain second-level routes to obtain the filtered second-level route menus;

[0019] Recursively process the data of each route in the second routing menu, and insert a return page into the last item of the processed second routing menu to obtain the routing menu;

[0020] The routing menu is stored in a preset empty array in the database for use by front-end users after successful login.

[0021] Further, the recursive data processing of each route in the second routing menu includes:

[0022] Define the route type for all routes in the second route menu, define routes containing second-level or higher routes as main routes, and define routes not containing second-level routes as sub-routes;

[0023] If the main route contains multiple sub-routes, then determine whether the array length of each sub-route is empty;

[0024] Define the sub-route with an empty array length as the subordinate master route under this path, and delete the first sub-route under the subordinate master route;

[0025] Define the sub-route whose array length is not empty as the first subordinate sub-route under this path, and delete all second subordinate sub-routes under the first subordinate sub-route.

[0026] Furthermore, after deleting all second subordinate subroutines under the first subordinate subroutine, the process further includes:

[0027] Determine if the array length of the first subordinate sub-route is empty;

[0028] If so, then delete the first subordinate sub-route.

[0029] Thirdly, this disclosure provides a dynamic routing permission configuration device applied to a front-end, the device comprising:

[0030] The acquisition module is used to retrieve multiple route menus configured in the backend from the database by encapsulating request functions, and to obtain the user identifier through the user login interface;

[0031] The traversal module is used to traverse multiple routing menus based on the user identifier, determine the user permissions corresponding to the user identifier, and cache the user permissions in the database;

[0032] The determination module is used to determine the corresponding target route menu based on the user permissions;

[0033] The module is used to generate corresponding route configuration information based on the target route menu and the user permissions, and add the route configuration information to the route instance.

[0034] Fourthly, this disclosure provides a dynamic routing permission configuration device for a backend, the device comprising:

[0035] The processing module is used to retrieve multiple first-level routing menus from the database, filter out the first-level routing menus that do not contain second-level routes, and obtain the filtered second-level routing menus.

[0036] An insertion module is used to recursively process each route in the second routing menu and insert a return page into the last item of the processed second routing menu to obtain the routing menu.

[0037] The storage module is used to store the routing menu into a preset empty array in the database for use by front-end users after successful login.

[0038] Fifthly, this disclosure provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the dynamic routing permission configuration method described in the first or second aspect.

[0039] In a sixth aspect, this disclosure provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the dynamic routing permission configuration method described in the first or second aspect.

[0040] The embodiments of this application have the following advantages:

[0041] The dynamic routing permission configuration method provided in this application is applied to the front end. It retrieves multiple route menus configured in the backend from the database by encapsulating request functions and obtains a user identifier through a user login interface. Based on the user identifier, it iterates through the multiple route menus to determine the user permissions corresponding to the user identifier and caches the user permissions in the database. The corresponding target route menu is determined based on the user permissions. Corresponding route configuration information is generated based on the target route menu and the user permissions, and the route configuration information is added to the route instance. This application makes the code more concise and easier for staff to maintain by dynamically configuring route menus. When route configuration information changes, there is no need to manually modify the configuration items. This application can also generate different route menus for users with different roles and permissions, ensuring that users can only access route menus they have permission to access. It also eliminates the need to develop a separate route guard to prevent users from accessing pages they do not have permission to access by manually entering routes in the address bar, making permission control more flexible and convenient.

[0042] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0043] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0044] Figure 1 A flowchart illustrating a dynamic routing permission configuration method applied to a front-end, provided by an embodiment of this application, is shown.

[0045] Figure 2 A flowchart illustrating a dynamic routing permission configuration method applied to the backend, provided in an embodiment of this application, is shown.

[0046] Figure 3 This illustration shows a structural diagram of a dynamic routing permission configuration device applied to a front end, according to an embodiment of this application.

[0047] Figure 4 This illustration shows a structural diagram of a dynamic routing permission configuration device applied to the backend, provided in an embodiment of this application.

[0048] Figure 5 A schematic diagram of the hardware architecture of a computer device provided in an embodiment of this application is shown. Detailed Implementation

[0049] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0050] It should be noted that when an element is said to be "fixed" to another element, it can be directly on the other element or there may be an intervening element. When an element is said to be "connected" to another element, it can be directly connected to the other element or there may be an intervening element. Conversely, when an element is said to be "directly" on another element, there is no intervening element. The terms "vertical," "horizontal," "left," "right," and similar expressions used in this document are for illustrative purposes only.

[0051] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0052] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein in the template description is for the purpose of describing particular embodiments only and is not intended to limit the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0054] Example 1

[0055] like Figure 1The diagram shown is a flowchart of a dynamic routing permission configuration method applied to the front end in an embodiment of this application. The dynamic routing permission configuration method provided in this embodiment includes the following steps:

[0056] Step S110: Obtain multiple route menus configured on the backend from the database by encapsulating the request function, and obtain the user identifier through the user login interface.

[0057] In this embodiment, multiple route menus configured by the backend in the database are encapsulated by request function calls, and user permissions in each route menu are queried, added, edited, and deleted as needed. User identifiers are obtained through the user login interface. The user identifier may include a user ID and a user token, and each user identifier corresponds to multiple user permissions.

[0058] As you can understand, a user ID (Identity) is a unique identifier for each user, representing their identity and qualifications. A user token is an encrypted string generated by the front-end server, used as a "token" for client requests. When a user successfully logs in for the first time using their username and password, the server generates a token and its expiration time, returning this to the client. If the login is successful, the client only needs to use this token within the valid timeframe to request data, without needing to include the username and password again.

[0059] Step S120: Traverse the multiple routing menus according to the user identifier, determine the user permissions corresponding to the user identifier, and cache the user permissions in the database.

[0060] In some implementations, to avoid configuring permissions on the backend and reduce backend computational overhead, the step of traversing multiple route menus based on the user identifier to determine the user permissions corresponding to the user identifier includes:

[0061] Determine the target user identifier in the routing menu that corresponds to the current user identifier. Iterate through the user permissions corresponding to the target user identifier in the routing menu based on the target user identifier, and determine whether the target user identifier has the corresponding user permissions. If so, retain the corresponding user permissions and cache the user permissions in the database.

[0062] Step S130: Determine the corresponding target route menu based on the user permissions.

[0063] Step S140: Generate corresponding route configuration information based on the target route menu and the user permissions, and add the route configuration information to the route instance.

[0064] Furthermore, based on the obtained user permissions, a corresponding target route menu is determined. This target route menu includes the user identifier, user permissions, route ID, route path, route utility component name, route tag, and other route attribute information. Corresponding route configuration information, namely the route utility component name, is generated based on the target route menu and user permissions, and this generated route utility component name is added to the route instance.

[0065] This application provides a dynamic routing permission configuration method for front-end applications. Applied to the front-end, it retrieves multiple route menus configured in the back-end from the database by encapsulating request functions and obtains a user identifier through a user login interface. Based on the user identifier, it iterates through the multiple route menus to determine the user permissions corresponding to the user identifier and caches the user permissions in the database. The corresponding target route menu is determined based on the user permissions. Corresponding route configuration information is generated based on the target route menu and the user permissions, and the route configuration information is added to the route instance. This application makes the code more concise and easier for staff to maintain by dynamically configuring route menus. When route configuration information changes, there is no need to manually modify the configuration items. This application can also generate different route menus for users with different roles and permissions, ensuring that users can only access route menus they have permission to access. It also eliminates the need to develop a separate route guard to prevent users from accessing pages they do not have permission to access by manually entering routes in the address bar, making permission control more flexible and convenient.

[0066] Example 2

[0067] like Figure 2 The diagram shown is a flowchart of a dynamic routing permission configuration method applied to the backend in an embodiment of this application. The dynamic routing permission configuration method provided in this embodiment includes the following steps:

[0068] Step S210: Retrieve multiple first route menus from the database, and filter out the first route menus that do not contain second-level routes to obtain the filtered second route menu.

[0069] In this embodiment, the database stores multiple initial routing menus, i.e., first routing menus. Some first routing menus contain second-level routes, while others do not. It should be noted that second-level routes are direct subordinates of first-level routes, and the IP addresses assigned to second-level routes are dynamic. Setting dynamic IP addresses here applies to the ingress of the second-level routes. The DHCP service of the first-level routes assigns dynamic IP addresses to its subordinates, and the ingress of the second-level routes is configured to receive dynamic IP addresses.

[0070] After the backend retrieves multiple first-level route menus from the database, it filters them, removing those that do not contain second-level routes, thus obtaining the filtered second-level route menus.

[0071] Step S220: Recursively process the data of each route in the second routing menu, and insert a return page into the last item of the processed second routing menu to obtain the routing menu.

[0072] Specifically, define the route type for all routes in the second route menu. Define routes containing second-level or higher routes as main routes, and routes without second-level routes as sub-routes. Recursively process the data for each route in the second route menu, filtering by route type. If the returned route type does not exist (i.e., there is no second-level route), the current loop ends and the next loop begins.

[0073] The main route is checked. If the main route contains multiple sub-routes, the array length of each sub-route is checked to see if it is empty.

[0074] Define the sub-route with an empty array length as the subordinate master route under this path, and delete the first sub-route under the subordinate master route. If it is not deleted, an empty second route menu will appear.

[0075] Define the sub-route whose array length is not empty as the first subordinate sub-route under this path, and delete all second subordinate sub-routes under the first subordinate sub-route. Further, determine whether the array length of the first subordinate sub-route is empty; if so, delete the first subordinate sub-route; otherwise, an empty second route menu will appear.

[0076] It is understandable that a return page is inserted as the last item in the processed second route menu to obtain the route menu. In this embodiment, the return page is a 404 page. The 404 page must be inserted as the last item in the second route menu to accommodate an empty page and display normal prompt information; otherwise, the front-end will intercept all pages during the call and redirect to the 404 page.

[0077] Step S230: Store the routing menu in a preset empty array in the database for use by front-end users after successful login.

[0078] Finally, the routing menu is stored in a pre-defined empty array in the database, and the backend discusses and defines a usable return data format for the frontend to call after a user successfully logs in. After a user successfully logs in, the frontend calls the routing menu configured by the backend, and after the user logs out, the cached routing menu is cleared.

[0079] The dynamic routing permission configuration method for the backend provided in this application retrieves multiple first routing menus from the database and filters out those that do not contain second-level routes to obtain a filtered second routing menu. Each route in the second routing menu undergoes recursive data processing, and a return page is inserted as the last item in the processed second routing menu to obtain the routing menu. The routing menu is stored in a preset empty array in the database for use by frontend users after successful login. This application makes the code more concise and easier for staff to maintain by dynamically configuring the routing menu. When the routing configuration information changes, there is no need to manually modify the configuration items. This application can also generate different routing menus for users with different roles and permissions, ensuring that users can only access the routing menus they have permission to access. It also eliminates the need to develop a separate routing guard to prevent users from accessing pages they do not have permission to access by manually entering routes in the address bar, making permission control more flexible and convenient.

[0080] Example 3

[0081] like Figure 3 The diagram shown is a structural schematic of a dynamic routing permission configuration device 300 applied to the front end in an embodiment of this application. The device includes:

[0082] The acquisition module 310 is used to retrieve multiple route menus configured in the backend from the database by encapsulating request functions, and to obtain the user identifier through the user login interface;

[0083] The traversal module 320 is used to traverse multiple routing menus according to the user identifier, determine the user permissions corresponding to the user identifier, and cache the user permissions in the database;

[0084] The determination module 330 is used to determine the corresponding target route menu based on the user permissions;

[0085] Add module 340, which is used to generate corresponding route configuration information based on the target route menu and the user permissions, and add the route configuration information to the route instance.

[0086] Optionally, the aforementioned dynamic routing permission configuration device may further include:

[0087] The modification module is used to query, add, edit, and delete user permissions in each of the aforementioned route menus.

[0088] Optionally, the aforementioned dynamic routing permission configuration device may further include:

[0089] The determination submodule is used to determine the target user identifier corresponding to the current user identifier in the routing menu;

[0090] The first judgment module is used to traverse the user permissions corresponding to the target user identifier based on the target user identifier, and to determine whether the target user identifier has the corresponding user permissions.

[0091] The reserved module is used to retain the corresponding user permissions.

[0092] The dynamic routing permission configuration device for front-end applications provided in this application makes the code more concise and easier for staff to maintain by dynamically configuring the routing menu. When the routing configuration information changes, there is no need to manually modify the configuration items. This application can also generate different routing menus for users with different roles and permissions, ensuring that users can only access the routing menus they have permission to access. It also eliminates the need to develop a separate routing guard to prevent users from accessing pages they do not have permission to access by manually entering routes in the address bar, making permission control more flexible and convenient.

[0093] Example 4

[0094] like Figure 4 The diagram shown is a structural schematic of a dynamic routing permission configuration device 400 applied to the backend in an embodiment of this application. The device includes:

[0095] Processing module 410 is used to retrieve multiple first route menus from the database, filter out the first route menus that do not contain second-level routes, and obtain the filtered second route menu;

[0096] The insertion module 420 is used to recursively process each route in the second routing menu and insert a return page into the last item of the processed second routing menu to obtain the routing menu.

[0097] The storage module 430 is used to store the routing menu into a preset empty array in the database for use by front-end users after successful login.

[0098] Optionally, the aforementioned dynamic routing permission configuration device may further include:

[0099] The definition module is used to define the route type of all routes in the second route menu. Routes containing second-level or higher routes are defined as main routes, and routes not containing second-level routes are defined as sub-routes.

[0100] The second judgment module is used to determine whether the array length of each sub-route is empty if the main route contains multiple sub-routes.

[0101] The first definition submodule is used to define the sub-route with an empty array length as the subordinate master route under this path, and delete the first sub-route under the subordinate master route;

[0102] The second definition submodule is used to define the sub-routes whose array length is not empty as the first subordinate sub-routes under this path, and to delete all the second subordinate sub-routes under the first subordinate sub-routes.

[0103] Optionally, the aforementioned dynamic routing permission configuration device may further include:

[0104] The third judgment module is used to determine whether the array length of the first subordinate sub-route is empty;

[0105] The deletion module is used to delete the first subordinate sub-route.

[0106] The dynamic routing permission configuration device for the backend provided in this application makes the code more concise and easier for staff to maintain by dynamically configuring the routing menu. When the routing configuration information changes, there is no need to manually modify the configuration items. This application can also generate different routing menus for users with different roles and permissions, ensuring that users can only access the routing menus they have permission to access. It also eliminates the need to develop a separate routing guard to prevent users from accessing pages they do not have permission to access by manually entering routes in the address bar, making permission control more flexible and convenient.

[0107] Example 5

[0108] Figure 5 A schematic diagram of the hardware architecture of the computer device provided in this application is shown. The computer device includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, it implements the steps of the dynamic routing permission configuration method described in Embodiment 1.

[0109] In this embodiment, the computer device 500 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. For example, it can be a rack server, blade server, tower server, or cabinet server (including standalone servers or server clusters composed of multiple servers), etc. Figure 5 As shown, the computer device 500 includes, but is not limited to, at least: a memory 510, a processor 520, and a network interface 530 that can communicate and be linked to each other via a system bus. Wherein:

[0110] The memory 510 includes at least one type of computer-readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 510 may be an internal storage module of the computer device 500, such as the hard disk or memory of the computer device 500. In other embodiments, the memory 510 may also be an external storage device of the computer device 500, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. Of course, the memory 510 may include both the internal storage module and the external storage device of the computer device 500. In this embodiment, the memory 510 is typically used to store the operating system and various application software installed on the computer device 500, such as program code for video playback methods. In addition, the memory 510 can also be used to temporarily store various types of data that have been output or will be output.

[0111] In some embodiments, processor 520 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor 520 is typically used to control the overall operation of computer device 500, such as performing control and processing related to data interaction or communication with computer device 500. In this embodiment, processor 520 is used to run program code stored in memory 510 or process data.

[0112] Network interface 530 may include a wireless network interface or a wired network interface, which is typically used to establish a communication link between computer device 500 and other computer devices. For example, network interface 530 is used to connect computer device 500 to an external terminal via a network, establishing a data transmission channel and communication link between computer device 500 and the external terminal. The network may be an intranet, the Internet, Global System for Mobile Communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks.

[0113] It should be pointed out that, Figure 5 Only computer devices with components 510-530 are shown; however, it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.

[0114] In this embodiment, the dynamic routing permission configuration method stored in the memory 510 can also be divided into one or more program modules and executed by one or more processors (processor 520 in this embodiment) to complete the present invention.

[0115] Example 6

[0116] This embodiment also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the dynamic routing permission configuration method in this embodiment.

[0117] In this embodiment, the computer-readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computer device, such as the hard disk or memory of the computer device. In other embodiments, the computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the computer device. Of course, the computer-readable storage medium can also include both the internal storage unit and the external storage device of the computer device. In this embodiment, the computer-readable storage medium is typically used to store the operating system and various application software installed on the computer device. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or will be output.

[0118] In all examples shown and described herein, any specific values ​​should be interpreted as merely exemplary and not as limitations; therefore, other examples of exemplary embodiments may have different values.

[0119] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0120] The embodiments described above are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.

Claims

1. A method for configuring dynamic routing permissions, characterized in that, Applied to the front end, the method includes: The system retrieves multiple backend-configured route menus from the database by encapsulating request functions, and obtains user identifiers through the user login interface. The user identifier includes a user ID and a token with an expiration time. When requesting data from the database, the client only needs to send a data request with the token within the expiration time. Each route menu includes the user identifier and user permissions. After retrieving the multiple backend-configured route menus from the database by encapsulating request functions, the system further includes querying, adding, editing, and deleting user permissions for each route menu. The multiple routing menus are traversed according to the user identifier to determine the user permissions corresponding to the user identifier, and the user permissions are cached in the database; The corresponding target route menu is determined based on the user permissions; Based on the target route menu and the user permissions, generate corresponding route configuration information and add the route configuration information to the route instance, so that the user can only access the route menu that he or she has permission to access, and there is no need to develop additional route guards to prevent the user from entering paths that he or she does not have permission to access through the address bar; The step of traversing the routing menu based on the user identifier includes: determining the target user identifier in the routing menu that corresponds to the current user identifier; traversing the user permissions corresponding to the target user identifier based on the target user identifier, and determining whether the target user identifier has the corresponding user permissions; if so, retaining the corresponding user permissions.

2. A method for configuring dynamic routing permissions, characterized in that, Applied to the backend, the method includes: Retrieve multiple first-level route menus from the database, and filter out first-level route menus that do not contain second-level routes to obtain the filtered second-level route menu; where the second-level routes are direct subordinates of the first-level routes, and the IPs assigned to the second-level routes are dynamic; Recursively process the data of each route in the second route menu, and insert a return page into the last item of the processed second route menu to obtain the route menu; wherein, inserting a return page into the last item of the processed second route menu, the return page is a 404 page, the 404 page must be inserted into the last item of the second route menu to accommodate empty pages and normal display prompt information, otherwise the front end will intercept all pages when calling and will redirect to the 404 page; The routing menu is stored in a preset empty array in the database so that it can be called by the user on the front end to which the dynamic routing permission configuration method of claim 1 is applied after successful user login; The recursive data processing of each route in the second routing menu includes: defining the route type of all routes in the second routing menu; defining routes containing second-level or higher routes as main routes; defining routes not containing second-level routes as sub-routes; if a main route contains multiple sub-routes, determining whether the array length of each sub-route is empty; defining sub-routes with empty array lengths as subordinate main routes under this path, and deleting the first sub-route under the subordinate main route; defining sub-routes with non-empty array lengths as first subordinate sub-routes under this path, and deleting all second subordinate sub-routes under the first subordinate sub-routes; wherein, routes containing second-level or higher routes are main routes, and routes not containing second-level routes are sub-routes; After deleting all second subordinate subroutines under the first subordinate subroutine, the method further includes: determining whether the array length of the first subordinate subroutine is empty; if so, deleting the first subordinate subroutine.

3. A dynamic routing permission configuration device, characterized in that, Applied to the front end, the device includes: The acquisition module is used to retrieve multiple route menus configured in the backend from the database by encapsulating request functions, and to obtain user identifiers through the user login interface. The user identifier includes a user ID and a token with an expiration time. When requesting data from the database, the client only needs to send a data request with the token within the expiration time. Each route menu includes the user identifier and user permissions. After retrieving the multiple route menus configured in the backend from the database by encapsulating request functions, the module further includes: querying, adding, editing, and deleting user permissions in each route menu. The traversal module is used to traverse multiple routing menus based on the user identifier, determine the user permissions corresponding to the user identifier, and cache the user permissions in the database; The determination module is used to determine the corresponding target route menu based on the user permissions; The module is used to generate corresponding route configuration information based on the target route menu and the user permissions, and add the route configuration information to the route instance, so that the user can only access the route menu that he or she has permission to access, and there is no need to develop additional route guards to prevent the user from entering unauthorized paths through the address bar; The step of traversing the routing menu based on the user identifier includes: determining the target user identifier in the routing menu that corresponds to the current user identifier; traversing the user permissions corresponding to the target user identifier based on the target user identifier, and determining whether the target user identifier has the corresponding user permissions; if so, retaining the corresponding user permissions.

4. A dynamic routing permission configuration device, characterized in that, Applied to the backend, the device includes: The processing module retrieves multiple first-level routing menus from the database and filters out those that do not contain second-level routes, resulting in a filtered second-level routing menu. Second-level routes are direct subordinates of first-level routes, and their assigned IP addresses are dynamic. The insertion module is used to recursively process the data of each route in the second routing menu and insert a return page into the last item of the processed second routing menu to obtain the routing menu. The return page inserted into the last item of the processed second routing menu is a 404 page. The 404 page must be inserted into the last item of the second routing menu to accommodate empty pages and normal display prompts. Otherwise, the front end will intercept all pages when calling the module and will redirect to the 404 page. The storage module is used to store the routing menu into a preset empty array in the database, so that it can be called by the user on the front end to which the dynamic routing permission configuration method of claim 1 is applied after successful user login; The recursive data processing of each route in the second routing menu includes: defining the route type of all routes in the second routing menu; defining routes containing second-level or higher routes as main routes; defining routes not containing second-level routes as sub-routes; if a main route contains multiple sub-routes, determining whether the array length of each sub-route is empty; defining sub-routes with empty array lengths as subordinate main routes under this path, and deleting the first sub-route under the subordinate main route; defining sub-routes with non-empty array lengths as first subordinate sub-routes under this path, and deleting all second subordinate sub-routes under the first subordinate sub-routes; wherein, routes containing second-level or higher routes are main routes, and routes not containing second-level routes are sub-routes; After deleting all second subordinate subroutines under the first subordinate subroutine, the method further includes: determining whether the array length of the first subordinate subroutine is empty; if so, deleting the first subordinate subroutine.

5. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the dynamic routing permission configuration method according to any one of claims 1 or 2.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the dynamic routing permission configuration method according to any one of claims 1 or 2.

Citation Information

Patent Citations

  • Method for customizing menus by opening capacity

    CN112162844A

  • ERP dynamic permission control method based on VUE

    CN112231658A