A method and system for adding permissions to front-end projects

By obtaining the routing information of the front-end project, building high-order components and adding them to the routing, the permission management project is automatically generated, which solves the difficulty and high cost of permission management in front-end project development, and improves development efficiency and management complexity.

CN113835737BActive Publication Date: 2024-10-25TRAFFIC CONTROL TECH CO LTD
View PDF 17 Cites 0 Cited by

Patent Information

Application Number
CN202110977142.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-24
Publication Date
2024-10-25
Estimated Expiration
2041-08-24

AI Technical Summary

Technical Problem

It is difficult to manage permissions in front-end project development, which leads to increased costs and low development efficiency, and is not conducive to project maintenance.

Method used

By obtaining the routing information of the front-end project, determine the permission management target, build high-order components and add them to the routing, automatically generate permission management projects, and achieve control permissions on the front-end project.

Benefits of technology

It reduces the difficulty and maintenance work of permission management, reduces development costs, improves project development efficiency, and realizes complex permission management functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113835737B_ABST
    Figure CN113835737B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for adding permissions to a front-end project, comprising: obtaining routing information in a front-end project based on the framework type of the front-end project; determining a permission management target based on the routing information; determining a permission management component according to the permission management target, adding the permission management component to the routing of the front-end project, and obtaining a permission management project; adding a preset permission function code to the permission management project to obtain control permissions for the front-end project. The present invention automatically generates relevant permissions by adding permission management based on routing information when reading project files in the front-end project, so that users can customize permission management codes and implement more complex permission management functions, effectively saving the manpower cost of project development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and system for adding permissions to a front-end project. Background Art

[0002] In front-end project development, implementing permission management is a common requirement. With the rapid development of front-end project-related technologies, it is very inconvenient to implement permission management functions in each project structure. For example, if you want to add user permission functions in a mini-program, you must be very familiar with the development of permissions in the mini-program. If you want to develop a full-end software permission, you must know a lot of technology-related permission production experience. Not only does it take a lot of time to learn relevant knowledge, but it is also likely to miss the good time to launch the software. This situation is problematic.

[0003] Existing rights management technologies have the following defects:

[0004] 1) When front-end developers are faced with different front-end projects, it is very difficult to implement user permission functions according to the characteristics of different projects;

[0005] 2) Increased front-end project costs;

[0006] 3) It is not conducive to front-end project maintenance;

[0007] 4) Low project development efficiency.

[0008] Therefore, it is necessary to propose a new method for adding permissions to front-end projects. Summary of the invention

[0009] The present invention provides a method and system for adding permissions to a front-end project, which are used to solve the defects of the prior art in that adding permissions to a front-end project is difficult and has high development costs.

[0010] In a first aspect, the present invention provides a method for adding permissions to a front-end project, comprising:

[0011] Based on the framework type of the front-end project, obtain the routing information in the front-end project;

[0012] Determining a rights management target based on the routing information;

[0013] Determine a rights management component according to the rights management target, add the rights management component to the routing of the front-end project, and obtain a rights management project;

[0014] Add a preset permission function code in the permission management project to obtain control authority over the front-end project.

[0015] In one embodiment, the obtaining of routing information in the front-end project based on the framework type of the front-end project includes:

[0016] Determine the front-end project with a front-end and back-end separation mode;

[0017] By traversing preset key files in the front-end project, the front-end framework to be processed in the front-end project is obtained, and the framework type of the front-end framework to be processed is obtained.

[0018] In one embodiment, the obtaining routing information in the front-end project based on the framework type of the front-end project includes:

[0019] According to the framework type, the routing file in the front-end project is obtained, and the routing information is obtained from the routing file.

[0020] In one embodiment, determining a rights management target based on the routing information includes:

[0021] Constructing a rights management file, and determining a high-level component for rights management within the rights management file;

[0022] Based on the high-level component, the permission management target is determined.

[0023] In one embodiment, determining a rights management component according to the rights management target, adding the rights management component to the routing of the front-end project, and obtaining the rights management project includes:

[0024] If the front-end project is based on the web and is developed based on the vue framework and / or the React framework, then encapsulate the high-level component;

[0025] The high-order component determines the corresponding routing component and preset field, verifies the routing component based on the preset field, and obtains the permission management item.

[0026] In one embodiment, determining a rights management component according to the rights management target, adding the rights management component to the routing of the front-end project, and obtaining the rights management project further includes:

[0027] If the front-end project is developed based on the flutter cross-platform, the routing information is obtained, and the stack storing the routing information is intercepted;

[0028] Authentication information is added to the routing information to obtain routing information carrying the authentication information, and the authority management item is obtained by obtaining the routing information carrying the authentication information from the stack.

[0029] In a second aspect, the present invention further provides a system for adding permissions to a front-end project, comprising:

[0030] The acquisition module is used to obtain the routing information in the front-end project based on the framework type of the front-end project;

[0031] A first determination module, configured to determine a rights management target based on the routing information;

[0032] An adding module, used to determine a rights management component according to the rights management target, add the rights management component to the routing of the front-end project, and obtain a rights management project;

[0033] The processing module is used to add a preset permission function code in the permission management project to obtain control authority over the front-end project.

[0034] In one embodiment, it further includes:

[0035] The second determination module is used to determine the front-end project with a front-end and back-end separation mode; obtain the front-end framework to be processed in the front-end project by traversing the preset key files in the front-end project, and obtain the framework type of the front-end framework to be processed.

[0036] In a third aspect, the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for adding permissions to a front-end project as described in any one of the above are implemented.

[0037] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for adding permissions to a front-end project as described in any one of the above.

[0038] The method and system for adding permissions to a front-end project provided by the present invention reads project files in the front-end project, adds permission management based on routing information, and automatically generates relevant permissions, so that users can customize permission management codes and implement more complex permission management functions, effectively saving the manpower cost of project development. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1It is a flowchart of the method for adding permissions to a front-end project provided by the present invention;

[0041] Figure 2 It is a logical schematic diagram of the front-end automatically adding permissions provided by the present invention;

[0042] Figure 3 It is a structural diagram of the system for adding permissions to front-end projects provided by the present invention;

[0043] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0044] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0045] Front-end development is the process of creating front-end interfaces such as web pages or apps to present to users. It uses HTML, CSS, JavaScript, and various derived technologies, frameworks, and solutions to realize user interface interaction of Internet products. Front-end development evolved from web page production, and the name has obvious characteristics of the times. In the evolution of the Internet, web page production is a product of the Web 1.0 era. The main content of early websites was static, mainly pictures and text, and users' behavior in using websites was mainly browsing. With the development of Internet technology and the application of HTML5 and CSS3, modern web pages are more beautiful, with significant interactive effects and more powerful functions. It can be seen that the main function of front-end development is to better present the interface of the website to users.

[0046] In the process of front-end development, it is often necessary to add and set various permissions. In view of the various deficiencies in adding permissions in the prior art, the present invention proposes a new method for adding permissions to front-end projects. The purpose is to reduce the difficulty of permission management in front-end development and reduce the maintenance work of permission management, and also reduce the cost of front-end development permission management business.

[0047] Figure 1 It is a flow chart of the method for adding permissions to a front-end project provided by the present invention, such as Figure 1 As shown, including:

[0048] S1, based on the framework type of the front-end project, obtain the routing information in the front-end project;

[0049] S2, determining a rights management target based on the routing information;

[0050] S3, determining a rights management component according to the rights management target, adding the rights management component to the routing of the front-end project, and obtaining a rights management project;

[0051] S4, adding a preset permission function code to the permission management project to obtain control authority over the front-end project.

[0052] The method for adding permissions to a front-end project proposed by the present invention specifically includes:

[0053] First, the framework type information of the relevant front-end project is obtained. The relevant front-end project must be a basic project that can be run under a certain framework and meet the project framework of the front-end and back-end separation development mode before the method for adding permissions proposed in the present invention can be adopted.

[0054] By obtaining the framework type information, determine whether the current framework is Vue or React framework. According to the characteristics of different frameworks, further find out whether there is a routing file in the project and save the relevant routing information.

[0055] Based on the acquired routing information, the operating user is reminded which specific permissions in the routing need to be managed, and the relevant routing will be processed after the user makes a choice.

[0056] Then, a permission management file is created based on the routing information collected by the user. A high-level component for permission management is automatically created inside the permission management file to specifically manage permissions. The high-level component is added to the routing that the user previously selected to add permissions. At this time, permissions for the routing of the entire project can be managed.

[0057] Here, React framework and Vue framework have many similarities, including using Virtual DOM and providing responsive (Reactive) and componentized (Composable) view components. Focus on the core library, and leave other functions such as routing and global state management to related libraries. React has a richer ecosystem than Vue and both support native solutions. React's RN and Vue's Wee both support SSR server-side rendering, and both support props for communication between parent and child components. In terms of performance, React and Vue can provide similar performance in most common scenarios. Usually Vue will have a small advantage because Vue's Virtual DOM implementation is relatively lighter.

[0058] like Figure 2As shown, first, a basic front-end project is built, and permissions are automatically added to the basic front-end project to obtain a front-end project with permission management function. In this way, users can add custom injected front-end permission module code and finally obtain an advanced permission front-end project.

[0059] The present invention adds permission management by routing information when reading project files in the front-end project, automatically generates relevant permissions, allows users to customize permission management codes, implements more complex permission management functions, and effectively saves the manpower cost of project development.

[0060] Based on the above embodiment, the method includes before step S1:

[0061] Determine the front-end project with a front-end and back-end separation mode;

[0062] By traversing preset key files in the front-end project, the front-end framework to be processed in the front-end project is obtained, and the framework type of the front-end framework to be processed is obtained.

[0063] It should be noted that the front-end project targeted by the present invention must be a basic project that can be run under a certain framework, and only the project framework that meets the development model of front-end and back-end separation can be identified in the present invention.

[0064] When started, it will automatically traverse the key files of the project. For example, in the web version, it will first find the package.json file and then search for specific information about the framework used.

[0065] The present invention obtains the corresponding specific framework type information in a targeted manner by identifying the specific type of the front-end project, so as to facilitate the subsequent corresponding authority management.

[0066] Based on any of the above embodiments, step S1 of the method includes:

[0067] According to the framework type, the routing file in the front-end project is obtained, and the routing information is obtained from the routing file.

[0068] Optionally, based on the framework type information in the front-end project, generally, it is necessary to determine whether the Vue framework or the React framework is currently being used, and then find out whether there is a routing file in the project based on the characteristics of different frameworks. Assuming that the React framework is queried at this time, the routing information will be obtained based on the routing file and then saved.

[0069] The present invention adopts a method of obtaining routing information through respective corresponding routing files for different framework types, and is applicable to routing processing of various types of frameworks.

[0070] Based on any of the above embodiments, step S2 of the method includes:

[0071] Constructing a rights management file, and determining a high-level component for rights management within the rights management file;

[0072] Based on the high-level component, the permission management target is determined.

[0073] Optionally, based on the above embodiment, according to the obtained routing information, the present invention specifically constructs a rights management file, and then automatically creates a high-order component for rights management inside the rights management file.

[0074] Here, the high-order component is similar to a high-order function. It receives a React component as input and outputs a new React component. The high-order component makes the code more reusable, logical, and abstract. It can hijack the render method and control props and state. The implementation principle of the high-order function includes if a function operates other functions, that is, taking other functions as parameters or returning functions as return values.

[0075] Generally, there are two ways to implement high-order components:

[0076] Props proxy: The property component operates props through the wrapped React component;

[0077] Inheritance inversion: The higher-order component inherits from the wrapped React component.

[0078] The present invention further performs permission management by using high-level components in the permission management file, realizes the function of automatic permission setting, and improves the development efficiency of the project.

[0079] Based on any of the above embodiments, step S3 of the method includes:

[0080] If the front-end project is based on the web and is developed based on the vue framework and / or the React framework, then encapsulate the high-level component;

[0081] The high-order component determines the corresponding routing component and preset field, verifies the routing component based on the preset field, and obtains the permission management item.

[0082] Optionally, for different front-end framework types, the present invention performs different permission management methods on the routing of the entire front-end project through the high-order components constructed in the aforementioned embodiments.

[0083] If it is a web project, the mainstream frameworks are generally Vue and React, and the external presentation is in the form of mini-programs and quick applications, which are derivative products of web front-end technology.

[0084] For example, for the React framework, create a new file to encapsulate the high-order component, then set the routing component and preset fields, verify the routing component through the preset fields, and then implement permission management.

[0085] If it is a hybrid development framework, usually the hybrid development framework basically adopts the above-mentioned web-side framework vue and React, so the above method is also used to implement the construction of the permission management project.

[0086] The present invention aims at the front-end framework of commonly used web-side projects, obtains a complete permission management project through high-level components and setting routing components and preset fields, and facilitates users to add custom permission codes and obtain custom control permissions.

[0087] Based on any of the above embodiments, step S3 of the method further includes:

[0088] If the front-end project is developed based on the flutter cross-platform, the routing information is obtained, and the stack storing the routing information is intercepted;

[0089] Authentication information is added to the routing information to obtain routing information carrying the authentication information, and the authority management item is obtained by obtaining the routing information carrying the authentication information from the stack.

[0090] Alternatively, if the front-end project is based on Flutter, a new cross-platform technology, all routing information must be obtained first, and then the stack storing all router information is intercepted, and routing information is obtained based on the stack information. By injecting authentication information into the routing information, each time a routing rendering page is taken out of the stack, it can be decided whether to render the page, thereby achieving the purpose of permission management.

[0091] Here, flutter cross-platform technology is created by Google's engineering team to create high-performance, cross-platform mobile applications. Flutter is optimized for current and future mobile devices, focusing on low-latency input and high frame rate for Android and iOS. In addition, flutter can provide developers with a simple and efficient way to build and deploy cross-platform, high-performance mobile applications; providing users with a beautiful, fast, jitter-free app experience.

[0092] The present invention aims at the flutter cross-platform front-end framework, obtains a complete permission management project by managing a stack for storing routing information, and also facilitates users to add custom permission codes and obtain custom control permissions.

[0093] The system for adding permissions to a front-end project provided by the present invention is described below. The system for adding permissions to a front-end project described below and the method for adding permissions to a front-end project described above can be referenced to each other.

[0094] Figure 3 It is a structural diagram of the system for adding permissions to front-end projects provided by the present invention, such as Figure 3 As shown, it includes: an acquisition module 31, a first determination module 32, an adding module 33 and a processing module 34, wherein:

[0095] The acquisition module 31 is used to obtain the routing information in the front-end project based on the framework type of the front-end project; the first determination module 32 is used to determine the permission management target based on the routing information; the adding module 33 is used to determine the permission management component according to the permission management target, and add the permission management component to the routing of the front-end project to obtain the permission management project; the processing module 34 is used to add a preset permission function code in the permission management project to obtain control authority over the front-end project.

[0096] The present invention adds permission management by routing information when reading project files in the front-end project, automatically generates relevant permissions, allows users to customize permission management codes, implements more complex permission management functions, and effectively saves the manpower cost of project development.

[0097] Based on the above embodiment, the system also includes a second determination module 35, which is used to determine the front-end project with a front-end and back-end separation mode; by traversing the preset key files in the front-end project, obtaining the front-end framework to be processed in the front-end project, and obtaining the framework type of the front-end framework to be processed.

[0098] The present invention obtains the corresponding specific framework type information in a targeted manner by identifying the specific type of the front-end project, so as to facilitate the subsequent corresponding authority management.

[0099] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute a method for adding permissions to a front-end project, the method comprising: obtaining routing information in the front-end project based on the framework type of the front-end project; determining a permission management target based on the routing information; determining a permission management component according to the permission management target, adding the permission management component to the routing of the front-end project, and obtaining a permission management project; adding a preset permission function code in the permission management project to obtain control permissions for the front-end project.

[0100] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0101] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the method for adding permissions to a front-end project provided by the above methods, and the method includes: based on the framework type of the front-end project, obtaining routing information in the front-end project; based on the routing information, determining a permission management target; according to the permission management target, determining a permission management component, adding the permission management component to the routing of the front-end project, and obtaining a permission management project; adding a preset permission function code in the permission management project to obtain control authority over the front-end project.

[0102] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the above-mentioned methods for adding permissions to front-end projects, the methods comprising: obtaining routing information in the front-end project based on the framework type of the front-end project; determining a permission management target based on the routing information; determining a permission management component based on the permission management target, adding the permission management component to the routing of the front-end project to obtain a permission management project; adding a preset permission function code in the permission management project to obtain control authority over the front-end project.

[0103] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0104] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0105] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for adding permissions to a front-end project, characterized in that: include: Based on the framework type of the front-end project, obtain the routing information in the front-end project; Determining a rights management target based on the routing information; Determine a rights management component according to the rights management target, add the rights management component to the routing of the front-end project, and obtain a rights management project; Add a preset permission function code in the permission management project to obtain control authority over the front-end project; The framework type based on the front-end project obtains the routing information in the front-end project, which previously includes: Determine the front-end project with a front-end and back-end separation mode; By traversing preset key files in the front-end project, the front-end framework to be processed in the front-end project is obtained, and the framework type of the front-end framework to be processed is obtained.

2. The method for adding permissions to a front-end project according to claim 1, characterized in that: The obtaining of routing information in the front-end project based on the framework type of the front-end project includes: According to the framework type, the routing file in the front-end project is obtained, and the routing information is obtained from the routing file.

3. The method for adding permissions to a front-end project according to claim 1, characterized in that: The determining of the rights management target based on the routing information includes: Constructing a rights management file, and determining a high-level component for rights management within the rights management file; Based on the high-level component, the permission management target is determined.

4. The method for adding permissions to a front-end project according to claim 3, characterized in that: The step of determining a rights management component according to the rights management target, adding the rights management component to the routing of the front-end project, and obtaining the rights management project includes: If the front-end project is based on the web and is developed based on the vue framework and / or the React framework, then encapsulate the high-level component; The high-order component determines the corresponding routing component and preset field, verifies the routing component based on the preset field, and obtains the permission management item.

5. The method for adding permissions to a front-end project according to claim 3, characterized in that: The step of determining a rights management component according to the rights management target, adding the rights management component to the routing of the front-end project, and obtaining the rights management project further includes: If the front-end project is developed based on the flutter cross-platform, the routing information is obtained, and the stack storing the routing information is intercepted; Authentication information is added to the routing information to obtain routing information carrying the authentication information, and the authority management item is obtained by obtaining the routing information carrying the authentication information from the stack.

6. A system for adding permissions to a front-end project, characterized in that: include: The acquisition module is used to obtain the routing information in the front-end project based on the framework type of the front-end project; A first determination module, configured to determine a rights management target based on the routing information; An adding module, used to determine a rights management component according to the rights management target, add the rights management component to the routing of the front-end project, and obtain a rights management project; A processing module, used to add a preset permission function code in the permission management project to obtain control authority over the front-end project; The acquisition module is further used to determine the front-end project with a front-end and back-end separation mode; By traversing preset key files in the front-end project, the front-end framework to be processed in the front-end project is obtained, and the framework type of the front-end framework to be processed is obtained.

7. The system for adding permissions to a front-end project according to claim 6, further comprising: A second determination module is used to determine the front-end project with a front-end and back-end separation mode; By traversing preset key files in the front-end project, the front-end framework to be processed in the front-end project is obtained, and the framework type of the front-end framework to be processed is obtained.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method for adding permissions to a front-end project as described in any one of claims 1 to 5 are implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for adding permissions to a front-end project as described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Management method and device of Android authority, terminal and computer storage medium

    CN108549799A

  • Method and system for simplifying front-end and rear-end separation authority control based on Vue

    CN110442326A

  • Webpage menu generation method and device and server

    CN110502712A

  • Project framework construction method and device, computer equipment and storage medium

    CN110647320A

  • Vue-based modular routing management method and authority control method

    CN111835646A