The application discloses a front-end
route forced permission control method and
system based on a high-order component, is applied to a computer field React
technology stack, and solves the problems of dispersed existing front-end permission
control logic, no forced interception, poor adaptability and the like. The method realizes real-time updating of permission by defining a high-order component receiving permission code, a target component and the like, reading user permission from sessionStorage and listening to a storage event; all target components are wrapped with the component in a React
Router route configuration stage, unified permission
verification before
route access is preposed, and a target component or a permission-free component is rendered according to a result. The application realizes centralized encapsulation of permission logic, reduces maintenance cost, improves code
reusability, realizes forced interception from a route layer, adapts to complex
verification in multiple scenes, solves the problem of page flashing, and is realized based on sessionStorage and is light, has no additional
library dependence, is easy to integrate, and has low
coupling degree.