Page menu access control methods, devices, equipment and storage media
By associating the target role of the end user with the routing information and combining the relationship between routing and menu information, the routing structure information is dynamically loaded, which solves the problems of flexibility and high operation and maintenance costs in access control in web application systems, and enables page menu display without the need for the terminal to configure the routing file table locally.
Patent Information
- Application Number
- CN202210875316.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-22
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2042-07-22
AI Technical Summary
Existing access control methods in web application systems suffer from insufficient flexibility and high maintenance costs, especially since both hard-coding of terminal routing files and dynamically returning routing information by the server have their own drawbacks.
By obtaining the association between the target role of the end user and the routing information, and combining the association between the preset routing information and the menu information, the routing structure information is dynamically loaded to display the page menu. The terminal does not need to configure the routing file table locally, and the operation and maintenance personnel do not need to understand the routing technology.
It achieves universality and flexibility in permission design, reduces operation and maintenance costs, and dynamically loads the routing structure information display page menu on the terminal to adapt to changing needs.
Smart Images

Figure CN115221447B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, providing a page menu permission control method, a page menu permission control device, an electronic device, and a computer-readable storage medium. Background Technology
[0002] With the development of the internet, web application systems have emerged in various industries. Access control is an essential part of web application architecture design; for example, different users, after logging into the system, can only see pages within their authorized scope.
[0003] Currently, there are two common approaches. First, the terminal hardcodes routing information in the routing file, adds role identifiers, and compares them with the role identifiers returned by the server to control page menu permissions. While this method is simple and universal, it cannot effectively handle changing requirements. Second, the server associates roles with routing information and dynamically returns routing information, allowing the terminal to control page menu permissions. This method can flexibly respond to changing requirements, but it is less conducive to later maintenance by operations and maintenance personnel, increasing maintenance costs because these personnel lack knowledge of terminal routing technology. Summary of the Invention
[0004] The purpose of this application is to provide a page menu permission control method, a page menu permission control device, an electronic device, and a computer-readable storage medium, which achieves universality and flexibility in permission design through the combination of routing and menus.
[0005] This application proposes a page menu permission control method, the method comprising: obtaining a target role corresponding to a user of a terminal, and target routing information associated with the target role; determining the target menu information possessed by the target role according to a preset association relationship between routing information and menu information, so as to determine a target menu structure based on the target menu information; obtaining routing structure information according to the target routing information and the target menu structure; and sending the routing structure information to the terminal so that the terminal dynamically loads the routing structure information to display a page menu for the user.
[0006] Furthermore, before obtaining the target role corresponding to the user to which the terminal belongs, and the target routing information associated with the target role, the method further includes: entering all routing information required for the project; entering the menu information corresponding to the project; attaching the routing information to the corresponding menu information; configuring the association relationship between each role and the menu information to determine the routing information associated with each role.
[0007] Furthermore, the process of entering all the routing information required for the project includes: entering all the routing information required for the project in the routing management page, wherein the routing information includes at least one of title, route name, route path, and route component path; if the routing information includes a route component path, then the route component path in the routing information is validated.
[0008] Furthermore, the step of entering the menu information corresponding to the project includes: entering the menu information corresponding to the project in the menu management interface, wherein the menu information includes the menu name and menu category; and adjusting the parent-child structure and menu order of the menu information according to configuration requirements to determine the menu structure.
[0009] Furthermore, the step of attaching the routing information to the corresponding menu information includes: configuring a menu-to-route association table; determining the specified menu information in the menu management interface; receiving an add instruction and adding the specified routing information carried in the add instruction to the menu-to-route association table to associate the specified menu information with the specified routing information.
[0010] Furthermore, obtaining the target role corresponding to the user to which the terminal belongs includes: when the terminal calls the local information interface with the authentication identifier, obtaining the authentication identifier and extracting the user's user identifier from the authentication identifier; and querying the target role associated with the user based on the user identifier.
[0011] Furthermore, sending the routing structure information to the terminal includes: encoding the routing structure information and encrypting the encoded routing structure information to obtain encrypted information; sending the encrypted information to the terminal so that the terminal can decrypt and deencode the encrypted information and then dynamically load the routing structure information.
[0012] This application also proposes a page menu permission control device, the device comprising: an acquisition module, configured to acquire a target role corresponding to a user of a terminal, and target routing information associated with the target role; a determination module, configured to determine the target menu information possessed by the target role based on a preset association between routing information and menu information and the target routing information, and to determine a target menu structure based on the target menu information; a structure module, configured to obtain routing structure information based on the target routing information and the target menu structure; and a sending module, configured to send the routing structure information to the terminal, so that the terminal dynamically loads the routing structure information to display a page menu for the user.
[0013] This application also proposes an electronic device comprising: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the electronic device to perform the method described above.
[0014] This application also proposes a computer-readable storage medium storing computer-readable instructions thereon, which, when executed by a computer's processor, cause the computer to perform the method described above.
[0015] Compared with the prior art, this application has the following beneficial effects:
[0016] The technical solution provided in this application obtains target routing information associated with the user's target role, then determines menu information based on the target routing information, thereby determining the menu structure. According to the menu structure and the obtained specified routing information, the specified routing structure information owned by the user is obtained. The terminal dynamically loads the routing structure information and displays the corresponding page menu. Based on the combination of routing and menu, the universality and flexibility of permission design are achieved. Moreover, for the terminal, there is no need to configure the routing file table locally, nor is there a need to hard-code whether there is routing permission. The routing information is only maintained on the server, and the operation and maintenance personnel do not need to be aware of the existence of the routing, resulting in low maintenance costs. Attached Figure Description
[0017] Figure 1 A schematic diagram of one implementation environment involved in this application is shown;
[0018] Figure 2 A flowchart illustrating a page menu permission control method is shown in an exemplary embodiment of this application;
[0019] Figure 3 This application shows a schematic diagram illustrating a menu structure and routing structure information according to an exemplary embodiment.
[0020] Figure 4 It shows Figure 2 A flowchart in an exemplary embodiment prior to step S110 in the illustrated embodiment;
[0021] Figure 5 It shows Figure 4 A flowchart of step S101 in an exemplary embodiment shown in the illustrated example;
[0022] Figure 6 It shows Figure 4 A flowchart of step S102 in an exemplary embodiment shown in the illustrated example;
[0023] Figure 7 It shows in Figure 5 Based on the illustrated embodiment, step S103 is shown in a flowchart of an exemplary embodiment;
[0024] Figure 8 It shows Figure 1 A flowchart of step S110 in an exemplary embodiment shown in the illustrated example;
[0025] Figure 9 It shows Figure 1 A flowchart of step S130 in an exemplary embodiment shown in the illustrated example;
[0026] Figure 10 A schematic diagram of the configuration process in another page menu permission control method involved in this application is shown;
[0027] Figure 11 A flowchart illustrating another page menu permission control method is shown in an exemplary embodiment of this application;
[0028] Figure 12 This invention provides a schematic diagram illustrating the structure of a page menu permission control device according to an exemplary embodiment of this application.
[0029] Figure 13 A schematic diagram of the structure of an electronic device suitable for implementing embodiments of this application is shown. Detailed Implementation
[0030] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0031] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0032] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0033] It should also be noted that "multiple" as mentioned in this application refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0034] Please see Figure 1 , Figure 1 This is a schematic diagram of an implementation environment involved in this application. The implementation environment includes a terminal 10 and a server 20, which can be connected via a network, which can be a wired network or a wireless network, and is not limited herein.
[0035] The server 20 is used to control the permissions of the page menu displayed on the terminal 10. Different users can only see the page menu within their permission range. The terminal 10 is used to display the corresponding page menu to the user based on the server's permission control.
[0036] Optionally, server 20 obtains the target role corresponding to the user to which terminal 10 belongs, and the target routing information associated with the target role; determines the target menu information possessed by the target role according to the association between the preset routing information and the menu information, so as to determine the target menu structure based on the target menu information; obtains routing structure information according to the target routing information and the target menu structure; and sends the routing structure information to the terminal so that the terminal dynamically loads the routing structure information to display the page menu for the user.
[0037] Terminal 10 receives routing structure information sent by the server and dynamically loads the routing structure information to display a page menu for the user.
[0038] This application improves the flexibility and convenience of permission design by combining routing and menus.
[0039] The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This section does not impose any restrictions on this.
[0040] Terminals include, but are not limited to, smartphones, tablets, laptops, computers, smart voice interaction devices, smart home appliances, in-vehicle terminals, aircraft, etc.
[0041] The following is based on Figure 1The implementation environment shown provides a detailed explanation of the access control method:
[0042] Please see Figure 2 , Figure 2 This is a flowchart illustrating an exemplary embodiment of the present application of a page menu permission control method, which is composed of... Figure 1 The server execution shown includes steps S110 to S140, which are detailed below:
[0043] S110. Obtain the target role corresponding to the user to which the terminal belongs, and the target routing information associated with the target role.
[0044] It should be noted that a user-role mapping table is pre-stored on the server. Different users have corresponding roles on the server, and different roles have different permissions. For example, if the role is an administrator role, then the administrator role is granted all permissions, that is, the administrator role can know any data on the server. Or, if the role is a restricted role, this restricted role can know the specified restricted data. Therefore, the target role corresponding to the user of the terminal can be determined according to the user-role mapping table.
[0045] Optionally, a user can correspond to one role, or a user can correspond to multiple roles; when a user belonging to a terminal has two roles, two target roles can be obtained. Of course, when a user belonging to a terminal has two roles, one role can be selected as the target role, for example, selecting the role with higher privileges, or selecting a role based on the terminal's instructions.
[0046] Routing information refers to the key information for terminal page navigation, such as route name and route path.
[0047] In this embodiment of the application, roles and routing information are associated. After the target role is determined, the association between the role and the routing information is determined, and the target routing information associated with the target role is determined. The target routing information is the routing information with which the target role has the permissions.
[0048] S120. Determine the target menu information possessed by the target role based on the preset association between routing information and menu information and the target routing information, so as to determine the target menu structure based on the target menu information.
[0049] In this embodiment of the application, the server stores a preset association between routing information and menu information. Therefore, after determining the target routing information associated with the target role, the target routing information can be matched with the preset association between routing information and menu information to determine the target menu information possessed by the target role. Menu information refers to information describing the menu, such as menu name, category, order, content, etc.
[0050] Optionally, the number of menu information corresponds to the number of routing information. That is, the number of routing information determines the number of menu information. For example, if target role 1 has menu 1 and menu 2, then routing information 1 and routing information 2 corresponding to menu 1 and menu 2 can be determined respectively.
[0051] It should be noted that the target menu structure can be determined based on the target menu information. The menu structure is used to determine how to assemble the routes. This menu structure refers to the tree structure order of the menu, which includes the parent-child structure between two menu nodes, as well as the order between two sub-menus (or parent menus).
[0052] In this embodiment of the application, the target menu structure can be determined based on at least one of the menu category, menu order, and menu content in the target menu information.
[0053] S130. Obtain the routing structure information based on the target routing information and the target menu structure.
[0054] Understandably, since routing information is associated with menu information, once the target menu structure is known, the target routing information can be organized based on the target menu structure to obtain routing structure information. This routing structure information includes both the routing structure and the routing information. For example... Figure 3 As shown, the menu structure is as follows: Menu 1 is the parent menu, and Menu 2 and Menu 3 are sub-menus of Menu 1. Menu 2 is located in front of Menu 3. Menus 1, 2, and 3 correspond to routing information 1, 2, and 3, respectively. Thus, the routing structure information is routing information 1, and routing information 2 and routing information 3 under routing information 1.
[0055] S140. Send the routing structure information to the terminal so that the terminal can dynamically load the routing information to display the page menu for the user.
[0056] In this embodiment of the application, after determining the routing structure information, the routing structure information is sent to the terminal. The terminal can asynchronously and dynamically load the routing structure information, that is, load the corresponding routing information according to the routing structure, control the page menu permissions, and display the page menu for the user. As a result, the user can only see the restricted menus, such as only being able to see menu 1 and menu 2.
[0057] In this embodiment, target routing information associated with the user's target role is obtained, and then menu information is determined based on the target routing information to determine the menu structure. According to the menu structure and the obtained specified routing information, the specified routing structure information owned by the user is obtained. The terminal dynamically loads the routing structure information and displays the corresponding page menu. Based on the combination of routing and menu, the universality and flexibility in permission design are achieved. Moreover, for the terminal, there is no need to configure the routing file table locally, nor is there a need to hard-code whether there is routing permission.
[0058] It is worth noting that the page menu permission control method in this application embodiment also includes a configuration process, such as... Figure 4 As shown, Figure 4 It shows Figure 2 The flowchart in an exemplary embodiment preceding step S110 in the illustrated embodiment includes:
[0059] S101. Enter all the routing information required for the project.
[0060] S102. Enter the menu information corresponding to the item.
[0061] S103. Mount the routing information to the corresponding menu information.
[0062] S104. Configure the association between each role and menu information to determine the routing information associated with each role.
[0063] In this embodiment, routing information and menu information are entered. The routing information is attached to the corresponding menu information to associate the routing information with the menu information. The order in which the routing information and menu information are entered can be simultaneous, or the routing information can be entered first, or the menu information can be entered first. No limitation is made here.
[0064] Optionally, routing and menu information can be entered through the interface or through a script. For example, in developer mode, routing and menu information can be entered through the interface. Later, in the test and production environments, the information can be exported and entered into a script, which can then be executed without needing to enter it through the interface again.
[0065] Optionally, routing information can be attached to the corresponding menu information. This can be done by pre-setting the relationship between menus and routes, or by dynamically configuring the relationship between menu information and routing information as needed.
[0066] After configuring the menu and routing information, configure the relationship between roles and menu information. A role can correspond to one menu permission or multiple menu permissions; this is not limited here.
[0067] By configuring the association between roles and menu information, authorization is performed. It can be understood that through the above configuration process, roles and menu information are associated, and routing information is attached to the menu information. Therefore, after obtaining the target role, the routing information indirectly associated with the target role can be determined. For example, after obtaining the target role of the user to which the terminal belongs, the menu information pre-configured in S104 associated with the target role can be searched based on the target role. Then, based on the attachment relationship in S103, the routing information corresponding to the menu information can be determined.
[0068] In one example of an embodiment of this application, before configuring the association between each role and menu information, the method further includes: creating a new role and associating the role with a user. That is, the server creates a new role, obtains user information, and then associates the user information with the role to authorize the corresponding role for each user.
[0069] In this embodiment, page menu permissions can be controlled simply by maintaining server data and making basic configurations.
[0070] Optional, such as Figure 5 As shown, Figure 5 It shows Figure 4 The flowchart of step S101 in the illustrated embodiment, in an exemplary embodiment, shows that the process of entering all routing information required for the project includes:
[0071] S510. Enter all the route information required for the project on the route management page. The route information includes at least one of the following: title, route name, route path, and route component path.
[0072] In this embodiment, a route management interface is first displayed. In this interface, all the route information required for the project is entered according to the input instructions of the user. The route information includes a title, which is used to display the name of the left navigation menu; a route name, which is used by the user to distinguish the menu and to jump to the page based on the route when the user clicks the menu; a route path, which is used for page jumping, i.e., which page to jump to; and a route component path, which is used for page file jumping, i.e., which page file to jump to.
[0073] In some examples, routing information also includes fields such as whether to display it as a menu or whether to enable caching. Of course, the fields included in the routing information can be flexibly expanded according to actual needs.
[0074] S520. If the routing information includes routing component paths, then the routing component paths in the routing information are validated.
[0075] To ensure the accuracy of the redirection, this embodiment of the application also needs to verify the routing component path in the routing information to check whether the routing component path is filled in accurately.
[0076] Optionally, the import function of JavaScript can be used to verify whether the routing component path is filled in correctly. If it is incorrect, an error message can be given so that it can be corrected.
[0077] Optional, such as Figure 6 As shown, Figure 6 for Figure 4 The flowchart shown for step S102 in an exemplary embodiment includes the process of entering the menu information corresponding to the item:
[0078] S610. Enter the menu information corresponding to the project in the menu management interface. The menu information includes the menu name and menu category.
[0079] In this embodiment, a menu management interface is shown, in which menu information is entered according to the user's input instructions. The menu displayed in the menu management interface is a tree structure, meaning that the menu nodes in the tree structure have parent-child relationships and a sequential relationship. Each menu node contains information including the menu name and menu category. The menu category includes target menus, page menus, and button menus. Directory menus are like the non-leaf node menus in the left navigation bar; page menus are leaf node menus; clicking a leaf node menu generally redirects to a different page; and button menus are controls for adding or editing on the page.
[0080] S620. Adjust the parent-child structure and menu order of menu information according to configuration requirements to determine the menu structure.
[0081] Understandably, the menu nodes in the tree structure can be adjusted according to configuration requirements. For example, dragging the menu nodes in the tree structure can change the parent-child structure and menu order of the menu information, i.e., the tree structure order, which is used to determine the menu structure of the left navigation bar.
[0082] Optional, such as Figure 7 As shown, Figure 7 In order to be in Figure 5 Based on the flowchart shown, step S103 in an exemplary embodiment, the process of attaching routing information to the corresponding menu information includes:
[0083] S710, Configuration Menu and Routing Association Table.
[0084] S720. Specify the menu information in the menu management interface.
[0085] S730 receives the add command and adds the specified route information carried in the add command to the menu and route association table to associate the specified menu information with the specified route information.
[0086] In this embodiment of the application, a menu-route association table can be created, in which menu information and route information are associated.
[0087] The menu management interface displays a menu tree structure on the left and a route menu association table on the right. First, a specific menu item is selected in the menu tree structure. This can be done via touch, mouse, or other methods within the menu management interface. After selecting the menu item, an add command is received in the menu management interface. This add command includes, but is not limited to, commands obtained from user-input touch operations. This add command carries the specified route information, which is then added to the menu and route association table. This associates the specified menu item with the specified route information, thus enabling the corresponding route information to be attached to the corresponding menu item.
[0088] Optional, such as Figure 8 As shown, Figure 8 for Figure 1 The flowchart shown in an exemplary embodiment illustrates step S110, where the process of obtaining the target role corresponding to the user to whom the terminal belongs includes:
[0089] S111. When the terminal calls the local information interface with the authentication identifier, obtain the authentication identifier and extract the user's identifier from the authentication identifier.
[0090] In this embodiment of the application, the authentication identifier of the terminal refers to the authentication identifier after the terminal is verified, indicating the legitimacy of the terminal; optionally, the authentication identifier of the terminal is a JWT (JSON Web Token) identifier. JWT, as a stateless authentication identifier, has been widely used in various distributed applications; JWT tokens are used to authenticate the validity and legitimacy of users.
[0091] The terminal calls the server's information interface carrying the authentication identifier. The server can then intercept the terminal's request through the information interface and obtain the authentication identifier from the request. It should be noted that the authentication identifier carries the user's user identifier, which includes, but is not limited to, the user's account and user identity identifier.
[0092] After obtaining the authentication identifier, such as after obtaining a JWT, the server uses unbase64 (a function that returns a decoded base64 string in binary form) to parse the body of the JWT, thereby extracting the user identifier.
[0093] In this embodiment, the authentication identifier is sent from the server to the terminal. For example, when a user logs in on the terminal, the terminal sends the user's login information to the server. The server authenticates the terminal based on the login information. If the authentication is successful, the server sends an authentication identifier to the terminal. The login information can be a username and password. The server then verifies the correctness of the username and password and sends the authentication identifier to the terminal. After receiving the authentication identifier, the terminal can request the corresponding page menu from the server for display.
[0094] S112. Query the target role associated with the user based on the user identifier.
[0095] As mentioned earlier, the server stores the correspondence between users and roles, specifically the correspondence between user identifiers and roles, and then queries the target role associated with the user based on the user identifier.
[0096] Optional, such as Figure 9 As shown, Figure 9 for Figure 1 The flowchart of step S130 shown in an exemplary embodiment illustrates that the process of sending routing structure information to the terminal includes:
[0097] S131. Encode the routing structure information and encrypt the encoded routing structure information to obtain encrypted information.
[0098] In this embodiment of the application, in order to ensure the accuracy and security of information transmission, the routing structure information is encoded to ensure that the information is not garbled, and then the encoded routing structure information is encrypted to ensure the security of the information.
[0099] Optionally, the routing structure information is Base64 encoded (an encoding method that uses 64 printable characters to represent binary data), and the encoded routing structure information is encrypted using the 3DES (Triple DES) algorithm.
[0100] S132. Send the encrypted information to the terminal so that the terminal can decrypt and deencode the encrypted information and then dynamically load the routing structure information.
[0101] The server sends encrypted information to the terminal, which then decodes and de-encodes the encrypted information to obtain routing information.
[0102] Optionally, the server can send encrypted information to the terminal through a local information interface.
[0103] Here, we will explain how the terminal dynamically loads routing structure information.
[0104] As mentioned earlier, routing structure information includes routing information and routing structure. Therefore, the terminal recursively processes the routing information structure and uses the `require` runtime dynamic import technology to load the page components corresponding to the component paths in the routing information, thus obtaining a dynamic route array. This dynamic route array is added to the routing of Vue (one of the terminal frameworks). The assembled dynamic route array is recursively traversed, and the system's left-side menu navigation bar is displayed according to the route structure and information. The name of the left-side menu bar is read from the titles in the routes. A certain system has four menu pages: A, B, C, and D. In the system's role management interface, two new roles, `role1` and `role2`, are created. `role1` is associated with the menus of A and B, and `role2` is associated with the menus of C and D. Furthermore, system users `user1` is associated with `role1`, and `user2` is associated with `role2`. When `user1` logs into the system, he can only see menus A and B in the left-side menu navigation bar; when `user2` logs into the system, he can only see menus C and D.
[0105] To facilitate understanding, this embodiment uses a concrete example to illustrate the access control method. This access control method aims to address the dynamic changes in terminal page permissions, allowing terminal developers to maintain system scalability without modifying terminal code. This page menu access control method includes a configuration process and an application process; the configuration process, such as... Figure 10 As shown, it includes:
[0106] S1010, enter the routing management interface, and enter the routing information according to business needs.
[0107] The routing information includes fields such as title, route path, route component, whether to display it as a menu, and whether to enable caching. If business needs require it later, the routing management system can also expand the fields.
[0108] S1020, Perform routing information verification.
[0109] Clicking the route verification button on the interface uses JS import technology to verify whether the component path of the route is filled in accurately. If it is incorrect, an error message is given, the developer corrects it, and the route information is verified again after correction.
[0110] S1030. Enter the menu management interface and enter the menu information.
[0111] Once the routing information verification is successful, you will enter the menu management interface. The menu in the menu management interface is displayed in a tree structure. Each menu node contains the following information: menu name, menu category (directory menu, page menu, button menu). The directory menu consists of non-leaf nodes in the system's left navigation bar menu, the page menu consists of leaf nodes, and the button menu consists of add or edit buttons on the page. Furthermore, the nodes in the menu tree can be dragged to change the order of the menu tree structure, which determines the menu structure in the system's left navigation bar.
[0112] S1040. Mount the route according to the relationship between the menu and the route.
[0113] Based on the relationship between menus and routes, the menu management interface associates menus with routes. For example, the menu management interface displays a menu tree structure on the left and a route-menu association table on the right. First, a menu item is selected. Second, a search box in the menu management interface allows users to search for routes by name and add them to the menu-route association table, thus linking the menu item with the route. However, there is a one-to-one correspondence between menu items and routes. Additionally, routes can be removed from the route association table, thereby severing the link between the route and the menu.
[0114] S1050, enter the role management interface and configure the association between roles and menus.
[0115] Configuring the association between roles and menus can be similar to configuring the association between menus and routes, and will not be elaborated here. By configuring the association between role IDs and menu IDs (i.e., menu information), the relationship between role IDs and route IDs (i.e., route information) is established. Then, the order of the menus determines how the route structure is assembled.
[0116] like Figure 11 As shown, the terminal dynamically loads and displays the left-side menu navigation bar. The specific steps include:
[0117] S1110. The user logs in on the terminal login screen.
[0118] After entering the username and password on the terminal login screen, the server verifies the accuracy of the username and password and returns a JWT identifier.
[0119] S1120, The terminal calls the server's interface for obtaining user information.
[0120] After the terminal obtains the JWT, it includes the interface for retrieving user information via the JWT.
[0121] S1130. The server obtains the user's associated role and gets the routing information and menu information based on the role.
[0122] The server intercepts terminal requests through the user information interface, obtains the JWT, parses the body of the JWT using unbase64, extracts the user ID, and then queries the user's associated role based on the user ID to obtain the routing and menu information of the role.
[0123] S1140. The server assembles authorized routing structure information based on the menu structure and the obtained permission routing information, and then encrypts the routing structure information before sending it to the terminal.
[0124] This routing structure will directly determine the display structure of the system's left navigation bar; routes without permission will not be returned to the terminal, and the terminal does not need to perform any judgment or filtering operations.
[0125] Before returning the route structure to the terminal, the server first performs base64 encoding to prevent Chinese character encoding issues. Then, it uses 3DES to encrypt the route information.
[0126] S1150: After the terminal decrypts the routing structure information, it loads the page component corresponding to the routing path and assembles the routing information.
[0127] After obtaining the routing information, it is assembled into the routing information structure required by the terminal framework. Then, the page components corresponding to the component paths in the routing information are loaded using the require runtime dynamic import technology, thus obtaining the dynamic routing information.
[0128] S1160, Add the organization's dynamic routing information to the overall route set.
[0129] Add the dynamic route array to Vue's total route set.
[0130] S1170, Traverse the total route set to display the system's left-side menu navigation bar.
[0131] The assembled routing information structure is recursively traversed, and the left-hand menu navigation bar of the system is displayed according to the routing structure and information.
[0132] The following specific examples illustrate the user login and different page displays in the Product Service Design Center.
[0133] Assume the system's left-side menu navigation bar includes Rules Management and System Management. Under Rules Management, there are rule example pages, rule template pages, and a new rule instance page. Under System Management, there are user interface, user group interface, and management menu interface.
[0134] 1. The routing table information is shown in Table 1 below:
[0135]
[0136] Table 1
[0137] 2. Based on the above routing table, enter the routing information into the database.
[0138] 3. In the menu management interface, according to business needs, you need to enter the corresponding menu structure. For example, the menu information for rule management is as follows: Menu Name: Rule Management, Menu Category: Directory; Create a new rule instance menu, which is a sub-menu of rule management, with the following information: Menu Name: Rule Instance, Menu Category: Page Menu; Create another new menu for adding a rule instance with the following information: Menu Name: Add Rule Instance, Menu Category: Button Menu. Configure the remaining menus according to the above structure.
[0139] 4. Attach routing information to the menu. For example, associate routes under rule management with the rule management menu. In the menu management interface, search for routes based on the rule management route name and add the retrieved routes to the menu route association table. The association of other menus with routes is the same.
[0140] 5. Go to the role management interface and create two new roles, for example, a rule management role and a system management role. The rule management role is associated with the rule management menu, rule example menu, rule template menu, and create new rule example menu; the system management role is associated with the system management menu, user management menu, user group management menu, and the management menu interface. Essentially, this is a relationship between the role ID and the route ID.
[0141] 6. Create two new users, for example, test1 and test2. Finally, associate test1 with the rule management role and test2 with the system management role. When user test1 logs in successfully, it obtains a JWT and uses it to call the server interface. The server first obtains the authorized route ID based on the role, then obtains the route structure information based on the association between the route ID and the menu ID, and the menu tree structure. Finally, the route structure information returned by the interface only includes the route information for rule management, rule instances, rule templates, and newly added rule instances. The specific structure of the route structure information is as follows: [
[0143] {
[0144] "component":"@ / layout / index",
[0145] "enableCache":0,
[0146] "icon":"rule_manager,
[0147] "id":"802022",
[0148] "isMenu":1,
[0149] "name":"ruleManager",
[0150] "path":" / ruleManager",
[0151] "remark":"Rule management routing",
[0152] "title":"Rule Management", / / The parent menu page is Rule Management
[0153] "children":[
[0154] {
[0155] "children":[],
[0156] "component":"@ / views / ruleModel / index",
[0157] "enableCache":0,
[0158] "icon":"rule_model,
[0159] "id":"802023",
[0160] "isMenu":1,
[0161] "name":"ruleModel",
[0162] "path":" / ruleModel",
[0163] "remark":"Rule Template Routing",
[0164] "title":"Rule Template"
[0165] }, / / Submenu pages are rule templates
[0166] {
[0167] "children":[],
[0168] "component":"@ / views / ruleInstance / index",
[0169] "enableCache":0,
[0170] "icon":"rule_instance,
[0171] "id":"802024",
[0172] "isMenu":1,
[0173] "name":"ruleInstance",
[0174] "path":" / ruleInstance",
[0175] "remark":"Rule Instance Routing",
[0176] "title":""Rule Instance"}, / / The submenu page is for rule instances.
[0177] {
[0178] "children":[],
[0179] "component":"@ / views / ruleInstance / createIndex",
[0180] "enableCache":0,
[0181] "icon":"",
[0182] "id":"802025",
[0183] "isMenu":0,
[0184] "name":"ruleInstanceCreate",
[0185] "path":" / ruleInstanceCreate",
[0186] "remark":"Add a new rule instance route",
[0187] "title":"Add Rule Instance", / / Submenu page is for Adding Rule Instances
[0188] }]
[0189] } ]
[0191] 7. The routing structure information server will use base64 encoding and 3DES encryption technology to encrypt the data before transmitting it to the terminal.
[0192] 8. After receiving the routing structure information, the terminal decrypts and decodes it, then begins to use a recursive algorithm to traverse the above routing structure. During the recursive process, it also utilizes JavaScript's `require([`module path`], resolve)` technique to load the routing component pages. The specific loading function is as follows:
[0193] export const loadView=(view)=>{
[0194] return(resolve)=>require([`${path}`],resolve)
[0195] }
[0196] The final assembled accessible routes will be placed into the accessRoutes array.
[0197] 9. Terminal frameworks (vue, angular.react) will add dynamic routes using the router.addRoutes(accessRoutes) method.
[0198] 10. Finally, by using a recursive algorithm to traverse accessRoutes and combining it with the terminal UI framework (elment-ui), the left-side menu navigation bar can be dynamically displayed.
[0199] 11. Ultimately, user test1 can only see the rule management menu, rule example menu, and rule template menu, and cannot see the system management, user management, user group management, and management menu interfaces.
[0200] 12. If user test2 logs in, step 6 will be repeated. In the end, the left-hand menu navigation bar will only display the system management menu, user management menu, user group management menu and management menu interface. The rule management menu, rule example menu and rule template menu will not be visible.
[0201] 13. If a user's page permissions need to be changed, page permission control can be configured simply by going to the role configuration. If you want to adjust the order of the menu items in the system's left navigation bar, simply go to the menu management interface and adjust the menu order accordingly.
[0202] The method provided in this application provides an intermediate association between the menu and the route. Secondly, the role ID is not directly associated with the menu ID, but rather with the route ID. Finally, based on the menu structure and the association between the menu and the route, the authorized route information can be obtained. Ultimately, when a user logs in, the system returns the route information of the user's roles. The terminal dynamically loads the route information and displays the corresponding menu. Terminal developers do not need to change the terminal code, thus achieving system scalability. When configuring permissions, maintenance personnel do not need to be aware of the existence of the route, thus achieving system maintainability.
[0203] The following describes an apparatus embodiment of this application, which can be used to execute the page menu permission control method in the above embodiments of this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the page menu permission control method described above.
[0204] like Figure 12 As shown, Figure 12 This is a schematic diagram illustrating the structure of a page menu permission control device according to an exemplary embodiment of this application. The device is deployed on a server and includes:
[0205] The acquisition module 1210 is used to acquire the target role corresponding to the user to which the terminal belongs, and the target routing information associated with the target role;
[0206] The determination module 1220 is used to determine the target menu information possessed by the target role based on the preset association between routing information and menu information and the target routing information, and to determine the target menu structure based on the target menu information;
[0207] Structure module 1230 is used to obtain routing structure information based on target routing information and target menu structure;
[0208] The sending module 1240 is used to send routing structure information to the terminal so that the terminal can dynamically load the routing structure information to display a page menu for the user.
[0209] In some embodiments of this application, based on the foregoing scheme, the device further includes a configuration module, which is used to input all routing information required by the project; input menu information corresponding to the project; attach the routing information to the corresponding menu information; and configure the association relationship between each role and the menu information to determine the routing information associated with each role.
[0210] In some embodiments of this application, based on the foregoing scheme, the configuration module is further used to enter all the routing information required for the project in the routing management page. The routing information includes at least one of title, route name, route path, and route component path. If the routing information includes a route component path, the route component path in the routing information is verified.
[0211] In some embodiments of this application, based on the aforementioned scheme, the configuration module is further used to input the menu information corresponding to the item in the menu management interface. The menu information includes the menu name and menu category. The parent-child structure and menu order of the menu information are adjusted according to the configuration requirements to determine the menu structure.
[0212] In some embodiments of this application, based on the foregoing scheme, the configuration module is further configured to configure the menu and route association table; determine the specified menu information in the menu management interface; receive an add instruction, and add the specified route information carried in the add instruction to the menu and route association table to associate the specified menu information with the specified route information.
[0213] In some embodiments of this application, based on the foregoing scheme, the acquisition module 1210 is further configured to acquire the authentication identifier when the terminal calls the local information interface carrying the authentication identifier, and extract the user's user identifier from the authentication identifier; and query the target role associated with the user based on the user identifier.
[0214] In some embodiments of this application, based on the aforementioned scheme, the sending module 1240 is further configured to encode the routing structure information and encrypt the encoded routing structure information to obtain encrypted information; and send the encrypted information to the terminal so that the terminal can decrypt and deencode the encrypted information and then dynamically load the routing structure information.
[0215] It should be noted that the apparatus provided in the above embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module and unit performs operations has been described in detail in the method embodiments, and will not be repeated here.
[0216] The apparatus of this application embodiment obtains target routing information associated with a user's target role, then determines menu information based on the target routing information, thereby determining the menu structure. According to the menu structure and the obtained specified routing information, the specified routing structure information owned by the user is obtained. The terminal dynamically loads the routing structure information and displays the corresponding page menu. Based on the combination of routing and menu, the universality and flexibility of permission design are achieved. Moreover, for the terminal, there is no need to configure the routing file table locally, nor is there a need to hard-code whether there is routing permission. The routing information is only maintained on the server, and the operation and maintenance personnel do not need to be aware of the existence of the routing, resulting in low maintenance costs.
[0217] In one exemplary embodiment, an electronic device includes one or more processors and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the electronic device to perform the aforementioned method. It is understood that the electronic device may be deployed within a server.
[0218] Figure 13 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment.
[0219] It should be noted that this electronic device is merely an example adapted to this application and should not be construed as providing any limitation on the scope of use of this application. Furthermore, this electronic device should not be interpreted as requiring or depending on any specific feature. Figure 13 One or more components of the exemplary electronic device shown.
[0220] like Figure 13 As shown, in an exemplary embodiment, the electronic device includes a processing component 1301, a memory 1302, a power supply component 1303, a multimedia component 1304, an audio component 1305, a processor 1306, a sensor component 1307, and a communication component 1308. Not all of these components are mandatory; the electronic device may add or remove other components according to its functional requirements, and this embodiment does not impose any limitations.
[0221] Processing component 1301 typically controls the overall operation of an electronic device, such as operations related to display, data communication, and log data synchronization. Processing component 1301 may include one or more processors 1306 to execute instructions to complete all or part of the aforementioned operations. Furthermore, processing component 1301 may include one or more modules to facilitate interaction between processing component 1301 and other components. For example, processing component 1301 may include a multimedia module to facilitate interaction between multimedia component 1304 and processing component 1301.
[0222] Memory 1302 is configured to store various types of data to support operation of the electronic device, examples of which include instructions for any application or method operating on the electronic device. Memory 1302 stores one or more modules configured to be executed by one or more processors 1306 to perform all or part of the steps in the methods described in the above embodiments.
[0223] Power supply assembly 1303 provides power to various components of an electronic device. Power supply assembly 1303 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device.
[0224] Multimedia component 1304 includes a screen that provides an output interface between an electronic device and a user. In some embodiments, the screen may include a TP (Touch Panel) and an LCD (Liquid Crystal Display). If the screen includes a touch panel, the screen can be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.
[0225] Audio component 1305 is configured to output and / or input audio signals. For example, audio component 1305 includes a microphone configured to receive external audio signals when the electronic device is in an operating mode, such as a call mode, recording mode, or voice recognition mode. In some embodiments, audio component 1305 also includes a speaker for outputting audio signals.
[0226] Sensor assembly 1307 includes one or more sensors for providing state assessments of various aspects of the electronic device. For example, sensor assembly 1307 can detect the on / off state of the electronic device and can also detect temperature changes in the electronic device.
[0227] The communication component 1308 is configured to facilitate wired or wireless communication between electronic devices and other devices. The electronic devices can access wireless networks based on communication standards, such as Wi-Fi (Wireless-Fidelity).
[0228] Understandable. Figure 13 The structure shown is for illustrative purposes only; electronic devices may include structures that are more advanced than those shown. Figure 13 The more or fewer components shown, or having the same Figure 13 The different components are shown. Figure 13 Each component shown can be implemented using hardware, software, or a combination thereof.
[0229] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not incorporated into the electronic device.
[0230] It should be noted that the computer-readable storage medium shown in the embodiments of this application can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0231] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0232] The above description is merely a preferred exemplary embodiment of this application and is not intended to limit the implementation of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application. Therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.
Claims
1. A method for controlling page menu permissions, characterized in that, The method includes: Enter all the routing information required for the project, enter the menu information corresponding to the project, attach the routing information to the corresponding menu information, configure the association between each role and the menu information, and determine the routing information associated with each role; Obtain the target role corresponding to the user to which the terminal belongs, and the target routing information associated with the target role; The target menu information of the target role is determined based on the association between the preset routing information and the menu information, so as to determine the target menu structure based on the target menu information; The routing structure information is obtained based on the target routing information and the target menu structure; The routing structure information is sent to the terminal so that the terminal dynamically loads the routing structure information to display a page menu for the user.
2. The method according to claim 1, characterized in that, All routing information required for the entry project includes: Enter all the route information required for the project on the route management page. The route information includes at least one of the following: title, route name, route path, and route component path. If the routing information includes a routing component path, then the routing component path in the routing information is validated.
3. The method according to claim 1, characterized in that, The process of entering the menu information corresponding to the item includes: Enter the menu information corresponding to the item in the menu management interface. The menu information includes the menu name and menu category. Adjust the parent-child structure and menu order of the menu information according to configuration requirements to determine the menu structure.
4. The method according to claim 3, characterized in that, The step of attaching the routing information to the corresponding menu information includes: Configure the menu and route association table; Specify the menu information in the menu management interface; Upon receiving an add instruction, the specified route information carried in the add instruction is added to the menu and route association table to associate the specified menu information with the specified route information.
5. The method according to claim 1, characterized in that, The step of obtaining the target role corresponding to the user to whom the terminal belongs includes: When the terminal calls the local information interface carrying the authentication identifier, the authentication identifier is obtained, and the user identifier of the user is extracted from the authentication identifier; Query the target role associated with the user based on the user identifier.
6. The method according to claim 1, characterized in that, Sending the routing structure information to the terminal includes: The routing structure information is encoded, and the encoded routing structure information is encrypted to obtain encrypted information; The encrypted information is sent to the terminal so that the terminal can decrypt and deencode the encrypted information and then dynamically load the routing structure information.
7. A page menu permission control device, characterized in that, The device includes: The configuration module is used to input all the routing information required for the project, input the menu information corresponding to the project, attach the routing information to the corresponding menu information, and configure the association between each role and the menu information to determine the routing information associated with each role. The acquisition module is used to acquire the target role corresponding to the user to which the terminal belongs, and the target routing information associated with the target role; The determination module is used to determine the target menu information possessed by the target role based on the preset association between routing information and menu information and the target routing information, and to determine the target menu structure based on the target menu information; The structure module is used to obtain routing structure information based on the target routing information and the target menu structure; The sending module is used to send the routing structure information to the terminal so that the terminal dynamically loads the routing structure information to display a page menu for the user.
8. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, cause the electronic device to perform the method of any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that, when executed by the processor of a computer, cause the computer to perform the method described in any one of claims 1 to 6.
Citation Information
Patent Citations
Front-end authority control method and device when user browses website and storage device
CN109669597A
An operation permission dynamic configuration method based on a page menu and related equipment
CN109784033A