Method, device and equipment for determining active state of operation button and storage medium
By obtaining and setting the static configuration information and matrix elements of the operation buttons, the problem of redundant code in the active state of operation buttons in the web front end is solved, and efficient active state management and rendering are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINAN INSPUR DATA TECH CO LTD
- Filing Date
- 2026-04-02
- Publication Date
- 2026-06-30
AI Technical Summary
In web front-end technology, existing technologies lead to code redundancy in determining the active state of operation buttons and make it difficult to efficiently manage the active state of buttons under different resource types and states.
By obtaining the resource type and status information of the target instance, the static configuration information and initial matrix are determined. The matrix elements are set according to the resource status information. The active state of the operation button is determined using the preset matrix conditions and passed to the operation component for rendering.
The amount of code in the operation components has been reduced, code redundancy has been avoided, code maintainability and efficiency have been improved, and unified management of the active state of operation buttons has been achieved.
Smart Images

Figure CN122309014A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Web front-end technology, and in particular to a method, apparatus, device, and storage medium for determining the active state of an operation button. Background Technology
[0002] In web front-end technology, the activity state of an action button is typically used to indicate whether the button is enabled. Generally, determining the activity state of an action button requires considering the resource state. Consequently, developers need to write different code based on the various combinations of resource states. This results in relatively redundant code for the action component. Summary of the Invention
[0003] This application provides a method, apparatus, electronic device, storage medium, and program product for determining the active state of an operation button, in order to solve the problem of redundant code in the operation component.
[0004] This application provides a method for determining the active state of an operation button, including: Obtain the target resource type and resource status information of the target instance; Based on the target resource type, determine the static configuration information of at least one operation button corresponding to the target resource type; Based on the static configuration information of the target operation button, determine at least one resource status condition corresponding to the target operation button, and determine the initial matrix corresponding to the target operation button, wherein the target operation button is any one of at least one operation buttons; Based on resource status information and at least one resource status condition, the elements in the initial matrix are set to obtain the target matrix; Based on the target matrix and preset matrix conditions, the activity state of the target operation button is determined, and the activity state of the target operation button is passed to the target operation component of the target instance so that the target operation component can render and display the target operation button according to the activity state and static configuration information of the target operation button.
[0005] This application also provides a device for determining the active state of an operation button, including: The acquisition module is used to obtain the target resource type and resource status information of the target instance; The determination module is used to determine the static configuration information of at least one operation button corresponding to the target resource type based on the target resource type; determine at least one resource state condition corresponding to the target operation button based on the static configuration information of the target operation button, and determine the initial matrix corresponding to the target operation button, wherein the target operation button is any one of the at least one operation button; set the elements in the initial matrix according to the resource state information and at least one resource state condition to obtain the target matrix; determine the activity state of the target operation button according to the target matrix and the preset matrix conditions, and pass the activity state of the target operation button to the target operation component of the target instance, so that the target operation component can render and display the target operation button according to the activity state and static configuration information of the target operation button.
[0006] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of determining the active state of any of the above-described operation buttons when executing the computer program.
[0007] This application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for determining the active state of any of the above-described operation buttons.
[0008] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of determining the active state of any of the above-described operation buttons.
[0009] This application first obtains the target resource type and resource status information of the target instance. Then, based on the target resource type, the static configuration information of the corresponding operation button is determined. For the target operation button, the corresponding resource status conditions and initial matrix can be determined based on its static configuration information. Furthermore, based on the real-time obtained resource status information and resource status conditions, the elements in the initial matrix are numerically set to obtain the target matrix. Based on the target matrix and preset matrix conditions, the activity state of the target operation button is determined and input to the target operation component of the target instance. Finally, the target operation component only needs to render and display the target operation button based on the input activity state and static configuration information. Under this scheme, for operation buttons of the same type under the same resource type, each instance can share the same code to determine the activity state of the operation button and finally input the activity state into the instance's operation component, which can reduce the amount of code in the operation component and avoid code redundancy. Attached Figure Description
[0010] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 A flowchart illustrating a method for determining the active state of an operation button, provided in an embodiment of this application; Figure 2 This is a schematic diagram of the rendering operation of an operation component provided in an embodiment of this application; Figure 3 A schematic diagram of a matrix rule provided in an embodiment of this application; Figure 4 A schematic diagram of a device for determining the active state of an operation button provided in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0013] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.
[0014] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0015] The following explains the technical terms used in this application: Operation component: This refers to a reusable front-end component encapsulated based on the component-based features of the Vue framework, primarily used for loading and rendering operation buttons. Vue is a JavaScript framework used to build user interfaces.
[0016] Operation buttons: These are the specific interface elements rendered by the operation component according to the configuration. For example, the clickable buttons "Power on" and "Power off" that the program ultimately provides to the user.
[0017] Active state: refers to the interactive state of operation buttons on the page, such as whether they are grayed out, whether they are displayed, or whether they have a disabled prompt message.
[0018] Hard coding refers to a coding method in which business logic or decision rules are directly and fixedly written in the program source code.
[0019] Rendering refers to the entire process of dynamically generating and updating components and their data into a visual interface. Rendering of operational components includes both the initial interface generation upon loading and automatic interface updates driven by data.
[0020] In web front-end development projects, taking virtualization systems as an example, resource operations are frequently involved, which in turn involve encapsulating operation buttons. Taking virtual machines as an example, during the rendering of operation buttons, some buttons can be grayed out based on the virtual machine's resource status information. Generally, the rendering of operation components is done through configuration files. Different resource types involve different operations. Therefore, static configuration information for operation buttons of different resource types such as virtual machines, storage, and hosts can be predefined in the configuration file, and then the operation component can accept dynamic parameters for rendering. The activity state of the operation buttons needs to be updated based on specific resource status information. Different resource types involve different resource status information, and the resource status information includes a great deal of complexity. If developers write code based on different combinations of resource statuses, requiring the code execution to determine whether to gray out the operation button according to various combinations of resource statuses, the code will be redundant and difficult to use. Each time a new resource status is added, it needs to be coded and added to the activity state judgment code, which is inconvenient.
[0021] To address the aforementioned technical problems, embodiments of this application provide a method for determining the active state of an operation button, which can be executed by an electronic device, such as... Figure 1 As shown, the specific processing steps for determining the active state of an operation button may include: Step S101: Obtain the target resource type and resource status information of the target instance.
[0022] The target resource type can be a virtual machine, a host, storage, etc. For example, the target instance can be virtual machine 001, and the target resource type of the target instance is virtual machine. Resource status information refers to the real-time, dynamic attributes and status data of the instance, such as whether it is powered on, has tools installed, is under maintenance, or is executing a task.
[0023] Specifically, after a user enters the resource management page, the electronic device displays rendered operation buttons for each instance. The user can then perform corresponding operations on these buttons to manage the resources. For any given instance (i.e., the target instance), the electronic device can first determine its resource type. For example, after entering the virtual machine's resource management page, it can confirm that the instance's resource type is a virtual machine. Furthermore, after the user enters the resource management page, the electronic device can dynamically retrieve real-time resource status information for each instance by calling backend APIs.
[0024] Step S102: Determine the static configuration information of at least one operation button corresponding to the target resource type, based on the target resource type.
[0025] The static configuration information may include the identification information, display text, location, and initial activity state of the operation buttons. When the number of operation buttons is large (e.g., greater than a preset threshold), the static configuration information may also include grouping information.
[0026] Specifically, the electronic device may pre-store a target configuration file. This target configuration file may include a list of operation buttons corresponding to different resource types. The list of operation buttons may include static configuration information for at least one operation button. For example, the target configuration file may be "btn.xml", and the static configuration information for the power button of the host resource type may be "btn.xml". <btn type="”HOST""> <button> Power on< / button> < / btn> After entering the resource management page for the target resource type, the electronic device can determine the list of operation buttons corresponding to the target resource type in the target configuration file.
[0027] Step S103: Based on the static configuration information of the target operation button, determine at least one resource state condition corresponding to the target operation button, and determine the initial matrix corresponding to the target operation button.
[0028] The target operation button can be any one of the operation buttons corresponding to the target resource type.
[0029] Specifically, under the target resource type, different operation buttons correspond to different resource status conditions. For example, the electronic device can store the mapping relationship between the identification information of the operation button and the resource status conditions. Therefore, the electronic device can determine at least one resource status condition corresponding to the target operation button based on the identification information of the target operation button and the mapping relationship.
[0030] The initial matrix size can be the same for different operation buttons, and the electronic device can directly obtain the preset initial matrix. Alternatively, the initial matrix size can be different for different operation buttons. The electronic device can store the mapping relationship between the identification information of the operation buttons and the initial matrix, and then determine the initial matrix corresponding to the target operation button based on the identification information of the target operation button and the mapping relationship.
[0031] Step S104: Based on the resource status information and at least one resource status condition, set the elements in the initial matrix to obtain the target matrix.
[0032] Specifically, resource status conditions can indicate the conditions that the resource status needs to meet when the operation button displays specified content. Resource status information can indicate the status of the target instance. Accordingly, the electronic device can analyze the resource status information to determine the resource status conditions that it meets and the resource status conditions that it does not meet. Then, based on the analysis results, the values of the elements in the initial matrix can be set. For example, the values of the elements corresponding to the met resource status conditions can be set to 1, and the values of the elements corresponding to the unmet resource conditions can be set to 0.
[0033] Step S105: Determine the active state of the target operation button based on the target matrix and preset matrix conditions, and pass the active state of the target operation button to the target operation component of the target instance.
[0034] The activity status can include display status, usage status, and disable prompt information. The display status indicates whether the operation button is displayed, including both displayed and hidden states. The usage status indicates whether the operation button is disabled or enabled, including both disabled and enabled states. The disable prompt information is the reason for disabling the operation button when its usage status is disabled. For example, if the target instance is powered on, the power-on operation button is disabled, and the disable prompt reason is that the target instance is already powered on.
[0035] The initial activity state mentioned above may include the default display state, usage state, and disabled prompt information. The initial activity state can be changed after the resource status information of the instance changes, that is, the activity state is determined in real time.
[0036] Specifically, matrix conditions can be used to indicate the conditions that the matrix must meet when an operation button displays specified content. Correspondingly, the electronic device can analyze the target matrix to determine whether it conforms to the preset matrix conditions, and analyze the results (i.e., whether the matrix conditions are met) to determine the active state of the target operation button. For example, a specified logical operation can be performed on the elements of the target matrix to obtain the final operation result. Based on the operation result, the active state corresponding to the operation result is determined as the active state of the target operation button.
[0037] Furthermore, the target operation component can obtain the target resource type through an external configuration interface (e.g., "props"). Then, it can use the target resource type to determine the static configuration information of at least one operation button corresponding to the target resource type from the target configuration file.
[0038] Finally, the electronic device can pass the activity state of the target operation button to the target operation component of the target instance through the aforementioned external configuration interface. The target operation component can then render and display the target operation button according to its activity state and static configuration information.
[0039] refer to Figure 2 The resource type parameter can be represented by "type" to indicate the resource type of the instance. The grouping parameter can be represented by "group" to indicate whether the operation column is grouped. The display status parameter can be represented by "hidden" to indicate whether the operation button is displayed. The usage status parameter can be represented by "disabled" to indicate whether the operation button is available. The operation component can read the corresponding static configuration information from the btn.xml file based on the passed resource type parameter, as well as the passed grouping parameter, display status parameter, and usage status parameter, and render the operation button accordingly.
[0040] The method for determining the activity state of an operation button according to an embodiment of this application first obtains the target resource type and resource status information of the target instance. Then, based on the target resource type, the static configuration information of the corresponding operation button is determined. For the target operation button, the corresponding resource status conditions and initial matrix can be determined based on its static configuration information. Further, based on the real-time obtained resource status information and resource status conditions, the elements in the initial matrix are numerically set to obtain the target matrix. Based on the target matrix and preset matrix conditions, the activity state of the target operation button is determined and input to the target operation component of the target instance. Finally, the target operation component only needs to render and display the target operation button based on the input activity state and static configuration information. Under this scheme, for operation buttons of the same type under the same resource type, each instance can share the same code to determine the activity state of the operation button and finally input the activity state into the operation component of the instance, which can reduce the amount of code in the operation component and avoid code redundancy.
[0041] Specifically, each instance corresponds to an operation component, which is dedicated to rendering operation buttons. In related technologies, each operation component internally hard-codes the logic for setting the activity state of various operation buttons. For each type of operation button, its activity state depends on the instance's resource state information. With a large number of resource state information entries and numerous combinations of conditional logic (e.g., if-else statements), the operation component's code becomes quite redundant. With a large number of instances, the increased code further exacerbates the code redundancy problem. In this solution, for the same type of operation button across all instances of the same resource type, the same rule can be used to determine the activity state, which is then directly input into the instance's operation component. The operation component can then render the corresponding operation button according to the input activity state. This eliminates the need for complex conditional logic within the operation component; instead, it can directly render the operation button based on the input activity state (i.e., a data-driven approach), significantly reducing the amount of code.
[0042] In some optional implementations, a resource status condition may correspond to the position of an element in the initial matrix. Accordingly, step S104 above, which sets the elements in the initial matrix according to the resource status information and at least one resource status condition to obtain the target matrix, may include the following specific steps: Step 1: Based on the target resource status and the first resource status condition, determine the target judgment result of the first resource status condition.
[0043] Step 2: Based on the first resource state condition and the pre-constructed mapping relationship between resource state conditions and element positions, determine the position of the first element corresponding to the first resource state condition in the initial matrix.
[0044] Step 3: Based on the target judgment result, determine the first value corresponding to the target judgment result.
[0045] Step four: Assign the first value to the first element at the first element position to complete the setting operation corresponding to the first resource state condition.
[0046] Step 5: After completing the setting operations corresponding to various resource status conditions, the target matrix is obtained.
[0047] Wherein, the first resource state condition is any one of at least one resource state conditions, and the target resource state is the resource state corresponding to the first resource state condition among at least one resource states.
[0048] Specifically, taking the first resource state condition as an example, the electronic device can determine the corresponding target resource state from the resource state information, determine whether the target resource state meets the first resource state condition, and obtain the target judgment result, which is either compliant or non-compliant.
[0049] Since an element position in the initial matrix can correspond to a resource state condition, the electronic device can determine the first element position corresponding to the first resource state condition based on the first resource state condition and the pre-constructed mapping relationship between the resource state condition and the element position.
[0050] Then, the electronic device can obtain the first value corresponding to the target judgment result based on the target judgment result, and set the value of the first element in the initial matrix at the first element position to the first value (for example, the first value can be 1). For any resource state condition, the electronic device can perform the corresponding setting operation in a similar manner. Thus, after completing the setting operations corresponding to various resource state conditions, the final target matrix can be obtained.
[0051] For example, the first resource trigger condition is [status != "open"]. That is, when it is determined that the target instance's status is not equal to "on", the first resource status meets the first resource trigger condition. In this case, the value of the corresponding element in the second row can be set to 1. When it is determined that the target instance's status is equal to "on", the first resource status does not meet the first resource trigger condition. In this case, the value of the corresponding element in the second row can be set to 0. That is, when the target instance is in the "on" state, the "on" operation button must be grayed out, and clicking the "on" operation button is prohibited.
[0052] In this way, by mapping resource status conditions to element positions and setting values for elements in the initial matrix, a single code can be reused for the same operation button of the same resource type. This eliminates the need to set complex code logic based on different combinations of resource statuses, thus reducing the amount of code.
[0053] In some optional implementations, each row in the matrix can correspond to matrix conditions of different properties, and the priority of each row can be different. Generally, the priority of the rows decreases from top to bottom. Therefore, in the process of determining the active state of the target operation button, each row in the matrix can be analyzed sequentially according to its priority from high to low. For example, in step S105 above, determining the active state of the target operation button based on the target matrix and preset matrix conditions can include the following specific steps: Step 1: Determine whether the elements in the first row of the target matrix satisfy the matrix conditions corresponding to the first row.
[0054] Step 2: If the elements in the first row satisfy the matrix conditions corresponding to the first row, the enabled state is determined as the active state of the target operation button.
[0055] Alternatively, in step three, if it is determined that the elements in the first row of the target matrix do not satisfy the matrix conditions corresponding to the first row, determine whether the elements in the middle row of the target matrix satisfy the matrix conditions corresponding to the middle row.
[0056] Step 4: If the elements in the middle row satisfy the matrix conditions corresponding to the middle row, the disabled state is determined as the active state of the target operation button.
[0057] Alternatively, in step five, if it is determined that the elements in the middle row do not meet the matrix conditions corresponding to the middle row, perform target logical operations on the elements in the last row of the target matrix to obtain the target operation result.
[0058] Step 6: Based on the target calculation result, determine the state corresponding to the target calculation result as the active state of the target operation button.
[0059] In this context, middle row elements refer to all row elements other than the first and last row elements.
[0060] Specifically, the electronic device can first determine whether the first row of the target matrix satisfies the matrix conditions corresponding to the first row. If so, the enabled state can be directly determined as the active state of the target operation button. If not, it can continue to determine whether the middle row of the elements satisfies the matrix conditions corresponding to the middle row. If so, the disabled state can be determined as the active state of the target operation button. If not, it can continue to perform the specified target logic operation on the last row of the elements to obtain the final target operation result.
[0061] like Figure 3 As shown, the resource status condition corresponding to the first row element can be a higher priority permission condition. Furthermore, the matrix condition corresponding to the first row can be that there exists an element in the first row with a value equal to the second value, where the second value can be 1. Accordingly, when it is determined that any element in the first row of the target matrix has a value equal to the second value, it can be determined that the first row element satisfies the matrix condition corresponding to the first row.
[0062] The resource status condition corresponding to the middle row element can be a high-priority hard constraint condition. Therefore, the matrix condition corresponding to the middle row can be that there exists an element in the middle row with a value that is the third value, which is different from the second value and can be 0. Accordingly, when it is determined that any element in the middle row of the target matrix has the third value, it can be determined that the middle row element satisfies the matrix condition corresponding to the middle row.
[0063] The resource status conditions corresponding to the trailing element can be default fallback conditions, that is, relatively ordinary conditions. This layer of analysis is only performed when there is no quick permission or explicit prohibition. Accordingly, in step five above, the electronic device can perform target logic operations on the maintenance element, obtain the target operation result, and then determine the status corresponding to the target operation result based on the target operation result, and determine the determined status as the usage status of the target operation button.
[0064] Thus, the matrix conditions described above are set according to different properties (i.e., Figure 3 The data acquisition control is disabled, offering high flexibility. Furthermore, by clearly defining the order in which different conditions take effect, the execution logic is rigorous, accurately determining the usage status of the target operation button.
[0065] It should be noted that the matrix conditions mentioned above can be flexibly set according to the needs of the operation buttons. For example, matrix conditions can be set by column or by the entire matrix.
[0066] In some alternative implementations, some operation buttons may only require one or two of the above three matrix conditions. Accordingly, the electronic device can perform the following specific steps: Before performing the matrix element analysis for the target operation button, the identification information of the candidate rows can be obtained first. This candidate row identification information indicates the row to be analyzed. Then, the electronic device can determine the type of the candidate row based on its identification information and the mapping relationship between row identification information and row type. Subsequently, it can determine the target matrix conditions corresponding to the candidate row type from preset matrix conditions, and compare the elements in the candidate row with the matrix conditions to determine whether the elements satisfy the matrix conditions. If yes, the enabled state can be determined as the target operation button's usage state; otherwise, the disabled state can be determined as the target operation button's usage state.
[0067] For example, for the edit operation button, the three resource status conditions are: support for hot editing, tools installed, and not under maintenance. If any one of these conditions is not met, the edit operation button cannot be used. Therefore, it can be placed in the second row of the target matrix, which is also the candidate row. The second row is a middle row, and the matrix conditions of the middle row can be used to analyze whether the elements of the middle row meet the conditions for enabling the edit operation button. If the current target instance's resource status is support for hot editing, tools not installed, and under maintenance, the corresponding values are [1, 0, 1]. If there is an element with a value of 0, then the disabled state can be determined as the edit button's usable state.
[0068] In this way, the conditions used can be flexibly set according to the actual needs of the operation buttons. Furthermore, during the coding process, there is no need to write different matrix condition codes for different operation buttons; instead, the corresponding matrix condition codes can be selected for analysis directly through the identifier information of the candidate rows, further reducing the amount of code and solving the problem of code redundancy.
[0069] In some alternative implementations, the target logical operation can be an AND logical operation, and accordingly, step six above may include the following specific steps: Step 1: If the target calculation result is determined to be the second value, the enabled state is set as the usage state of the target operation button.
[0070] Alternatively, in step 2, if the target calculation result is determined to be the third value, the enabled state is determined to be the usage state of the target operation button.
[0071] Specifically, when the target operation result is determined to be the second value, it can be assumed that all elements in the trailing row have the second value. This means the resource status of the target instance meets the condition for enabling the target operation button. In this case, the enabled state can be directly determined as the usage state of the target operation button. When the target operation result is determined to be the third value, it can be assumed that there are elements in the trailing row with the third value. This means the resource status of the target instance does not meet the condition for enabling the target operation button. In this case, the disabled state can be determined as the usage state of the target operation button.
[0072] Example 1: The target matrix is a 3x3 matrix, represented as [[1, 0, 0], [0, 1, 1], [0, 0, 1]]. For the first row, there is an element with a value of 1. In this case, the enabled state can be directly determined as the usage state of the target operation button, without needing to analyze the subsequent elements.
[0073] Example 2: The target matrix is a 3x3 matrix, represented as [[0, 0, 0], [0, 1, 1], [0, 0, 1]]. For the first row, there is no element with a value of 1, that is, all elements have a value of 0. At this time, we can analyze the second row. There is an element with a value of 0 in the second row. Therefore, we can directly determine the disabled state as the enabled state of the target operation button, without needing to analyze the subsequent elements.
[0074] Example 3: The target matrix is a 3x3 matrix, represented as [[0, 0, 0], [1, 1, 1], [0, 0, 1]]. For the first row, there is no element with a value of 1, that is, all elements have a value of 0. At this time, we can analyze the second row. There is no element with a value of 0 in the second row. We can perform an AND operation on the values of the third row, and the result is 0. Therefore, the disabled state can be determined as the enabled state of the target operation button.
[0075] In some optional implementations, the target matrix may include a number of elements greater than the number of enabled resource state conditions. In the target matrix, enabled element positions can be marked as a first state, i.e., unlocked, and disabled element positions can be marked as a second state, i.e., locked. In the locked state, the value of the element at that position can be a default value, for example, 1. After an element position is enabled, i.e., marked as unlocked, the value of the element at that position can be updated according to the resource state corresponding to the resource state condition at that position. Accordingly, the electronic device may also perform the following specific steps: Step 1: Obtain the updated status conditions of the third resource.
[0076] Step 2: Based on the third resource state condition and the mapping relationship between the resource state condition and the element position, determine the position of the third element corresponding to the third resource state condition.
[0077] Step 3: Unlock the third element position so that the value of the third element at the third element position can be updated according to the real-time acquired third resource status.
[0078] The third resource state can be a resource state corresponding to the third resource state condition.
[0079] Specifically, please refer to Figure 3 After acquiring the third resource status condition that needs to be updated (i.e., adding data), the electronic device can determine the position of the third element corresponding to the third resource status condition based on the third resource status condition and the mapping relationship between the resource status condition and the element position. Then, the third element position can be unlocked, i.e., enabled, so that the value of the third element at the third element position can be updated based on the real-time acquired third resource status, rather than simply maintaining the default value.
[0080] Therefore, in related technologies, adding a new resource state condition requires rewriting the code, which is inconvenient. This solution, however, only requires enabling the corresponding element position, eliminating the need for code writing, making it more convenient and efficient.
[0081] In some alternative implementations, refer to Figure 3 When data needs to be deleted, electronic devices can perform the following operations: The fourth resource status condition to be deleted is obtained. Based on the fourth resource status condition and the mapping relationship between resource status conditions and element positions, the position of the fourth element corresponding to the fourth resource status condition is determined. Furthermore, the fourth element position can be locked, i.e., disabled.
[0082] Therefore, for deletion operations, this solution only requires disabling them without modifying the code, which is quite convenient.
[0083] In some alternative implementations, refer to Figure 3 When data needs to be updated, electronic devices can perform the following operations: Obtain the fifth resource state condition to be updated, determine the original resource state condition corresponding to the fifth resource state condition based on the mapping relationship between resource state conditions and element positions, and replace the original resource state condition with the fifth resource state condition.
[0084] In some optional implementations, after determining the disabled state as the active state of the target operation button, a disabled prompt message for the target operation button can be further determined. Accordingly, the electronic device can also perform the following specific steps: Step 1: Identify the second element in the target matrix whose value is the third value, and determine the position of the second element in the target matrix.
[0085] Step 2: Based on the position of the second element and the mapping relationship between the resource status conditions and the element positions, determine the second resource status condition corresponding to the position of the second element.
[0086] Step 3: Based on the second resource status conditions, determine the disabled prompt message for the target operation button.
[0087] Specifically, since the resource status condition for indicating the activation button is not met, the electronic device can identify the second element in the target matrix whose value is the third value. This second element can be one or more elements. Alternatively, since some element positions in the target matrix may not be enabled, it can identify only whether the value of the element at the unlocked position in the target matrix is the third value; that is, determine the value of the corresponding element at the unlocked position. Furthermore, if the aforementioned disabled state is obtained through analysis of the middle row elements, the electronic device can determine the second element with the third value in the middle row elements of the target matrix. If the aforementioned disabled state is obtained through analysis of the tail row elements, the electronic device can determine the second element with the third value in the tail row elements of the target matrix.
[0088] After identifying the second element, the electronic device can determine the position of each second element in the target matrix. Then, based on the mapping relationship between resource status conditions and element positions, it can determine the second resource status condition corresponding to each second element position. Finally, the electronic device can determine that any failure to meet the second resource status condition will result in a disabled prompt message for the target operation button.
[0089] In traditional hard-coding, developers not only need to write logic to determine whether a button is disabled, but also typically need to manually write and assign the corresponding disabled message in the same if-else branch. This easily leads to errors where the message doesn't match the logic, or certain scenarios are missed. This solution, however, only needs to identify the position of the element with the third value to determine the corresponding disabled message, eliminating the need for any additional logic in the rendering process, thus reducing code size. Furthermore, updating the message only requires modifying the description text in the mapping relationship; there's no need to modify the logic, component code, or matrix calculation rules, making it more convenient and efficient.
[0090] In some alternative implementations, the display state described above can also be determined in a similar manner to the usage state, which will not be elaborated here.
[0091] This allows for comprehensive control over active states such as usage status, display status, and disabled prompts. Controlling each state reduces the amount of code, thereby reducing the amount of code related to active state control in the operation component and avoiding code redundancy.
[0092] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.
[0093] Embodiments of this application also provide a device for determining the active state of an operation button, such as... Figure 4 As shown, it includes: Module 410 is used to obtain the target resource type and resource status information of the target instance; The determination module 420 is used to determine, based on the target resource type, the static configuration information of at least one operation button corresponding to the target resource type; based on the static configuration information of the target operation button, determine at least one resource state condition corresponding to the target operation button, and determine an initial matrix corresponding to the target operation button, wherein the target operation button is any one of the at least one operation button; based on the resource state information and at least one resource state condition, set the elements in the initial matrix to obtain the target matrix; based on the target matrix and the preset matrix conditions, determine the activity state of the target operation button, and pass the activity state of the target operation button to the target operation component of the target instance, so that the target operation component can render and display the target operation button according to the activity state and static configuration information of the target operation button.
[0094] In some optional implementations, the resource status information includes at least one resource status; the determination module 420 is specifically used for: Based on the first resource state condition and the target resource state, determine the target judgment result of the first resource state condition, wherein the first resource state condition is any one of at least one resource state condition, and the target resource state is the resource state corresponding to the first resource state condition among at least one resource states. Based on the first resource state condition and the pre-constructed mapping relationship between the resource state condition and the element position, the position of the first element corresponding to the first resource state condition is determined in the initial matrix. Based on the target judgment result, determine the first value corresponding to the target judgment result; Assign the first value to the first element at the first element position to complete the setting operation corresponding to the first resource state condition; After completing the setting operations corresponding to at least one resource state condition, the target matrix is obtained.
[0095] In some optional implementations, the active state of the target operation button includes at least the usage state of the target operation button; the determining module 420 is specifically used for: Determine whether the elements in the first row of the target matrix satisfy the matrix conditions corresponding to the first row; If the elements in the first row satisfy the matrix conditions corresponding to the first row, the enabled state will be determined as the usage state of the target operation button. Alternatively, if it is determined that the elements in the first row of the target matrix do not satisfy the matrix conditions corresponding to the first row, determine whether the elements in the middle row of the target matrix satisfy the matrix conditions corresponding to the middle row. If the elements in the middle row satisfy the matrix conditions corresponding to the middle row, the disabled state will be determined as the enabled state of the target operation button. Alternatively, if it is determined that the elements in the middle row do not satisfy the matrix conditions corresponding to the middle row, the target logical operation is performed on the elements in the last row of the target matrix to obtain the target operation result; Based on the target calculation result, the state corresponding to the target calculation result is determined as the usage state of the target operation button.
[0096] In some optional implementations, the matrix condition corresponding to the first row is that there is an element in the first row with a value of the second value, and the matrix condition corresponding to the middle row is that there is an element in the middle row with a value of the third value.
[0097] In some alternative implementations, the determining module 420 is specifically used for: If the target calculation result is determined to be the second value, the enabled state will be determined as the usage state of the target operation button; Alternatively, if the target calculation result is determined to be a third value, the disabled state can be determined as the enabled state of the target operation button.
[0098] In some optional implementations, the active state of the target operation button also includes a disabled prompt message for the target operation button; the determining module 420 is further configured to: After determining the disabled state as the active state of the target operation button, identify the second element in the target matrix whose value is the third value, and determine the position of the second element in the target matrix. Based on the position of the second element and the mapping relationship between the resource state conditions and the element positions, determine the second resource state condition corresponding to the position of the second element; Based on the second resource status condition, determine the disabled prompt message for the target operation button.
[0099] In some alternative embodiments, the device further includes an update module 430 for: Get the updated status conditions of the third resource; Based on the third resource state condition and the mapping relationship between the resource state condition and the element position, determine the position of the third element corresponding to the third resource state condition; The third element position is unlocked so that the value of the third element at the third element position can be updated according to the real-time acquired third resource status. The third resource status is the resource status corresponding to the third resource status condition.
[0100] For a description of the features in the embodiment corresponding to the device for determining the active state of the operation button, please refer to the relevant description in the embodiment corresponding to the method for determining the active state of the operation button, which will not be repeated here.
[0101] Embodiments of this application also provide an electronic device, such as... Figure 5 As shown, it includes a memory 10 and a processor 20. The memory 10 stores a computer program, and the processor 20 is configured to run the computer program to perform the steps in the embodiment of the method for determining the active state of any of the operation buttons described above.
[0102] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in the embodiments of the method for determining the active state of any of the above-described operation buttons when it is run.
[0103] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0104] The embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in the embodiments of the method for determining the active state of any of the above-described operation buttons.
[0105] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in the embodiments of the method for determining the active state of any of the above-described operation buttons.
[0106] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0107] The foregoing has provided a detailed description of the method, apparatus, electronic device, storage medium, and program product for determining the active state of an operation button provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.
Claims
1. A method for determining the active state of an operation button, characterized in that, include: Obtain the target resource type and resource status information of the target instance; Based on the target resource type, determine the static configuration information of at least one operation button corresponding to the target resource type; Based on the static configuration information of the target operation button, at least one resource status condition corresponding to the target operation button is determined, and an initial matrix corresponding to the target operation button is determined, wherein the target operation button is any one of at least one of the operation buttons; Based on the resource status information and at least one of the resource status conditions, the elements in the initial matrix are set to obtain the target matrix; Based on the target matrix and preset matrix conditions, the activity state of the target operation button is determined, and the activity state of the target operation button is passed to the target operation component of the target instance, so that the target operation component renders and displays the target operation button according to the activity state and static configuration information of the target operation button.
2. The method for determining the active state of an operation button according to claim 1, characterized in that, The resource status information includes at least one resource status; the step of setting the elements in the initial matrix according to the resource status information and at least one resource status condition to obtain the target matrix includes: Based on the first resource state condition and the target resource state, the target judgment result of the first resource state condition is determined, wherein the first resource state condition is any one of at least one of the resource state conditions, and the target resource state is at least one of the resource states that corresponds to the first resource state condition. Based on the first resource state condition and the pre-constructed mapping relationship between resource state conditions and element positions, the position of the first element corresponding to the first resource state condition is determined in the initial matrix. Based on the target judgment result, determine the first value corresponding to the target judgment result; Assign the first value to the first element at the first element position to complete the setting operation corresponding to the first resource state condition; After completing the setting operations corresponding to at least one of the resource state conditions, the target matrix is obtained.
3. The method for determining the active state of an operation button according to claim 1 or 2, characterized in that, The active state of the target operation button includes at least the usage state of the target operation button; determining the active state of the target operation button based on the target matrix and preset matrix conditions includes: Determine whether the elements in the first row of the target matrix satisfy the matrix conditions corresponding to the first row; If it is determined that the first row element satisfies the matrix condition corresponding to the first row, the enabled state is determined as the usage state of the target operation button; Alternatively, if it is determined that the elements in the first row of the target matrix do not satisfy the matrix conditions corresponding to the first row, it is determined whether the elements in the middle row of the target matrix satisfy the matrix conditions corresponding to the middle row. If it is determined that the middle row element satisfies the matrix condition corresponding to the middle row, the disabled state is determined as the usage state of the target operation button; Alternatively, if it is determined that the middle row element does not satisfy the matrix condition corresponding to the middle row, target logical operation is performed on the tail row element of the target matrix to obtain the target operation result; Based on the target calculation result, the state corresponding to the target calculation result is determined as the usage state of the target operation button.
4. The method for determining the active state of an operation button according to claim 3, characterized in that, The matrix condition corresponding to the first row is that there is an element in the first row with a value of the second value, and the matrix condition corresponding to the middle row is that there is an element in the middle row with a value of the third value.
5. The method for determining the active state of an operation button according to claim 3, characterized in that, The step of determining the state corresponding to the target calculation result as the usage state of the target operation button based on the target calculation result includes: If the target calculation result is determined to be the second value, the activation state is determined to be the usage state of the target operation button; Alternatively, if the target calculation result is determined to be a third value, the disabled state can be determined as the usage state of the target operation button.
6. The method for determining the active state of an operation button according to claim 4 or 5, characterized in that, The active status of the target operation button also includes a disabled prompt message for the target operation button; After determining the disabled state as the active state of the target operation button, the method further includes: Identify the second element in the target matrix whose value is the third value, and determine the position of the second element in the target matrix; Based on the position of the second element and the mapping relationship between the resource status condition and the element position, determine the second resource status condition corresponding to the position of the second element; Based on the second resource status condition, determine the disabled prompt message for the target operation button.
7. The method for determining the active state of an operation button according to claim 4, characterized in that, The method further includes: Get the updated status conditions of the third resource; Based on the third resource state condition and the mapping relationship between the resource state condition and the element position, determine the third element position corresponding to the third resource state condition; The position of the third element is unlocked so that the value of the third element at the position of the third element is updated according to the real-time acquired third resource status, wherein the third resource status is the resource status corresponding to the third resource status condition.
8. A device for determining the active state of an operation button, characterized in that, include: The acquisition module is used to obtain the target resource type and resource status information of the target instance; The determining module is used to determine the static configuration information of at least one operation button corresponding to the target resource type based on the target resource type; Based on the static configuration information of the target operation button, at least one resource status condition corresponding to the target operation button is determined, and an initial matrix corresponding to the target operation button is determined, wherein the target operation button is any one of at least one of the operation buttons; Based on the resource status information and at least one of the resource status conditions, the elements in the initial matrix are set to obtain a target matrix; based on the target matrix and preset matrix conditions, the activity state of the target operation button is determined, and the activity state of the target operation button is passed to the target operation component of the target instance, so that the target operation component renders and displays the target operation button according to the activity state and static configuration information of the target operation button.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the method for determining the active state of an operation button as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the method for determining the active state of an operation button as described in any one of claims 1 to 7.