Single-page application page access method and device based on dynamic routing

By adopting a dynamic routing-based page access method in a single-page application, dynamically match the routing table and rendering the page components according to user roles and permissions, the security risks and resource waste caused by static routing configuration are solved, and efficient and secure page access and loading are achieved.

CN120045800APending Publication Date: 2025-05-27BUBI (BEIJING) NETWORK TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411939945.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-26
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

The static routing configuration of a single page application leads to security risks and waste of resources. Unauthorized users may access restricted pages, and the static routing configuration leads to unnecessary resource loading, affecting the page loading speed.

Method used

The single-page application page access method based on dynamic routing is adopted. By receiving user access requests on the front end, obtaining access parameter information in the user access information, and matching the dynamic routing table based on predefined routing rules, the required target page components are determined, and the target page components are rendered on the front end.

Benefits of technology

Dynamic routing management for different user roles and permissions is realized, which improves page access security and efficiency, avoids the phenomenon of unauthorized users accessing restricted pages, and saves loading and rendering resources of unrelated components, improving home page loading efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045800A_ABST
    Figure CN120045800A_ABST
Patent Text Reader

Abstract

The invention relates to a single-page application page access method and device based on dynamic routing, and the method comprises the steps: receiving an access request of a user for single-page application page access at a front end, the access request carrying user access information; obtaining access entry parameter information corresponding to the user access information, wherein the access entry parameter information comprises at least one of the following: a target user role and a target user permission; based on the access entry parameter information, performing matching in a routing rule predefined at the front end to obtain a dynamic routing table corresponding to the access entry parameter information; the routing rule comprises routing table definition groups corresponding to different parameter entering conditions, and the parameter entering conditions comprise at least one of the following conditions: user roles and user permissions; and determining a required target page component according to the dynamic routing table, and rendering the target page component at the front end to obtain a target application page. Card control logic of specific page access for different user roles and permissions is effectively realized, and access safety and page loading efficiency are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of front-end technologies, and in particular, to a method and apparatus for accessing single-page application pages based on dynamic routing. Background Art

[0002] A single-page application (SPA) is an application with only one Web page. It loads a single HTML page and dynamically updates the page when the user interacts with the application, providing an efficient page loading and smooth user experience. The core of an SPA is to achieve dynamic loading and replacement of page content through the asynchronous communication technology Ajax (which can send requests to the server asynchronously. During the waiting for the response, it does not block the current page, and in this case, the browser can do its own things. Only after successfully obtaining the response does the browser start to process the response data), thus avoiding the drawback of traditional multi-page applications that need to reload the entire page every time a page jump occurs.

[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following technical problems in the related art: For single-page applications, route management is usually static, that is, the available routing paths are determined at the start of the application, and these paths remain unchanged throughout the application life cycle. However, in a static routing configuration, all routing paths are public, and even pages that require specific permissions to access may be directly accessed via a Uniform Resource Identifier (URL), resulting in potential security risks because unauthorized users may attempt to access restricted pages; at the same time, static routing configuration may lead to unnecessary resource loading, affecting the page loading speed, and a long first-screen loading time will affect the user experience. Summary of the Invention

[0004] To solve the above technical problems or at least partially solve the above technical problems, embodiments of the present disclosure provide a method and apparatus for accessing single-page application pages based on dynamic routing.

[0005] In a first aspect, embodiments of the present disclosure provide a method for accessing single-page application pages based on dynamic routing. The method includes: receiving, at the front end, an access request for accessing a single-page application page, where the access request carries: user access information; obtaining access parameter information corresponding to the user access information, where the access parameter information includes at least one of the following: target user role, target user permission; based on the access parameter information, matching in a pre-defined routing rule at the front end to obtain a dynamic routing table corresponding to the access parameter information; the routing rule includes a routing table definition group corresponding to different parameter conditions, and the parameter conditions include at least one of the following: user role, user permission; determining a required target page component according to the dynamic routing table, and rendering the target page component at the front end to obtain a target application page.

[0006] In some embodiments, a mapping relationship is constructed between the above access input parameter information and the page component list. Determining the required target page component according to the above dynamic routing table includes: determining the target page component list corresponding to the above access input parameter information according to the access input parameter information in the above dynamic routing table and the pre-constructed mapping relationship; determining the required target page component according to the above target page component list.

[0007] In some embodiments, the above mapping relationship is constructed in the above routing rule, and the construction form is as follows: in the above routing rule, the page path and the page component list corresponding to the same access input parameter information are set in the same routing table definition group, and different access input parameter information corresponds to different routing table definition groups, so as to construct the mapping relationship between the access input parameter information and the page component list.

[0008] In some embodiments, determining the target page component list corresponding to the above access input parameter information according to the access input parameter information in the above dynamic routing table and the pre-constructed mapping relationship includes: traversing and parsing the above routing rule to locate the target routing table definition group corresponding to the above access input parameter information; determining the page component list in the above target routing table definition group as the target page component list corresponding to the above access input parameter information.

[0009] In some embodiments, the above method further includes: when the access input parameter information corresponding to the user access information indicates that the current user has multiple user roles or multiple user permissions, determining the first association relationship between the multiple user roles or determining the second association relationship between the multiple user permissions; determining the target presentation strategy according to the above first association relationship or the above second association relationship; wherein, the above target presentation strategy is one of the following: fusion presentation strategy, alternative presentation strategy, security presentation strategy; the above fusion presentation strategy means presenting the page components corresponding to multiple user roles or multiple user permissions after integration; the above alternative presentation strategy means presenting the page components corresponding to one of the multiple user roles or multiple user permissions; the above security presentation strategy means presenting some or all of the page components corresponding to multiple user roles or multiple user permissions in a security manner matching the current running environment. Wherein, determining the required target page component according to the above dynamic routing table includes: determining the required target page component according to the above dynamic routing table and the above target presentation strategy.

[0010] In some embodiments, rendering the above target page component in the front end to obtain a target application page includes:

[0011] Obtaining the above target page component from the full amount of page components stored in the front end, and rendering the above target page component to obtain a target application page; or,

[0012] Determine whether there is an overlapping page component in the loaded components cached in the target cache area at the front end with the above-mentioned target page component; in the case of the existence of an overlapping page component, obtain the above-mentioned overlapping page component from the target cache area, and load the remaining page components except the above-mentioned overlapping page component from the back end; render the above-mentioned target page component to obtain a target application page.

[0013] In some embodiments, the above-mentioned target cache area is used to cache the page components first loaded from the back end. The method further includes: counting the usage frequency of the loaded components cached in the above-mentioned target cache area; counting the historical access frequency of the above-mentioned single-page application page accessed at the front end; performing cache cleaning according to the above-mentioned historical access frequency and the above-mentioned usage frequency; the above-mentioned cache cleaning includes: in the case where the above-mentioned historical access frequency is higher than a first set value, sorting according to the usage frequency of the cached loaded components and releasing the storage space corresponding to the first loaded components with a usage frequency less than a second set value; in the case where the above-mentioned historical access frequency is less than the second set value, clearing all the components cached in the above-mentioned target cache area.

[0014] In a second aspect, an embodiment of the present disclosure provides a single-page application page access device based on dynamic routing. The above-mentioned device includes: a request receiving module, a parameter information obtaining module, a dynamic routing generation module, and an application page generation module. The above-mentioned request receiving module is used to receive an access request for accessing a single-page application page by a user on a general front-end page, and the above-mentioned access request carries: user access information. The above-mentioned parameter information obtaining module is used to obtain access parameter information corresponding to the above-mentioned user access information, and the above-mentioned access parameter information includes at least one of the following: target user role, target user permission. The above-mentioned dynamic routing generation module is used to match in the routing rules predefined at the front end based on the above-mentioned access parameter information to obtain a dynamic routing table corresponding to the above-mentioned access parameter information; the above-mentioned routing rules include routing table definition groups corresponding to different parameter conditions, and the above-mentioned parameter conditions include at least one of the following: user role, user permission. The above-mentioned application page generation module is used to determine the required target page components according to the above-mentioned dynamic routing table, and render the above-mentioned target page components at the front end to obtain a target application page.

[0015] In a third aspect, an embodiment of the present disclosure provides an electronic device. The above-mentioned electronic device includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; the memory is used to store a computer program; the processor is used to implement the above-mentioned method for accessing a single-page application page based on dynamic routing when executing the program stored on the memory.

[0016] Fourthly, embodiments of the present disclosure provide a computer-readable storage medium. A computer program is stored on the above computer-readable storage medium. When the computer program is executed by a processor, the method for accessing a single-page application page based on dynamic routing as described above is implemented.

[0017] The above technical solutions provided by the embodiments of the present disclosure have at least some or all of the following advantages:

[0018] By predefining a routing table definition group corresponding to different input parameter conditions in the routing rules at the front end, the customization of the corresponding relationship between various input parameter conditions and the corresponding dynamic routing table can be realized. Then, when the front end receives an access request for accessing a single-page application page, by obtaining the access input parameter information corresponding to the user access information carried in the request and matching the access input parameter information based on the above predefined routing rules, the corresponding dynamic routing table can be quickly matched, and the required target page component can be determined accordingly; since the routing table is dynamically generated and matches the user role or user permission, the card control logic for accessing specific pages for different user roles and permissions is effectively implemented; at the same time, since the routing rules are customized on demand during predefined, the matching process is very efficient, and the access security of the page can be improved, and the access efficiency of the single-page application page can be improved; the phenomenon that unauthorized users access restricted pages is avoided; at the same time, since the target page components required by the dynamic routing table are also rendered on demand and do not load redundant components, it helps to improve the home page loading efficiency and save the loading and rendering resources corresponding to irrelevant components. Description of the Drawings

[0019] The drawings here are incorporated into the specification and form a part of this specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure.

[0020] To more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.

[0021] Figure 1 Schematically shows a flowchart of a method for accessing a single-page application page based on dynamic routing according to an embodiment of the present disclosure;

[0022] Figure 2 Schematically shows an implementation flowchart of step S140 according to an embodiment of the present disclosure;

[0023] Figure 3 Schematically shows a flowchart of a method for accessing a single-page application page based on dynamic routing according to another embodiment of the present disclosure;

[0024] Figure 4 Schematically shows a structural block diagram of a single-page application page access device based on dynamic routing according to an embodiment of the present disclosure;

[0025] Figure 5 Schematically shows a structural block diagram of an electronic device provided by an embodiment of the present disclosure. Detailed implementation manners

[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are some but not all of the embodiments of the present disclosure. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.

[0027] The first exemplary embodiment of the present disclosure provides a method for accessing a single-page application page based on dynamic routing. The above method is executed by a front-end device having a display screen.

[0028] The method provided in this embodiment customizes the routing rules according to actual requirements during the development stage. Specifically, a routing table definition group corresponding to different input parameter conditions is predefined in the front-end routing rules, which can realize the customization of the corresponding relationship between various input parameter conditions and the corresponding dynamic routing tables, and realize the customization requirements of the routing rules adapted to various business scenarios. Thus, during the access stage of the single-page application, high-efficiency matching at the front end and user permission control access can be realized according to different requirements.

[0029] Figure 1 Schematically shows a flowchart of a method for accessing a single-page application page based on dynamic routing according to an embodiment of the present disclosure.

[0030] Refer to Figure 1 As shown, the method for accessing a single-page application page based on dynamic routing in the embodiment of the present disclosure includes the following steps: S110, S120, S130, and S140.

[0031] In step S110, an access request for accessing a single-page application page is received at the front end, and the above access request carries: user access information.

[0032] For example, in an implementation scenario, the user initiates an access request for a single-page application page through an interactive operation on a general page at the front end; the general page refers to a page that is the same for all user roles, such as a unified login page or a unified navigation page. The user access information may include: the login account registered by the user, such as user identification information indicating the user's identity, such as the user's mobile phone number, the user's name, the user's ID number, etc.; in some embodiments, the user access information may further include: security verification information, such as dynamic verification codes, login timestamps, verification pattern information, etc.

[0033] The interactive operation may include, but is not limited to: the user enters the login account registered by the user and the dynamic verification code in a general page at the front end (such as a login page), and clicks the login function key, which is regarded as receiving an access request from the user to access the single-page application page.

[0034] In step S120, obtain the access parameter information corresponding to the user access information, where the access parameter information includes at least one of the following: target user role, target user permission.

[0035] The user has pre-registered in the single-page application and has a corresponding login account, and the corresponding user role and user permission are assigned to the login account during the user registration. Each user role will be pre-configured with a corresponding permission set. For example, the permission set includes at least one of the following categories: data permission, menu permission, etc.; the menu permission controls the access difference of the user to the system menu or function, and the data permission controls the user's permissions for reading, writing, modifying, etc. of specific data. In some embodiments, in order to reduce the storage pressure at the front end, the configuration information such as the user role and user permission corresponding to the login account during user registration can be stored on the server side. After receiving the access request at the front end in step S110, query at least one of the user role or user permission corresponding to the user access information from the server side.

[0036] In some embodiments, the input parameter condition may only limit the user role, or only limit the user permission, or may also limit both the user role and the user permission at the same time. Correspondingly, when obtaining the access parameter information corresponding to the user access information, it is also necessary to obtain the target user role, the target user permission, or both the target user role and the target user permission at the same time.

[0037] Based on the differences in the development version, test version, usage version, operation and maintenance version, etc. of the single-page application, the user roles can include but are not limited to: administrator role, ordinary user role, operator role, tester role, etc.; according to the subdivision of the usage scenario, the user roles can also be refined according to the differences in the affiliated institutions, different functional departments, job ranks corresponding to the same functional department, etc. For example, they can be divided into: first-level ordinary user role, second-level ordinary user role. Different levels of ordinary user roles have different data viewing permissions. The data that the second-level ordinary user role can see is a subset of the data that the first-level ordinary user role can see, and the first-level ordinary user role can view the data that the second-level ordinary user role cannot see. Another example is to divide into: user role of institution A, user role of institution B. The menu permissions corresponding to the user roles of different institutions are different; another example is to divide into: user role of department A of institution X and user role of department B of institution X. The user roles of different departments have different data permissions and different menu permissions.

[0038] In step S130, based on the above access parameter information, match it in the pre-defined routing rules in the front end to obtain the dynamic routing table corresponding to the above access parameter information; the above routing rules include routing table definition groups corresponding to different parameter conditions, and the above parameter conditions include at least one of the following: user role, user permission.

[0039] The pre-defined routing rules include routing table definition groups corresponding to different parameter conditions. Taking the user role as an example of the parameter condition, it can be understood that the parameter condition can also include user permission or other information, such as the running environment, and the parameter conditions carried in different routing table definition groups in the same set of routing rules may be different, and at least one of the user role and user permission is included in the common parameter conditions.

[0040] The following is an example of a routing rule:

[0041] Routing table definition group 1: {Parameter condition (condition): [User role: level1 user (indicating the first-level ordinary user role)];

[0042] Routing table information: {Page path (path): profile level1 (for example, routed to the display page corresponding to all data)}

[0043] };

[0044] Routing table definition group 2: {Parameter condition (condition): [User role: level2 user (indicating the second-level ordinary user role)];

[0045] Routing table information: {Page path (path): profile level2 (e.g., routing to a restricted data display page)}

[0046] };

[0047] Routing table definition group 3: {Input parameter condition (condition): [User role: admin (indicating the administrator role), Running environment: production environment (production)];

[0048] Routing table information: {Page path (path): dashboard (e.g., routing to the page corresponding to the management dashboard)}

[0049] }.

[0050] By matching in the pre-defined routing rules in the front end, the routing table definition group corresponding to the target user role (as an example of access input parameter information) can be obtained. For example, in an access request R1, the corresponding target user role is level1user (as an example of access input parameter information), then by matching in the routing rules, the corresponding matching routing table definition group 1 can be obtained, and the page path (path): profile level1 can be determined from it, and a dynamic routing table is generated according to the page path for guiding to the target application page.

[0051] In step S140, the required target page component is determined according to the above dynamic routing table, and the above target page component is rendered in the front end to obtain the target application page.

[0052] Since the target page component is determined and rendered on demand according to the dynamic routing table, the loading and rendering of irrelevant components are avoided, saving the corresponding resources and the required time cost.

[0053] In the embodiment including steps S110 to S140, by predefining a routing table definition group corresponding to different input parameter conditions in the front-end routing rules, the customization of the corresponding relationship between various input parameter conditions and the dynamic routing table can be achieved. Then, when the front-end receives an access request for a single-page application page, by obtaining the access input parameter information corresponding to the user access information carried in the request and matching the access input parameter information based on the above-predefined routing rules, the corresponding dynamic routing table can be quickly matched, and the required target page component can be determined accordingly; since the routing table is dynamically generated and matches the user role or user permission, the card control logic for specific page access for different user roles and permissions is effectively implemented; at the same time, since the routing rules are customized on demand during predefined, the matching process is very efficient, and it can improve the page access security and the access efficiency of the single-page application page; the phenomenon that unauthorized users access restricted pages is avoided; at the same time, since the target page components required by the dynamic routing table are also rendered on demand and do not load redundant components, it helps to improve the home page loading efficiency and save the loading and rendering resources corresponding to irrelevant components.

[0054] Figure 2 Schematically shows an implementation flowchart of step S140 according to an embodiment of the present disclosure.

[0055] In some embodiments, a mapping relationship is constructed between the above access input parameter information and the page component list. In some embodiments, the above mapping relationship can be stored in the front-end. The specific storage form is not limited.

[0056] Refer to Figure 2 As shown, in the above step S140, determining the required target page component according to the above dynamic routing table includes the following steps: S210 and S220.

[0057] In step S210, according to the access input parameter information in the above dynamic routing table and the pre-constructed mapping relationship, determine the target page component list corresponding to the above access input parameter information.

[0058] In some embodiments, in order to save front-end storage resources and improve the search efficiency, the above mapping relationship is constructed in the above routing rules, and the construction form is as follows: in the above routing rules, the page path and the page component list corresponding to the same access input parameter information are set in the same routing table definition group, and different access input parameter information corresponds to different routing table definition groups, so as to construct the mapping relationship between the access input parameter information and the page component list. In this way, the page component list corresponding to the access input parameter information can be determined by locating the target routing table definition group where the above access input parameter information is located, achieving the effect of saving front-end storage resources and improving the search efficiency.

[0059] In the embodiment of constructing the above mapping relationship into a routing rule, in the above step S210, according to the access parameter information in the above dynamic routing table and the pre-constructed mapping relationship, determining the target page component list corresponding to the above access parameter information includes: traversing and parsing the above routing rule to locate the target routing table definition group corresponding to the above access parameter information; determining the page component list within the above target routing table definition group as the target page component list corresponding to the above access parameter information.

[0060] For example, an example of constructing a mapping relationship into a routing rule is as follows:

[0061] Routing table definition group 1: {input parameter condition (condition): [user role: level1 user (indicating the role of a first-level ordinary user)];

[0062] Routing table information: {page path (path): profile level1 (for example, routing to the display page corresponding to all data); page component list (component list): profile level1_component list1}

[0063] };

[0064] Routing table definition group 2: {input parameter condition (condition): [user role: level2 user (indicating the role of a second-level ordinary user)];

[0065] Routing table information: {page path (path): profile level2 (for example, routing to the restricted data display page);; page component list (component list): profile level2_componentlist2}

[0066] };

[0067] Routing table definition group 3: {input parameter condition (condition): [user role: admin (indicating the administrator role), running environment: production environment (production)];

[0068] Routing table information: {page path (path): dashboard (for example, routing to the page corresponding to the management dashboard);; page component list (component list): dashboard_component list3}

[0069] };

[0070] By setting the page paths and page component lists corresponding to the same access input parameter information in the same routing table definition group, and different access input parameter information corresponding to different routing table definition groups, a mapping relationship between the access input parameter information and the page component list is constructed. In this way, by locating the target routing table definition group where the target user role level1 user (an example of access input parameter information) is located: routing table definition group 1, and being able to determine the page component list corresponding to level1 user in this routing table definition group 1: profile level1_component list1 as the target page component list corresponding to the above access input parameter information, the search is efficient and storage resources are effectively saved.

[0071] In step S220, according to the above target page component list, determine the required target page components.

[0072] In some embodiments, for the case where the access input parameter information corresponding to the user access information indicates that the current user has one user role or one type of user role, the page components included in the target page component list are determined as the required target page components.

[0073] Figure 3 Schematically shows a flowchart of a single-page application page access method based on dynamic routing according to another embodiment of the present disclosure.

[0074] In other embodiments, there may be a case where the access input parameter information corresponding to the user access information indicates that the current user has multiple user roles or multiple user permissions. In this case, the embodiments of the present disclosure provide the following component determination logic: determine the target presentation strategy according to the association relationship between multiple user roles or multiple user permissions, and combine the target page component list and the target presentation strategy to determine the required target page components.

[0075] In this embodiment, the above method further includes the following steps in addition to steps S110~S130, S210, and S220: S310 and S320, where S220 is schematically shown as a refined implementation step S220a, see Figure 3 shown. Step S310 is executed after step S220, and steps S310 and S320 are executed before step S220.

[0076] In step S310, when the access input parameter information corresponding to the user access information indicates that the current user has multiple user roles or multiple user permissions, determine the first association relationship between multiple user roles or determine the second association relationship between multiple user permissions.

[0077] In step S320, determine the target presentation strategy according to the above first association relationship or the above second association relationship; wherein, the above target presentation strategy is one of the following: fusion presentation strategy, alternative presentation strategy, and secure presentation strategy.

[0078] The above fusion presentation strategy means presenting after integrating page components corresponding to multiple user roles or multiple user permissions.

[0079] For example, if the first association relationship or the second association relationship indicates that multiple user roles or multiple user permissions corresponding to the current user have an overlay relationship (for example, the permissions of a first-level ordinary user role and a second-level ordinary user role can be overlaid), then determine the target presentation strategy as the fusion presentation strategy.

[0080] The above alternative presentation strategy means presenting page components corresponding to one of multiple user roles or multiple user permissions.

[0081] For example, if the first association relationship or the second association relationship indicates that multiple user roles or multiple user permissions corresponding to the current user are parallel to each other or cannot be overlaid (for example, the tester role and the user role have a non-overlay relationship), then determine the target presentation strategy as the alternative presentation strategy.

[0082] The above secure presentation strategy means presenting some or all of the page components corresponding to multiple user roles or multiple user permissions in a secure manner based on a match with the current running environment. In the secure presentation strategy, the matching situation with the current running environment is also considered. For example, when the current running environment is the proxy mode and the current user role corresponds to both the tester role and the user role, the user role is preferentially matched, and the page components corresponding to the user role are presented in a secure manner; when the current running environment is the compatibility mode and the running script file is the preset language, the secure presentation strategy preferentially matches the tester role and presents the page components corresponding to the tester role in a secure manner. Another example: when the current user role corresponds to both the first-level ordinary user role and the second-level ordinary user role at the same time, all page components can be presented simultaneously according to the detection of the current running environment.

[0083] Among them, in the above step S220, determining the required target page components according to the above dynamic routing table includes the following detailed step S220a: determining the required target page components according to the above dynamic routing table and the above target presentation strategy.

[0084] In the embodiments including steps S310 and S320, by determining the association relationships corresponding to multiple user roles or multiple user permissions and determining the adapted target presentation strategy, it helps to make an accurate selection in the subsequent determination of the required target page components, and achieve refined on-demand loading and corresponding rendering presentation.

[0085] In some embodiments of the present disclosure, in order to improve the component loading efficiency and reduce the communication delay required for component loading, the front end is also set to cache the page components for the first-time loaded page, and the logic of obtaining the loaded components from the cache subsequently. At the same time, in order to improve the front-end space utilization rate or reduce the ineffective occupation of storage space, the logic of periodically clearing the cache or clearing part of the cache is also set.

[0086] In the above step S140, rendering the target page component at the front end to obtain the target application page includes:

[0087] Obtain the target page component from all the page components stored at the front end, and render the target page component to obtain the target application page.

[0088] In this embodiment, by writing all the page components in the front-end code, that is, all the page components are stored at the front end. After determining the target page components required according to the above dynamic routing table, only need to obtain the target page component from all the page components at the front end and render it to obtain the target application page.

[0089] Alternatively, in some other embodiments, rendering the target page component at the front end to obtain the target application page includes:

[0090] Determine whether there is an overlapping page component in the loaded components cached in the target cache area at the front end with the target page component;

[0091] In the case of having an overlapping page component, obtain the overlapping page component from the target cache area, and load the remaining page components except the overlapping page component from the backend;

[0092] Render the target page component to obtain the target application page.

[0093] In this embodiment, it is based on the method of loading page components from the backend and caching the page components loaded for the first time; by setting the logic that the front end caches the page components loaded for the first time and subsequently obtains the loaded components from the cache, it can improve the component loading efficiency and reduce the communication delay required for the components to be loaded from the backend.

[0094] In some embodiments, the target cache area is used to cache the page components loaded from the backend for the first time.

[0095] The above method further includes:

[0096] Count the usage frequency of the loaded components cached in the target cache area; for example, count the number of usage times within a preset period (such as one week, one day, etc.);

[0097] Count the historical access frequency of the single-page application page accessed at the front end;

[0098] Perform cache cleaning based on the above historical access frequencies and the above usage frequencies.

[0099] The above cache cleaning includes: when the above historical access frequency is higher than the first set value, sorting according to the usage frequencies of the loaded components in the cache and releasing the storage space corresponding to the first loaded components with usage frequencies less than the second set value; when the above historical access frequency is less than the second set value, clearing all the components cached in the above target cache area.

[0100] In this embodiment, by setting the logic for periodically cleaning the cache or cleaning part of the cache, the front-end space utilization rate is effectively improved or the ineffective occupation of the storage space is reduced.

[0101] The second exemplary embodiment of the present disclosure provides a single-page application page access device based on dynamic routing.

[0102] Figure 4 Schematically shows a structural block diagram of a single-page application page access device based on dynamic routing according to an embodiment of the present disclosure.

[0103] Refer to Figure 4 As shown, the single-page application page access device 400 provided by the embodiment of the present disclosure includes: a request receiving module 410, an input parameter information obtaining module 420, a dynamic routing generation module 430, and an application page generation module 440.

[0104] The above request receiving module 410 is used to receive an access request for accessing a single-page application page by a user on a general front-end page, and the above access request carries: user access information.

[0105] The above input parameter information obtaining module 420 is used to obtain access input parameter information corresponding to the above user access information, and the above access input parameter information includes at least one of the following: target user role, target user permission.

[0106] The above dynamic routing generation module 430 is used to match in the pre-defined routing rules in the front-end based on the above access input parameter information to obtain a dynamic routing table corresponding to the above access input parameter information; the above routing rules include a routing table definition group corresponding to different input parameter conditions, and the above input parameter conditions include at least one of the following: user role, user permission.

[0107] The above application page generation module 440 is used to determine the required target page components according to the above dynamic routing table and render the above target page components in the front-end to obtain a target application page.

[0108] In some embodiments, a mapping relationship is constructed between the above access input parameter information and the page component list. Determining the required target page component according to the above dynamic routing table includes: determining the target page component list corresponding to the above access input parameter information according to the access input parameter information in the above dynamic routing table and the pre-constructed mapping relationship; determining the required target page component according to the above target page component list.

[0109] In some embodiments, the above mapping relationship is constructed in the above routing rule, and the construction form is as follows: in the above routing rule, the page path and the page component list corresponding to the same access input parameter information are set in the same routing table definition group, and different access input parameter information corresponds to different routing table definition groups, so as to construct the mapping relationship between the access input parameter information and the page component list.

[0110] In some embodiments, determining the target page component list corresponding to the above access input parameter information according to the access input parameter information in the above dynamic routing table and the pre-constructed mapping relationship includes: traversing and parsing the above routing rule to locate the target routing table definition group corresponding to the above access input parameter information; determining the page component list in the above target routing table definition group as the target page component list corresponding to the above access input parameter information.

[0111] In some embodiments, the above device 400 further includes: an association relationship determination module and a presentation strategy determination module.

[0112] The above association relationship determination module is used to determine the first association relationship between multiple user roles or the second association relationship between multiple user permissions when the access input parameter information corresponding to the user access information indicates that the current user has multiple user roles or multiple user permissions.

[0113] The above presentation strategy determination module is used to determine the target presentation strategy according to the above first association relationship or the above second association relationship; wherein, the above target presentation strategy is one of the following: a fusion presentation strategy, an alternative presentation strategy, and a security presentation strategy. The above fusion presentation strategy means presenting the page components corresponding to multiple user roles or multiple user permissions after integration; the above alternative presentation strategy means presenting the page components corresponding to one of multiple user roles or multiple user permissions; the above security presentation strategy means presenting some or all of the page components corresponding to multiple user roles or multiple user permissions in a security manner matching the current running environment.

[0114] Among them, determining the required target page component according to the above dynamic routing table includes: determining the required target page component according to the above dynamic routing table and the above target presentation strategy.

[0115] In some embodiments, rendering the target page component at the front end to obtain the target application page includes:

[0116] Obtain the target page component from the full set of page components stored at the front end, and render the target page component to obtain the target application page.

[0117] In this embodiment, by writing the full set of page components in the front-end code, that is, the front end stores the full set of page components. After determining the required target page component according to the above dynamic routing table, only need to obtain the target page component from the full set of page components at the front end and render it to obtain the target application page.

[0118] Alternatively, in some other embodiments, rendering the target page component at the front end to obtain the target application page includes:

[0119] Determine whether there is a coincident page component in the loaded components cached in the target cache area at the front end that coincides with the target page component;

[0120] In the case of a coincident page component, obtain the coincident page component from the target cache area, and load the remaining page components except the coincident page component from the back end;

[0121] Render the target page component to obtain the target application page.

[0122] In this embodiment, it is based on the method of loading page components from the back end and caching the page components loaded for the first time; by setting the front end to cache the page components loaded for the first time and the logic of obtaining the loaded components from the cache subsequently, it can improve the component loading efficiency and reduce the communication delay required for loading components from the back end.

[0123] In some embodiments, the target cache area is used to cache the page components first loaded from the back end.

[0124] The above device 400 further includes: a component usage frequency statistics module, a page access frequency statistics module, and a cache cleaning module.

[0125] The above component usage frequency statistics module is used to count the usage frequency of the loaded components cached in the target cache area.

[0126] The above page access frequency statistics module is used to count the historical access frequency of the single-page application page accessed at the front end.

[0127] The above cache cleaning module is used to perform cache cleaning according to the above historical access frequency and the above usage frequency. The above cache cleaning includes: when the above historical access frequency is higher than the first set value, sorting according to the usage frequency of the loaded components in the cache and releasing the storage space corresponding to the first loaded component whose usage frequency is less than the second set value; when the above historical access frequency is less than the second set value, clearing all the components cached in the above target cache area. In this embodiment, by setting the logic for periodically cleaning the cache or cleaning part of the cache, the front-end space utilization rate is effectively improved or the invalid occupation of the storage space is reduced.

[0128] In the device 400 provided in this embodiment, by predefining a routing table definition group corresponding to different input parameter conditions in the front-end routing rules, the customization of the corresponding relationship between various input parameter conditions and the corresponding dynamic routing table can be realized. Then, when the front-end receives an access request for a single-page application page, by obtaining the access input parameter information corresponding to the user access information carried in the request and matching the access input parameter information based on the above predefined routing rules, the corresponding dynamic routing table can be quickly matched, and the required target page component can be determined accordingly; since the routing table is dynamically generated and matches the user role or user permission, the card control logic for accessing specific pages for different user roles and permissions is effectively realized; at the same time, since the routing rules are customized on demand during predefined, the matching process is very efficient, and the access security of the page can be improved, and the access efficiency of the single-page application page can be improved; the phenomenon that unauthorized users access restricted pages is avoided; at the same time, since the target page components required by the dynamic routing table are also rendered on demand and do not load redundant components, it helps to improve the home page loading efficiency and save the loading and rendering resources corresponding to irrelevant components.

[0129] For more details of this embodiment, reference can also be made to the relevant description of the first embodiment, which will not be elaborated here.

[0130] Any number of the functional modules included in the above-mentioned apparatus 400 may be combined and implemented in one module, or any one of them may be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules may be combined with at least part of the functions of other modules and implemented in one module. At least one of the functional modules included in the above-mentioned apparatus 400 may be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or any other reasonable way of integrating or packaging circuits, etc., implemented by hardware or firmware, or implemented in any one of the three implementation manners of software, hardware, and firmware, or in an appropriate combination of any several of them. Alternatively, at least one of the functional modules included in the above-mentioned apparatus 400 may be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding functions may be executed.

[0131] The third exemplary embodiment of the present disclosure provides an electronic device.

[0132] Figure 5 A block diagram of the electronic device provided by the embodiment of the present disclosure is schematically shown.

[0133] Referring to Figure 5 As shown, the electronic device 500 provided by the embodiment of the present disclosure includes a processor 501, a communication interface 502, a memory 503, and a communication bus 504. Among them, the processor 501, the communication interface 502, and the memory 503 complete communication with each other through the communication bus 504; the memory 503 is used to store a computer program; when the processor 501 executes the program stored on the memory, the method for accessing a single-page application page based on dynamic routing as described above is implemented.

[0134] The fourth exemplary embodiment of the present disclosure further provides a computer-readable storage medium. A computer program is stored on the above-mentioned computer-readable storage medium, and when the computer program is executed by a processor, the method for accessing a single-page application page based on dynamic routing as described above is implemented.

[0135] The above-mentioned computer-readable storage medium may be included in the device or apparatus described in the above embodiments; it may also exist alone without being assembled into the device or apparatus. The above-mentioned computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0136] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0137] It should be noted that in the technical solutions provided by the embodiments of the present disclosure, in aspects such as the collection, gathering, updating, analysis, processing, use, transmission, and storage of user personal information, they all comply with the provisions of relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. Necessary measures are taken for user personal information to prevent illegal access to user personal information data, and to safeguard the security of user personal information, network security, and national security.

[0138] It should be noted that in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

[0139] The above are only specific embodiments of the present disclosure, enabling those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to these embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features claimed herein.

Claims

1. A single-page application page access method based on dynamic routing, characterized in that: include: Receiving, at the front end, an access request from a user to access a single-page application page, the access request carrying: user access information; Obtain access input parameter information corresponding to the user access information, wherein the access input parameter information includes at least one of the following: target user role and target user authority; Based on the access input parameter information, matching is performed in the routing rules predefined in the front end to obtain a dynamic routing table corresponding to the access input parameter information; the routing rules include a routing table definition group corresponding to different input parameter conditions, and the input parameter conditions include at least one of the following: user role, user authority; The required target page component is determined according to the dynamic routing table, and the target page component is rendered on the front end to obtain the target application page.

2. The method according to claim 1, characterized in that A mapping relationship is established between the access input parameter information and the page component list; Determining the required target page components according to the dynamic routing table includes: Determine a target page component list corresponding to the access input parameter information according to the access input parameter information and the pre-built mapping relationship in the dynamic routing table; According to the target page component list, the required target page components are determined.

3. The method according to claim 2, characterized in that The mapping relationship is constructed in the routing rules, and the construction form is as follows: in the routing rules, the page path and page component list corresponding to the same access input parameter information are set in the same routing table definition group, and different access input parameter information corresponds to different routing table definition groups, so as to construct a mapping relationship between the access input parameter information and the page component list.

4. The method according to claim 3, characterized in that Determining a target page component list corresponding to the access input parameter information according to the access input parameter information and the pre-built mapping relationship in the dynamic routing table includes: Traversing and parsing the routing rules to locate the target routing table definition group corresponding to the access input parameter information; The page component list within the target routing table definition group is determined as the target page component list corresponding to the access input parameter information.

5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: When the access input parameter information corresponding to the user access information indicates that the current user has multiple user roles or multiple user permissions, determining a first association relationship between the multiple user roles or determining a second association relationship between the multiple user permissions; Determine a target presentation strategy according to the first association relationship or the second association relationship; wherein the target presentation strategy is one of the following: a fusion presentation strategy, a selection presentation strategy, and a security presentation strategy; the fusion presentation strategy means that page components corresponding to multiple user roles or multiple user permissions are integrated and presented; the selection presentation strategy means that page components corresponding to one of multiple user roles or multiple user permissions are presented; the security presentation strategy means that page components corresponding to multiple user roles or multiple user permissions are partially or fully presented based on a security method that matches the current operating environment; Wherein, determining the required target page component according to the dynamic routing table includes: According to the dynamic routing table and the target presentation strategy, the required target page components are determined.

6. The method according to any one of claims 1 to 4, characterized in that Rendering the target page component on the front end to obtain the target application page includes: Obtain the target page component from the full set of page components stored in the front-end, and render the target page component to obtain the target application page; or, Determine whether there are any overlapping page components with the target page component in the loaded components cached in the target cache area of ​​the front end; if there are overlapping page components, obtain the overlapping page components from the target cache area, and load the remaining page components except the overlapping page components from the back end; render the target page component to obtain the target application page.

7. The method according to claim 6, characterized in that The target cache area is used to cache page components that are loaded from the backend for the first time; The method further comprises: Counting the usage frequency of the loaded components cached in the target cache area; Count the historical access frequency of the single-page application page on the front end; Cache cleaning is performed according to the historical access frequency and the usage frequency; the cache cleaning includes: In the case where the historical access frequency is higher than the first set value, the cached loaded components are sorted according to their usage frequencies and the storage space corresponding to the first loaded component whose usage frequency is less than the second set value is released; When the historical access frequency is less than a second set value, all components cached in the target cache area are cleared.

8. A single-page application page access device based on dynamic routing, characterized in that: include: A request receiving module is used to receive, on a common front-end page, an access request from a user to access a single-page application page, wherein the access request carries: user access information; An input parameter information acquisition module is used to obtain access input parameter information corresponding to the user access information, wherein the access input parameter information includes at least one of the following: target user role and target user authority; A dynamic routing generation module is used to match the access input parameter information in the routing rules predefined in the front end to obtain a dynamic routing table corresponding to the access input parameter information; the routing rules include a routing table definition group corresponding to different input parameter conditions, and the input parameter conditions include at least one of the following: user role, user authority; The application page generation module is used to determine the required target page components according to the dynamic routing table, and render the target page components on the front end to obtain the target application page.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 7 when executing a program stored in a memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Access control method, system, equipment and product based on path matching

    CN122310498A

  • Path matching based access control method, system, device and product

    CN122310498B