Permission configuration method and device

By automatically generating permission attribute values ​​in large projects, the problems of inconsistent permission identifier naming and low configuration efficiency are solved, achieving accuracy and consistency in permission configuration, and improving development efficiency and system maintainability.

CN121008828APending Publication Date: 2025-11-25CLP JINXIN SOFTWARE (SHANGHAI CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511002961.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-18
Publication Date
2025-11-25

AI Technical Summary

Technical Problem

In existing technologies, permission configuration in large projects or multi-module collaborative development scenarios suffers from inconsistent permission identifier naming and a lack of standardized formats, resulting in low configuration efficiency, errors, and impacts system manageability and development efficiency.

Method used

By acquiring the source code and relative path information in the current editing environment, parsing the document structure object, identifying interactive component nodes, and combining permission attributes and path information, the system automatically generates permission attribute values ​​and injects them into the source code, reducing manual configuration.

Benefits of technology

It improves the accuracy and consistency of permission configuration, reduces the workload of developers, increases development efficiency, and enhances the traceability and maintainability of permission configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121008828A_ABST
    Figure CN121008828A_ABST
Patent Text Reader

Abstract

The invention provides a permission configuration method and device. The method comprises the following steps: acquiring a source code and relative path information of a target document edited in a current editing environment; wherein the relative path information is used for representing position information of the target document relative to a root directory of a working area of the current editing environment; analyzing the source code to obtain a document structure object of the target document; performing node traversal on the document structure object to identify a target node corresponding to the interaction component from each node of the document structure object; according to the permission attribute corresponding to the target node and the relative path information, generating an attribute value of the permission attribute in the source code; wherein the attribute value is used for performing permission configuration of the interaction component, so that the accuracy and consistency of permission configuration are improved, the workload of manual permission configuration of developers is reduced, and the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a permission configuration method and apparatus. Background Technology

[0002] In front-end development and permission management systems, to achieve fine-grained access control over user interface interactive components (such as buttons, menu items, links, etc.), it is usually necessary to configure permission identifiers for these interactive components. This ensures that the system can accurately determine whether a user is qualified to perform the corresponding operation based on their permission status. Permission attributes, as fields in the code used to mark permission information, have attribute values ​​that are the corresponding permission identifiers. They are the core basis for permission management systems to perform permission management (such as verification and access decisions).

[0003] Currently, in actual development, permission attribute values ​​are typically defined manually by developers and inserted into the source code. While this approach offers some flexibility in small projects, it exposes numerous problems in large projects or multi-module collaborative development scenarios: such as inconsistent permission identifier naming, lack of standardized formatting, and inefficient permission configuration. Especially in complex systems containing numerous interactive components, manually writing permission identifiers for each component is time-consuming and laborious, and prone to configuration errors, severely impacting system manageability and development efficiency. Summary of the Invention

[0004] This disclosure provides a permission configuration method and apparatus to at least partially solve one of the technical problems in the related art. The technical solution of this disclosure is as follows:

[0005] According to a first aspect of the present disclosure, a permission configuration method is provided, comprising: obtaining the source code and relative path information of a target document being edited in the current editing environment; wherein the relative path information is used to characterize the location information of the target document relative to the root directory of the workspace of the current editing environment; parsing the source code to obtain a document structure object of the target document; performing node traversal on the document structure object to identify a target node corresponding to an interactive component from each node of the document structure object; generating an attribute value of the permission attribute in the source code according to the permission attribute corresponding to the target node and the relative path information; wherein the attribute value is used to configure the permissions of the interactive component.

[0006] According to a second aspect of the present disclosure, a permission configuration apparatus is provided, comprising: an acquisition module for acquiring the source code and relative path information of a target document being edited in the current editing environment; wherein the relative path information is used to characterize the location information of the target document relative to the root directory of the workspace of the current editing environment; a parsing module for parsing the source code to obtain a document structure object of the target document; a traversal module for performing node traversal on the document structure object to identify target nodes corresponding to interactive components from each node of the document structure object; and a generation module for generating attribute values ​​of the permission attributes in the source code based on the permission attributes corresponding to the target nodes and the relative path information; wherein the attribute values ​​are used for permission configuration of the interactive components.

[0007] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to execute the instructions to implement the permission configuration method as described in the first aspect of the present disclosure.

[0008] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided that, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the permission configuration method as described in the first aspect of the present disclosure.

[0009] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising: a computer program that, when executed by a processor, implements the permission configuration method as described in the first aspect of the present disclosure.

[0010] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects:

[0011] In this technical solution, by obtaining the source code and relative path information of the target document being edited in the current editing environment, the system can perceive the context and location of the file content where the component is located, improving the traceability of permission configuration. Furthermore, by parsing the source code to obtain the document structure object and performing node traversal operations, the system can accurately identify component nodes with interactive functions, ensuring that permission configuration applies to the correct user interface (UI) elements. Then, by combining the permission attribute fields corresponding to the target node with the relative path information, permission attribute values ​​are automatically generated and automatically injected into the source code, reducing the workload of developers manually configuring permissions and improving development efficiency. Specifically, when generating permission attribute values, based on... The display text and relative path information of the interactive component corresponding to the target node are used to automatically generate component identification information with a unified structure and clear semantics. Then, the component identification information is combined with the permission attribute field and automatically written into the source code, which enhances the accuracy and consistency of permission configuration. In addition, when generating component identification, the mapping identifier matching the display text of the interactive component is obtained. Since the mapping identifier reflects the functional intent of the interactive component and the relative path information provides the context position of the interactive component in the document, the mapping identifier matching the display text of the interactive component is combined with the relative path information of the interactive component to generate component identification information. This improves the semantics and readability of permission identification naming, and effectively avoids permission identification conflicts between components with the same function on the same page.

[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0013] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.

[0014] Figure 1 This is a flowchart illustrating the permission configuration method shown in the first embodiment of this disclosure;

[0015] Figure 2 This is a flowchart illustrating the permission configuration method shown in the second embodiment of this disclosure;

[0016] Figure 3 This is a flowchart illustrating the permission configuration method shown in the third embodiment of this disclosure;

[0017] Figure 4 This is a flowchart illustrating the permission configuration method shown in the fourth embodiment of this disclosure;

[0018] Figure 5 This is a flowchart illustrating the permission configuration method shown in the fifth embodiment of this disclosure;

[0019] Figure 6 This is a flowchart illustrating the permission configuration method shown in the sixth embodiment of this disclosure;

[0020] Figure 7 This is a schematic diagram illustrating the principle of the permission configuration method shown in the embodiments of this disclosure;

[0021] Figure 8 This is a schematic diagram of the permission configuration device shown in the seventh embodiment of this disclosure;

[0022] Figure 9 This is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present disclosure. Detailed Implementation

[0023] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.

[0024] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0025] It should be noted that the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the technical solution disclosed herein are all carried out with the consent of the user, and all comply with the provisions of relevant laws and regulations, and do not violate public order and good morals.

[0026] Currently, developers need to manually input permission identifiers for interactive components (such as buttons) during the development process. This method relies on manual input of permission identifiers, which has drawbacks such as high error rate, low efficiency, poor consistency and lack of context awareness.

[0027] To address the aforementioned issues, this disclosure proposes a permission configuration method and apparatus.

[0028] The permission configuration method and apparatus of embodiments of this disclosure are described below with reference to the accompanying drawings.

[0029] Figure 1This is a flowchart illustrating the permission configuration method shown in the first embodiment of this disclosure. It should be noted that the execution entity in this embodiment can be a permission configuration device, which can be applied to any electronic device with computing capabilities, enabling the electronic device to perform permission configuration functions.

[0030] like Figure 1 As shown, the permission configuration method includes the following steps:

[0031] Step 101: Obtain the source code and relative path information of the target document being edited in the current editing environment.

[0032] The relative path information is used to represent the location of the target document relative to the root directory of the current editing environment's workspace.

[0033] To ensure the traceability of permission identifiers, one possible approach is to determine the permission attribute values ​​corresponding to interactive components in the document based on the content context and file path information of the currently edited document.

[0034] As an example, in the current editing environment (e.g., VS Code, WebStorm), obtain the source code of the target document being edited, and obtain the path location of the target document relative to the root directory of the workspace in the project structure.

[0035] Step 102: Parse the source code to obtain the document structure object of the target document.

[0036] To facilitate the identification of subsequent interactive components, in this embodiment of the disclosure, the source code is parsed to obtain a document structure object. The document structure object refers to the structured representation parsed from the source code. The document structure object may include an abstract syntax tree (AST), a document object model tree (DOM tree), etc.

[0037] Step 103: Perform node traversal on the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object.

[0038] To facilitate locating component nodes requiring permission configuration, the document structure object is traversed. The target node is identified from each node in the document structure object. There can be one or more target nodes. Target nodes indicate interactive components, which include UI elements that users can click, input, and select, such as buttons. <button>,Link Form items <input> wait.

[0039] Step 104: Generate the attribute values ​​of the permission attributes in the source code based on the permission attributes and relative path information corresponding to the target node.

[0040] The attribute values ​​are used to configure permissions for interactive components.

[0041] To reduce manual intervention in permission configuration and improve the efficiency and consistency of permission configuration, in this embodiment of the disclosure, component identification information of interactive components is generated based on the permission attributes corresponding to the target node and the relative path information of the file to which it belongs. Then, the corresponding permission attribute values ​​are automatically generated based on the component identification information and injected into the source code to realize permission configuration of interactive components.

[0042] In summary, by obtaining the source code and relative path information of the target document being edited in the current editing environment, the system can perceive the context and location of the file content where the component is located, improving the traceability of permission configuration. Furthermore, by parsing the source code to obtain the document structure object and performing node traversal operations, the system can accurately identify component nodes with interactive functions, ensuring that permission configuration applies to the correct UI elements. In addition, by combining the permission attribute fields corresponding to the target node with the relative path information, permission attribute values ​​are automatically generated and automatically injected into the source code, improving the accuracy and consistency of permission configuration, reducing the workload of developers manually configuring permissions, and improving development efficiency.

[0043] To clearly illustrate how the permission attribute values ​​are generated in the source code based on the permission attributes and relative path information corresponding to the target node in the above embodiments, this disclosure proposes another permission configuration method.

[0044] Figure 2 This is a flowchart illustrating the permission configuration method shown in the second embodiment of this disclosure.

[0045] like Figure 2 As shown, the permission configuration method includes the following steps:

[0046] Step 201: Obtain the source code and relative path information of the target document being edited in the current editing environment.

[0047] The relative path information is used to represent the location of the target document relative to the root directory of the current editing environment's workspace.

[0048] Step 202: Parse the source code to obtain the document structure object of the target document.

[0049] Step 203: Perform node traversal on the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object.

[0050] Step 204: Extract the display text of the interactive component corresponding to the target node from the source code.

[0051] The displayed text is used to indicate the interactive functions of the interactive controls.

[0052] To make permission identifiers more closely aligned with business functions and easier to understand and maintain, in this embodiment of the disclosure, the text content (also known as display text) of the interactive component represented by the target node displayed to the user on the interface is extracted. The display text contains the functional semantics of the component, such as the text "save" or "delete" on a button. The component identifier is generated by combining the display text, which can realize the generation of component identifier information based on the actual functional semantics of the component.

[0053] Step 205: Generate component identification information for interactive components based on the displayed text and relative path information.

[0054] It should be noted that, since the displayed text reflects the functional intent of the interactive component, and the relative path information reflects the location information of the file where the interactive component is located, in order to improve the consistency and accuracy of permission identification, the component identification information of the interactive component is generated by combining the displayed text and the relative path information. For example, the component identification information of the interactive component can be obtained by directly concatenating the relative path information and the displayed text; or, the relative path information and the displayed text can be transformed by setting mapping rules (such as regular expressions), and the component identification information can be generated based on the transformed information.

[0055] It should be noted that when there are multiple target nodes, for interactive components that display the same text corresponding to the target nodes, the component identification information of interactive components that display the same text is the same. Thus, these interactive components that display the same text generate consistent permission identifiers during the permission configuration process, thereby achieving consistency and standardization of permission management.

[0056] Step 206: Generate the attribute value of the permission attribute in the source code content based on the component identification information and the permission attribute of the interactive component.

[0057] To reduce human error and improve development efficiency, one possible approach is to combine component identification information with permission attribute fields and automatically write the component identification information into the source code.

[0058] In this embodiment of the disclosure, the generated permission identifier is written as an attribute value to the tag of the interactive component corresponding to the target node.

[0059] It should be noted that the execution process of steps 201 to 203 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.

[0060] In summary, by extracting the display text of the interactive component corresponding to the target node from the source code, the system can obtain the functional semantic information carried by the component. Furthermore, by combining the relative path information of the file where the interactive component is located, the path information of the document where the interactive component is located is identified, ensuring that the generated permission identifiers have consistency and contextual relevance, and avoiding naming conflicts and path dependency issues between different interactive components. Then, the display text and path information are integrated to automatically generate component identifier information with a unified structure and clear semantics. Finally, the component identifier information is combined with the permission attribute field and automatically written into the source code. This not only reduces the workload of developers manually configuring permissions and improves development efficiency, but also enhances the accuracy and consistency of permission configuration. At the same time, by generating permission identifiers by combining the semantics and path information of interactive components, the maintainability and traceability of the system are improved.

[0061] To clearly illustrate how the above embodiments generate the attribute values ​​of permission attributes in the source code content based on the component identification information and the permission attributes of the interactive components, this disclosure proposes another permission configuration method.

[0062] Figure 3 This is a flowchart illustrating the permission configuration method shown in the third embodiment of this disclosure.

[0063] like Figure 3 As shown, the permission configuration method includes the following steps:

[0064] Step 301: Obtain the source code and relative path information of the target document being edited in the current editing environment.

[0065] The relative path information is used to represent the location of the target document relative to the root directory of the current editing environment's workspace.

[0066] Step 302: Parse the source code to obtain the document structure object of the target document.

[0067] Step 303: Perform node traversal on the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object.

[0068] Step 304: Extract the display text of the interactive component corresponding to the target node from the source code.

[0069] The displayed text is used to indicate the interactive functions of the interactive controls.

[0070] Step 305: Generate component identification information for interactive components based on the displayed text and relative path information.

[0071] Step 306: In response to the existence of an interactive component's permission attribute in the source code and the attribute value of the permission attribute being empty, determine the attribute value position in the source code based on the attribute position of the permission attribute in the source code.

[0072] To improve the efficiency of permission configuration, as a possible implementation, permission attributes that have been declared but not assigned values ​​can be automatically populated with attribute values.

[0073] As an example, permission attributes (such as permission, v-permission, etc.) have been added to the interactive component, but the permission attribute has not been assigned a value, or has been assigned an invalid value such as an empty string or an empty object. By parsing the document structure object, the node where the permission attribute is located and its position in the source code (also known as the attribute position) can be located. Based on this position, the position of the corresponding attribute value can be determined.

[0074] Step 307: Generate the attribute value of the permission attribute at the attribute value position based on the component identification information.

[0075] Then, the component identifier information of the interactive component generated based on the displayed text and relative path information is used as the attribute value of the permission attribute and inserted into the attribute value position.

[0076] It should be noted that the execution process of steps 301 to 305 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.

[0077] In summary, when a permission attribute is detected to exist in the source code but its value is empty, the system accurately identifies the location where the attribute value should be inserted based on its position in the source code. Combined with the generated component identifier information, the system automatically fills in the attribute value at the specified location. This achieves intelligent identification and automatic completion of unassigned permission attributes, eliminating the need for developers to manually enter attribute values, effectively reducing repetitive work and human error, and improving permission configuration efficiency. Furthermore, by uniformly generating and injecting attribute values, the system ensures consistent naming conventions, further enhancing system maintainability and data consistency.

[0078] To clearly illustrate how the above embodiments generate the attribute values ​​of permission attributes in the source code content based on the component identification information and the permission attributes of the interactive components, this disclosure proposes another permission configuration method.

[0079] Figure 4 This is a flowchart illustrating the permission configuration method shown in the fourth embodiment of this disclosure.

[0080] like Figure 4 As shown, the permission configuration method includes the following steps:

[0081] Step 401: Obtain the source code and relative path information of the target document being edited in the current editing environment.

[0082] The relative path information is used to represent the location of the target document relative to the root directory of the current editing environment's workspace.

[0083] Step 402: Parse the source code to obtain the document structure object of the target document.

[0084] Step 403: Perform node traversal on the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object.

[0085] Step 404: Extract the display text of the interactive component corresponding to the target node from the source code.

[0086] The displayed text is used to indicate the interactive functions of the interactive controls.

[0087] Step 405: Generate component identification information for interactive components based on the displayed text and relative path information.

[0088] Step 406: In response to the absence of permission attributes for the interactive component in the source code, determine the tag location of the interactive component in the source code.

[0089] To improve the flexibility of permission configuration, as a possible implementation, when it is detected that the target interactive component (such as a button or menu item) has not declared any permission attributes, that is, the interactive component does not have any permission-related attribute fields, the specific tag position of the interactive component in the source code is located by parsing the document structure object (such as AST or DOM tree). For example, locating...< / button> <button>The starting position of the label.

[0090] Step 407: At the label location, create the permission attribute of the interactive component and determine the location of the attribute value of the created permission attribute.

[0091] To improve the accuracy of permission attribute injection, a new permission attribute field is inserted within the component tag, and the specific location where the attribute value should be inserted is further determined (e.g., between quotation marks, inside an expression).

[0092] Step 408: Generate the attribute value of the permission attribute of the interactive component at the attribute value position based on the component identification information.

[0093] In order to automate and structure permission configuration, in this embodiment of the disclosure, the previously generated component identification information is written as an attribute value into the created permission attribute, so as to realize the writing of the attribute value corresponding to the permission attribute.

[0094] It should be noted that the execution process of steps 401 to 405 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.

[0095] In summary, by identifying the label positions of interactive components that do not declare permission attributes, creating permission attributes at those label positions, and inserting corresponding attribute values ​​based on component identification information, intelligent generation and injection of permission configuration information are achieved, effectively improving the automation level and development efficiency of permission management.

[0096] To clearly illustrate how the above embodiments generate component identification information of interactive components based on displayed text and relative path information, this disclosure proposes another permission configuration method.

[0097] Figure 5 This is a flowchart illustrating the permission configuration method shown in the fifth embodiment of this disclosure.

[0098] like Figure 5 As shown, the permission configuration method includes the following steps:

[0099] Step 501: Obtain the source code and relative path information of the target document being edited in the current editing environment.

[0100] The relative path information is used to represent the location of the target document relative to the root directory of the current editing environment's workspace.

[0101] Step 502: Parse the source code to obtain the document structure object of the target document.

[0102] Step 503: Perform node traversal on the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object.

[0103] Step 504: Extract the display text of the interactive component corresponding to the target node from the source code.

[0104] The displayed text is used to indicate the interactive functions of the interactive controls.

[0105] Step 505: Obtain the mapping identifier that matches the displayed text.

[0106] To improve the accuracy and flexibility of permission identifier generation, a multi-level identifier matching mechanism can be introduced as a possible implementation. This mechanism retrieves the mapping identifier that matches the displayed text from the identifier configuration file or a mapping table. Then, combined with the relative path information of the document containing the interactive component, semantically consistent component identifier information is generated.

[0107] As an example, in response to the existence of an identifier configuration file, the identifier configuration file is queried based on the displayed text; wherein the identifier configuration file includes the correspondence between tags and identifiers; in response to the existence of an identifier in the identifier configuration file that corresponds to the displayed text, the identifier with the correspondence is used as the mapping identifier.

[0108] In other words, during the generation of component identifier information for interactive components, in order to improve the accuracy and adaptability of permission identifier naming, if an identifier configuration file is detected, the identifier configuration file is automatically queried based on the displayed text of the interactive component (such as "Save" on a button). It should be noted that the identifier configuration file predefines the correspondence between text and identifier, and the identifier configuration file can be pre-configured according to user needs, so that the permission identifiers can adapt to the naming habits of different projects or teams.

[0109] As another example, in response to the absence of an identifier in the identifier configuration file that corresponds to the displayed text, the identifier mapping table is queried based on the displayed text; wherein, the identifier mapping table includes the mapping relationship between tags and identifiers; in response to the presence of an identifier in the identifier mapping table that corresponds to the displayed text, the identifier with the mapping relationship is used as the mapping identifier.

[0110] In other words, when it is detected that the displayed text of the current interactive component does not have a corresponding permission identifier in the user-defined identifier configuration file, the preset identifier mapping table is further searched based on the displayed text. The identifier mapping table can contain a general mapping relationship between text and identifier. If there is an identifier in the set identifier mapping table that has a mapping relationship with the displayed text, then the identifier with the mapping relationship is directly used as the mapping identifier.

[0111] As another example, in response to the absence of an identifier with a mapping relationship in the identifier mapping table, a prompt window is rendered and displayed; wherein the prompt window is used to prompt for input of the mapping identifier.

[0112] In other words, if there is no identifier in the identifier mapping table that has a mapping relationship with the displayed text, a prompt pop-up or input box can be dynamically created in the front-end interface to guide developers or configuration personnel to manually enter the permission identifier.

[0113] Step 506: Generate component identification information for interactive components based on relative path information and mapping identifiers.

[0114] To improve the accuracy and efficiency of permission configuration, in this embodiment of the disclosure, relative path information can be combined with mapping identifiers (e.g., concatenated) based on set rules to automatically generate component identifier information.

[0115] Step 507: Generate the attribute value of the permission attribute in the source code content based on the component identification information and the permission attribute of the interactive component.

[0116] It should be noted that the execution process of steps 501 to 504 and step 507 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.

[0117] In summary, by obtaining a mapping identifier that matches the displayed text of the interactive component, this mapping identifier reflects the functional intent of the interactive component. Furthermore, since the relative path information provides the contextual location of the interactive component, the mapping identifier, combined with the relative path information of the interactive component, generates the final component identifier information. Thus, based on the component identifier information and the permission attributes of the interactive component, the attribute values ​​of the permission attributes are generated in the source code content. This not only improves the semantics and readability of the permission identifier naming, but also effectively avoids permission identifier conflicts between components with the same function in different modules or pages.

[0118] To clearly illustrate how the relative path information of the target document being edited in the current editing environment is obtained in the above embodiments, this disclosure proposes another permission configuration method.

[0119] Figure 6 This is a flowchart illustrating the permission configuration method shown in the sixth embodiment of this disclosure.

[0120] like Figure 6 As shown, the permission configuration method includes the following steps:

[0121] Step 601: Obtain the source code of the target document being edited in the current editing environment.

[0122] Step 602: Obtain the root path information of the root directory of the current editing environment's workspace.

[0123] In this embodiment of the disclosure, the path information of the root directory of the project where the workspace is located (also known as the root path information) is obtained from the current editing environment (such as VS Code). The root path information refers to the absolute path of the entire project folder.

[0124] Step 603: Perform path transformation on the root path information to obtain relative path information.

[0125] To avoid inconsistencies in permission identifiers due to differences in local paths among different developers, this embodiment of the disclosure performs path conversion on the root path information to obtain relative path information. For example, file extensions and fixed prefixes (such as src / ) are removed from the root path information to obtain relative path information (such as views / user / settings).

[0126] Step 604: Parse the source code to obtain the document structure object of the target document.

[0127] Step 605: Perform node traversal on the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object.

[0128] Step 606: Generate the attribute values ​​of the permission attributes in the source code based on the permission attributes and relative path information corresponding to the target node.

[0129] The attribute values ​​are used to configure permissions for interactive components.

[0130] It should be noted that the execution process of steps 601, 604 to 606 can be implemented in any of the embodiments of this disclosure. This disclosure does not limit this and will not elaborate further.

[0131] In summary, by obtaining the root path information of the root directory of the current editing environment's workspace and performing path conversion on the root path information, the relative path information of the target document relative to the project root directory is obtained. This accurately reflects the module and page hierarchy to which the interactive component belongs. At the same time, since the relative path information does not depend on the developer's local absolute path, it avoids data inconsistency issues caused by differences in development environments, thus improving the system's portability and stability.

[0132] Based on the above embodiments, such as Figure 7 As shown, taking a button as an example of an interactive component, the permission configuration method of this disclosure embodiment can also be implemented based on the following steps, the specific steps of which are as follows:

[0133] (1) Obtain the editing environment

[0134] The plugin automatically triggers, obtaining the content of the currently edited file through the editor interface of VS Code (Visual Studio Code). Specifically, it first locates the currently open editor window (e.g., vscode.window.activeTextEditor), then reads all the code text (i.e., source code) in the document, and simultaneously obtains the root directory location of the project (root path information), thereby automatically locking the current editing context and avoiding errors caused by manually searching for files.

[0135] (2) Parse file path

[0136] Convert the full path of a file (i.e., the root path information) into an absolute path relative to the root directory. For example, remove the fixed prefix "src / " and the file extension (.vue / .html, etc.) to get a concise path like "views / user / settings". This path will be used as a prefix for permission identification to mark the location information of the file in the project.

[0137] (3) Parse code text

[0138] The code text is analyzed using a HyperText Markup Language (HTML) parsing tool to generate a document structure object. Then, each node in the document structure object is traversed to find button labels (el-button, the button component of the Element UI framework). The text displayed on the button (innerText), such as "Save" or "Delete", is then extracted. This text will serve as key information for permission matching. At the same time, it is checked whether the button already has a permission attribute (v-allow). The permission attribute result is obtained, which is divided into three cases: the attribute exists but has no value (null), the attribute value is empty (empty), and the attribute does not exist at all (none).

[0139] (4) Generate permission identifier

[0140] The system prioritizes searching the identifier configuration file within the project. This file contains a mapping between "button text" and "identifier." If the identifier is not found in the configuration file, a pre-defined mapping table (buttonsMap) is used, such as "save" corresponding to "save". The final generated permission identifier (component identifier information) is in the format of "simplified path:button mapping value", for example, "views / user / settings:save". This configuration file-based management method ensures consistent and easily modifiable permission identifiers, avoiding the confusion caused by manual settings.

[0141] (5) Add or update permission attributes

[0142] For buttons that already have permission attributes (with attribute values ​​of null or empty), the system will locate the attribute and directly replace it with the new permission value. For buttons without this attribute (in the 'none' state), a new attribute (v-allow="${value}") will be inserted at the beginning of the button label. The entire modification process will be completed through VS Code's batch editing function (TextEdit object), operating automatically like a "find and replace" tool, avoiding spelling errors caused by manual input and making the code more standardized.

[0143] (6) Handle abnormal situations and notify the user.

[0144] If the system encounters button text that doesn't match the identifier configuration file, it will count these unmatched button texts and display a prompt message informing the user that they need to set it manually. If the identifier configuration file (falcon-magic.json) doesn't exist or fails to read, an error message will also be displayed, guiding the user to configure the file first. This approach ensures that most cases are handled automatically while providing clear guidance for manual handling in special cases.

[0145] Corresponding to the permission configuration method provided in the above embodiments, this disclosure also provides a permission configuration device. Since the permission configuration device provided in this disclosure corresponds to the permission configuration method provided in the above embodiments, the implementation of the permission configuration method is also applicable to the permission configuration device provided in this disclosure, and will not be described in detail in this disclosure.

[0146] Figure 8 This is a schematic diagram of the permission configuration device shown in the seventh embodiment of this disclosure.

[0147] like Figure 8 As shown, the permission configuration device 800 includes: an acquisition module 810, a parsing module 820, a traversal module 830, and a generation module 840.

[0148] The document includes the following modules: an acquisition module 810, which acquires the source code and relative path information of the target document being edited in the current editing environment; the relative path information represents the location of the target document relative to the root directory of the workspace in the current editing environment; a parsing module 820, which parses the source code to obtain the document structure object of the target document; a traversal module 830, which traverses the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object; and a generation module 840, which generates attribute values ​​for permission attributes in the source code based on the permission attributes and relative path information corresponding to the target node; the attribute values ​​are used for permission configuration of the interactive component.

[0149] As one possible implementation of this disclosure, the generation module 840 is used to extract the display text of the interactive component corresponding to the target node from the source code; wherein the display text is used to indicate the interactive function of the interactive control; generate component identification information of the interactive component based on the display text and relative path information; and generate the attribute value of the permission attribute in the source code content based on the component identification information and the permission attribute of the interactive component.

[0150] As one possible implementation of this disclosure, the generation module 840 is configured to, in response to the existence of an interactive component's permission attribute in the source code and the attribute value of the permission attribute being empty, determine the attribute value position in the source code based on the attribute position of the permission attribute in the source code; and generate the attribute value of the permission attribute at the attribute value position based on the component identification information.

[0151] As one possible implementation of this disclosure, the generation module 840 is configured to, in response to the absence of a permission attribute for the interactive component in the source code, determine the tag position of the interactive component in the source code; at the tag position, create a permission attribute for the interactive component and determine the position of the attribute value of the created permission attribute; and generate the attribute value of the permission attribute of the interactive component at the attribute value position according to the component identification information.

[0152] As one possible implementation of this disclosure, the generation module 840 is used to obtain a mapping identifier that matches the displayed text; and to generate component identifier information of the interactive component based on the relative path information and the mapping identifier.

[0153] As one possible implementation of this disclosure, the generation module 840 is configured to query the identifier configuration file based on the displayed text in response to the existence of an identifier configuration file; wherein the identifier configuration file includes the correspondence between text and identifiers; and in response to the existence of an identifier in the identifier configuration file that corresponds to the displayed text, the identifier with the corresponding relationship is used as a mapping identifier.

[0154] As one possible implementation of this disclosure, the generation module 840 is further configured to, in response to the absence of an identifier in the identifier configuration file that corresponds to the displayed text, query a set identifier mapping table based on the displayed text; wherein, the set identifier mapping table includes the mapping relationship between tags and identifiers; in response to the presence of an identifier in the set identifier mapping table that corresponds to the displayed text, use the identifier with the mapping relationship as the mapping identifier.

[0155] As one possible implementation of this disclosure, the permission configuration device 800 further includes a prompting module.

[0156] The prompting module is used to render and display a prompt window in response to the absence of a mapping relationship between the set identifier and the identifier mapping table; the prompt window is used to prompt for the input of the mapping identifier.

[0157] As one possible implementation of this disclosure, the acquisition module 810 is used to acquire the root path information of the root directory of the current editing environment's workspace; and to perform path conversion on the root path information to obtain relative path information.

[0158] The permission configuration device of this disclosure improves the traceability of permission configuration by obtaining the source code and relative path information of the target document being edited in the current editing environment, enabling the system to perceive the context and location of the file content where the component is located. Furthermore, by parsing the source code to obtain a document structure object and performing node traversal operations, it accurately identifies component nodes with interactive functions, ensuring that permission configuration applies to the correct UI elements. In addition, by combining the permission attribute fields corresponding to the target node with the relative path information, permission attribute values ​​are automatically generated and automatically injected into the source code, improving the accuracy and consistency of permission configuration, reducing the workload of developers manually configuring permissions, and improving development efficiency.

[0159] In an exemplary embodiment, an electronic device is also proposed.

[0160] The electronic devices include:

[0161] processor;

[0162] Memory used to store processor-executable instructions;

[0163] The processor is configured to execute instructions to implement the permission configuration method as proposed in any of the foregoing embodiments.

[0164] As an example, Figure 9 This is a schematic diagram of the structure of an electronic device 900 as shown in an exemplary embodiment of this disclosure, as follows: Figure 9 As shown, the aforementioned electronic device 900 may further include:

[0165] The system includes a memory 910 and a processor 920, and a bus 930 connecting different components (including the memory 910 and the processor 920). The memory 910 stores a computer program, and when the processor 920 executes the program, it implements the permission configuration method described in the embodiments of this disclosure.

[0166] Bus 930 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.

[0167] Electronic device 900 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by electronic device 900, including volatile and non-volatile media, removable and non-removable media.

[0168] The memory 910 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 940 and / or cache memory 950. The server 900 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 960 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 9 Not shown; usually referred to as "hard drive"). Although Figure 9 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 930 via one or more data media interfaces. Memory 910 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this disclosure.

[0169] A program / utility 980 having a set (at least one) of program modules 970 may be stored, for example, in memory 910. Such program modules 970 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 970 typically perform the functions and / or methods described in the embodiments of this disclosure.

[0170] Electronic device 900 can also communicate with one or more external devices 990 (e.g., keyboard, pointing device, display 991, etc.), and with one or more devices that enable a user to interact with electronic device 900, and / or with any device that enables electronic device 900 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 992. Furthermore, electronic device 900 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 993. As shown, network adapter 993 communicates with other modules of electronic device 900 via bus 930. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0171] The processor 920 performs various functional applications and data processing by running programs stored in the memory 910.

[0172] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the permission configuration method of this disclosure embodiment, and will not be repeated here.

[0173] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, which can be executed by a processor of an electronic device to perform the permission configuration method proposed in any of the above embodiments. Optionally, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0174] In an exemplary embodiment, a computer program product is also provided, including a computer program / instructions, characterized in that the computer program / instructions, when executed by a processor, implement the permission configuration method proposed in any of the above embodiments.

[0175] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.

[0176] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.< / button>

Claims

1. A permission configuration method, characterized in that, include: Obtain the source code and relative path information of the target document being edited in the current editing environment; wherein, the relative path information is used to represent the location information of the target document relative to the root directory of the workspace of the current editing environment; The source code is parsed to obtain the document structure object of the target document; The document structure object is traversed to identify the target node corresponding to the interactive component from each node of the document structure object; Based on the permission attributes corresponding to the target node and the relative path information, the attribute values ​​of the permission attributes are generated in the source code; wherein, the attribute values ​​are used to configure the permissions of the interactive component.

2. The method according to claim 1, characterized in that, The step of generating the attribute value of the permission attribute in the source code based on the permission attribute corresponding to the target node and the relative path information includes: From the source code, extract the display text of the interactive component corresponding to the target node; wherein, the display text is used to indicate the interactive function of the interactive control; Based on the displayed text and the relative path information, generate the component identification information of the interactive component; Based on the component identification information and the permission attributes of the interactive component, the attribute value of the permission attribute is generated in the source code content.

3. The method according to claim 2, characterized in that, The step of generating the attribute value of the permission attribute in the source code content based on the component identification information and the permission attribute of the interactive component includes: In response to the existence of a permission attribute of the interactive component in the source code and the attribute value of the permission attribute being empty, the attribute value position in the source code is determined according to the attribute position of the permission attribute in the source code. Based on the component identification information, the attribute value of the permission attribute is generated at the attribute value location.

4. The method according to claim 2, characterized in that, The step of generating the attribute value of the permission attribute in the source code content based on the component identification information and the permission attribute of the interactive component includes: In response to the absence of permission attributes for the interactive component in the source code, the label location of the interactive component is determined in the source code; At the label location, create the permission attribute of the interactive component and determine the location of the attribute value of the created permission attribute; Based on the component identification information, the attribute value of the permission attribute of the interactive component is generated at the attribute value position.

5. The method according to claim 2, characterized in that, The step of generating component identification information for the interactive component based on the displayed text and the relative path information includes: Obtain the mapping identifier that matches the displayed text; Based on the relative path information and the mapping identifier, the component identifier information of the interactive component is generated.

6. The method according to claim 5, characterized in that, The step of obtaining the mapping identifier that matches the displayed text includes: In response to the existence of an identifier configuration file, the identifier configuration file is queried based on the displayed text; wherein, the identifier configuration file includes the correspondence between text and identifiers; In response to the existence of an identifier in the identifier configuration file that corresponds to the displayed text, the identifier that corresponds to the text is used as the mapping identifier.

7. The method according to claim 6, characterized in that, The method further includes: If no identifier corresponding to the displayed text exists in the identifier configuration file, the set identifier mapping table is queried based on the displayed text; wherein, the set identifier mapping table includes the mapping relationship between tags and identifiers; In response to the existence of an identifier in the defined identifier mapping table that has a mapping relationship with the displayed text, the identifier with the mapping relationship is used as the mapping identifier.

8. The method according to claim 7, characterized in that, The method further includes: In response to the absence of the mapped identifier in the defined identifier mapping table, a prompt window is rendered and displayed; The prompt window is used to prompt for the input of the mapping identifier.

9. The method according to claim 1, characterized in that, Obtain the relative path information of the target document being edited in the current editing environment, including: Obtain the root path information of the root directory of the current editing environment's workspace; The root path information is transformed to obtain the relative path information.

10. A permission configuration device, characterized in that, include: The acquisition module is used to acquire the source code and relative path information of the target document being edited in the current editing environment; wherein, the relative path information is used to represent the position information of the target document relative to the root directory of the workspace of the current editing environment; A parsing module is used to parse the source code to obtain the document structure object of the target document; The traversal module is used to traverse the document structure object to identify the target node corresponding to the interactive component from each node of the document structure object; The generation module is used to generate the attribute value of the permission attribute in the source code based on the permission attribute corresponding to the target node and the relative path information; wherein the attribute value is used to configure the permission of the interactive component.

Citation Information

Cited By

  • Authority management method, electronic equipment and computer readable medium

    CN121283774A

  • A permission management method, an electronic device, and a computer readable medium

    CN121283774B