Form page code generation method and device, storage medium and electronic equipment
By automatically generating form page code and combining pre-configured files and template source code, the problems of long development time and inconsistent coding styles are solved, achieving efficient and standardized code generation and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI GEWU ZHIYUAN NETWORK TECH CO LTD
- Filing Date
- 2024-10-18
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, developing form page code is time-consuming, and inconsistent coding styles among developers lead to maintenance difficulties and a high bug rate.
By obtaining the pre-configuration file and predefined template source code of the target form page, parsing the field information and generating code information, and automatically generating code using operators and field information in the pre-configuration file, the template source code includes both non-editable and editable parts to ensure consistent code style.
It enables automatic generation of form page code, improving code development efficiency and quality, reducing the bug rate, and ensuring code standardization and consistency.
Smart Images

Figure CN121900736A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to computer technology, and more particularly to a method, apparatus, storage medium, and electronic device for generating form page code. Background Technology
[0002] The business system includes many list pages and configuration form pages. Currently, these pages are all manually developed by front-end developers. This development model has the following problems: First, the development time is long; second, different developers have different coding styles, which is not conducive to later maintenance; third, manually developed code has a high bug rate. Summary of the Invention
[0003] This disclosure provides a method, apparatus, storage medium, and electronic device for generating form page code, so as to realize the automatic generation of form page code, improve the consistency of code style, and improve code development efficiency and quality.
[0004] In a first aspect, embodiments of this disclosure provide a method for generating form page code, including:
[0005] Obtain the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information in the target form page;
[0006] Obtain the predefined first template source code, which includes a non-editable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators.
[0007] Write the field information from the pre-configuration file into the undefined fields in the first template source code;
[0008] Editable code information is generated based on the operator and the field information in the pre-configuration file. The code information of the uneditable part and the editable code information are used to generate the first code information corresponding to the target form page.
[0009] Secondly, embodiments of this disclosure also provide a form page code generation apparatus, comprising:
[0010] The information acquisition module is used to acquire the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information in the target form page;
[0011] The template acquisition module is used to acquire a predefined first template source code, which includes a non-editable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators.
[0012] The information writing module is used to write the field information in the pre-configuration file into the undefined field in the first template source code;
[0013] The code generation module is used to generate editable code information based on the operator and the field information in the pre-configuration file. The code information of the uneditable part and the editable code information are used to generate the first code information corresponding to the target form page.
[0014] Thirdly, embodiments of this disclosure also provide an electronic device, the electronic device comprising:
[0015] One or more processors;
[0016] Storage device for storing one or more programs.
[0017] When the one or more programs are executed by the one or more processors, the one or more processors implement the form page code generation method provided in the embodiments of this disclosure.
[0018] Fourthly, embodiments of this disclosure also provide a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the form page code generation method provided in embodiments of this disclosure.
[0019] This embodiment of the disclosure generates target form page code information by setting template source code. The code information of the form pages generated from the template source code has a consistent development style, facilitating the maintenance of code information for different form pages. Simultaneously, the template source code includes both non-editable and editable parts. The editable parts are updated using the pre-configuration file corresponding to the target form page, eliminating the need to edit the non-editable parts. This improves the standardization of the target form page's code information and avoids bugs generated during manual coding, reducing the bug rate. Furthermore, operators are set in the editable part of the template source code. These operators perform corresponding operations on the field information in the pre-configuration file to obtain editable code information, achieving automatic generation of structured information. Attached Figure Description
[0020] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0021] Figure 1 This is a flowchart illustrating a form page code generation method provided in an embodiment of this disclosure;
[0022] Figure 2This is a schematic diagram illustrating the process of generating the first code information provided in an embodiment of this disclosure;
[0023] Figure 3 This is a flowchart illustrating a form page code generation method provided in an embodiment of this disclosure;
[0024] Figure 4 This is a schematic diagram illustrating the process of generating linkage code information provided in the embodiments of this disclosure;
[0025] Figure 5 This is a schematic diagram of the structure of a form page code generation device provided in an embodiment of this disclosure;
[0026] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0027] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.
[0028] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.
[0029] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.
[0030] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.
[0031] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0032] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0033] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0034] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.
[0035] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0036] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.
[0037] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0038] Figure 1 This is a flowchart illustrating a form page code generation method provided in an embodiment of this disclosure. This embodiment is applicable to the automatic generation of form page code. The method can be executed by a form page code generation device, which can be implemented in software and / or hardware, optionally through an electronic device, such as a mobile terminal, PC, or server. The mobile terminal can be, for example, a mobile phone or tablet computer.
[0039] like Figure 1 As shown, the method includes:
[0040] S110. Obtain the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information in the target form page.
[0041] S120. Obtain a predefined first template source code, which includes an uneditable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators.
[0042] S130. Write the field information in the pre-configuration file into the undefined field in the first template source code.
[0043] S140. Based on the operator and the field information in the pre-configuration file, generate edit code information, and generate the first code information corresponding to the target form page from the code information of the uneditable part and the edit code information.
[0044] In this embodiment, multiple form pages may be included in the same system or application. To improve the consistency of code style, accuracy, and standardization of code across multiple form pages within the same system or application, a template source code is pre-set. This template source code can be determined based on the historical code of previously generated form pages. This template source code can serve as a template for the generation of subsequent form page code information. The template source code includes non-editable and editable portions. The non-editable portions are those that cannot be edited further, while the editable portions are those that can be edited again. New form page code information can be generated by editing the editable portions of the template source code.
[0045] Understandably, the uneditable portion of the source code is identical to local code information in the historical code of the generated form page. This uneditable portion of the source code may include, but is not limited to, the form page's framework code information and database call code information, which can characterize the code style. Correspondingly, during the generation of the target form page's code information, the uneditable portion of the source code in the first template is in an uneditable state, ensuring that the target form page's code information has the same style as the historical code information of the generated form page. Furthermore, the uneditable portion of the source code improves the standardization of the target form page's code information and avoids potential bugs that might occur during the coding process of this portion of the code by developers.
[0046] It is understandable that different form pages may include different fields. For example, form page 1 may include fields A, B, and C, while form page 2 may include fields F and E. This indicates that the code corresponding to the above fields in the form pages can be changed, and different form pages can be formed by setting different fields. Accordingly, during the creation of template source code, the changeable parts of the historical code of the generated form pages can be set as editable parts, and the immutable parts of the historical code of the generated form pages can be set as non-editable parts to form template source code. Optionally, the associated code information of the fields in the generated form pages can be identified in the historical code of the generated form pages. The associated code information of the fields in the historical code of the generated form pages can be identified as the changeable parts of the code and set as editable parts; the code information in the historical code of the generated form pages other than the associated code information of the fields can be identified as the immutable parts of the code. The immutable parts of the code can be retained and set as non-editable parts to form a code template. Optionally, the historical code of the generated form page is obtained. The historical code of the generated form page includes a first mark and a second mark. The first mark represents the code that cannot be changed, and the second mark represents the code that can be changed. By identifying the mark corresponding to each code information in the historical code, the code information with the first mark is retained and set as the uneditable part; the code information with the second mark is set as the editable part to form the template source code.
[0047] The template source code can be pre-created; for example, there can be multiple template source codes. The first template source code can be the template source code required to generate the template form page, and it can be one of the multiple template source codes. Optionally, the first template source code can be determined in response to a template selection operation. For example, an interactive page is displayed, which includes multiple candidate template source codes. The first template source code can be determined based on the user's template selection operation on the interactive page. Optionally, the first template source code can be determined based on the type of the target form page. Different types can correspond to different template source codes, and the corresponding template source code can be called as the first template source code based on the type of the target form page.
[0048] In this embodiment, the target form page is a form page to be generated based on user requirements. The requirement information corresponding to the target form page and the code information corresponding to the first template source code are used to generate the target form page, thereby enabling the development of the target form page. The requirement information corresponding to the target form page can be reflected in the pre-configuration file corresponding to the target form page. The pre-configuration file corresponding to the target form page may include IDL (Interface Definition Language) information.
[0049] In one embodiment, the pre-configuration file corresponding to the target form page can be pre-set or imported from an external source. By parsing the pre-configuration file, pre-configuration information is obtained, which includes field information for the fields included in the target form page. Specifically, the pre-configuration file can be parsed using a syntax tree parsing method to obtain the field information, which may include, but is not limited to, field names, field types, and field enumeration values. In some embodiments, the pre-configuration information also includes information such as whether there are validation rules or linkage relationships.
[0050] Optionally, after obtaining the field information, the system may further include displaying the field information of the target form page on the interactive page; and updating the field information in response to editing operations on the field information on the interactive page. By displaying the field information on the interactive page, developers can view the field information through the interactive interface. Furthermore, if the parsed field information does not meet the requirements of the target form page, the field information can be edited through the interactive page to update the aforementioned field information. Editing operations on field information on the interactive page may include, but are not limited to, adding, modifying, and deleting information. Accordingly, updating field information includes, but is not limited to, adding fields and their corresponding information, deleting one or more fields and their corresponding information, and modifying the information corresponding to any field, such as adding, deleting, or modifying the enumeration value of a field, or modifying validation rules or linkage relationships.
[0051] By visualizing the parsed field information, the editing and confirmation of field information in the target form page are facilitated, enabling dynamic changes to field information in the target form page without repeatedly modifying the pre-configuration file. Correspondingly, the code information for the target form page is generated based on the updated field information.
[0052] In some embodiments, the pre-configuration file corresponding to the target form page can be generated based on field information collected from the target form page via an interactive page. Specifically, an interactive page is displayed, which includes a field information collection control to obtain the field information input by the user. The interactive page may also include a field creation control; in response to a trigger operation on the field creation control, a newly added field information collection control is displayed on the interactive page to collect the field information of the newly added field. By collecting at least one field input by the user and its corresponding field information through the interactive page to form a pre-configuration file, a visual configuration process for the pre-configuration file is realized, simplifying the generation process of the pre-configuration file.
[0053] In the above embodiments, the storage address of the code information of the target form page can also be selected on the interactive page. For example, the storage address can be a folder, which makes it convenient to store the code information of the target form page.
[0054] The system generates the corresponding first code information for the target form page by parsing the field information and the first template source code. Specifically, the field information and the first template source code can be input into a logic generator, which then outputs the first code information. The logic generator generates code quickly and consumes few computational resources, meeting the need for rapid generation of large amounts of structured code information.
[0055] The editable portion of the first template source code includes operators and corresponding fields to be defined. Operators can be understood as symbols representing operation types, with each operator representing a specific operation type. The fields to be defined for each operator can be template fields, serving as placeholders. This can be achieved by abstracting code operation logic from historical code into corresponding operators based on the type of code operation, and then introducing these operators into the first template source code. Correspondingly, the logic generator can identify these operators and execute the corresponding code operation logic to obtain the code information associated with each operator. In essence, by executing the corresponding code operation logic on the parsed field information using operators, the code information corresponding to the fields in the target form page is obtained.
[0056] The parsed field information is injected into the first template source code, replacing the undefined fields corresponding to the operators. For example, the parsed fields include aaa, bbb, and ccc, along with their respective field information. Correspondingly, these fields and their information are written into the corresponding undefined fields in the first template source code, thus combining the operators with the parsed field information. For example, the defined field "NAME" in the first template source code is replaced with the field name "name" from the parsed field information, and the defined field "TITLE" is replaced with the field type "label" from the parsed field information. A correspondence exists between the undefined fields in the first template source code and the parsed field information; based on this correspondence, the field information is injected into the undefined fields in the first template source code.
[0057] By using operators and parsing field information, the code information corresponding to the fields in the target form page is obtained. The code information corresponding to the fields in the target form page can form editable code information. The editable code information and the non-editable part of the source code in the first template source code can form the first code information.
[0058] Optionally, the operators include, but are not limited to, one or more of the following: loop iteration operators, replacement operators, insertion operators, and import operators. The loop iteration operator, represented by `ForEach`, is used to iterate through each field in the pre-configuration file and generate component code information corresponding to each field. It is understood that the target form page may include multiple fields, such as time, product type, and logistics method, and corresponding code information is generated for each field. The field name / field type and other field attributes of the aforementioned fields are injected into the undefined field corresponding to the loop iteration operator. When the logic generator recognizes the loop iteration operator, it iterates through the multiple fields corresponding to the loop iteration operator, generating code information for each field. Optionally, the logic generator generates corresponding code information based on field attributes, where field attributes may include field type, field name, or enumeration values. Specifically, the logic generator determines the component type corresponding to the field based on the field attributes and generates component code information corresponding to the component type. The logic generator can be configured with a correspondence between component types and field attributes, which determines the component type corresponding to the field attribute. For example, if the field type is "time" or the field name is "xxx_time", the logic generator will generate the component code information corresponding to the DatePicker component. For example, if the field information includes an enumeration value, the logic generator will generate the component code information corresponding to the Select component. For example, if the field type is "name", the logic generator will generate the component code information corresponding to the input component.
[0059] The replacement operator can be represented by `Replace`, used to replace source code information in the first template source code with new code information. Specifically, it can replace characters or strings in the first template source code with new code information. The new code information can be component code information corresponding to any of the aforementioned fields or externally imported code information; there are no limitations here. Optionally, replacement conditions can be preset. The replacement operation is performed when the new code information meets the above replacement conditions; otherwise, the replacement operation is not performed. The replacement conditions can include the field correspondence between the source code information in the first template source code and the new code information.
[0060] The insertion operator, represented by `Insert`, is used to insert new code information into the first template source code. The pre-configuration information parsed from the pre-configuration file also includes the code insertion location and a description or identifier of the inserted code. For example, imported code information can be read using the identifier of the inserted code, and this new code information carries the identifier. Alternatively, new code information can be generated based on the description of the inserted code, for instance, through a pre-trained neural network model. This new code information includes, but is not limited to, validation code information corresponding to fields and linkage code information between fields.
[0061] For example, the code insertion location could be the top of a component on the target form page, and the description information for the inserted code could be the interface required by the target form page. The interface code information is read, or generated based on the description information, and used as new code information. The code insertion operation is then performed, inserting the new code information into the first template source code based on the insertion location. Optionally, insertion conditions can be pre-set. The code insertion operation is performed when the new code information meets the insertion conditions; otherwise, it is not performed. The insertion conditions can be configured according to requirements, for example, they could be Boolean conditions.
[0062] The import operator can be represented by AddImport, which is used to import the field information set in the pre-configuration file. For example, the set field information can be the enumeration value corresponding to the field.
[0063] In this embodiment, generating edit code information based on the operators and field information in the pre-configuration file includes: identifying the operators and performing the operations corresponding to the operators on the field information corresponding to the operators. Specifically, by identifying the loop traversal operator, the fields corresponding to the loop traversal operator are traversed to generate component code information corresponding to each field; by identifying the replacement operator, the component code information corresponding to each field is used to replace the source code information in the first template source code; by identifying the insertion operator, new code information is obtained and inserted into the first template source code based on the code insertion position. This new code information may include, but is not limited to, the verification code information corresponding to the field and the linkage code information between fields; by identifying the import operator, the enumeration value corresponding to the field is imported into the first template source code. Based on the operations corresponding to at least one of the above operators, edit code information is obtained, which may include the code information generated by the operations corresponding to at least one of the above operators. The first template source code is updated by editing the code information to obtain first code information, that is, the code information of the uneditable part and the edit code information form the first code information.
[0064] Based on the above embodiments, see Figure 2 , Figure 2 This is a schematic diagram illustrating the generation process of the first code information provided in this embodiment. IDL information (i.e., a pre-configuration file) is obtained and parsed to obtain field information. First template source code is obtained and parsed using a parser to obtain code information for the non-editable portion and operators for the editable portion. Context information is obtained by injecting the field information into the fields to be defined corresponding to the operators. The context information is then processed by a logic encoder, i.e., the operations corresponding to the operators are executed sequentially on the code information to generate editable code information. The editable code information and the non-editable code information are merged to form the first code information.
[0065] The technical solution provided in this embodiment generates the code information of the target form page by setting template source code. The code information of the form pages generated by the template source code has the same development style, which facilitates the maintenance of the code information of different form pages. Simultaneously, the template source code includes both non-editable and editable parts. The editable part is updated through the pre-configuration file corresponding to the target form page, eliminating the need to edit the non-editable parts. This improves the standardization of the code information of the target form page and avoids bugs generated during manual coding, reducing the bug rate. Furthermore, operators are set in the editable part of the template source code. These operators perform corresponding operations on the field information in the pre-configuration file to obtain editable code information, achieving automatic generation of structured information.
[0066] Figure 3 This is a flowchart of a form page code generation method provided in this disclosure, which is optimized based on the above embodiment. The method specifically includes:
[0067] S210. Obtain the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information and description information in the target form page.
[0068] S220. Obtain a predefined first template source code, which includes an uneditable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators. Write the field information in the preconfiguration file into the fields to be defined in the first template source code.
[0069] S230. Based on the operator and the field information in the pre-configuration file, generate edit code information, and generate the first code information corresponding to the target form page from the code information of the uneditable part and the edit code information.
[0070] S240. Generate prompt information based on the description information, and generate second code information based on the prompt information using a code generation model.
[0071] S250. Generate target code information corresponding to the target form page based on the first code information and the second code information.
[0072] The code information of the target form page includes not only structured code information corresponding to at least one field, but also validation code information and / or linkage code information. The validation code information can be understood as the code information that implements the validation rules, used to validate the input information corresponding to the field in the target form page to determine whether the input information corresponding to the field meets the format conditions. The linkage code information can be understood as the code information that represents the linkage relationship between at least two fields in the target form page, used to realize the dynamic linkage between at least two fields in the target form page.
[0073] Understandably, the logic of verification rules and linkage relationships is highly flexible and diverse. Complex verification rules and linkage relationships cannot be described using structured information, thus making it impossible to generate verification code and linkage code information using a logic generator. To address this issue, a code generation model is pre-set, and the description information corresponding to the verification rules and / or linkage relationships is written into a pre-configuration file. The verification code and / or linkage code information are then generated using the code generation model and the description information.
[0074] Optionally, the description information includes verification description information and / or field-linked description information, and the second code information includes verification code information and / or linked code information. The description information can be collected through an interactive page. The description information can be one or more items, and a second code information can be generated based on each description information. Correspondingly, the second code information can be one or more items.
[0075] The validation description information can be a description of the validation rules for fields in the target form page. For example, a field in the target form page could be time, and the validation rules for time could include hourly data being integers less than or equal to 24, and minute and second data being integers less than 59. The linkage description information can be a description of the linkage relationship between two or more fields in the target form page. For example, fields in the target form page could include logistics information and object type; when object type is A, logistics information is B.
[0076] The code generation model is a pre-trained neural network model. Optionally, the code generation model can be an LLM (Large Language Model), and the specific type of LLM model is not limited here. This code generation model can be trained based on developed sample code information and corresponding descriptive information. This sample code information can be validation code information and / or linkage code information.
[0077] Based on the description information parsed from the pre-configuration file, prompt information is generated. This prompt information is then used as input to the code generation model, resulting in the output of the second code information. When there are multiple pieces of description information, prompt information is generated for each piece of description information. The code generation model then processes each prompt information separately to obtain the second code information corresponding to each piece of description information. For example, the description information can be used as the prompt information, or the description information can be converted into an embedding vector, and the embedding vector can be used as the prompt information.
[0078] It is understood that the first code information may be the main code information of the target form page, and the second code information may be additional code information. In some embodiments, the target code information corresponding to the target form page includes the first code information; in some embodiments, the target code information corresponding to the target form page includes both the first code information and the second code information; accordingly, the first code information and at least one second code information are merged to obtain the target code information.
[0079] Optionally, the pre-configuration file includes the insertion position of the second code information. The insertion operation of the second code information is implemented by the insertion operator. Based on the above insertion position, the second code information is inserted into the first code information to form the target code information.
[0080] The technical solution provided in this embodiment generates first code information based on a pre-configuration file and the first template source code using a logic generator. It then generates second code information using a code generation model and descriptive information. The first and second code information together form the target code information corresponding to the target form page. The logic generator is highly efficient, consumes few resources, and can support the generation of structured code information corresponding to a large number of fields. The code generation model can support the generation of code information with complex logic. By generating the first and second code information using two different methods, it balances the generation of structured code information and code information with complex logic, improving the efficiency and reliability of automated code information generation.
[0081] Based on the above embodiments, in order to ensure that the second code information is consistent in style with the code information in other form pages in the same system or application, a second template source code is added to the prompt information to provide a template reference for the generation of the second code information, so that the second code information and the second template source code have the same style.
[0082] Optionally, the second template source code corresponding to the description information is obtained, and prompt information is generated based on the second template source code and the description information; second code information is generated based on the prompt information using a code generation model. For example, the second template source code can be determined based on the code type corresponding to the description information. For instance, the code type corresponding to the description information can be a linkage code type or a verification code type, and the second template source code can be determined from a pre-set template source code according to the code type corresponding to the description information. For example, the second template source code can be determined based on the template selection operation of the interactive page. The second template source code can be historical verification code information or historical linkage code information.
[0083] Optionally, a prompt information assembly template is obtained. This template may include prompts for the template source code and prompts for the descriptive information. For example, the prompt for the template source code could be "The following is an example of the linkage code," and the prompt for the descriptive information could be "The following is a description of the linkage relationship." Accordingly, the second template source code and descriptive information are added to the corresponding positions of the above prompts to form the prompt information. By inputting the above prompt information into the code generation model, the second code information output by the code generation model is obtained.
[0084] Based on the above embodiments, it is understood that the description information is input by the user. In order to avoid interference from the description habits or differences of different users in the second code information generation process, a preset knowledge base is set in this embodiment. The preset knowledge base includes knowledge documents in the same system or application. By matching the knowledge information corresponding to the description information in the preset knowledge base, contextual information can be provided for the description information, which facilitates the code generation model's understanding of the description information.
[0085] Optionally, the description information is converted into vector information; the vector information is matched for similarity in a preset knowledge base to obtain knowledge information that matches the description information; the preset knowledge base includes vector information corresponding to preset knowledge documents; the prompt information is updated based on the knowledge information that matches the description information; and second code information is generated based on the prompt information using a code generation model.
[0086] In this embodiment, the vector information corresponding to the description information is obtained by vectorizing the description information. For example, the description information can be processed by a vectorization model to obtain vector information; or, the description information can be segmented into multiple keywords, and the keywords can be vectorized separately to form the vector information corresponding to the description information.
[0087] The preset knowledge base is a pre-created database containing vector information corresponding to preset knowledge documents. The preset knowledge base can be constructed as follows: Preset knowledge documents are obtained; these documents can be web pages, text documents, or system / application-related documents. The preset knowledge documents are segmented into multiple document blocks. Each document block is vectorized to obtain its corresponding vector information. The preset knowledge base is then constructed based on this vector information. The preset knowledge base may include the correspondence between the document block index information and the corresponding vector information of the document blocks. The preset knowledge base can be updated periodically, for example, by adding vector information corresponding to new knowledge documents, thereby improving its comprehensiveness and accuracy.
[0088] The vector information corresponding to the description information is matched for similarity in a preset knowledge base. Specifically, the similarity data between the vector information corresponding to the description information and each vector information in the preset knowledge base is determined, and knowledge information that matches the description information is selected based on the similarity data. For example, document blocks corresponding to vector information with similarity data greater than a preset threshold can be identified as knowledge information that matches the description information; or, the document blocks corresponding to the vector information can be sorted based on the similarity data, and K document blocks can be selected as knowledge information that matches the description information.
[0089] Optionally, prompt information is generated based on the description information and the knowledge information that matches the description information; alternatively, prompt information is generated based on the description information, the knowledge information that matches the description information, and the second template source code. The above prompt information can be implemented based on a prompt information assembly template, by adding one or more of the description information, the knowledge information that matches the description information, and the second template source code to the corresponding positions of the prompt words in the prompt information assembly template to obtain the prompt information.
[0090] Optionally, before inputting the prompt information into the code generation model, a length check is performed on the prompt information. If the length of the prompt information exceeds a threshold, the number of knowledge pieces matching the description information is reduced until the length of the prompt information is less than the threshold. Specifically, this can be achieved by reducing the number K of knowledge pieces matching the description information, or by increasing a preset threshold for the similarity data.
[0091] Based on the above embodiments, see Figure 4 , Figure 4 This is a schematic diagram illustrating the generation process of linkage code information provided in this embodiment. The linkage description information is obtained, and then processed through text segmentation and vectorization to obtain vector information corresponding to the linkage description information. This vector information is matched against a preset knowledge base to determine the matched context information, which is the knowledge information matching the description information. The linkage template source code (i.e., the second template source code) corresponding to the linkage description information is obtained. The context information, linkage description information, and linkage template source code are assembled into a prompt information. A token calculation is performed on the prompt information, i.e., determining whether the length of the prompt information is greater than a threshold. If the length of the prompt information is greater than the threshold, the number of pieces of information k in the context information is reduced. If the length of the prompt information is less than the threshold, the prompt word is input into the LLM model to obtain the linkage code information output by the LLM model, i.e., the second code information.
[0092] 4 is understandable. Figure 4 This is just one example; when the linked description information is replaced with the verification description information, it can be based on... Figure 4 The diagram shown generates verification code information corresponding to the verification description information.
[0093] Based on the above embodiments, the first code information, the second code information, and the target code information are all generated in the code editing application; the target form page is displayed in the network view. Data communication between the code editing application and the network view is pre-established, for example, by establishing a communication interface between the code editing application and the network view to realize data transmission between the code editing application and the network view, so that the code information generated in the code editing application can be rendered in the network view, realizing the visual development of the target form page. For example, the code editing application can be a VSCode application, in which a React environment is set up, including a local development environment and a production environment. A new view folder is created in the VSCode application to maintain the code of the React application. The code of the React environment is packaged separately, and two sets of packaging configurations are maintained for the production environment and the local development environment. Different paths for React application resources are set according to the environment, and the paths are injected into the script src of the webview html to load the React application.
[0094] Optionally, the code information corresponding to the target form page generated in the code editing application is converted into static resources, and the static resources are injected into the page file of the web view. The target form page is then rendered in the web view based on the static resources in the page file, wherein the code editing application and the web view establish data communication in advance. The page file can be a page file of the web view, such as an HTML file, and the web view can render the content in the HTML file to display the target form page.
[0095] In this embodiment, the code information corresponding to the target form page generated by the code editing application is packaged and converted into static resources. The static resources are then injected into the page file of the network view through the communication interface between the code editing application and the network view. The content of the page file is then rendered in the network view, and the target form page is rendered without closing the webview page.
[0096] Optionally, the code information corresponding to the target form page can be periodically converted into static resources and injected into the page file. Periodic updates of the page file then enable periodic hot updates of the view corresponding to the target form page. During each hot update, the target code information corresponding to the target form page can be converted into static resources and injected into the page file, updating the page file's content. Alternatively, incremental code information corresponding to the target form page can be obtained, converted into static resources, and injected into the page file, updating the page file's content. The network view then renders the updated page file content, achieving periodic hot updates of the target form page.
[0097] Figure 5 This is a schematic diagram of a form page code generation device provided in an embodiment of the present disclosure, as shown below. Figure 2 As shown, the device includes: an information acquisition module 310, a template acquisition module 320, an information writing module 330, and a code generation module 340.
[0098] Information acquisition module 310 is used to acquire the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information in the target form page;
[0099] The template acquisition module 320 is used to acquire a predefined first template source code, which includes a non-editable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators.
[0100] Information writing module 330 is used to write field information from the pre-configuration file into undefined fields in the first template source code;
[0101] The code generation module 340 is used to generate editable code information based on the operator and the field information in the pre-configuration file, and the code information of the uneditable part and the editable code information generate the first code information corresponding to the target form page.
[0102] The technical solution provided in this disclosure generates target form page code information by setting template source code. The code information of the form pages generated from the template source code has a consistent development style, facilitating the maintenance of code information for different form pages. Simultaneously, the template source code includes both non-editable and editable parts. The editable parts are updated using the pre-configuration file corresponding to the target form page, eliminating the need to edit the non-editable parts. This improves the standardization of the target form page's code information and avoids bugs generated during manual coding, reducing the bug rate. Furthermore, operators are set in the editable part of the template source code. These operators perform corresponding operations on the field information in the pre-configuration file to obtain editable code information, achieving automatic generation of structured information.
[0103] Based on the above embodiments, optionally, the code generation module 340 is used to: identify the operator and perform the operation corresponding to the operator on the field information corresponding to the operator.
[0104] Optionally, the operators include one or more of the following: loop traversal operator, replacement operator, insertion operator, and import operator; wherein, the loop traversal operator is used to traverse each field in the pre-configuration file and generate component code information corresponding to each field; the replacement operator is used to replace the source code information in the first template source code with new code information; the insertion operator is used to insert new code information into the first template source code; and the import operator is used to import the field information set in the pre-configuration file.
[0105] Optionally, based on the above embodiments, the pre-configuration file may also include descriptive information;
[0106] The code generation module 340 is further configured to generate prompt information based on the description information, generate second code information based on the prompt information through the code generation model, and generate target code information corresponding to the target form page based on the first code information and the second code information.
[0107] Optionally, the description information includes verification description information and / or field linkage description information, and the second code information includes verification code information and / or linkage code information.
[0108] Optionally, the code generation module 340 is further configured to obtain the second template source code corresponding to the description information, generate prompt information based on the second template source code and the description information, and generate second code information based on the prompt information through the code generation model.
[0109] Optionally, the code generation module 340 is further configured to convert the description information into vector information; perform similarity matching on the vector information in a preset knowledge base to obtain knowledge information that matches the description information; the preset knowledge base includes vector information corresponding to preset knowledge documents; update the prompt information based on the knowledge information that matches the description information; and generate second code information based on the prompt information through a code generation model.
[0110] Based on the above embodiments, optionally, the information acquisition module 310 is further configured to display field information in the target form page on the interactive page; and update the field information in response to an editing operation on the field information on the interactive page.
[0111] Based on the above embodiments, optionally, the code information corresponding to the target form page is generated in a code editing application, wherein the code information corresponding to the target form page includes one or more of the first code information and the target code information;
[0112] The device further includes a form page rendering module, used to convert the code information corresponding to the target form page generated by the code editing application into static resources, inject the static resources into the page file of the network view, and render the target form page in the network view based on the static resources in the page file, wherein the code editing application and the network view establish data communication in advance.
[0113] The form page code generation apparatus provided in this disclosure can execute the form page code generation method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0114] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be realized; in addition, the specific names of each functional unit are only for easy differentiation and are not used to limit the protection scope of the embodiments of this disclosure.
[0115] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Reference is made below. Figure 6 It illustrates an electronic device suitable for implementing embodiments of the present disclosure (e.g., Figure 6The diagram below shows the structure of the terminal device or server 500. The terminal device in this embodiment may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and vehicle terminals (e.g., vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0116] like Figure 6 As shown, electronic device 500 may include a processing unit (e.g., central processing unit, graphics processor, etc.) 501, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 502 or a program loaded from storage device 508 into random access memory (RAM) 503. The RAM 503 also stores various programs and data required for the operation of electronic device 500. The processing unit 501, ROM 502, and RAM 503 are interconnected via bus 504. An edit / output (I / O) interface 505 is also connected to bus 504.
[0117] Typically, the following devices can be connected to I / O interface 505: input devices 506 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 507 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 508 including, for example, magnetic tapes, hard disks, etc.; and communication devices 509. Communication device 509 allows electronic device 500 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 6 An electronic device 500 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.
[0118] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, it performs the functions defined in the methods of embodiments of this disclosure.
[0119] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
[0120] The electronic device provided in this embodiment and the form page code generation method provided in the above embodiments belong to the same inventive concept. Technical details not described in detail in this embodiment can be found in the above embodiments, and this embodiment has the same beneficial effects as the above embodiments.
[0121] This disclosure provides a computer storage medium storing a computer program that, when executed by a processor, implements the form page code generation method provided in the above embodiments.
[0122] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0123] In some implementations, clients and servers can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future-developed networks.
[0124] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.
[0125] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to:
[0126] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: obtain a pre-configuration file corresponding to the target form page; parse the pre-configuration file to obtain field information in the target form page; and obtain a predefined first template source code, wherein the first template source code includes a non-editable part and an editable part, and the editable part includes operators and fields to be defined corresponding to the operators.
[0127] Write the field information in the pre-configuration file into the undefined fields in the first template source code; generate edit code information based on the operator and the field information in the pre-configuration file, and generate the first code information corresponding to the target form page from the code information of the uneditable part and the edit code information.
[0128] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including but not limited to object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0129] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0130] The units described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a unit does not necessarily limit the unit itself; for example, the first acquisition unit can also be described as "a unit that acquires at least two Internet Protocol addresses".
[0131] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.
[0132] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0133] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.
[0134] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0135] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.
Claims
1. A method for generating form page code, characterized in that, include: Obtain the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information in the target form page; Obtain the predefined first template source code, which includes a non-editable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators. Write the field information from the pre-configuration file into the undefined fields in the first template source code; Editable code information is generated based on the operator and the field information in the pre-configuration file. The code information of the uneditable part and the editable code information are used to generate the first code information corresponding to the target form page.
2. The method according to claim 1, characterized in that, The process of generating edit code information based on the operator and the field information in the pre-configuration file includes: Identify the operator and perform the operation corresponding to the operator on the field information corresponding to the operator.
3. The method according to claim 1 or 2, characterized in that, The operators include one or more of the loop traversal operator, the substitution operator, the insertion operator, and the import operator; The loop traversal operator is used to traverse each field in the pre-configuration file and generate the component code information corresponding to each field; The replacement operator is used to replace the source code information in the first template source code with new code information; The insertion operator is used to insert new code information into the first template source code; The import operator is used to import the field information set in the pre-configuration file.
4. The method according to claim 1, characterized in that, The pre-configuration file also includes descriptive information; The method further includes: Based on the description information, a prompt message is generated; and through a code generation model, a second code message is generated based on the prompt message. The target code information corresponding to the target form page is generated based on the first code information and the second code information.
5. The method according to claim 4, characterized in that, The description information includes verification description information and / or field linkage description information, and the second code information includes verification code information and / or linkage code information.
6. The method according to claim 4, characterized in that, The method further includes: Obtain the second template source code corresponding to the description information, and generate prompt information based on the second template source code and the description information; The code generation model generates second code information based on the prompt information.
7. The method according to claim 4 or 6, characterized in that, The method further includes: Convert the description information into vector information; The vector information is matched for similarity in a preset knowledge base to obtain knowledge information that matches the description information; the preset knowledge base includes vector information corresponding to preset knowledge documents; The prompt information is updated based on the knowledge information that matches the description information; The code generation model generates second code information based on the prompt information.
8. The method according to claim 1, characterized in that, The method further includes: The interactive page displays the field information from the target form page; In response to an editing operation on the field information in the interactive page, the field information is updated.
9. The method according to claim 4, characterized in that, The code information corresponding to the target form page is generated in the code editing application, wherein the code information corresponding to the target form page includes one or more of the first code information and the target code information; The method further includes: converting the code information corresponding to the target form page generated in the code editing application into static resources, injecting the static resources into the page file of the network view, and rendering the target form page in the network view based on the static resources in the page file, wherein the code editing application and the network view establish data communication in advance.
10. A form page code generation device, characterized in that, include: The information acquisition module is used to acquire the pre-configuration file corresponding to the target form page, and parse the pre-configuration file to obtain the field information in the target form page; The template acquisition module is used to acquire a predefined first template source code, which includes a non-editable part and an editable part. The editable part includes operators and fields to be defined corresponding to the operators. The information writing module is used to write the field information in the pre-configuration file into the undefined field in the first template source code; The code generation module is used to generate editable code information based on the operator and the field information in the pre-configuration file. The code information of the uneditable part and the editable code information are used to generate the first code information corresponding to the target form page.
11. An electronic device, characterized in that, The electronic device includes: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the form page code generation method as described in any one of claims 1-9.
12. A storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform the form page code generation method as described in any one of claims 1-9.