Method, device, electronic device and storage medium for generating state manager
By analyzing the interface, describing the language file and generating interactive pages, users select the interface and return fields, and automatically generate the state manager, solving the problems of state manager development costs and understanding costs in the existing technology, and improving the development experience.
Patent Information
- Application Number
- CN202110872776.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-30
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-07-30
AI Technical Summary
The existing state managers include repetitive code, which increases the development and understanding costs, especially in complex applications, which require handwriting implementation, which increases the burden on developers.
By obtaining interface description language files, parsing abstract syntax trees, generating target interaction pages, users select target interfaces and return fields, and automatically generate state managers to avoid manual development process.
It reduces development costs and understanding costs, improves the user's development experience, and can automatically generate a complete state manager, reducing the need to understand the details of the state manager.
Smart Images

Figure CN113590120B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for generating a state manager. Background Art
[0002] The front-end basically uses componentized and responsive frameworks for application development, such as Vue and React frameworks. Componentization means splitting an application into multiple independent and fully functional components. A complete component usually includes a UI (User Interface) part and a logic part; responsiveness means that the UI part of the front-end application is rendered according to the state of the logic part. When the state of the logic part changes, the UI part will automatically change accordingly.
[0003] When the application is relatively simple, state management is done independently by components, that is, defining states, using states, and changing states within components. When the application is more complex, cross-component communication problems will arise, and a state manager is needed. However, since the state manager contains a lot of repetitive code, it needs to be written manually, which increases the development cost. In addition, during the handwriting process, it is necessary to understand the concept of the state manager, which increases the cost of understanding. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a method, device, electronic device and computer-readable storage medium for generating a state manager.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for generating a state manager, comprising:
[0006] Obtaining an interface description language file, and obtaining interface information from the interface description language file; the interface information includes an interface name, an interface description, and return field information;
[0007] Generate a target interaction page according to the interface information, wherein the target interaction page is used for allowing a user to select a target interface;
[0008] In response to a selection operation of a user on the target interaction page, determining a target interface and a target return field selected by the user;
[0009] A state manager is generated according to the target interface and the target return field.
[0010] In the disclosed embodiment, the state manager can be automatically generated according to the above-mentioned state manager generation method, which reduces the development cost compared with hand-written code. In addition, since a complete state manager can be generated in the disclosed embodiment, it can be used even when the user does not fully understand the details of the state manager, which reduces the understanding cost and improves the user's development experience.
[0011] According to the first aspect, in a possible implementation manner, obtaining an interface description language file and obtaining interface information from the interface description language file includes:
[0012] According to the pre-configured interface description language file path, obtaining the interface description language file content;
[0013] Parsing the content of the interface description language file to obtain an abstract syntax tree;
[0014] The abstract syntax tree is traversed to obtain the interface information.
[0015] In the disclosed embodiment, the information in the interface description language file can be more conveniently obtained through the abstract syntax tree, thereby improving the efficiency of obtaining the interface information.
[0016] According to the first aspect, in a possible implementation manner, the type of the interface description language file is a structure type, and the returned field information includes a field sequence number, a field name, and a field type.
[0017] According to the first aspect, in a possible implementation manner, generating a target interaction page according to the interface information includes:
[0018] Start the Hypertext Transfer Protocol web service;
[0019] In response to the user's operation of accessing a target browser, the target interactive page is rendered and generated based on the interface information, and the target browser corresponds to the web page service.
[0020] According to the first aspect, in a possible implementation, the target interaction page includes an interface list part, a return field part, and a submission part; the interface list part includes a plurality of interface items for the user to select, and the interface item includes the interface name; the return field part is used to display the return field corresponding to the target interface item selected by the user; the submission part is used to generate a submission instruction in response to the user's submission request;
[0021] The step of responding to a selection operation of a user on the target interaction page and determining a target interface and a target return field selected by the user comprises:
[0022] In response to the user's selection operation on the interface list portion, selecting a target interface from a plurality of interfaces;
[0023] In response to the user's selection operation on the return field part, selecting a target return field from a plurality of fields corresponding to the target interface;
[0024] In response to the user's triggering operation on the submitted part, generating a submission instruction;
[0025] According to the submit instruction, the web page service is closed, and the target interface and the target return field are determined.
[0026] According to the first aspect, in a possible implementation manner, the returned field portion is expanded in a tree manner, and the returned field portion includes a plurality of field items, each field item including a field name and a field description.
[0027] According to the first aspect, in a possible implementation manner, generating a state manager according to the target interface and the target return field includes:
[0028] Generate a state of the state manager according to the target return field, wherein the name of the state is the name of the target return field;
[0029] The instructions and side effects of the state manager are generated according to the target interface and the target return field, and the names of the instructions and the side effects are the names of the target interface.
[0030] In a second aspect, an embodiment of the present disclosure provides a device for generating a state manager, including:
[0031] An acquisition module, used to acquire an interface description language file and acquire interface information from the interface description language file; the interface information includes an interface name, an interface description and return field information;
[0032] A first generating module, configured to generate a target interaction page according to the interface information, wherein the target interaction page is used for a user to select a target interface;
[0033] A determination module, configured to respond to a selection operation of a user on the target interaction page and determine a target interface and a target return field selected by the user;
[0034] The second generating module is used to generate a state manager according to the target interface and the target return field.
[0035] According to the second aspect, in a possible implementation manner, the acquisition module is specifically configured to:
[0036] According to the pre-configured interface description language file path, obtaining the interface description language file content;
[0037] Parsing the content of the interface description language file to obtain an abstract syntax tree;
[0038] The abstract syntax tree is traversed to obtain the interface information.
[0039] According to the second aspect, in a possible implementation, the type of the interface description language file is a structure type, and the returned field information includes a field sequence number, a field name, and a field type.
[0040] According to the second aspect, in a possible implementation manner, the first generating module is specifically configured to:
[0041] Start the Hypertext Transfer Protocol web service;
[0042] In response to the user's operation of accessing a target browser, the target interactive page is rendered and generated based on the interface information, and the target browser corresponds to the web page service.
[0043] According to the second aspect, in a possible implementation, the target interaction page includes an interface list part, a return field part, and a submission part; the interface list part includes a plurality of interface items for the user to select, and the interface item includes the interface name; the return field part is used to display the return field corresponding to the target interface item selected by the user; the submission part is used to generate a submission instruction in response to the user's submission request; the determination module is specifically used to:
[0044] The step of responding to a selection operation of a user on the target interaction page and determining a target interface and a target return field selected by the user comprises:
[0045] In response to the user's selection operation on the interface list portion, selecting a target interface from a plurality of interfaces;
[0046] In response to the user's selection operation on the return field part, selecting a target return field from a plurality of fields corresponding to the target interface;
[0047] In response to the user's triggering operation on the submitted part, generating a submission instruction;
[0048] According to the submit instruction, the web page service is closed, and the target interface and the target return field are determined.
[0049] According to the second aspect, in a possible implementation, the returned field portion is expanded in a tree-like manner, and the returned field portion includes a plurality of field items, each field item including a field name and a field description.
[0050] According to the second aspect, in a possible implementation manner, the second generating module is specifically configured to:
[0051] Generate a state of the state manager according to the target return field, wherein the name of the state is the name of the target return field;
[0052] The instructions and side effects of the state manager are generated according to the target interface and the target return field, and the names of the instructions and the side effects are the names of the target interface.
[0053] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the state manager generation method described in the first aspect are performed.
[0054] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the method for generating a state manager as described in the first aspect are executed.
[0055] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0057] Figure 1 A schematic diagram showing an exemplary architecture of a method for generating a state manager provided by an embodiment of the present disclosure is shown;
[0058] Figure 2 A flow chart of a method for generating a state manager provided by an embodiment of the present disclosure is shown;
[0059] Figure 3 A flow chart of a method for obtaining interface information from an interface description language file provided by an embodiment of the present disclosure is shown;
[0060] Figure 4 A flow chart of a method for generating a target interactive page provided by an embodiment of the present disclosure is shown;
[0061] Figure 5 A schematic diagram of a target interaction page provided by an embodiment of the present disclosure is shown;
[0062] Figure 6 A flow chart of a method for determining a target interface and a target return field selected by a user provided by an embodiment of the present disclosure is shown;
[0063] Figure 7 A flow chart of a method for generating a state manager according to a target interface and a target return field provided by an embodiment of the present disclosure is shown;
[0064] Figure 8 A schematic diagram showing another target interaction page provided by an embodiment of the present disclosure is shown;
[0065] Fig. 9 A schematic diagram of the structure of a device for generating a state manager provided by an embodiment of the present disclosure is shown;
[0066] Fig.10 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0067] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0068] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0069] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0070] The front-end basically uses componentized and responsive frameworks for application development, such as Vue and React frameworks. Componentization means splitting an application into multiple independent and fully functional components. A complete component usually includes a UI (User Interface) part and a logic part. Responsiveness means that the UI part of the front-end application is rendered according to the state of the logic part. When the state of the logic part changes, the UI part will automatically change accordingly.
[0071] When the application is relatively simple, state management is done independently by the components, that is, defining the state, using the state, and changing the state within the component. When the application is more complex, cross-component communication problems will arise, and a state manager is needed. The state manager generally uses centralized management and unidirectional data flow to solve the state management problem. Among them, centralized management refers to the unified definition and management of the state of all components; unidirectional data flow means that the change of state is unidirectional.
[0072] The state manager generally consists of three parts: state, action, and effect. The state can only be changed through an action, and the effect includes the function of requesting the server interface and calling an action to change the state.
[0073] After research, it was found that although the state manager makes the maintenance of the state clear and standardized, the existing state manager contains a lot of repetitive code and needs to be written manually, which increases the development cost. In addition, during the handwriting process, it is necessary to understand the concept of the state manager, which increases the cost of understanding.
[0074] Based on the above research, the present disclosure provides a method for generating a state manager, which obtains an interface description language file and obtains interface information from the interface description language file; the interface information includes an interface name, an interface description, and return field information; a target interaction page is generated according to the interface information, and the target interaction page is used for users to select a target interface; in response to a user's selection operation on the target interaction page, the target interface and the target return field selected by the user are determined; and a state manager is generated according to the target interface and the target return field. In this way, a state manager can be automatically generated through an interface description language file, avoiding the manual development process, saving development costs, and reducing the understanding costs of developers.
[0075] The application scheme is described in detail below in conjunction with a specific system application architecture.
[0076] See also Figure 1 , Figure 1 FIG. 2 shows an exemplary system architecture of a method for generating a state manager that can be applied to the present application. Figure 1As shown, system architecture 100 may include electronic devices 10, 20, network 30 and server 40. Network 30 is used to provide a medium for communication links between electronic devices 10, 20 and server 40. Network 30 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0077] The user can use the electronic device 10, 20 to interact with the server 40 through the network 30 to receive or send messages, etc. Various client applications, such as a browser, etc., can be installed on the electronic device 10, 20. The electronic device 10, 20 can be various electronic devices with a display screen and a processor, including but not limited to a laptop portable computer and a desktop computer, etc.
[0078] The server 40 may be a server that provides various services, such as a server that supports browser applications displayed on the electronic devices 10 and 20. The server 40 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data, and artificial intelligence platforms.
[0079] The state manager generation method provided in the embodiment of the present application is generally executed by the electronic devices 10 and 20, and can certainly be executed by the server 40, which is not limited here. In some possible implementations, the state manager generation method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0080] See also Figure 2 FIG. 1 is a flowchart of a method for generating a state manager provided in an embodiment of the present disclosure. Figure 2 The method for generating the state manager shown includes the following S101 to S104:
[0081] S101, obtaining an interface description language file, and obtaining interface information from the interface description language file; the interface information includes an interface name, an interface description, and return field information.
[0082] Among them, IDL is an interface description language independent of programming languages. IDL can describe interfaces simply, clearly and completely. IDL has nothing to do with programming languages and can be converted into various programming languages through certain mapping relationships.
[0083] It can be understood that constructing a state manager mainly requires two types of information: interface and state. Interface information can be obtained from an interface description language (IDL) file. State information is generally obtained from fields in the interface return type, and developers need to select it as needed.
[0084] IDL types can be divided into simple types and structure types. Simple types include strings, numbers, etc. Structure types include several fields, each of which includes a field number, a field name, and a field type. In this embodiment, the type of the IDL is a structure type, and the returned field information includes a field number, a field name, and a field type.
[0085] In some embodiments, see Figure 3 As shown, for step S101, when obtaining an interface description language file and obtaining interface information from the interface description language file, the following steps S1011 to S1013 may be included:
[0086] S1011, acquiring the interface description language file content according to the pre-configured interface description language file path.
[0087] S1012, parsing the content of the interface description language file to obtain an abstract syntax tree.
[0088] S1013: traverse the abstract syntax tree to obtain the interface information.
[0089] Exemplarily, the IDL file content may be obtained according to the specified IDL file path, and then the IDL file content may be parsed using an AST parser to obtain an AST, and the AST may be traversed to obtain the interface information.
[0090] Among them, the Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of the source code. Through the AST, it is easier to obtain information in the source code, for example, to obtain type information in the IDL file.
[0091] In other embodiments, a preset parsing function stack may be used to parse the IDL file to obtain an AST. The preset parsing function stack is composed of one or more parsing functions, each of which can parse a grammatical rule in an IDL file, and the parsing function can be pre-written according to the grammatical rule of the IDL file. In order to parse the IDL file, parsing functions for parsing various grammatical rules in the IDL file can be pre-written, so that for one of the grammatical rules, there is at least one parsing function in the parsing function stack that can parse out its grammatical structure.
[0092] S102, generating a target interaction page according to the interface information, wherein the target interaction page is used for allowing a user to select a target interface.
[0093] It can be understood that after acquiring the interface information, a target interaction page can be generated according to the interface information, and then the target interface and target return field selected by the user can be determined according to the user's selection operation on the target interaction page.
[0094] In some embodiments, see Figure 4 , with respect to S102, when generating the target interaction page according to the interface information, the following S1021 to S1022 may be included:
[0095] S1021, start the Hypertext Transfer Protocol web page service.
[0096] S1022, in response to the user's operation of accessing a target browser, rendering and generating the target interactive page based on the interface information, the target browser corresponding to the web page service.
[0097] Exemplarily, a local Hyper Text Transfer Protocol (HTTP) application service may be started, and then in response to a user accessing a target browser, a request is sent to a server of the HTTP application service to obtain interface information, and then the target interactive page is rendered and generated based on the obtained interface information.
[0098] See also Figure 5 , is a schematic diagram of a target interaction page provided by an embodiment of the present disclosure, such as Figure 5 As shown, the target interaction page includes an interface list part A, a return field part B and a submission part C. The interface list part A includes multiple interface items A1 for the user to select, that is, the interface list part A is a list containing multiple interface items A1, and the interface item A1 can be selected. Each interface item A1 includes an interface name A11, an interface description A12 and an interface check box A13.
[0099] The return field part B is used to display the return field corresponding to the target interface item selected by the user. For example, after the GetUserInfo interface item is selected, the return field part B displays the return field corresponding to the GetUserInfo interface, and the return field part can be expanded in a tree manner. The return field part includes multiple field items, each field item includes a field name B1, a field description B2, and a field check box B3. It should be noted that when the type of the expanded field is a structure, the expanded field item also includes an expand / collapse button B4. Clicking the expand / collapse button B4 can expand / collapse the field item of the structure.
[0100] The submit part C is used to generate a submit instruction in response to the user's submit request. Specifically, the submit part C includes a submit button, and clicking the submit button can generate a submit instruction, that is, confirming the selected target interface (such as GetUserInfo) and target return field (such as employeeld:string).
[0101] S103, responding to the user's selection operation on the target interaction page, determining the target interface and target return field selected by the user.
[0102] It is understood that after the target interaction page is generated, the user can select the content displayed on the target interaction page and finally determine the target interface and target return field selected by the user. Figure 6 As shown, in response to the user's selection operation on the target interaction page, when determining the target interface and the target return field selected by the user, the following S1031 to S1034 may be included:
[0103] S1031, in response to the user's partial selection operation on the interface list, selecting a target interface from a plurality of interfaces.
[0104] S1032: In response to the user's selection operation on the return field part, select a target return field from a plurality of fields corresponding to the target interface.
[0105] S1033: In response to the user's triggering operation on the submitted part, generate a submission instruction.
[0106] S1034: According to the submit instruction, close the web page service, and determine the target interface and the target return field.
[0107] For example, after the user selects the target interface and target return field and clicks the Submit button, a request (i.e., a submit instruction) will be sent to the server of the HTTP application service. After receiving the request, the server will close the HTTP application service and return the target interface and target return field selected by the user.
[0108] The HTTP application service core code example is as follows:
[0109]
[0110]
[0111] S104: Generate a state manager according to the target interface and the target return field.
[0112] Exemplarily, after obtaining the target interface and the target return field, it is determined that the construction of the state manager mentioned above mainly requires two types of information, namely, interface and state. Therefore, the state manager can be generated according to the target interface and the target return field.
[0113] Specifically, see Figure 7 As shown, when the state manager is generated according to the target interface and the target return field, the following S1041 to S1042 may be included:
[0114] S1041: Generate a state of the state manager according to the target return field, where the name of the state is the name of the target return field.
[0115] Exemplarily, the state of the state manager may be generated according to the selected target return field, the name of the state is the name of the target return field, and the initial value of the state is the default value of the target return field type.
[0116] S1042: Generate instructions and side effects of the state manager according to the target interface and the target return field, where the name of the instruction and the name of the side effect are the name of the target interface.
[0117] Exemplarily, a state manager instruction is generated based on the selected target interface and target return field. The name of the instruction is the target interface name; the payload of the instruction is the target return field; the payload is used to update the corresponding state in the function body of the instruction. In addition, a state manager side effect is generated based on the selected target interface and target return field. The name of the side effect is the target interface name; in the function body of the side effect, the interface is requested, the specified field of the returned data is obtained, and the instruction is called using the specified field as the payload.
[0118] Among them, the key node examples of the semi-automatic generation of the state manager process are as follows:
[0119] 1. Provided IDL files
[0120]
[0121]
[0122]
[0123] In the disclosed embodiment, the state manager can be automatically generated according to the above-mentioned state manager generation method, which reduces the development cost compared with hand-written code. In addition, since a complete state manager can be generated in the disclosed embodiment, it can be used even when the user does not fully understand the details of the state manager, which reduces the understanding cost and improves the user's development experience.
[0124] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0125] Based on the same technical concept, the embodiment of the present disclosure also provides a state manager generation device corresponding to the state manager generation method. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned state manager generation method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0126] Reference Fig. 9 FIG. 5 is a schematic diagram of a state manager generation device 500 provided in an embodiment of the present disclosure, wherein the state manager generation device includes:
[0127] The acquisition module 501 is used to acquire an interface description language file and obtain interface information from the interface description language file; the interface information includes an interface name, an interface description and return field information;
[0128] A first generating module 502, configured to generate a target interaction page according to the interface information, wherein the target interaction page is used for a user to select a target interface;
[0129] A determination module 503 is used to respond to a selection operation of the user on the target interaction page and determine a target interface and a target return field selected by the user;
[0130] The second generating module 504 is used to generate a state manager according to the target interface and the target return field.
[0131] In a possible implementation manner, the acquisition module 501 is specifically used to:
[0132] According to the pre-configured interface description language file path, obtaining the interface description language file content;
[0133] Parsing the content of the interface description language file to obtain an abstract syntax tree;
[0134] The abstract syntax tree is traversed to obtain the interface information.
[0135] In a possible implementation manner, the type of the interface description language file is a structure type, and the returned field information includes a field sequence number, a field name, and a field type.
[0136] In a possible implementation, the first generating module 502 is specifically configured to:
[0137] Start the Hypertext Transfer Protocol web service;
[0138] In response to the user's operation of accessing a target browser, the target interactive page is rendered and generated based on the interface information, and the target browser corresponds to the web page service.
[0139] In a possible implementation, the target interaction page includes an interface list part, a return field part, and a submission part; the interface list part includes a plurality of interface items for the user to select, and the interface item includes the interface name; the return field part is used to display the return field corresponding to the target interface item selected by the user; the submission part is used to generate a submission instruction in response to the user's submission request; the determination module 503 is specifically used to:
[0140] The step of responding to a selection operation of a user on the target interaction page and determining a target interface and a target return field selected by the user comprises:
[0141] In response to the user's selection operation on the interface list portion, selecting a target interface from a plurality of interfaces;
[0142] In response to the user's selection operation on the return field part, selecting a target return field from a plurality of fields corresponding to the target interface;
[0143] In response to the user's triggering operation on the submitted part, generating a submission instruction;
[0144] According to the submit instruction, the web page service is closed, and the target interface and the target return field are determined.
[0145] In a possible implementation manner, the returned field portion is expanded in a tree-like manner, and the returned field portion includes a plurality of field items, each of which includes a field name and a field description.
[0146] In a possible implementation, the second generating module 504 is specifically configured to:
[0147] Generate a state of the state manager according to the target return field, wherein the name of the state is the name of the target return field;
[0148] The instructions and side effects of the state manager are generated according to the target interface and the target return field, and the names of the instructions and the side effects are the names of the target interface.
[0149] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0150] Based on the same technical concept, the embodiment of the present disclosure also provides an electronic device. Fig.10 , which is a schematic diagram of the structure of an electronic device 700 provided in an embodiment of the present disclosure, including a processor 701, a memory 702, and a bus 703. The memory 702 is used to store execution instructions, including a memory 7021 and an external memory 7022; the memory 7021 is also called an internal memory, which is used to temporarily store the operation data in the processor 701 and the data exchanged with the external memory 7022 such as a hard disk. The processor 701 exchanges data with the external memory 7022 through the memory 7021.
[0151] In the embodiment of the present application, the memory 702 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 701. That is, when the electronic device 700 is running, the processor 701 communicates with the memory 702 through the bus 703, so that the processor 701 executes the application code stored in the memory 702, and then executes the method in any of the aforementioned embodiments.
[0152] Among them, the memory 702 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0153] The processor 701 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0154] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 700. In other embodiments of the present application, the electronic device 700 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0155] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for generating a state manager in the above method embodiment are executed. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0156] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the state manager generation method in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0157] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0158] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0159] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0160] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0161] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0162] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for generating a state manager, characterized in that: include: Obtaining an interface description language file, and obtaining interface information from the interface description language file; The interface information includes interface name, interface description and return field information; Generate a target interaction page according to the interface information, wherein the target interaction page is used for allowing a user to select a target interface; In response to a selection operation of a user on the target interaction page, determining a target interface and a target return field selected by the user; Generate a state manager according to the target interface and the target return field, wherein the state manager includes states, instructions and side effects, Wherein, generating a state manager according to the target interface and the target return field includes: Generate a state of the state manager according to the target return field, wherein the name of the state is the name of the target return field; The instructions and side effects of the state manager are generated according to the target interface and the target return field, and the names of the instructions and the side effects are the names of the target interface.
2. The method according to claim 1, characterized in that The obtaining of the interface description language file and obtaining the interface information from the interface description language file includes: According to the pre-configured interface description language file path, obtaining the interface description language file content; Parsing the content of the interface description language file to obtain an abstract syntax tree; The abstract syntax tree is traversed to obtain the interface information.
3. The method according to claim 1 or 2, characterized in that: The type of the interface description language file is a structure type, and the returned field information includes a field sequence number, a field name, and a field type.
4. The method according to claim 1, characterized in that: The generating a target interactive page according to the interface information includes: Start the Hypertext Transfer Protocol web service; In response to the user's operation of accessing a target browser, the target interactive page is rendered and generated based on the interface information, and the target browser corresponds to the web page service.
5. The method according to claim 4, characterized in that The target interaction page includes an interface list part, a return field part and a submission part; the interface list part includes a plurality of interface items for the user to select, and the interface items include the interface name; The return field part is used to display the return field corresponding to the target interface item selected by the user; The submitting part is used to generate a submit instruction in response to the user's submit request; The step of responding to the user's selection operation on the target interaction page and determining the target interface and target return field selected by the user comprises: In response to the user's selection operation on the interface list portion, selecting a target interface from a plurality of interfaces; In response to the user's selection operation on the return field part, selecting a target return field from a plurality of fields corresponding to the target interface; In response to the user's triggering operation on the submitted part, generating a submission instruction; According to the submit instruction, the web page service is closed, and the target interface and the target return field are determined.
6. The method according to claim 5, characterized in that The returned field part is expanded in a tree form, and the returned field part includes a plurality of field items, each of which includes a field name and a field description.
7. A device for generating a state manager, characterized in that: include: An acquisition module, used to acquire an interface description language file and obtain interface information from the interface description language file; The interface information includes interface name, interface description and return field information; A first generating module, configured to generate a target interaction page according to the interface information, wherein the target interaction page is used for a user to select a target interface; A determination module, configured to respond to a selection operation of a user on the target interaction page and determine a target interface and a target return field selected by the user; A second generating module is used to generate a state manager according to the target interface and the target return field, wherein the state manager includes states, instructions and side effects. Wherein, generating a state manager according to the target interface and the target return field includes: Generate a state of the state manager according to the target return field, wherein the name of the state is the name of the target return field; The instructions and side effects of the state manager are generated according to the target interface and the target return field, and the names of the instructions and the side effects are the names of the target interface.
8. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the method for generating a state manager as described in any one of claims 1-6 are performed.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating a state manager as described in any one of claims 1 to 6 are executed.
Citation Information
Patent Citations
Interface document generation method and device, electronic equipment and medium
CN111638908A
Method, device and terminal for automatically generating data interface without programming
CN112799659A