Form component execution method and device, electronic equipment and storage medium
By determining the linkage relationship and execution order of form components by pre-installed graphs, the problem of inconsistent linkage results of form components in low-code platforms is solved, ensuring the consistency of linkage results and system stability.
Patent Information
- Application Number
- CN202510406524.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-18
AI Technical Summary
The low-code platform cannot execute the linkage of form components in a reasonable order, resulting in the linkage results being unpredictable and may lead to errors.
Through the pre-set directional graph, the linkage relationship and execution order between form components are determined, and the execution functions of form components are executed in the preset order to ensure the consistency of linkage results.
It realizes the expected consistency of the results of form components linkage, reduces error occurrence, and improves system stability and user satisfaction.
Smart Images

Figure CN120335896A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular, to a method, device, electronic device, and storage medium for executing form components. Background Art
[0002] Currently, although most low-code platforms can support the component linkage function of automatically generating forms, they can only operate normally in some relatively simple linkage scenarios. For example, these platforms can operate normally when form components are only affected by a single linkage method.
[0003] Most low-code platforms cannot execute the linkages of form components in a reasonable order, but trigger linkage functions in an uncertain order. This will make the final linkage result of the form unpredictable. Different execution orders of linkage functions will result in different final linkage results of the form, which may cause the linkage result to be different from the expectation and lead to errors.
[0004] Therefore, there is an urgent need for a method for executing form components to make the final execution result (i.e., the linkage result) consistent with the expectation. Summary of the Invention
[0005] Embodiments of this application provide a method, device, electronic device, and storage medium for executing form components to make the final execution result (i.e., the linkage result) consistent with the expectation.
[0006] In a first aspect, an embodiment of this application provides a method for executing form components, including:
[0007] Determine a first form component, where the first form component is a form component whose state changes in response to a user operation;
[0008] According to a preset directed graph, determine a second set of form components that have a linkage relationship with the first form component, where the second set of form components includes multiple second form components, and the linkage relationship indicates that a state change of the first form component will cause a state change of the second form component, and the preset directed graph represents the linkage relationship and execution order between form components;
[0009] According to the preset directed graph and the second set of form components, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components according to the execution order of the second form components.
[0010] In a possible implementation manner, determining the second set of form components that have a linkage relationship with the first form component according to the preset directed graph includes:
[0011] According to the preset directed graph, determine an initial second set of form components that have a linkage relationship with the first form component;
[0012] Based on the change of the state of the first form component, obtain the return value of the linkage condition function, where the return value represents whether the target form component meets the condition state change condition, and the condition state change condition represents that the changed state of the first form component can cause the target form component to send a state change, and the target component is any form component in the initial second form component;
[0013] Based on the return value of the linkage condition function and the initial second form component set, determine the third form component, where the third form component is the form component in the initial second form component set that does not meet the condition state change condition;
[0014] Remove the third form component from the initial second form component set to obtain the second form component set.
[0015] In a possible implementation manner, based on the preset directed graph and the second form component set, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components according to the execution order of the second form components, including:
[0016] Create an execution function call stack, where the execution function call stack is used to execute the execution functions corresponding to the second form components according to the execution order of the second form components;
[0017] Determine the fourth form component, where the fourth form component is any form component in the second form component set;
[0018] Based on the execution weights in the directed graph, obtain the execution order of multiple execution functions of the fourth form component, where there is a corresponding relationship between the execution weights and the execution order of the execution functions;
[0019] According to the execution order of the execution functions of the fourth form component, push the execution functions of the fourth form component corresponding to the execution order onto the function call stack;
[0020] Based on the preset directed graph and the second form component set, determine the first subset of vertices to be processed with dependencies in the second form component set, where the form components in the first subset of vertices to be processed with dependencies need to be executed prior to the fourth form component;
[0021] Based on the first subset of vertices to be processed with dependencies, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components according to the execution order of the second form components.
[0022] In a possible implementation manner, based on the first subset of vertices to be processed with dependencies, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components according to the execution order of the second form components, including:
[0023] If the first subset of dependent vertices to be processed is empty, execute the execution function of the fourth form component. After the execution function of the fourth form component is executed, remove the corresponding execution function of the fourth form component from the function call stack;
[0024] When all the execution functions of the fourth form component are executed, remove the fourth form component from the second set of form components to obtain an updated second set of form components;
[0025] Take any form component in the updated second set of form components as the fourth form component, and execute the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the updated second set of form components is empty.
[0026] In a possible implementation, the method further includes:
[0027] If the first subset of dependent vertices to be processed is not empty, determine the fifth form component, where the fifth form component is any form component in the first subset of dependent vertices to be processed;
[0028] According to the preset directed graph and the second set of form components, determine the second subset of dependent vertices to be processed in the second set of form components, where the second subset of dependent vertices to be processed is executed prior to the fifth form component;
[0029] If the second subset of dependent vertices to be processed is not empty, determine the sixth form component and loop until there is a final form component, where the sixth form component is any form component in the second subset of dependent vertices to be processed, and the subset of dependent vertices to be processed of the final form component is empty;
[0030] According to the execution weights in the directed graph, obtain the execution order of multiple execution functions of the final form component, where there is a corresponding relationship between the execution weights and the execution order of the execution functions;
[0031] Push the execution functions of the final form component corresponding to the execution order onto the function call stack according to the execution order of the execution functions of the final form component;
[0032] Execute the execution function of the final form component. After the execution function of the final form component is executed, remove the corresponding execution function of the final form component from the function call stack;
[0033] When all the execution functions of the final form component are executed, remove the final form component from the second set of form components to obtain an updated second set of form components;
[0034] Update any form component in the second form component set as the fourth form component, and perform the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the second form component set is empty.
[0035] In a possible implementation manner, the method further includes:
[0036] Obtain a linkage action structure, where the linkage action structure includes at least an influencing source component, an affected source component, an action type, an execution function, and an execution weight. The influencing source component represents a form component that causes a state change in other form components. The affected source component is the form component whose state is caused to change. The action type represents the type of the linkage action. The execution function represents the actual action of the linkage action. The execution weight represents the execution order of the execution action;
[0037] Obtain a preset directed graph according to the linkage action structure.
[0038] In a possible implementation manner, when the preset directed graph is a cross linked list, obtaining a preset directed graph according to the linkage action structure includes:
[0039] Obtain the vertices of the cross linked list according to the influencing source component, the affected source component, the action type, the execution weight, and the execution function. The vertices of the cross linked list include a first incoming arc pointer, an outgoing arc pointer, the form component attributes corresponding to the vertex, and an execution function list. The outgoing arc pointer points to the first arc with the vertex of the cross linked list as the arc tail. The first incoming arc pointer points to the first arc with the vertex of the cross linked list as the arc head. The execution function list is the function that needs to be executed. The vertices of the cross linked list represent form components. The form component attributes corresponding to the vertex are the attributes of the form component corresponding to the vertex of the cross linked list;
[0040] Obtain the arcs of the cross linked list according to the influencing source component and the affected source component. The arcs of the cross linked list include an arc head, an arc tail, a next same arc head pointer, and a next same arc tail pointer. The next same arc head pointer points to the next arc with the same arc head. The next same arc tail pointer points to the next arc with the same arc tail. The arc represents the linkage relationship and execution order between form components. The arc head represents the vertex of the cross linked list whose state is caused to change. The arc tail represents the vertex of the cross linked list that causes the state change. The arc head and the arc tail have a corresponding relationship;
[0041] Obtain a preset directed graph according to the vertices of the cross linked list and the arcs of the cross linked list.
[0042] In a second aspect, an embodiment of the present application provides a form component execution device, including:
[0043] The first determination module is configured to determine a first form component, where the first form component is a form component whose state changes in response to a user operation.
[0044] The second determination module is configured to determine a set of second form components having a linkage relationship with the first form component according to a preset directed graph, where the set of second form components includes multiple second form components, and the linkage relationship indicates that a state change of the first form component will cause a state change of the second form components, and the preset directed graph represents the linkage relationship and execution order between form components.
[0045] The third determination module is configured to determine the execution order of the second form components according to the preset directed graph and the set of second form components, and execute the execution functions corresponding to the second form components in accordance with the execution order of the second form components.
[0046] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0047] The memory stores computer execution instructions;
[0048] The processor executes the computer execution instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementation manners of the first aspect.
[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored, and when the computer execution instructions are executed by a processor, they are used to implement the above first aspect and / or various possible implementation manners of the first aspect.
[0050] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the above first aspect and / or various possible implementation manners of the first aspect.
[0051] The embodiments of the present application provide a method, an apparatus, an electronic device, and a storage medium for executing a form component. By determining a first form component, where the first form component is a form component whose state changes in response to a user operation; according to a preset directed graph, determining a second set of form components having a linkage relationship with the first form component, where the second set of form components includes multiple second form components, and the linkage relationship indicates that a state change of the first form component will cause a state change of the second form component, and the preset directed graph represents the linkage relationship and execution order among form components; according to the preset directed graph and the second set of form components, determining the execution order of the second form components, and executing the execution functions corresponding to the second form components according to the execution order of the second form components. By means of the preset directed graph, a second set of form components having a linkage relationship with the first form component is determined, and by means of the preset directed graph and the second set of form components, the execution order of the second form components is determined. Through the preset directed graph, the execution functions of the execution functions of each form component are confirmed to prevent the call order from being chaotic, resulting in an error in the pointing result of the finally obtained form component, and enabling the linkage to be more flexible. Description of the Drawings
[0052] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present application and used together with the specification to explain the principles of the present application.
[0053] Figure 1 It is a schematic flowchart of the method for executing a form component provided by the present application;
[0054] Figure 2 It is a schematic structural diagram of a linkage action provided by an embodiment of the present application;
[0055] Figure 3 It is a schematic structural diagram of a vertex of a cross-linked list provided by an embodiment of the present application;
[0056] Figure 4 It is a schematic structural diagram of an arc of a cross-linked list provided by an embodiment of the present application;
[0057] Figure 5 It is a schematic flowchart of another method for executing a form component provided by the present application;
[0058] Figure 6 It is a schematic diagram of a directed graph provided by an embodiment of the present application;
[0059] Figure 7 It is a schematic structural diagram of a cross-linked list provided by an embodiment of the present application;
[0060] Figure 8 It is a schematic structural diagram of the apparatus for executing a form component provided by the present application;
[0061] Figure 9 Structural schematic diagram of the electronic device provided by this application;
[0062] Through the above-mentioned drawings, specific embodiments of this application have been shown, and more detailed descriptions will be provided hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of this application in any way, but to illustrate the concept of this application to those skilled in the art by referring to specific embodiments. Specific embodiments
[0063] Here, exemplary embodiments will be described in detail, and examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numerals in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. On the contrary, they are merely examples of devices and methods consistent with some aspects of this application as detailed in the appended claims.
[0064] Currently, most low-code platforms cannot execute the linkage of form components in a reasonable order, but trigger the linkage functions in an uncertain order, which makes the final linkage result of the form unpredictable. And if you want the linkage to be triggered in a fixed order, programmers need to perform some additional manual operations on the linkage process, such as adding locks during function execution, to ensure the orderly execution of the functions, which goes against the concept of automation. In this case, although the product uses automated tools, programmers still need to manually add additional code to intervene in the linkage to obtain the desired effect, and there is no advantage of automation in terms of cost savings.
[0065] The form component execution method, device, electronic device, and storage medium provided by this application, by responding to user operations, cause the state of the first form component to change. Through a preset directed graph, determine the second form component set that has a linkage relationship with the first form component. The linkage relationship indicates that a change in the state of the first form component will cause a change in the state of the form components in the second form component set. At the same time, through the preset directed graph, determine the execution order of the second form components in the second form component set, and execute the execution functions corresponding to the second form components according to the execution order of the second form components. By presetting the linkage relationship between each form component and the execution order of the execution functions corresponding to the form components in advance through the preset directed graph, the execution result of the final form component meets the preset result, and at the same time, no other additional code needs to be added, reducing the workload.
[0066] The following uses specific embodiments to elaborate in detail on the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0067] Figure 1 It is a schematic flowchart of the method for executing a form component provided by the present application. As Figure 1 shown, the method includes:
[0068] S101. Determine the first form component, where the first form component is a form component whose state changes in response to a user operation.
[0069] Among them, a form component is: A form component is a basic element in user interface design, used to collect data input by users. These components can be used in various applications and websites for users to submit information, conduct searches, fill out registration forms, etc. Common form components include:
[0070] Text box: Used to input single-line text, such as name or email address.
[0071] Text area: Used to input multi-line text, such as comments or feedback.
[0072] Checkbox: Allows users to select one or more options from a group of options.
[0073] Radio button: Allows users to select one option from a group of options.
[0074] Drop-down menu: Provides a drop-down list for users to select.
[0075] Button: Used to submit the form or perform other operations.
[0076] Label: Used to describe or identify form elements.
[0077] File upload: Allows users to upload files.
[0078] Date picker: Used to select a date.
[0079] Slider: Used to select a value within a range.
[0080] Toggle switch: Used to switch the state between on and off.
[0081] The state change can refer to: The state change of a form component involves the conversion of the component between different states when the user interacts with the form. These state changes can affect the user experience and the functionality of the form. Specifically, it includes: The user enters content through an input box, and a certain option in the checkbox is selected.
[0082] S102. Determine a second set of form components that has a linkage relationship with the first form component according to a preset directed graph, where the second set of form components includes multiple second form components, and the linkage relationship indicates that a state change of the first form component will cause a state change of the second form component, and the preset directed graph represents the linkage relationship and execution order between form components.
[0083] Among them, the preset directed graph is a graphical structure, and the edges therein have directivity. This means that each edge points from one node to another node, rather than simply connecting two nodes. The preset directed graph can be used to represent various relationships and processes, such as task dependencies, network flows, state machines, etc. Specifically, it can be a cross-linked list.
[0084] Specifically, it can be: when the first form component can be a checkbox, the second set of form component groups can include input boxes. Specifically, when the user selects the "other" option in the checkbox, the input box will be displayed. When the user selects the "other" option, it means that the state of the first form component has changed, and the display means that the state of the second form component has changed.
[0085] In the embodiment of the present application, determining a second set of form components that has a linkage relationship with the first form component according to a preset directed graph includes:
[0086] Determine an initial second set of form components that has a linkage relationship with the first form component according to the preset directed graph;
[0087] Obtain the return value of the linkage condition function according to the state change of the first form component, where the return value represents whether the target form component meets the condition state change condition, and the condition state change condition indicates that the changed state of the first form component can cause the target form component to send a state change, and the target component is any form component in the initial second set of form components;
[0088] Determine a third set of form components according to the return value of the linkage condition function and the initial second set of form components, where the third set of form components are form components in the initial second set of form components that do not meet the condition state change condition;
[0089] Remove the third set of form components from the initial second set of form components to obtain the second set of form components.
[0090] Among them, the return value of the linkage condition function can be true or false. When the return value of the linkage condition function is false, it means that the state of the first form component will not cause the state of the current form component to change. When the return value of the linkage condition function is true, it means that the state of the first form component will cause the state of the current form component to change.
[0091] Specifically, the first form component can be a multiple - select box, and the multiple - select box options include: singing, dancing, other. According to the preset directed graph, determine the initial set of second form components that have a linkage relationship with the first form component. The initial set of second form components contains an input box, and the target component is this input box. If the user does not select "other" in the multiple - select box, then at this time, the state change of the multiple - select box will not cause the state of this input box to change. At this time, the return value of the linkage condition function is false. When the linkage condition function is false, it means that this input box is a form component that does not meet the condition for state change. Determine this input box as the third form component, and remove this input box from the initial set of second form components to obtain the set of second form components.
[0092] The advantage of this setting is that by determining the components that will actually be affected by the state change of the first form component as the set of second form components, the linkage relationship based on the preset directed graph is particularly useful in complex forms and interactive applications, and can significantly improve the intelligence level of the system and user satisfaction.
[0093] S103. According to the preset directed graph and the set of second form components, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components according to the execution order of the second form components.
[0094] Among them, when the set of second form components contains form component A, form component B, and form component C, through the preset directed graph, it is confirmed that the execution order of the second form components is: first execute form component A and form component B, and only after form component A and form component B are both executed, then execute form component C. Therefore, it is necessary to execute in sequence: the execution function of form component A, the execution function of form component B, and the execution function of form component C.
[0095] In the embodiment of the present application, according to the preset directed graph and the set of second form components, determining the execution order of the second form components and executing the execution functions corresponding to the second form components according to the execution order of the second form components includes:
[0096] Create an execution function call stack, where the execution function call stack is used to execute the execution functions corresponding to the second form components according to the execution order of the second form components;
[0097] Determine the fourth form component, where the fourth form component is any form component in the set of second form components;
[0098] According to the execution weights in the directed graph, obtain the execution order of multiple execution functions of the fourth form component, where there is a corresponding relationship between the execution weights and the execution order of the execution functions;
[0099] Push the execution functions of the fourth form components corresponding to the execution order onto the function call stack according to the execution order of the execution functions of the fourth form components;
[0100] Determine a first subset of dependent vertices to be processed in the second set of form components according to a preset directed graph and the second set of form components, where the form components in the first subset of dependent vertices to be processed need to be executed prior to the fourth form components;
[0101] Determine the execution order of the second form components according to the first subset of dependent vertices to be processed, and execute the execution functions corresponding to the second form components in accordance with the execution order of the second form components.
[0102] Among them, the smaller the execution weight, the more prioritized the execution order. The larger the execution weight, the more backward the execution order.
[0103] If there is a first subset of dependent vertices to be processed, the form components in the first subset of dependent vertices to be processed need to be executed first, and then the fourth form components are processed until all the form components in the second set of form components are executed. If there is no first subset of dependent vertices to be processed, the fourth form components are executed first, and then the other form components in the second set of form components are executed until all the form components in the second set of form components are executed.
[0104] Create an execution function call stack. When the second set of form components includes form component A, form component B, and form component C, arbitrarily select form component C in the second set of form components as the fourth form component. Form component C includes execution functions C1, C2, C3, and C4. The execution weight of C1 is 1, the execution weight of C2 is 2, the execution weight of C3 is 3, and the execution weight of C4 is 4. Then, the ones with larger weights are pushed onto the execution function call stack first, and the ones with smaller weights are pushed onto the execution function call stack later. Then, the push order onto the stack is: C4 -> C3 -> C2 -> C1. According to the preset directed graph, it is determined that form component A and form component B need to be executed before form component C can be executed. Then, the first subset of dependent vertices to be processed includes form component A and form component B. Then, form component A and form component B are executed first, and then form component C is processed until all the form components in the second set of form components are executed.
[0105] The advantage of such a setting is that through the management of dependencies and weights, it is ensured that the components are executed in the correct order, avoiding errors caused by unmet dependencies.
[0106] In the embodiments of the present application, determining the execution order of the second form components according to the first subset of dependent vertices to be processed, and executing the execution functions corresponding to the second form components in accordance with the execution order of the second form components includes:
[0107] If the first subset of dependent vertexes to be processed is empty, execute the execution function of the fourth form component. After the execution function of the fourth form component is executed, remove the corresponding execution function of the fourth form component from the function call stack;
[0108] When all the execution functions of the fourth form component are executed, remove the fourth form component from the second set of form components to obtain an updated second set of form components;
[0109] Take any form component in the updated second set of form components as the fourth target form component, and execute the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the updated second set of form components is empty.
[0110] Among them, if the first subset of dependent vertexes to be processed is empty, it means that no form component needs to be executed before the fourth form component. Therefore, the fourth form component needs to be executed first at this time.
[0111] If the second set of form components includes: form component A, form component B, and form component C. The fourth form component is form component C, and form component C contains execution functions C1, C2, C3, and C4. The execution weight of C1 is 1, the execution weight of C2 is 2, the execution weight of C3 is 3, and the execution weight of C4 is 4. Then, the one with the larger weight is pushed into the function call stack first, and the one with the smaller weight is pushed into the function call stack later. Then the push order is: C4 -> C3 -> C2 -> C1. First, execute function C1. After C1 is executed, delete C1 from the function call stack. Then execute C2. After C2 is executed, delete C2 from the function call stack. And so on until C3 and C4 are executed. When all the execution functions of form component C are executed, delete form component C from the second set of form components. At this time, an updated second set of form components is obtained, and the updated second set of form components includes form component A and form component B. Take any one of form component A and form component B as the fourth form component, and so on until the updated second set of form components is empty.
[0112] The advantage of this setting is that by checking the subset of dependent vertexes to be processed, it is ensured that each component is executed only after the components it depends on are executed, avoiding errors caused by unmet dependencies. Through orderly execution and dependency management, race conditions and uncertainties are reduced, and the stability of the system is improved.
[0113] In the embodiment of the present application, the method further includes:
[0114] If the first subset of dependent vertexes to be processed is not empty, determine the fifth form component, where the fifth form component is any form component in the first subset of dependent vertexes to be processed;
[0115] Determine a second subset of vertices to be processed that depend on other components in the second form component set according to a preset directed graph, where the second subset of vertices to be processed that depend on other components is executed prior to the fifth form component;
[0116] If the second subset of vertices to be processed that depend on other components is not empty, determine a sixth form component and loop through it until a final form component is reached. The sixth form component is any form component in the second subset of vertices to be processed that depend on other components, and the subset of vertices to be processed that depend on other components of the final form component is empty;
[0117] Based on the execution weights in the directed graph, obtain the execution order of multiple execution functions of the final form component, where there is a corresponding relationship between the execution weights and the execution order of the execution functions;
[0118] According to the execution order of the execution functions of the final form component, push the execution functions of the final form component corresponding to the execution order onto the function call stack;
[0119] Execute the execution functions of the final form component. After the execution functions of the final form component are executed, remove the corresponding execution functions of the final form component from the function call stack;
[0120] When all the execution functions of the final form component have been executed, remove the final form component from the second form component set to obtain an updated second form component set;
[0121] Take any form component in the updated second form component set as the fourth form component, and execute the step of obtaining the execution order of multiple execution functions of the fourth form component based on the execution weights in the directed graph until the updated second form component set is empty.
[0122] If the first subset of vertices to be processed that depend on other components is not empty, it indicates that there are form components that need to be executed prior to the fourth form component. Therefore, the form components in the subset of vertices to be processed that depend on other components need to be executed first at this time.
[0123] If the second form component set contains form component A, form component B, form component C, and form component D, and the fourth form component is form component D, determine the form components in the second form component set that are prior to form component D for processing as the second subset of dependent vertices to be processed, including: form component A, form component B, and form component C. Arbitrarily select a form component from the second form component set as the fifth form component. When the fifth form component is form component C, according to the preset directed graph, determine that the form components in the second form component set that are prior to form component C for processing are form component A and form component B. Then form component A and form component B are used as the second subset of dependent vertices to be processed, and so on, until the final component A is determined. The final form component A contains execution functions A1, A2, A3, and A4. The execution weight of A1 is 1, the execution weight of A2 is 2, the execution weight of A3 is 3, and the execution weight of A4 is 4. Then the ones with larger weights are pushed into the execution function call stack first, and the ones with smaller weights are pushed into the execution function call stack later. So the push order into the stack is: A4 -> A3 -> A2 -> A1. First, execute function A1. After execution, delete A1 from the function call stack. Then execute A2. After execution, delete A2 from the function call stack. And so on until A3 and A4 are executed. When all the execution functions of form component A are executed, delete form component A from the second form component set to obtain the updated second form component set: form component B, form component C, and form component D. Then use any one of form component B, form component C, and form component D as the fourth form component. Then loop to execute according to the execution weights in the directed graph to obtain the execution order of multiple execution functions of the fourth form component, and so on, until the updated second form component set is empty.
[0124] The advantage of this setting is that: if the second subset of dependent vertices to be processed is not empty, continue to determine the sixth form component, and loop in turn until a final form component is found whose subset of dependent vertices to be processed is empty. This recursive processing ensures that all dependencies are satisfied.
[0125] The form component execution method, device, electronic device, and storage medium provided by this application, by responding to user operations, cause the state of the first form component to change. Through a preset directed graph, a second set of form components that have a linkage relationship with the first form component is determined. The linkage relationship indicates that a change in the state of the first form component will cause a change in the state of the form components in the second set of form components. At the same time, through the preset directed graph, the order of the second form components in the second set of form components is determined. According to the execution order of the second form components, the execution functions corresponding to the second form components are executed. By presetting the linkage relationship between each form component and the execution order of the execution functions corresponding to the form components in advance through the preset directed graph, the execution result of the final form component meets the preset result, and at the same time, no other additional code needs to be added, reducing the workload.
[0126] In the above embodiment of this application, the method further includes:
[0127] Obtain a linkage action structure, where the linkage action structure includes at least an influencing source component, an affected source component, an action type, an execution function, and an execution weight. The influencing source component represents a form component that causes a state change in other form components. The affected source component is the form component whose state is caused to change. The action type represents the type of the linkage action. The execution function represents the actual action of the linkage action. The execution weight represents the execution order of the execution action;
[0128] Obtain a preset directed graph according to the linkage action structure.
[0129] Among them, Figure 2 is a schematic diagram of a linkage action structure provided by an embodiment of this application. As Figure 2 shown, the linkage action structure includes an influencing source component, an affected source component, an action type, an execution function, and an execution weight. The action type includes component value, component option, and component visibility. Component value indicates that the value filled in by the user in the influencing source component will affect the state of the affected source component. Component option indicates that the option selected by the user in the influencing source component will affect the state of the affected source component. Component visibility indicates that the display state of the influencing source component to the user (including the display or non-display state) will affect the state of the affected source component.
[0130] The influencing source component property is an array structure that records all form components that can affect other form components in a certain linkage process. The affected component needs to record a single component, which is the form component affected in this linkage process. The action type specifies the effect of the action, and there are three types in total: changing the form value corresponding to the component (i.e., the form value), changing the options of the component (i.e., the component options), and changing the visible or hidden state of the component (i.e., the component visibility); the execution function is the action that needs to be executed during the linkage process; the execution weight is an optional property that takes effect when multiple actions point to the same component. The greater the weight, the greater the impact of the action. If the actions have different effects, the action with the smallest weight is executed first. If the actions have the same effect, the action with the largest weight takes effect. When the user does not specify the action weight, this property defaults to 1.
[0131] Based on the corresponding relationship between the linkage action structure and the preset directed graph, the preset directed graph can be obtained.
[0132] The advantage of this setting is that this method is particularly effective in applications that require complex interaction and dependency management, and can significantly improve the intelligence and user satisfaction of the system. By ensuring that components are executed in the correct order and conditions, the system can better respond to user input and operations.
[0133] In the above embodiments of the present application, when the preset directed graph is a cross linked list, according to the linkage action structure, obtaining the preset directed graph includes:
[0134] Based on the influencing source component, the affected source component, the action type, the execution weight, and the execution function, obtaining the vertices of the cross linked list, where the vertices of the cross linked list include the first incoming arc pointer, the outgoing arc pointer, the form component properties corresponding to the vertices, and the execution function list. The outgoing arc pointer points to the first arc with the vertex of the cross linked list as the arc tail, the first incoming arc pointer points to the first arc with the vertex of the cross linked list as the arc head, the execution function list is the function that needs to be executed, the vertices of the cross linked list represent form components, and the form component properties corresponding to the vertices are the properties of the form components corresponding to the vertices of the cross linked list;
[0135] Based on the influencing source component and the affected source component, obtaining the arcs of the cross linked list, where the arcs of the cross linked list include the arc head, the arc tail, the next same arc head pointer, and the next same arc tail pointer. The next same arc head pointer points to the next arc with the same arc head, the next same arc tail pointer points to the next arc with the same arc tail, the arc represents the linkage relationship and execution order between form components, the arc head represents the vertex of the cross linked list whose state change is triggered, the arc tail represents the vertex of the cross linked list that triggers the state change, and there is a corresponding relationship between the arc head and the arc tail;
[0136] Based on the vertices of the cross linked list and the arcs of the cross linked list, obtaining the preset directed graph.
[0137] Among them, the directed graph can be represented by a cross linked list.
[0138] The cross linked list is a special data structure used to represent sparse matrices or directed graphs. It combines the characteristics of row linked lists and column linked lists to efficiently store and operate on sparse data. A sparse matrix refers to a matrix in which most elements are zero, and the cross linked list saves space by only storing non-zero elements.
[0139] Figure 3 FIG. is a schematic structural diagram of a vertex of a cross linked list provided by an embodiment of the present application, as Figure 3 shown. The vertex of the cross linked list includes a first incoming arc pointer, an outgoing arc pointer, the form component attributes corresponding to the vertex, and an execution function list. The component attributes corresponding to the node (i.e., prop), Prop is the data passed from the parent component to the child component. They allow the parent component to pass information to the child component, enabling the child component to render or operate based on this information.
[0140] Figure 4 FIG. is a schematic structural diagram of an arc of a cross linked list provided by an embodiment of the present application, as Figure 4 shown. The arc of the cross linked list includes an arc head, an arc tail, a pointer to the next arc with the same head, and a pointer to the next arc with the same tail.
[0141] The arc head represents the end point, and the arc tail represents the starting point. If there is an arc, for example, there is a form component A -> form component B, then in this arc, the arc tail is form component A, and the arc head is form component B.
[0142] If the influencing source components include form component A, form component B, and form component C, and the affected source components include form component B, form component C, and form component D, then the vertices of the cross-linked list include form component A, form component B, form component C, and form component D. There is a linkage action structure as follows: A->B->C->D, A->B->D, A->D. Then the first incoming arc pointer corresponding to form component B is A->B, the first outgoing arc pointer of form component B is B->D, the form component attribute is the data passed from form component A to form component B (i.e., the content that causes form component B to send a status change), the execution function list is obtained according to the execution function, execution weight, and action type. In A->B->C->D for C->D, execution function 4; in A->B->D for B->D, execution function 3, and in A->D execution function 1. Then the execution function list of the vertices of the cross-linked link corresponding to form component D includes execution function 1, execution function 3, and execution function 4. At this time, for the arcs included in A->B->D, there are: A->B, B->D, and for the arcs included in A->B->C->D, there are: A->B, B->C, C->D. For A->B and A->D, the arc tails are the same, so A->D is the next arc with the same arc tail as A->B. For A->D and B->D, the arc heads are the same, so B->D is the next arc with the same arc head as A->D.
[0143] The advantage of this setting is that using a cross-linked list to construct a preset directed graph can significantly improve the efficiency and manageability of complex interactions between form components. This method not only improves the performance of the system but also enhances the flexibility of development and maintenance.
[0144] Figure 5 It is a schematic flowchart of another form component execution method provided by this application, as Figure 5 shown. This method includes:
[0145] S501. Obtain the linkage action structure.
[0146] S502. Obtain a directed graph according to the linkage action structure.
[0147] Among them, Figure 6 It is a schematic diagram of a directed graph provided by an embodiment of this application, as Figure 6 shown. This directed graph includes form component A, form component B, form component C, and form component D. The included linkage processes include: A->B->C->D, A->B->D, A->D. A->B executes action 1 (i.e., the execution function), and the execution weight (i.e., the weight) is 1. B->C executes action 3 (i.e., the execution function), and the execution weight (i.e., the weight) is 1. B->D executes action 4 (i.e., the execution function), and the execution weight (i.e., the weight) is 2. A->D executes action 2 (i.e., the execution function), and the execution weight (i.e., the weight) is 1.
[0148] S503. Represent a directed graph using a cross-linked list.
[0149] Figure 7 The figure is a schematic diagram of a cross-linked list structure provided by an embodiment of the present application. The cross-linked list includes a vertex class and an arc class. The vertex class includes form components A (denoted as vertex A hereafter), B (denoted as vertex B hereafter), C (denoted as vertex C hereafter), and D (denoted as vertex D hereafter). The arc class represents the linkage relationships between the vertices. Specifically, the linkage process includes: A -> B -> C -> D, A -> B -> D, A -> D. Therefore, the arc class includes: A -> B, A -> D, B -> D, B -> C, C -> D. Vertex A points to arc A -> B, arc A -> B points to arc A -> D, and arc A -> D points to arc B -> D. Vertex B points to arc A -> B, arc B -> D, and arc B -> D points to arc B -> C and arc C -> D. Vertex C points to arc B -> C and arc C -> D, and vertex D points to arc C -> D. Action 1 is included in vertex B, action 3 (i.e., an execution function list) is included in vertex C, and actions 2 and 4 (i.e., execution function lists) are included in vertex D.
[0150] S504. When vertex A responds to a user operation, send a status change and start the linkage execution process.
[0151] Among them, when vertex A responds to a user operation, the method of sending a status change and starting the linkage execution process is as follows:
[0152] Step 1: Taking vertex A as the starting point (i.e., the first form component), enumerate the second form component set through the out-arc pointer. The second form component set is vertex B, vertex C, and vertex D.
[0153] Step 2: Iteratively execute the operation in Step 1 for each form component (i.e., vertex B, vertex C, and vertex D) in the associated vertex two-form component set.
[0154] Step 3: When it is detected that the second form component set is empty, terminate the recursion.
[0155] Among them, in Step 3, the associated actions need to be executed based on all the affected nodes (the second form component set) found in the first step. At the same time, this step also requires the idea of recursion. Different from the forward influence search in Step 1, the focus of Step 2 is on reverse dependency search. To implement Step 2, it needs to be carried out in 4 steps: basic matrix
[0156] Step 2-1: Function call stack initialization: Create a function call stack that will store and call functions in the correct order.
[0157] Step 2-2: Vertex processing loop:
[0158] 2-2-a. The basic matrix extracts the target vertex (i.e., any one of vertex B, vertex C, and vertex D) from the second form component set, and performs a descending order sorting on the vertex execution function list according to the weight. The basic matrix
[0159] 2-2-b. The basic matrix sequentially pushes the sorted execution functions onto the execution stack. After all the execution functions of the target vertex are completed, the target vertex is removed from the second form component set.
[0160] 2-2-c. The basic matrix retrieves the set of predecessor vertices that directly affect the current vertex through backtracking of the incoming arc pointer.
[0161] 2-2-d. The basic matrix calculates the intersection of the set of predecessor vertices and the affected set to obtain the subset of dependent vertices to be processed.
[0162] Step 2-3. Dependence recursive processing:
[0163] 2-3-a. The basic matrix recursively executes the operations in steps 2a-2d for each dependent vertex in the subset of dependent vertices to be processed
[0164] 2-3-b. The basic matrix terminates the current recursive level when the subset of dependent vertices to be processed is empty.
[0165] Step 2-4. Sequential execution phase:
[0166] 2-4-a. The basic matrix pops item by item according to the stack top priority principle.
[0167] 2-4-b. The basic matrix determines whether the function dependency item has changed. If it has changed, the function is executed; otherwise, this function execution is skipped.
[0168] 2-4-c. Detect the remaining vertices in the affected set, and repeat steps 2-1 to 2-4 until the subset of dependent vertices to be processed is emptied.
[0169] After these two steps are executed, the linkage actions can be executed in the correct order. The entire execution linkage process ensures the execution topological order through reverse dependency analysis, and its correctness is guaranteed by the following three constraints:
[0170] 1. Weight sorting constraint: Functions with higher priority obtain the priority of execution (i.e., functions with smaller weights are executed first).
[0171] 2. Dependence order constraint: The associated functions of the predecessor vertices must be executed before the successor vertices.
[0172] 3. State isolation constraint: The function execution process does not modify the current second form component set being processed.
[0173] Finally, this proposal introduces the third part, that is, the linkage condition setting part. After setting the linkage conditions, it will affect the triggering of linkage actions when the form changes. This device adds an optional parameter for the linkage condition function to the structure of the execution function. During the sequential execution process in the second stage (step 2-4-a), a dual determination logic is introduced:
[0174] 1. Condition pre-check stage: Call the linkage condition function and obtain the boolean return value
[0175] 2. Execution determination process:
[0176] a. If the linkage condition function returns logical false, immediately terminate the execution process of the current execution function.
[0177] b. If the linkage condition function returns logical true, traverse the set of dependent vertices of the current associated action.
[0178] c. Verify the updated status of the dependencies through the vertex status change flag.
[0179] d. When there is no effective change in the set of dependent vertices, trigger the short-circuit logic to skip the current execution.
[0180] Another method for executing form components provided by an embodiment of this application determines in advance the call order of linkage scenarios in any situation by constructing a directed graph in advance, preventing the occurrence of a chaotic call order that may lead to incorrect form data. It also realizes the concept of automation in the execution order. In addition, it supports users to customize and add conditions for linkages. After setting the conditions, the linkages will only be triggered under the specified conditions, making the linkages more flexible, saving network resources in some scenarios, and optimizing the user experience.
[0181] Figure 8 It is a schematic structural diagram of a form component execution device provided for this application, as Figure 8 shown. The form component execution device 80 provided in this embodiment includes a first determination module 801, a second determination module 802, and a third determination module 803. Among them:
[0182] The first determination module 801 is used to determine a first form component, where the first form component is a form component whose state changes in response to a user operation;
[0183] The second determination module 802 is used to determine a set of second form components that have a linkage relationship with the first form component according to a preset directed graph. The set of second form components contains multiple second form components. The linkage relationship indicates that the state change of the first form component will cause the state change of the second form component. The preset directed graph represents the linkage relationship and execution order between form components;
[0184] A third determination module 803, configured to determine the execution order of the second form components according to a preset directed graph and the second form component set, and execute the execution functions corresponding to the second form components according to the execution order of the second form components.
[0185] In a possible implementation, the second determination module 802 is configured to:
[0186] Determine an initial second form component set having a linkage relationship with the first form component according to the preset directed graph;
[0187] Obtain a linkage condition function return value according to the change of the first form component state, where the return value represents whether the target form component meets the conditional state change condition, and the conditional state change condition represents that the changed state of the first form component can cause the target form component to send a state change, and the target component is any form component in the initial second form component set;
[0188] Determine a third form component according to the linkage condition function return value and the initial second form component set, where the third form component is a form component in the initial second form component set that does not meet the conditional state change condition;
[0189] Remove the third form component from the initial second form component set to obtain the second form component set.
[0190] In a possible implementation, the second determination module 802 is further configured to:
[0191] Obtain a linkage action structure, where the linkage action structure includes at least an influencing source component, an affected source component, an action type, an execution function, and an execution weight. The influencing source component represents a form component that causes a state change in other form components, the affected source component is a form component whose state is caused to change, the action type represents the type of the linkage action, the execution function represents the actual action of the linkage action, and the execution weight represents the execution order of the execution action;
[0192] Obtain a preset directed graph according to the linkage action structure.
[0193] In a possible implementation, the second determination module 802 is further configured to:
[0194] Vertices of the cross-linked list are obtained based on the influencing source component, the affected source component, the action type, the execution weight, and the execution function. Among them, the vertices of the cross-linked list include the first incoming arc pointer, the outgoing arc pointer, the form component attributes corresponding to the vertex, and the execution function list. The outgoing arc pointer points to the first arc with the vertex of the cross-linked list as the arc tail, the first incoming arc pointer points to the first arc with the vertex of the cross-linked list as the arc head, the execution function list is the function to be executed, and the vertices of the cross-linked list represent form components. The form component attributes corresponding to the vertex are the attributes of the form component corresponding to the vertex of the cross-linked list;
[0195] Arcs of the cross-linked list are obtained based on the influencing source component and the affected source component. Among them, the arcs of the cross-linked list include the arc head, the arc tail, the next same arc head pointer, and the next same arc tail pointer. The next same arc head pointer points to the next arc with the same arc head, the next same arc tail pointer points to the next arc with the same arc tail, the arc represents the linkage relationship and execution order between form components, the arc head represents the vertex of the cross-linked list whose state change is triggered, the arc tail represents the vertex of the cross-linked list that triggers the state change, and there is a corresponding relationship between the arc head and the arc tail;
[0196] A preset directed graph is obtained based on the vertices of the cross-linked list and the arcs of the cross-linked list.
[0197] In a possible implementation, the third determination module 803 is used to:
[0198] Create an execution function call stack, where the execution function call stack is used to execute the execution functions corresponding to the second form components according to the execution order of the second form components;
[0199] Determine the fourth form component, where the fourth form component is any form component in the second form component set;
[0200] According to the execution weights in the directed graph, obtain the execution order of multiple execution functions of the fourth form component, where there is a corresponding relationship between the execution weights and the execution order of the execution functions;
[0201] Push the execution functions of the fourth form component corresponding to the execution order onto the function call stack according to the execution order of the execution functions of the fourth form component;
[0202] According to the preset directed graph and the second form component set, determine the first subset of vertices to be processed and dependent in the second form component set, where the form components in the first subset of vertices to be processed and dependent need to be executed prior to the fourth form component;
[0203] According to the first subset of vertices to be processed and dependent, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components according to the execution order of the second form components.
[0204] In a possible implementation, the third determination module 803 is further configured to:
[0205] If the first set of dependent vertices to be processed is empty, execute the execution function of the fourth form component. After the execution function of the fourth form component is executed, remove the corresponding execution function of the fourth form component from the function call stack;
[0206] When all the execution functions of the fourth form component are executed, remove the fourth form component from the second set of form components to obtain an updated second set of form components;
[0207] Use any form component in the updated second set of form components as the fourth form component, and execute the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the updated second set of form components is empty.
[0208] In a possible implementation, the third determination module 803 is further configured to:
[0209] If the first set of dependent vertices to be processed is not empty, determine a fifth form component, where the fifth form component is any form component in the first set of dependent vertices to be processed;
[0210] According to the preset directed graph and the second set of form components, determine a second set of dependent vertices to be processed in the second set of form components, where the second set of dependent vertices to be processed is executed prior to the fifth form component;
[0211] If the second set of dependent vertices to be processed is not empty, determine a sixth form component and loop until there is a final form component, where the sixth form component is any form component in the second set of dependent vertices to be processed, and the set of dependent vertices to be processed of the final form component is empty;
[0212] According to the execution weights in the directed graph, obtain the execution order of multiple execution functions of the final form component, where there is a corresponding relationship between the execution weights and the execution order of the execution functions;
[0213] Push the execution function of the final form component corresponding to the execution order onto the function call stack according to the execution order of the execution function of the final form component;
[0214] Execute the execution function of the final form component. After the execution function of the final form component is executed, remove the corresponding execution function of the final form component from the function call stack;
[0215] When all the execution functions of the final form component are executed, remove the final form component from the second set of form components to obtain an updated second set of form components;
[0216] Update any form component in the second form component set as the fourth form component, and perform the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the second form component set is empty.
[0217] The form component execution device provided in this embodiment can execute the method provided in the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here in this embodiment.
[0218] Figure 9 It is a schematic structural diagram of the electronic device provided in this application. As Figure 9 shown, the electronic device 90 provided in this embodiment includes: at least one processor 901 and a memory 902. Optionally, the device 90 further includes a communication component 903. Among them, the processor 901, the memory 902, and the communication component 903 are connected through a bus 904.
[0219] In the specific implementation process, at least one processor 901 executes the computer execution instructions stored in the memory 902, so that at least one processor 901 executes the above method.
[0220] The specific implementation process of the processor 901 can refer to the above method embodiment, and its implementation principle and technical effect are similar, which will not be elaborated here in this embodiment.
[0221] In the above embodiment, it should be understood that the processor may be a central processing unit (English: Central Processing Unit, abbreviated as: CPU), or other general-purpose processors, digital signal processors (English: Digital Signal Processor, abbreviated as: DSP), application-specific integrated circuits (English: Application Specific Integrated Circuit, abbreviated as: ASIC), etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly embodied as being executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.
[0222] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0223] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the buses in the drawings of this application are not limited to only one bus or one type of bus.
[0224] This application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0225] This application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the processor executes the computer-executable instructions, the above method is implemented.
[0226] The above-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disc. The readable storage medium can be any available medium accessible by a general-purpose or special-purpose computer.
[0227] An exemplary readable storage medium is coupled to the processor, enabling the processor to read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an Application Specific Integrated Circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in a device.
[0228] The division of units is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces. The indirect coupling or communication connection of devices or units can be in an electrical, mechanical, or other form.
[0229] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed across multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0230] In addition, each functional unit in various embodiments of the present invention may be integrated into a processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
[0231] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present invention. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0232] Those of ordinary skill in the art can understand that all or part of the steps to implement the above method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps including the above method embodiments; and the aforementioned storage medium includes: various media such as ROM, RAM, magnetic disks, or optical discs that can store program codes.
[0233] Finally, it should be noted that: After considering the specification and practicing the invention disclosed herein, those skilled in the art will easily think of other implementation schemes of the present invention. The present invention aims to cover any variations, uses, or adaptive changes of the present invention. These variations, uses, or adaptive changes follow the general principles of the present invention and include the common general knowledge or conventional technical means in the technical field not disclosed in the present invention. It is not limited to the precise structure already described and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.
Claims
1. A method for executing a form component, characterized in that Including: Determine a first form component, where the first form component is a form component whose state changes in response to a user operation; According to a preset directed graph, determine a set of second form components that have a linkage relationship with the first form component, where the set of second form components includes multiple second form components, and the linkage relationship indicates that a state change of the first form component will cause a state change of the second form component, and the preset directed graph represents the linkage relationship and execution order between form components; According to the preset directed graph and the set of second form components, determine the execution order of the second form components, and execute the execution functions corresponding to the second form components in accordance with the execution order of the second form components.
2. The method according to claim 1, wherein The step of determining, according to the preset directed graph, a set of second form components that have a linkage relationship with the first form component includes: According to the preset directed graph, determine an initial set of second form components that have a linkage relationship with the first form component; Obtain a return value of a linkage condition function according to the state change of the first form component, where the return value represents whether a target form component meets a conditional state change condition, and the conditional state change condition indicates that the changed state of the first form component can cause the target form component to send a state change, and the target component is any form component in the initial set of second form components; According to the return value of the linkage condition function and the initial set of second form components, determine a third form component, where the third form component is a form component in the initial set of second form components that does not meet the conditional state change condition; Remove the third form component from the initial set of second form components to obtain the set of second form components.
3. The method according to claim 1, characterized in that, The step of determining, according to the preset directed graph and the set of second form components, the execution order of the second form components, and executing the execution functions corresponding to the second form components in accordance with the execution order of the second form components includes: Create an execution function call stack, where the execution function call stack is used to execute the execution functions corresponding to the second form components in accordance with the execution order of the second form components; Determine a fourth form component, where the fourth form component is any form component in the set of second form components; According to the execution weights in the directed graph, obtain the execution order of multiple execution functions of the fourth form component, where the execution weights have a corresponding relationship with the execution order of the execution functions; Push the execution functions of the fourth form component corresponding to the execution order into the function call stack in accordance with the execution order of the execution functions of the fourth form component; According to the preset directed graph and the set of second form components, determine a first subset of pending dependent vertices in the set of second form components, where the form components in the first subset of pending dependent vertices need to be executed prior to the fourth form component; Determine the execution order of the second form component according to the first subset of dependent vertices to be processed, and execute the execution function corresponding to the second form component in accordance with the execution order of the second form component.
4. The method according to claim 3, wherein The step of determining the execution order of the second form component according to the first subset of dependent vertices to be processed, and executing the execution function corresponding to the second form component in accordance with the execution order of the second form component includes: If the first subset of dependent vertices to be processed is empty, execute the execution function of the fourth form component. After the execution function of the fourth form component is executed, remove the execution function of the corresponding fourth form component from the function call stack. When all the execution functions of the fourth form component have been executed, remove the fourth form component from the second form component set to obtain an updated second form component set. Take any form component in the updated second form component set as the fourth form component, and execute the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the updated second form component set is empty.
5. The method according to claim 3, characterized in that The method further includes: If the first subset of dependent vertices to be processed is not empty, determine a fifth form component, where the fifth form component is any form component in the first subset of dependent vertices to be processed. Determine a second subset of dependent vertices to be processed in the second form component set according to the preset directed graph and the second form component set, where the second subset of dependent vertices to be processed is executed prior to the fifth form component. If the second subset of dependent vertices to be processed is not empty, determine a sixth form component and loop sequentially until a final form component exists, where the sixth form component is any form component in the second subset of dependent vertices to be processed, and the subset of dependent vertices to be processed of the final form component is empty. Obtain the execution order of multiple execution functions of the final form component according to the execution weights in the directed graph, where there is a corresponding relationship between the execution weights and the execution order of the execution functions. Push the execution functions of the final form component corresponding to the execution order onto the function call stack in accordance with the execution order of the execution functions of the final form component. Execute the execution function of the final form component. After the execution function of the final form component is executed, remove the execution function of the corresponding final form component from the function call stack. When all the execution functions of the final form component have been executed, remove the final form component from the second form component set to obtain an updated second form component set. Take any form component in the updated second form component set as the fourth form component, and execute the step of obtaining the execution order of multiple execution functions of the fourth form component according to the execution weights in the directed graph until the updated second form component set is empty.
6. The method according to any one of claims 1-5, characterized in that, The method further includes: Obtain a linked-action structure, where the linked-action structure includes at least an influencing source component, an influenced source component, an action type, an execution function, and an execution weight. Among them, the influencing source component represents a form component that causes a status change in other form components, the influenced source component is the form component whose status is caused to change, the action type represents the type of the linked action, the execution function represents the actual action of the linked action, and the execution weight represents the execution order of the execution action; Obtain the preset directed graph according to the linked-action structure.
7. The method according to claim 6, wherein When the preset directed graph is a cross linked list, the obtaining the preset directed graph according to the linked-action structure includes: Obtain the vertices of the cross linked list according to the influencing source component, the influenced source component, the action type, the execution weight, and the execution function. Among them, the vertices of the cross linked list include a first incoming arc pointer, a first outgoing arc pointer, the form component attributes corresponding to the vertex, and an execution function list. The first outgoing arc pointer points to the first arc with the vertex of the cross linked list as the arc tail, the first incoming arc pointer points to the first arc with the vertex of the cross linked list as the arc head, the execution function list is the function to be executed, and the vertex of the cross linked list represents a form component, and the form component attributes corresponding to the vertex are the attributes of the form component corresponding to the vertex of the cross linked list; Obtain the arcs of the cross linked list according to the influencing source component and the influenced source component. Among them, the arcs of the cross linked list include an arc head, an arc tail, a next same arc head pointer, and a next same arc tail pointer. The next same arc head pointer points to the next arc with the same arc head, the next same arc tail pointer points to the next arc with the same arc tail, the arc represents the linked relationship and execution order between form components, the arc head represents the vertex of the cross linked list whose status is caused to change, the arc tail represents the vertex of the cross linked list that causes the status change, and the arc head and the arc tail have a corresponding relationship; Obtain the preset directed graph according to the vertices of the cross linked list and the arcs of the cross linked list.
8. A form component execution device for executing the method according to any one of claims 1-7, characterized in that, Include: A first determination module, configured to determine a first form component, where the first form component is a form component whose status changes in response to a user operation; A second determination module, configured to determine a second form component set having a linked relationship with the first form component according to the preset directed graph, where the second form component set includes multiple second form components, and the linked relationship means that the status change of the first form component will cause the status of the second form component to change, and the preset directed graph represents the linked relationship and execution order between form components; A third determination module, configured to determine the execution order of the second form components according to the preset directed graph and the second form component set, and execute the execution functions corresponding to the second form components according to the execution order of the second form components.
9. An electronic device, characterized in that, Include: A memory, a processor; The memory stores computer execution instructions; The processor executes the computer-executable instructions stored in the memory, such that the processor performs the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1-7.
11. A computer program product, characterized in that, It includes a computer program, and the computer program implements the method according to any one of claims 1-7.
Citation Information
Cited By
Form linkage updating method and device, electronic equipment and storage medium
CN122431698A