A routing configuration method, device, equipment, storage medium and product
By using an array structure to store routes in route management, multiple route structures can be constructed, solving the problem of low node location efficiency under tree structures and achieving efficient and accurate route configuration and flexible expansion.
Patent Information
- Application Number
- CN202411306097.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2044-09-19
AI Technical Summary
In existing routing management technologies, tree-structured routing nodes are inefficient and prone to errors, resulting in inaccurate node location and making it difficult to meet the expansion and access control needs of complex websites.
Routes are stored using an array structure. By obtaining node attributes, route objects are constructed and stored in array form to form a route table array. It supports various route structures such as tree, sequential, inheritance, and parallel, enabling efficient and accurate route configuration.
It improves the efficiency and accuracy of routing node location, enhances the flexibility and scalability of routing configuration, and reduces algorithm complexity and response time.
Smart Images

Figure CN119109781B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field, and in particular to a routing configuration method and device, equipment, storage medium and product. BACKGROUND
[0002] With the development of front-end application technology, the functions of the websites built now are more and more complex and three-dimensional. These functions rely on equally complex page structures and permission controls. A routing structure management mechanism that is easy to extend, modify, controlled by permissions and applicable to different scenarios is one of the most basic and important technologies for each large website.
[0003] Most of the current routing management technologies use tree-shaped routing structures. When adding new nodes and finding parent pages, repeated recursive operations are required to traverse the entire tree. This method has high algorithm complexity and is prone to errors in locating routing nodes, resulting in low efficiency in locating routing nodes. Therefore, a routing configuration method that improves the efficiency and accuracy of node positioning is needed. SUMMARY
[0004] The present application provides a routing configuration method that stores routing based on array structure, implements routing configuration, and improves the efficiency and accuracy of routing node positioning.
[0005] In a first aspect, the embodiments of the present application provide a routing configuration method, comprising:
[0006] Obtaining node attributes of a to-be-configured routing; the node attributes are used to define the hierarchical relationship between the to-be-configured routing and other routings;
[0007] Constructing the to-be-configured routing in the form of an object according to the node attributes to obtain a routing object;
[0008] Storing all the routing objects in the form of an array to obtain a routing table array, thereby completing routing configuration.
[0009] Further, the node attributes include constant attributes, and the constant attributes include at least one of hierarchical relationship information, permission identification, routing path, default jump path, custom parameters, whether to hide, and routing associated components.
[0010] Further, the method further comprises:
[0011] Determining deletion indication information of a to-be-deleted routing based on an input routing deletion operation; wherein the deletion indication information is position information in the routing table array or a specified routing feature;
[0012] Finding the to-be-deleted routing in the routing table array according to the deletion indication information to delete the to-be-deleted routing.
[0013] determine a feature of the route to be modified based on the inputted route modification operation;
[0014] find the route to be modified in the routing table array according to the feature of the route to be modified to modify the route to be modified.
[0015] Further, after the route configuration is completed by storing all the route objects in the form of an array to obtain a routing table array, the method further comprises:
[0016] construct a routing structure according to the hierarchical relationship between the route to be configured and other routes based on the routing table array; wherein the routing structure comprises at least one of a tree structure, a sequential structure, an inheritance structure and a parallel structure.
[0017] Further, after the routing structure is constructed according to the hierarchical relationship between the route to be configured and other routes, the method further comprises:
[0018] when the hierarchical relationship changes, clear the routing structure;
[0019] construct a new routing structure according to the changed hierarchical relationship.
[0020] Further, the node attribute comprises hierarchical relationship information, the hierarchical relationship information comprises parent node identification information, current node identification information and previous node identification information of the same level, when the routing structure is a tree structure, the method of constructing a routing structure according to the hierarchical relationship between the route to be configured and other routes based on the routing table array comprises:
[0021] construct a corresponding child node array for each route object; wherein the child node array is used to store the route objects corresponding to all the child nodes of the route object;
[0022] find all the child nodes corresponding to each route object based on the parent node identification information and the current node identification information in the routing table array;
[0023] for each route object, traverse all the child nodes, and based on the current node identification information and the previous node identification information of the same level of the child nodes, add the child nodes to a specified position in the child node array to obtain a tree structure routing structure.
[0024] Further, the node attribute comprises a source pointer and a target pointer, when the routing structure is a sequential structure, the method of constructing a routing structure according to the hierarchical relationship between the route to be configured and other routes based on the routing table array comprises:
[0025] create a sequential routing stack;
[0026] obtain a routing order of routing objects required by the sequential structure, and determine a source pointer and a target pointer of each routing object according to the routing order;
[0027] add each routing object and the corresponding source pointer and target pointer into the sequential routing stack according to the routing order based on the routing table array, to obtain a routing structure of the sequential structure.
[0028] Further, the node attribute includes hierarchical relationship information, and the hierarchical relationship information includes node identifier information and inherited attribute. The inherited attribute is used to specify a to-be-inherited attribute, and the to-be-inherited attribute refers to a node attribute that can be inherited and shared by other routing objects. When the routing structure is an inheritance structure, the constructing of the routing structure according to the hierarchical relationship between the to-be-configured routing and other routings based on the routing table array includes:
[0029] create a shared stack and an inheritance routing stack;
[0030] add the inherited attribute and the node identifier information of the inherited routing object and the node identifier information of the inheritance routing object corresponding to the inherited routing object into the shared stack based on a mapping relationship between the inherited routing object and the inheritance routing object. The inherited routing object has the inherited attribute, and the inheritance routing object is a routing object used to inherit the to-be-inherited attribute of the corresponding inherited routing object.
[0031] add the inherited attribute and the node identifier information of the inherited routing object into the inheritance routing stack, to obtain a routing structure of the inheritance structure.
[0032] Further, when the routing structure is a parallel structure, the constructing of the routing structure according to the hierarchical relationship between the to-be-configured routing and other routings based on the routing table array includes:
[0033] obtain routing objects required by the parallel structure from the routing table array;
[0034] when the routing objects required by the parallel structure are in a stack of a target routing structure, delete the routing objects required by the parallel structure from the stack of the target routing structure. The target routing structure is a sequential structure or an inheritance structure.
[0035] Further, the obtaining of the node attribute of the to-be-configured routing includes:
[0036] obtain an existing routing structure;
[0037] Traverse the existing routing structure to determine a to-be-configured route and obtain hierarchical relationship information of the to-be-configured route as node attributes of the to-be-configured route.
[0038] Further, the node attributes include constant attributes, and the constant attributes include permission identifiers.
[0039] Traverse all routing objects in the routing table array.
[0040] When the permission identifier of the routing object is not in a preset control permission set, delete the routing object from the routing table array, wherein the control permission set is a set of permission identifiers of all routing objects that a user is authorized to access.
[0041] Further, the node attributes include constant attributes, and the constant attributes include hierarchical relationship information, and the hierarchical relationship information includes parent node identifier information and a default jump path.
[0042] When the default jump path cannot be jumped, determine target parent node identifier information according to the routing table array, wherein the target parent node identifier information is parent node identifier information of a routing object corresponding to the default jump path.
[0043] Determine a target routing object according to the target parent node identifier information and jump to the target routing object, wherein parent node identifier information of the target routing object is the target parent node identifier information.
[0044] In a second aspect, an embodiment of the present application provides a routing configuration device, including:
[0045] A data acquisition module is configured to acquire node attributes of a to-be-configured route, and the node attributes are used to define hierarchical relationship between the to-be-configured route and other routes.
[0046] A routing object construction module is configured to construct the to-be-configured route in the form of an object according to the node attributes to obtain a routing object.
[0047] A routing configuration module is configured to store all routing objects in the form of an array to obtain a routing table array to complete routing configuration.
[0048] In a third aspect, an embodiment of the present application provides a routing configuration device, including:
[0049] A memory is configured to store a computer program.
[0050] A processor is configured to execute the computer program.
[0051] The processor implements the routing configuration method of any one of the first aspect when executing the computer program.
[0052] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program. The computer program is executed to implement the routing configuration method of any one of the first aspect.
[0053] In a fifth aspect, an embodiment of the present application provides a computer program product, which includes computer instructions. The computer instructions are executed by a processor to implement the routing configuration method of any one of the first aspect.
[0054] Compared with the prior art, the routing configuration method, device, equipment, computer readable storage medium and computer program product provided by the embodiment of the present application have the beneficial effects that: the node attribute of the to-be-configured route is obtained; the node attribute is used to define the hierarchical relationship between the to-be-configured route and other routes; the to-be-configured route is constructed in the form of an object according to the node attribute, and a route object is obtained; all the route objects are stored in the form of an array, and a route table array is obtained, so as to complete the route configuration, which can improve the efficiency and accuracy of node positioning, and thus improve the flexibility and scalability of route configuration. BRIEF DESCRIPTION OF DRAWINGS
[0055] In order to more clearly illustrate the technical features of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0056] Figure 1 is a flow diagram of an embodiment of a routing configuration method provided by the present application;
[0057] Figure 2 is a structural diagram of an embodiment of a routing configuration device provided by the present application;
[0058] Figure 3 is a structural diagram of an embodiment of a routing configuration device provided by the present application. DETAILED DESCRIPTION
[0059] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0060] With reference to the drawings of the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application. Figure 1 Figure 1 is a flow diagram of a routing configuration method provided by the embodiments of the present application, and the routing configuration method comprises steps S1-S3:
[0061] S1, obtaining node attributes of a to-be-configured route; the node attributes are used to define a hierarchical relationship between the to-be-configured route and other routes;
[0062] S2, constructing the to-be-configured route in the form of an object according to the node attributes, to obtain a route object;
[0063] S3, storing all the route objects in the form of an array to obtain a route table array, to complete routing configuration.
[0064] In a specific implementation, first, the node attributes of each to-be-configured route are determined, the node attributes include the hierarchical relationship between the to-be-configured route and other routes and other route information, all the to-be-configured routes are constructed in the form of an object according to the obtained node attributes, to obtain a route object, all the route objects are stored in the form of an array to obtain a route table array, and routing configuration is completed according to the route table array.
[0065] In an optional implementation, the node attributes include constant attributes, and the constant attributes include at least one of hierarchical relationship information, a permission identifier, a route path, a default jump path, a custom parameter, whether to hide, and a route-associated component.
[0066] Specifically, the node attribute includes a constant attribute, a variable attribute, and a function attribute. The constant attribute defines a basic structure and a relationship of the route, and includes at least one of a route name name, hierarchical relationship information, a permission identifier pageCode, a route path path, a default jump path redirect, a custom parameter meta, whether to hide hidden, and a route associated component component. The hierarchical relationship information includes parent node identifier information parentId, current node identifier information Id, and a previous node identifier information preId of a same level. The parent node identifier information represents a unique identifier Id of an upper level route, and is empty when there is no parent node. The current node identifier information represents a unique identifier Id of a current route. The previous node identifier information represents a unique identifier Id of a previous route of the current route in a same level route, and is empty when there is no previous route.
[0067] It should be noted that the name of the variable attribute can be the same as or different from the constant attribute. When the name of the variable attribute is the same as the constant attribute, the variable attribute covers the constant attribute. When the route object is in a temporary life cycle, it is detected whether the route object has a function attribute when entering the route. The function attribute supports parameter passing and callback, and also supports modifying the constant attribute or the variable attribute in a currently effective life cycle.
[0068] In an optional implementation, the method further includes:
[0069] determining, based on an input route deletion operation, deletion indication information of a route to be deleted; wherein the deletion indication information is position information in the route table array or a specified route feature;
[0070] finding, according to the deletion indication information, the route to be deleted in the route table array, to delete the route to be deleted;
[0071] determining, based on an input route modification operation, a feature of a route to be modified;
[0072] finding, according to the feature of the route to be modified, the route to be modified in the route table array, to modify the route to be modified.
[0073] Specifically, the route is extended and deleted based on the route table array. When the route needs to be deleted, the route can be deleted according to the position of the route to be deleted in the route table array or a specified route feature. For example, when the position of the route to be deleted in the route table array is n, and the number of routes to be deleted starting from the current position of the route to be deleted is m, the route object n and m route objects before the route object n are deleted.
[0074] When the deletion is performed according to the specified route feature of the route to be deleted, only the loop operation is needed to traverse the route table array and judge whether the route meets the specified route feature of the route to be deleted. All route objects in the route table array are traversed, and when a route object meets the specified route feature of the route to be deleted, it is deleted. All route objects are looped and judged until all route objects meeting the specified route feature of the route to be deleted are deleted.
[0075] It can be understood that when the modification is performed according to the specified route feature of the route to be modified, only the loop operation is needed to traverse the route table array and judge whether the route meets the specified route feature. All route objects in the route table array are traversed, and when a route object meets the specified route feature of the route to be modified, it is modified. All route objects are looped and judged until all route objects meeting the specified route feature of the route to be modified are modified.
[0076] In an optional embodiment, after the route configuration is completed by storing all the route objects in the form of an array to obtain a route table array, the method further comprises:
[0077] Based on the route table array, a route structure is constructed according to the hierarchical relationship between the route to be configured and other routes. The route structure includes at least one of a tree structure, a sequential structure, an inheritance structure, and a parallel structure.
[0078] Specifically, the present application can construct different route structures based on the node attributes of the route, and different route structures can exist in superposition. The route structure includes a tree structure, a sequential structure, an inheritance structure, and a parallel structure.
[0079] In an optional embodiment, after the route structure is constructed according to the hierarchical relationship between the route to be configured and other routes, the method further comprises:
[0080] When the hierarchical relationship changes, the route structure is cleared.
[0081] A new route structure is constructed according to the changed hierarchical relationship.
[0082] Specifically, the routing structure constructed by the application adopts the strategy of being generated as needed and being destroyed after use, which can avoid the idling and waste of resources, reduce the load pressure of the project, and when the hierarchical relationship between the to-be-configured route and other routes changes, i.e., the constructed routing structure deviates from the current business scenario, the routing structure can be set to be invalid. The invalidation setting can be performed by setting the invalidation in the beforeDestroy hook of the page component when the page corresponding to the routing structure is destroyed, clearing the cache or stack corresponding to the routing structure, generating a new routing structure according to the changed hierarchical relationship, and recycling the memory and cache in time, which can reduce the consumption of the storage space and computing power of the website.
[0083] In an optional implementation, the node attribute includes hierarchical relationship information, the hierarchical relationship information includes parent node identification information, current node identification information, and previous node identification information of the same level, when the routing structure is a tree structure, the constructing of the routing structure based on the routing table array according to the hierarchical relationship between the to-be-configured route and other routes includes:
[0084] constructing a corresponding child node array for each routing object, wherein the child node array is used to store routing objects corresponding to all child nodes of the routing object;
[0085] finding all child nodes corresponding to each routing object based on the parent node identification information and the current node identification information in the routing table array;
[0086] for each routing object, traversing all child nodes, adding the child nodes to a specified position in the child node array based on the current node identification information and the previous node identification information of the same level of the child nodes, and obtaining a tree structure routing structure.
[0087] Specifically, the tree structure as the basic structure of the website route is the most common route conforming to the menu style structure, and is configured through a constant attribute in the application. An idMap is first created so that a node can be quickly found according to an id. A corresponding child node array is constructed for each route object, and the child node array stores all child nodes of the route object. Each route object is traversed, and is added to a child node array of a parent node corresponding to a parent node identifier information parentId and a node identifier information Id of the node. After all child nodes corresponding to each route object are found, the child nodes need to be sequentially sorted based on the node identifier information Id and a previous node identifier information preId of the child nodes to determine the positions of the child nodes in the child node array of the parent node and insert the child nodes. When the previous node identifier information preId of the child node is empty, the child node is inserted at the end of the child node array of the parent node. Finally, the route structure of the tree structure is obtained. If the previous node identifier information preId is inaccurate, the finally generated tree structure will also be incorrect. Therefore, in the process of constructing the tree structure, the accuracy and consistency of the data need to be ensured. The constructed route of the tree structure is generally stored in a cache, and can be effective in the entire running cycle of the project.
[0088] The application constructs the route structure of the tree structure, performs one traversal operation on the route table array, has low algorithm complexity, consumes less computing resources, and the route structure of the tree structure can be directly received by a vue-router and a menu component in a Vue project to generate a route and a menu that can be directly used in the project.
[0089] In an optional implementation, the node attribute includes a source pointer and a target pointer. When the route structure is a sequential structure, the route structure is constructed based on the route table array and a hierarchical relationship between the to-be-configured route and other routes, and includes the following steps.
[0090] A sequential route stack is created.
[0091] A route sequence of a route object required by the sequential structure is obtained, and a source pointer and a target pointer of each route object are determined according to the route sequence.
[0092] Each route object and the corresponding source pointer and target pointer are sequentially added to the sequential route stack based on the route table array and the route sequence, to obtain the route structure of the sequential structure.
[0093] Specifically, when there is a requirement for the loading of multiple pages in a certain order, a sequential structure route structure needs to be constructed, and the sequential structure route requires the loading of pages to be performed in a specified order, otherwise the new page cannot be opened. In some scenarios, a sequential structure is required, for example, when the next page business needs to accept the parameter passing of the previous page, the next page needs to pass through the specified page authentication, or when the control source page or target page must be a certain type of page in the jump.
[0094] In constructing the sequential structure route structure, a sequential route stack is first created to store route objects with sequential requirements, the route order of the route objects required for the sequential structure to be constructed is obtained, and the source pointer and target pointer of each route object are determined according to the route order. For example, according to the business requirements, the route order to be constructed is to pass through route object A to reach route object B, and then to route object C. According to the route order, it can be determined that the source pointer of route object A is empty and the target pointer is B, the source pointer of route object B is A and the target pointer is C, and the source pointer of route object C is B and the target pointer is empty. Based on the route table array, all route objects are added to the sequential route stack in the route order, and the source pointer and target pointer of each route object are added to the variable attribute of the route object in the sequential route stack. The variable attribute of the route object in the route table array is not modified, and the sequential structure route structure is obtained.
[0095] Further, when jumping according to the constructed sequential structure, the source pointer and target pointer can be checked for safety to avoid route jumping errors. Using the beforeEach hook of vue-router, the source route and target route of the current page route object can be obtained, and the source route and target route obtained by using the beforeEach hook are compared with the source pointer and target pointer of the route object in the sequential route stack. When the comparison is consistent, the jump operation is performed, the sequential structure route structure takes effect, otherwise the jump is terminated and an error prompt is given, which can ensure the accuracy and legality of the jump order.
[0096] It should be noted that the source pointer and target pointer can be an attribute or a function. When the pointer is an attribute, the corresponding source route and target route can be obtained directly according to the attribute. When the pointer is a function, the source route and target route of the route object are determined according to the function logic, which is not limited to a single source and target constraint, and can expand the application scope of the sequential route.
[0097] In an optional implementation, the node attribute includes hierarchical relationship information, the hierarchical relationship information includes a node identifier and inherited attributes, and the inherited attributes are used to specify to-be-inherited attributes, which refer to node attributes that can be inherited and shared by other routing objects; when the routing structure is an inheritance structure, constructing a routing structure according to hierarchical relationships between the to-be-configured routing and other routings based on the routing table array includes:
[0098] creating a shared stack and an inheritance routing stack;
[0099] adding the inherited attributes and the node identifier of the inherited routing object and the node identifier of the inheritance routing object corresponding to the inherited routing object to the shared stack based on a mapping relationship between the inherited routing object and the inheritance routing object, wherein the inherited routing object has the inherited attributes, and the inheritance routing object is a routing object used to inherit to-be-inherited attributes of the corresponding inherited routing object;
[0100] adding the inherited attributes and the node identifier of the inherited routing object to the inheritance routing stack to obtain a routing structure of an inheritance structure.
[0101] Specifically, when a page is loaded, sometimes some subpages need to inherit some attributes from a specified page, for example, page attributes or public IDs, or a permission verification of a public page is granted to multiple subpages at the same time, in which case a routing structure of an inheritance structure needs to be constructed, a shared stack and an inheritance routing stack are first created, a mapping relationship between an inherited routing object and an inheritance routing object is obtained, the inherited attributes and the node identifier of the inherited routing object and the node identifier of the inheritance routing object corresponding to the inherited routing object are added to the shared stack, the inherited attributes and the node identifier of the inherited routing object are added to the inheritance routing stack, and a routing structure of an inheritance structure is obtained based on the shared stack and the inheritance routing stack.
[0102] It should be noted that when a jump is performed according to the constructed inheritance structure, a legality verification can be performed on the inheritance relationship, a target routing of a current page routing object can be obtained by using a beforeEach hook of vue-router, it is determined in the inheritance routing stack whether the target routing needs necessary inherited attributes, and it is verified by using a built-in function attribute whether the inherited attributes are legal, if the inherited attributes are legal, the jump can be performed, the routing structure of the inheritance structure takes effect, otherwise the jump is terminated and an error is prompted.
[0103] In an optional implementation, when the routing structure is a parallel structure, constructing a routing structure according to hierarchical relationships between the to-be-configured routing and other routings based on the routing table array includes:
[0104] obtaining the route object required by the parallel structure from the route table array;
[0105] when the route object required by the parallel structure is in the stack of the target route structure, deleting the route object required by the parallel structure from the stack of the target route structure; wherein the target route structure is a sequential structure or an inheritance structure.
[0106] Specifically, when multiple independent contents or functions are simultaneously displayed, such as multiple tabs, a parallel structure route structure needs to be constructed, and the parallel structure refers to that each page is independent of each other, does not share data, and there is no problem of value transmission, inheritance or opening sequence of the page. The parallel structure cannot be superimposed with a route relationship having a sequential structure or an inheritance structure, and therefore, when the parallel structure is constructed, the original sequential structure and inheritance structure need to be cleared. First, the route object required by the parallel structure is obtained from the route table array, and when the route object required by the parallel structure is in the stack of the target route structure, the route object required by the parallel structure is deleted from the stack of the target route structure. The target route structure is a sequential structure or an inheritance structure, and the stack of the target route structure includes a sequential route stack, a shared stack and an inheritance route stack.
[0107] In an optional embodiment, the node attribute of the to-be-configured route is obtained, including:
[0108] obtaining an existing route structure;
[0109] traversing the existing route structure, determining a to-be-configured route, and obtaining the hierarchical relationship information of the to-be-configured route as the node attribute of the to-be-configured route.
[0110] Specifically, at present, many projects use complex structured routes, which can be converted into unstructured routes by using the route configuration method of the present application. The to-be-configured route is constructed in the form of an object and stored in the form of an array, and the route table array is used to complete the route configuration, so as to obtain at least one of a tree structure, a sequential structure, an inheritance structure or a parallel structure.
[0111] First, the existing route structure is obtained, all route nodes are traversed, the hierarchical relationship of the to-be-configured route is obtained, that is, the node identifier information, the parent node identifier information and the previous node identifier information of each to-be-configured route are obtained as the node attribute of the to-be-configured route. Then, all to-be-configured routes are constructed into route objects in the form of objects according to the node attribute, and all route objects are stored in the form of an array to obtain a route table array, and the route configuration is completed according to the route table array.
[0112] In an alternative embodiment, the node attribute comprises a constant attribute, the constant attribute comprises a permission identifier, and the method further comprises:
[0113] traversing all the route objects in the route table array;
[0114] when the permission identifier of the route object is not in the preset control permission set, deleting the route object from the route table array; wherein the control permission set is a set of permission identifiers of all route objects that the user is authorized to access.
[0115] Specifically, the control permission set is a set of permission identifiers of all route objects that the user is authorized to access, indicating which routes the current user has permission to access. All route objects in the route table array are traversed, and it is checked whether the permission identifier of each route object is in the preset control permission set. If the permission identifier of the route object is not in the control permission set, it indicates that the current user has no permission to access the route object, and the route object is deleted from the route table array.
[0116] In an alternative embodiment, the node attribute comprises a constant attribute, the constant attribute comprises hierarchy information, the hierarchy information comprises parent node identifier information and a default jump path, and the method further comprises:
[0117] when the default jump path cannot jump, determining target parent node identifier information according to the route table array, wherein the target parent node identifier information is the parent node identifier information of the route object corresponding to the default jump path;
[0118] determining a target route object according to the target parent node identifier information and jumping to the target route object; wherein the parent node identifier information of the target route object is the target parent node identifier information.
[0119] Specifically, in the current common method, when a route does not exist, it is generally jumped to a 404 page or logged out, but in many default jump scenarios, it is hoped that when the target route does not exist, it can be jumped to a specified route at the same level as the target route. In the present application, when the default jump path of the route object cannot jump, the parent node identifier information in the node attribute of the route object is determined according to the route table array. According to the parent node identifier information, other child nodes under the parent node, i.e., route objects at the same level as the route object, can be found, so that the target route object at the same level that is hoped to be jumped to can be determined.
[0120] Compared with the prior art, the application obtains node attributes of a to-be-configured route; the node attributes are used to define a hierarchical relationship between the to-be-configured route and other routes; the to-be-configured route is constructed in the form of an object according to the node attributes, to obtain a route object; all the route objects are stored in the form of an array, to obtain a route table array, so as to complete route configuration, and when a new node is added and a parent page is found, repeated recursive operations are not needed, the algorithm complexity is relatively low, the efficiency and accuracy of node positioning can be improved, the flexibility and scalability of route configuration are improved, and the algorithm complexity and response time are reduced.
[0121] In a second aspect, an embodiment of the application provides a route configuration device, as shown in Figure 2 The route configuration device includes:
[0122] As shown in Figure 2 The route configuration device includes:
[0123] The data acquisition module 21 is configured to acquire node attributes of a to-be-configured route; the node attributes are used to define a hierarchical relationship between the to-be-configured route and other routes.
[0124] The route object construction module 22 is configured to construct the to-be-configured route in the form of an object according to the node attributes, to obtain a route object.
[0125] The route configuration module 23 is configured to store all the route objects in the form of an array, to obtain a route table array, so as to complete route configuration.
[0126] In an optional implementation, the node attributes include constant attributes, and the constant attributes include at least one of hierarchical relationship information, a permission identifier, a route path, a default jump path, a custom parameter, whether to hide, and a route-associated component.
[0127] In an optional implementation, the device further includes a route modification module configured to:
[0128] determine deletion indication information of a to-be-deleted route based on an input route deletion operation; wherein the deletion indication information is position information in the route table array or a specified route feature;
[0129] find the to-be-deleted route in the route table array according to the deletion indication information, to delete the to-be-deleted route;
[0130] determine a feature of a to-be-modified route based on an input route modification operation;
[0131] According to the characteristics of the to-be-modified route, the to-be-modified route is found in the routing table array, so as to modify the to-be-modified route.
[0132] In an optional implementation, the apparatus further comprises a routing structure construction module, configured to:
[0133] According to the hierarchical relationship between the to-be-configured route and other routes, a routing structure is constructed based on the routing table array; wherein the routing structure comprises at least one of a tree structure, a sequential structure, an inheritance structure and a parallel structure.
[0134] In an optional implementation, the apparatus further comprises a routing structure updating module, configured to:
[0135] When the hierarchical relationship changes, the routing structure is cleared;
[0136] According to the changed hierarchical relationship, a new routing structure is constructed.
[0137] In an optional implementation, the node attribute comprises hierarchical relationship information, the hierarchical relationship information comprises parent node identification information, current node identification information and previous node identification information of the same level, and when the routing structure is a tree structure, the routing configuration module is further configured to:
[0138] For each routing object, a corresponding child node array is constructed; wherein the child node array is used to store routing objects corresponding to all child nodes of the routing object;
[0139] Based on the parent node identification information and the current node identification information in the routing table array, all child nodes corresponding to each routing object are found;
[0140] For each routing object, all child nodes are traversed, based on the current node identification information and the previous node identification information of the same level of the child nodes, the child nodes are added to a specified position in the child node array, so as to obtain a tree structure routing structure.
[0141] In an optional implementation, the node attribute comprises a source pointer and a target pointer, and when the routing structure is a sequential structure, the routing configuration module is further configured to:
[0142] A sequential routing stack is created;
[0143] The routing order of routing objects required by the sequential structure is obtained, and the source pointer and the target pointer of each routing object are determined according to the routing order;
[0144] Based on the routing table array, each routing object and corresponding source pointer and target pointer are added into the sequential routing stack according to the routing order, and a sequential structure routing structure is obtained.
[0145] In an optional implementation, the node attribute includes hierarchical relationship information, the hierarchical relationship information includes a node identifier and inherited attributes, and the inherited attributes are used to specify to-be-inherited attributes, which refer to node attributes that can be inherited and shared by other routing objects; when the routing structure is an inheritance structure, the routing configuration module is further configured to:
[0146] create a shared stack and an inheritance routing stack;
[0147] based on a mapping relationship between to-be-inherited routing objects and inheritance routing objects, add the to-be-inherited attributes and the node identifier of the to-be-inherited routing objects and the node identifier of the inheritance routing objects corresponding to the to-be-inherited routing objects into the shared stack; the to-be-inherited routing objects have the to-be-inherited attributes, and the inheritance routing objects are routing objects used to inherit to-be-inherited attributes of corresponding to-be-inherited routing objects;
[0148] add the to-be-inherited attributes and the node identifier of the to-be-inherited routing objects into the inheritance routing stack, and obtain a routing structure of an inheritance structure.
[0149] In an optional implementation, when the routing structure is a parallel structure, the routing configuration module is further configured to:
[0150] obtain routing objects required by the parallel structure from the routing table array;
[0151] when the routing objects required by the parallel structure are in a stack of a target routing structure, delete the routing objects required by the parallel structure from the stack of the target routing structure; the target routing structure is a sequential structure or an inheritance structure.
[0152] In an optional implementation, the node attribute of the to-be-configured routing includes:
[0153] obtain an existing routing structure;
[0154] traverse the existing routing structure, determine a to-be-configured routing, and obtain hierarchical relationship information of the to-be-configured routing as a node attribute of the to-be-configured routing.
[0155] In an optional implementation, the node attribute includes a constant attribute, and the constant attribute includes a permission identifier; the apparatus further includes a permission control module configured to:
[0156] traversing all the route objects in the route table array;
[0157] when the permission identifier of the route object is not in a preset control permission set, deleting the route object from the route table array; wherein the control permission set is a set of permission identifiers of all route objects that the user is authorized to access.
[0158] In an optional implementation, the node attribute includes a constant attribute, the constant attribute includes hierarchical relationship information, the hierarchical relationship information includes parent node identifier information and a default jump path, and the device further includes a jump control module configured to:
[0159] when the default jump path cannot jump, determining target parent node identifier information according to the route table array, wherein the target parent node identifier information is the parent node identifier information of a route object corresponding to the default jump path;
[0160] determining a target route object according to the target parent node identifier information and jumping to the target route object; wherein the parent node identifier information of the target route object is the target parent node identifier information.
[0161] In a third aspect, an embodiment of the present application provides a route configuration device, referring to Figure 3 as shown in the figure, the device includes:
[0162] as shown in the figure, the device includes: Figure 3
[0163] a memory 31 configured to store a computer program;
[0164] a processor 32 configured to execute the computer program;
[0165] When the processor 32 executes the computer program, the processor 32 implements the route configuration method in any of the above embodiments.
[0166] For example, the computer program can be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 32 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the route configuration device.
[0167] The processor 32 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0168] The memory 31 can be configured to store the computer program and / or modules, and the processor 32 can realize various functions of the routing configuration device by running or executing the computer program and / or modules stored in the memory 31, and calling data stored in the memory 31. The memory 31 can mainly include a program storage area and a data storage area, where the program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), and the like; and the data storage area can store data created based on use of the mobile phone (such as audio data, a phone book, etc.), and the like. In addition, the memory 31 can include a high-speed random access memory, and can also include a nonvolatile memory, for example, a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash storage device, or other volatile solid-state memory device.
[0169] It should be noted that the routing configuration device includes, but is not limited to, the processor and the memory, and those skilled in the art can understand that the routing configuration device can further include other components, which will not be described herein. Figure 3 The structural schematic diagram is only an example of the routing configuration device, and does not constitute a limitation on the routing configuration device, and the routing configuration device can include more components than the diagram, or combine certain components, or different components.
[0170] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, which stores a computer program. The computer program is executed to implement the routing configuration method in any of the above embodiments.
[0171] It should be understood that the present application implements all or part of the above-mentioned routing configuration method, which can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer readable storage medium, and the computer program can implement the steps of the above-mentioned routing configuration method when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0172] In a fifth aspect, the embodiments of the present application further provide a computer program product stored in a storage medium, and the program product is executed by at least one processor to implement the routing configuration method of any of the above-mentioned embodiments.
[0173] The above is only the preferred embodiment of the present application, but the protection scope of the present application is not limited thereto. It should be pointed out that for those skilled in the art, without departing from the technical principles of the present application, a number of equivalent obvious variations and / or equivalent replacement methods can be made, and these obvious variations and / or equivalent replacement methods should also be considered as the protection scope of the present application.
Claims
1. A method of routing configuration, characterized by, The method comprises the following steps: obtaining node attributes of a to-be-configured route; the node attributes are used to define a hierarchical relationship between the to-be-configured route and other routes; constructing the to-be-configured route in the form of an object according to the node attributes, to obtain a route object; storing all the route objects in the form of an array to obtain a route table array, to complete route configuration; the step of obtaining the node attributes of the to-be-configured route comprises the following steps: obtaining an existing route structure; traversing the existing route structure to determine a to-be-configured route and obtain hierarchical relationship information of the to-be-configured route, as the node attributes of the to-be-configured route.
2. The routing configuration method of claim 1, wherein, the node attributes comprise constant attributes, and the constant attributes comprise at least one of hierarchical relationship information, permission identification, a route path, a default jump path, a custom parameter, whether to hide, and a route-associated component.
3. The routing configuration method of claim 1, wherein, the method further comprises the following steps: determining deletion indication information of a to-be-deleted route based on an input route deletion operation; wherein the deletion indication information is position information or a specified route feature in the route table array; finding the to-be-deleted route in the route table array according to the deletion indication information, to delete the to-be-deleted route; determining a feature of a to-be-modified route based on an input route modification operation; finding the to-be-modified route in the route table array according to the feature of the to-be-modified route, to modify the to-be-modified route.
4. The routing configuration method of claim 1, wherein, after the step of storing all the route objects in the form of an array to obtain a route table array, to complete route configuration, the method further comprises the following steps: constructing a route structure according to the hierarchical relationship between the to-be-configured route and other routes based on the route table array; wherein the route structure comprises at least one of a tree structure, a sequential structure, an inheritance structure, and a parallel structure.
5. The routing configuration method of claim 4, wherein, after the step of constructing a route structure according to the hierarchical relationship between the to-be-configured route and other routes, the method further comprises the following steps: when the hierarchical relationship changes, clearing the route structure; constructing a new route structure according to the changed hierarchical relationship.
6. The routing configuration method of claim 4, wherein, the node attributes comprise hierarchical relationship information, and the hierarchical relationship information comprises parent node identification information, current node identification information, and a previous node identification information of the same level; when the route structure is a tree structure, the step of constructing a route structure according to the hierarchical relationship between the to-be-configured route and other routes based on the route table array comprises the following steps: constructing a corresponding child node array for each route object; wherein the child node array is used to store route objects corresponding to all child nodes of the route object; finding all child nodes corresponding to each route object based on the parent node identification information and the current node identification information in the route table array; for each route object, traversing all child nodes, and adding the child nodes to a specified position in the child node array based on the current node identification information and the previous node identification information of the same level of the child nodes, to obtain a tree structure route structure.
7. The routing configuration method of claim 4, wherein, The node attribute includes a source pointer and a target pointer, and when the routing structure is a sequential structure, the constructing of the routing structure according to the hierarchical relationship between the to-be-configured route and other routes based on the routing table array comprises: creating a sequential routing stack; obtaining a routing order of a routing object required by the sequential structure, and determining the source pointer and the target pointer of each routing object according to the routing order; adding each routing object and the corresponding source pointer and target pointer into the sequential routing stack according to the routing order based on the routing table array, to obtain the routing structure of the sequential structure.
8. The routing configuration method of claim 4, wherein, The node attribute includes hierarchical relationship information, and the hierarchical relationship information includes node identification information and inherited attributes, and the inherited attributes are used to specify to-be-inherited attributes, which are node attributes that can be inherited and shared by other routing objects; When the routing structure is an inheritance structure, the constructing of the routing structure according to the hierarchical relationship between the to-be-configured route and other routes based on the routing table array comprises: creating a shared stack and an inheritance routing stack; adding the inherited attributes of the inherited routing object, the node identification information, and the node identification information of the inheritance routing object corresponding to the inherited routing object into the shared stack based on a mapping relationship of the inherited routing object and the inheritance routing object; wherein the inherited routing object has the inherited attributes, and the inheritance routing object is a routing object used to inherit the to-be-inherited attributes of the corresponding inherited routing object; adding the inherited attributes of the inherited routing object and the node identification information into the inheritance routing stack, to obtain the routing structure of the inheritance structure.
9. The routing configuration method of claim 4, wherein, When the routing structure is a parallel structure, the constructing of the routing structure according to the hierarchical relationship between the to-be-configured route and other routes based on the routing table array comprises: obtaining a routing object required by the parallel structure from the routing table array; when the routing object required by the parallel structure is in a stack of a target routing structure, deleting the routing object required by the parallel structure from the stack of the target routing structure; wherein the target routing structure is a sequential structure or an inheritance structure.
10. The routing configuration method of claim 1, wherein, The node attribute includes a constant attribute, and the constant attribute includes a permission identifier, and the method further comprises: traversing all routing objects in the routing table array; when the permission identifier of the routing object is not in a preset control permission set, deleting the routing object from the routing table array; wherein the control permission set is a set of permission identifiers of all routing objects that a user is authorized to access.
11. The routing configuration method of claim 1, wherein, The node attribute includes a constant attribute, and the constant attribute includes hierarchical relationship information, and the hierarchical relationship information includes parent node identification information and a default jump path, and the method further comprises: when the default jump path cannot be jumped, determining target parent node identification information according to the routing table array, wherein the target parent node identification information is the parent node identification information of a routing object corresponding to the default jump path; Determine a target routing object according to the target parent node identification information and jump to the target routing object; wherein the parent node identification information of the target routing object is the target parent node identification information.
12. A routing configuration apparatus, characterized by comprising: The method comprises: a data acquisition module configured to acquire node attributes of a to-be-configured routing; the node attributes are used to define a hierarchical relationship between the to-be-configured routing and other routings; a routing object construction module configured to construct the to-be-configured routing in the form of an object according to the node attributes to obtain a routing object; a routing configuration module configured to store all the routing objects in the form of an array to obtain a routing table array, thereby completing routing configuration; the node attributes of the to-be-configured routing comprise: acquiring an existing routing structure; traversing the existing routing structure to determine a to-be-configured routing and acquire hierarchical relationship information of the to-be-configured routing as node attributes of the to-be-configured routing.
13. A routing configuration device, characterized by The method comprises: a memory configured to store a computer program; a processor configured to execute the computer program; wherein the processor, when executing the computer program, implements the routing configuration method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program, when executed, implements the routing configuration method according to any one of claims 1 to 11.
15. A computer program product, characterised in that, The computer readable storage medium stores a computer program, and the computer program, when executed, implements the routing configuration method according to any one of claims 1 to 11. The computer readable storage medium stores a computer program, and the computer program, when executed, implements the routing configuration method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Node generation method and device based on data processing, and computer equipment
CN111126931A
Method and device for configuring front-end route
CN114268538A