List component service code generation method and device, equipment and medium
By replacing the placeholders in the code template with context data and generating target business code, the problems of low efficiency and high cost when developing different list components in the prior art are solved, and the list component code with similar business logic is quickly generated.
Patent Information
- Application Number
- CN202311458455.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-02
- Publication Date
- 2025-05-06
AI Technical Summary
In the prior art, there are problems with low development efficiency and high cost when developing different list components. The main reason is that there are differences in different list display content, interaction logic and jump logic, different components need to be developed.
By obtaining the context data of the target list component, finding and replacing the placeholders in the code template, generating the target business code. The context data includes key-value pairs, the key represents the list configuration item field to be replaced, and the value represents the target configuration information.
This method reduces repetitive work in the code development process, allows the rapid generation of business code for list components with similar business logic based on existing list components, improving development efficiency and reducing development costs.
Smart Images

Figure CN119937995A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a method, device, equipment and medium for generating a list component business code. Background Art
[0002] At present, with the rapid development of information technology, related applications have gradually been integrated into people's lives, providing people with a variety of services. For example, in some scenarios, there are applications with list components. List components can be used to display a list of related data or items. It can provide a clear and intuitive interface layout and a convenient and efficient operation mode, allowing relevant personnel to quickly browse and process a large amount of information, which is conducive to improving work efficiency.
[0003] In the related art, there are generally a large number of lists in an application, and different lists may display different contents, corresponding interactions, and jump logics. Different list components often need to be developed to meet different needs, which results in low development efficiency and high costs.
[0004] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, device and medium for generating a list component business code, which can improve the development efficiency of the list component and reduce the development cost.
[0006] An aspect of an embodiment of the present application provides a method for generating a list component service code, the method comprising:
[0007] Acquire context data corresponding to the target list component; wherein the context data includes at least one key-value pair, the key in the key-value pair is used to represent the list configuration item field to be replaced, and the value in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced;
[0008] According to the context data, searching and determining the target code template corresponding to the target list component; wherein the target code template includes the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced in the target code template is a placeholder;
[0009] The placeholder in the target code template is replaced by the value of the key-value pair in the context data to obtain the target business code corresponding to the target list component.
[0010] On the other hand, an embodiment of the present application provides a device for generating a list component service code, the device comprising:
[0011] An acquisition unit, configured to acquire context data corresponding to a target list component; wherein the context data includes at least one key-value pair, the key in the key-value pair is used to represent the list configuration item field to be replaced, and the value in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced;
[0012] A search unit, configured to search and determine, according to the context data, a target code template corresponding to the target list component; wherein the target code template includes the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced in the target code template is a placeholder;
[0013] The replacement unit is used to replace the placeholder in the target code template by the value of the key-value pair in the context data to obtain the target business code corresponding to the target list component.
[0014] Optionally, the acquiring unit is specifically used for:
[0015] In response to the code generation instruction of the target object, a front-end scaffolding tool is created;
[0016] The context data corresponding to the target list component is obtained through the front-end scaffolding tool.
[0017] Optionally, the device further comprises a trigger unit; the trigger unit is specifically used for:
[0018] Detecting a touch screen operation of the target object on the terminal device, and triggering the code generation instruction according to the touch screen operation;
[0019] Alternatively, voice data of the target object is acquired, voice recognition is performed on the voice data, and the code generation instruction is triggered according to a result of the voice recognition.
[0020] Optionally, the device further includes a generating unit; the generating unit is specifically configured to:
[0021] Get the original code data of the first list component;
[0022] Performing field matching detection on the original code data to determine the list configuration item field contained in the original code data;
[0023] The field content of at least one list configuration item field in the original code data is replaced by a placeholder to obtain a code template corresponding to the first list component.
[0024] Optionally, the generating unit is specifically used for:
[0025] Extracting a first field contained in the original code data;
[0026] The first field is matched with a reference field to determine the list configuration item field included in the original code data; wherein the reference field is a preset list configuration item field.
[0027] Optionally, the generating unit is specifically used for:
[0028] Calculating the similarity between the reference field and the first field;
[0029] If the similarity between the reference field and the first field is greater than or equal to a preset threshold, the first field is determined to be a list configuration item field contained in the original code data; or, if the similarity between any of the reference fields and the first field is less than a preset threshold, it is determined that the first field does not belong to a list configuration item field.
[0030] Optionally, the generating unit is specifically used for:
[0031] Extracting a first feature vector corresponding to the reference field and a second feature vector corresponding to the first field;
[0032] determining a first length of the first eigenvector and a second length of the second eigenvector;
[0033] Obtaining a first value according to the product of the first length and the second length, and obtaining a second value according to the inner product of the first eigenvector and the second eigenvector;
[0034] The similarity is obtained according to the quotient of the second value and the first value.
[0035] Optionally, the generating unit is specifically used for:
[0036] Create a corresponding regular expression according to the reference field; wherein the reference field is a preset list configuration item field;
[0037] The original code data is subjected to field matching detection by using the regular expression to determine the list configuration item field contained in the original code data.
[0038] Optionally, the generating unit is specifically used for:
[0039] Constructing an automaton-based matching tree model according to a reference field; wherein the reference field is a preset list configuration item field;
[0040] Input characters in the original code data into the matching tree model to determine a target character combination in the original code data that matches the reference field;
[0041] According to the target character combination, the list configuration item field included in the original code data is determined.
[0042] Optionally, the searching unit is specifically used for:
[0043] Determine, according to the context data, a first code template including all the list configuration item fields to be replaced;
[0044] A second code template in which field contents of all the to-be-replaced list configuration item fields are placeholders is determined from the first code target, and the second code template is determined as a target code template.
[0045] Optionally, the replacement unit is specifically used for:
[0046] Calling a template engine to compile the target code template to obtain a target program function;
[0047] The values of the key-value pairs in the context data are input as parameters to the target program function to obtain a result string, and the result string is determined as the target service code.
[0048] On the other hand, an embodiment of the present application provides an electronic device, including a processor and a memory;
[0049] The memory is used to store computer programs;
[0050] The processor executes the computer program to implement the aforementioned method for generating the list component business code.
[0051] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the aforementioned method for generating a list component business code.
[0052] The embodiments of the present application at least include the following beneficial effects: The present application provides a method, device, equipment and medium for generating a business code of a list component, obtains context data corresponding to a target list component, and the context data includes at least one key-value pair, wherein the key is used to represent the list configuration item field to be replaced, and the value is used to represent the target configuration information corresponding to the list configuration item field to be replaced; through the context data, the target configuration information corresponding to certain list configuration item fields in the target list component can be set. Then, the target code template corresponding to the target list component can be found and determined through the context data, that is, the code template including the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced is a placeholder. Then, the placeholder of the target code template is replaced with the value of the key-value pair to obtain the target business code. The technical solution in the embodiment of the present application can reduce the repetitive work in the code development process, facilitate the rapid generation of business codes of list components with similar business logic based on existing list components, and is conducive to improving the development efficiency of list components and reducing development costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The accompanying drawings are used to provide further understanding of the technical solution of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present application and do not constitute a limitation on the technical solution of the present application.
[0054] Figure 1 A schematic diagram of a list displayed in an application provided in an embodiment of the present application;
[0055] Figure 2 A schematic diagram of a list displayed in another application provided in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of an implementation environment of a method for generating a list component business code provided in an embodiment of the present application;
[0057] Figure 4 A flowchart of a method for generating a list component service code provided in an embodiment of the present application;
[0058] Figure 5 A schematic diagram of an interface of a code development software provided in an embodiment of the present application;
[0059] Figure 6 A schematic diagram of a process for generating a code template provided in an embodiment of the present application;
[0060] Figure 7 A schematic diagram of a process for generating a standard service code provided in an embodiment of the present application;
[0061] Figure 8A schematic diagram of the implementation principle of a method for generating a list component business code provided in an embodiment of the present application;
[0062] Fig. 9 A specific flow chart of a method for generating a list component business code provided in an embodiment of the present application;
[0063] Fig.10 A schematic diagram of the structure of a device for generating a list component service code provided in an embodiment of the present application;
[0064] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0066] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0067] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0068] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0069] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0070] 1) List component, a program component used to display a list of related data or items.
[0071] 2) Front-end boilerplate (or scaffolding), an automated tool that helps developers quickly set up and build a new front-end project. Front-end scaffolding is mainly used to generate the initial project structure, required files, code templates, and configure the basic environment. Such tools improve development efficiency and allow developers to focus on implementing specific business logic without having to manually create and configure projects.
[0072] 3) JavaScript, a high-level, interpreted programming language. It is mainly used to achieve interactive and dynamic effects in web browsers, and can also run in environments such as server-side, mobile applications and desktop applications.
[0073] 4) Placeholder: A mark or symbol used in programming to represent a value to be filled.
[0074] 5) Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer and application service layer. Blockchain can include public chain, alliance chain and private chain. Among them, public chain refers to a blockchain that anyone can enter the blockchain network at any time to read data, send data or compete for accounting; alliance chain refers to a blockchain jointly managed by several organizations or institutions; private chain refers to a blockchain with certain centralized control. The write right of the private chain account book is controlled by a certain organization or institution, and the access and use of data are strictly managed by permissions.
[0075] At present, with the rapid development of information technology, related applications have gradually been integrated into people's lives, providing people with a variety of services. For example, in some scenarios, there are applications with list components. List components can be used to display a list of related data or items. It can provide a clear and intuitive interface layout and a convenient and efficient operation mode, allowing relevant personnel to quickly browse and process a large amount of information, which is conducive to improving work efficiency.
[0076] In the related art, there are generally a large number of lists in an application, and different lists may display different contents, corresponding interactions, and jump logics.
[0077] For example, please refer to Figure 1 and Figure 2 , Figure 1 A schematic diagram of a list displayed in an application provided in an embodiment of the present application is shown. Figure 1 The application shown in the figure is software for processing information security related information. Specifically, under its management module, it includes related lists corresponding to various different risks. Figure 1 The list displayed in the figure is the corresponding list of "Risk A", which includes multiple columns such as "Port", "Risk Level", "Asset Name", "Affiliated Institution", etc. Specific business information can be displayed under each column. Figure 2 , Figure 2 A schematic diagram of another list displayed in an application provided in an embodiment of the present application is shown. Figure 2 The list displayed in the figure is for "Risk B", which includes multiple columns such as "Vulnerability Name", "Tag", "Affected Assets", and "Number of Attacks". Figure 1 and Figure 2 The lists shown have basically the same overall functions, and the differences generally include but are not limited to: 1) different column fields of the lists; 2) different filter items of the lists; 3) different customized display contents of certain columns in the lists, and may have different interactions or jumps; (4) different interfaces called by each list. Of course, it can be understood that the above is only used to illustrate some differences that may exist between different lists, and does not mean to limit the actual differences between the lists. For example, in some cases, different lists may have some of the same column fields, or different lists may call the same interface, and this application does not limit this.
[0078] It is understandable that different list components need to be developed for different needs. In the related art, the general components of the list are generally used, or the business logic related to the list is encapsulated into an independent component. In the former, the general components often only contain some basic functions, and the code is relatively easy to be redundant. In actual use, such components still require developers to continue to modify and adjust the specific business logic based on the existing code to meet business needs, which leads to low application development efficiency and a large workload. There are also some problems with encapsulating the business logic related to the list into an independent component: for example, the list component may be reused in the project. If the function of the list component needs to be expanded, it will bring greater operational logic risks to the encapsulated list component; moreover, the list component obtained by encapsulating the business logic generally needs to be compatible with many situations, there are a large number of conditional judgments, the code implementation is relatively complex, and the maintenance difficulty is very high. Therefore, on the whole, the business code of the current list component has the problems of low development efficiency and high cost.
[0079] In view of this, a method, device, equipment and medium for generating a business code of a list component are provided in an embodiment of the present application, and context data corresponding to a target list component is obtained, wherein the context data includes at least one key-value pair, wherein the key is used to represent the list configuration item field to be replaced, and the value is used to represent the target configuration information corresponding to the list configuration item field to be replaced; through the context data, the target configuration information corresponding to certain list configuration item fields in the target list component can be set. Then, the target code template corresponding to the target list component can be found and determined through the context data, that is, the code template including the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced is a placeholder. Then, the placeholder of the target code template is replaced with the value of the key-value pair to obtain the target business code. The technical solution in the embodiment of the present application can reduce the repetitive work in the code development process, facilitate the rapid generation of business codes of list components with similar business logic based on existing list components, and is conducive to improving the development efficiency of list components and reducing development costs.
[0080] The method for generating the list component business code provided in the embodiment of the present application mainly relates to the field of information technology, for example, it may be but not limited to various application scenarios such as cloud technology, artificial intelligence, smart transportation, and assisted driving. It can be understood by those skilled in the art that the method for generating the list component business code provided in the embodiment of the present application can be executed in various application scenarios. Specifically, an exemplary description is given below:
[0081] Exemplarily, in some embodiments, the method for generating the list component business code in the embodiment of the present application can be applied in the scenario of task management. For example, a task management application can use a list component to display the to-do tasks of an object. Each task can contain information such as a title, description, and deadline, and can be easily viewed, edited, and deleted through the list component. Through the method for generating the list component business code in the embodiment of the present application, the underlying code of the list component corresponding to different task lists in the task management application can be quickly generated.
[0082] Exemplarily, in some embodiments, the method for generating the list component business code in the embodiment of the present application can be applied in online shopping scenarios. For example, an e-commerce application can use a list component to display information such as the name, price, and picture of a product. Shoppers can browse different products by scrolling through the list, and can click on the products in the list to view detailed information or perform operations such as purchase and collection. Through the method for generating the list component business code in the embodiment of the present application, the underlying code of the list component corresponding to different product lists in the e-commerce application can be quickly generated.
[0083] For example, in some embodiments, the method for generating the list component business code in the embodiment of the present application can be applied in a network social networking scenario. For example, a social media application may generally include a contact list, each contact may include information such as name, phone number, email address, etc., and the user can conveniently search and select contacts through the list component. Through the method for generating the list component business code in the embodiment of the present application, the underlying code of the list component corresponding to the contact list in the social media application can be quickly generated.
[0084] Of course, it is understood that the above application scenarios are only exemplary and do not limit the actual application of the method for generating the list component business code provided in the embodiment of the present application. Those skilled in the art can understand that in different application scenarios, the method for generating the list component business code provided in the embodiment of the present application can be used to perform the specified task.
[0085] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on the object's information, the object's behavioral data, the object's historical data, the object's location information, and other data related to the object's identity or characteristics, the object's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain sensitive information of the object, the object's separate permission or separate consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the object's separate permission or separate consent, the necessary object-related data for the normal operation of the embodiment of the present application will be obtained.
[0086] The specific implementation of the embodiment of the present application is described in detail below in conjunction with the accompanying drawings. First, a method for generating a list component service code provided in the embodiment of the present application is described in conjunction with the accompanying drawings.
[0087] Please refer to Figure 3 , Figure 3 The schematic diagram of the implementation environment of a method for generating a list component business code provided in an embodiment of the present application is shown. In the implementation environment, the main hardware and software entities involved include a terminal device 310 and a backend server 320. The terminal device 310 and the backend server 320 are connected in communication.
[0088] Specifically, the method for generating the list component business code provided in the embodiment of the present application can be executed alone on the terminal device 310 side, or can be executed alone on the background server 320 side, or can be executed based on data interaction between the terminal device 310 and the background server 320.
[0089] Exemplarily, the method for generating the list component business code provided in the embodiment of the present application is performed based on the data interaction between the terminal device 310 and the background server 320. In some embodiments, the terminal device 310 can be the development end of the application, and the background server 320 can be a background server for storing code templates. The developer can implement the development configuration of the list component in the application based on the terminal device 310 and the background server 320. Specifically, when it is necessary to develop a list component, the developer can determine the context data corresponding to the target list component and input the context data into the terminal device 310. After the terminal device 310 obtains the context data corresponding to the target list component, it can be transmitted to the background server 320. The background server 320 can search according to the context data to determine the target code template corresponding to the target list component. Then the target code template is returned to the terminal device 310, and the terminal device 310 can use the value of the key-value pair in the context data to replace the placeholder in the target code template, thereby obtaining the target business code corresponding to the target list component.
[0090] Among them, the terminal device 310 of the above embodiment may include a mobile phone, a computer, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc., but is not limited thereto.
[0091] The backend server 320 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.
[0092] In addition, the backend server 320 may also be a node server in the blockchain network.
[0093] The terminal device 310 and the backend server 320 can establish a communication connection through a wireless network or a wired network. The wireless network or wired network uses standard communication technology and / or protocols. The network can be set to the Internet or any other network, such as but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a private network or any combination of a virtual private network. Moreover, the above-mentioned software and hardware entities can use the same communication connection mode or different communication connection modes, and this application does not make specific restrictions on this.
[0094] Of course, it is understandable that Figure 3 The implementation environment in the example is just some optional application scenarios of the method for generating the list component business code provided in the embodiment of the present application. The actual application is not fixed. Figure 3 The method provided in the embodiment of the present application can be applied to various technical fields, such as cloud technology, artificial intelligence, smart transportation, assisted driving, etc., and the present application does not make any specific limitation on this.
[0095] Below, in combination with the above description of the implementation environment, a method for generating a list component business code provided in an embodiment of the present application is introduced and explained in detail.
[0096] like Figure 4 As shown, in the embodiment of the present application, a method for generating a list component business code is provided, and the method for generating a list component business code can be applied to Figure 4 In the terminal device 310 or the backend server 320 shown. Figure 4 The method for generating the list component business code provided in the embodiment of the present application specifically includes but is not limited to steps 410 to 430:
[0097] Step 410: Obtain context data corresponding to the target list component; wherein the context data includes at least one key-value pair, the key in the key-value pair is used to represent the list configuration item field to be replaced, and the value in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced;
[0098] In the embodiment of the present application, when generating the business code corresponding to the list component, the list component for which the business code needs to be generated is recorded as the target list component. This application does not limit the specific application scenarios and functions of the target list component. In the embodiment of the present application, the business code corresponding to the target list component is recorded as the target business code.
[0099] In this step, when the target business code corresponding to the target list component is generated, the context data corresponding to the target list component can be obtained. Here, the context data refers to some configuration data related to the business of the target list component. Specifically, the context data includes at least one key-value pair, wherein, for each key-value pair, the key (key) in the key-value pair is used to represent a list configuration item field to be replaced; the value (value) in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced, that is, the actual required configuration information at the target list component corresponding to the list configuration item field to be replaced.
[0100] In this step, there is no specific restriction on the content of the context data corresponding to the target list component. Exemplarily, for example, in some embodiments, the key (key) in the key-value pair in the context data may include the column configuration field columns in the list component, which can be used to define the information related to the columns in the list; in some embodiments, the key (key) in the key-value pair in the context data may include the list top configuration field options in the list component, which can be used to define the top-related settings in the list; in some embodiments, the key (key) in the key-value pair in the context data may also include a paging configuration field (pagination), a data source field (dataSource), a callback function field (onSelect, onEdit, onDelete), etc., and this application does not limit this. Relatively speaking, for different types of keys (key), their corresponding values (value) will also be different. In the embodiments of this application, this is introduced exemplarily. For example, when the key in a key-value pair is the column configuration field columns, its corresponding value can be the column title name; when the key in a key-value pair is the options configuration field at the top of the list, its corresponding value can be the configuration information of the search box, filter conditions, operation buttons, etc.
[0101] It should be noted that in the embodiments of the present application, the list configuration item field represented by the key in the context data may also be a more detailed subordinate field of the aforementioned example field. For example, in some embodiments, the column configuration field columns may include fields such as the column title field title, the column width field width, and the column sorting method sorter. These fields may also be set as the key in the context data, and the corresponding target configuration information may be set as the value for these keys according to the actual needs of the target list component.
[0102] It is understandable that in the embodiment of the present application, the target configuration information corresponding to certain list configuration item fields in the target list component can be set by context data. These target configuration information are related to the functions and applications of the target list component itself, and can be determined according to specific needs. The context data can be used later to realize the generation of the target business code based on the pre-stored code template. In this way, the generation efficiency of the target business code can be greatly improved, and the development difficulty and cost of the target list component can be reduced.
[0103] Step 420: search and determine the target code template corresponding to the target list component according to the context data; wherein the target code template includes the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced in the target code template is a placeholder;
[0104] In this step, after obtaining the context data corresponding to the target list component, the corresponding code template can be searched in a pre-established code template database based on the context data. In the embodiment of the present application, the code template corresponding to the target list component is recorded as the target code template.
[0105] Specifically, in the embodiment of the present application, the code template refers to the code obtained by replacing the field content of the list configuration item field in the business code corresponding to some list components with a placeholder. Generally speaking, for a list component, some field contents in its corresponding business code are common codes that can be reused in different business modules, such as the event processing function onQueryChange and the request function request. However, some field contents related to the display content and business logic of the list, such as the aforementioned list configuration item field, the field contents corresponding to the business codes of different list components are often different. Here, it should be pointed out that although there are differences in the field contents corresponding to the business codes of the list components, the functional frameworks of some list components are similar, that is, they may have the same list configuration item fields, but the field contents in the specific list configuration item fields are different. Therefore, in the embodiment of the present application, for some existing business codes corresponding to the list components, it can be considered to replace the field contents of the list configuration item fields with placeholders to obtain code templates, and then develop new list components based on the code templates.
[0106] For example, for an existing list component, some of the business codes it contains are as follows:
[0107]
[0108]
[0109] In the above business code, there are some field contents that can be reused in other list components, such as the event processing function onQueryChange and the request function request, etc. In the embodiment of the present application, based on the existing list component, the field content of the list configuration item field (at least one place) can be replaced with a placeholder. For example, the column configuration field columns in the above business code can be replaced with a placeholder to obtain a code template. Of course, it can be understood that in the embodiment of the present application, when generating a code template, for each existing list component, the field content of all the list configuration item fields can be replaced with a placeholder, or the field content of some of the list configuration item fields can be replaced with a placeholder, and the present application does not limit this.
[0110] In this step, when generating the target list component, the target code template can be found and determined from the existing code templates according to the context data. Specifically, it can be understood that in the embodiment of the present application, the context data includes at least one key-value pair, and the key in each key-value pair defines the list configuration item field to be replaced. Therefore, the target list component corresponding to all the list configuration item fields to be replaced can be determined according to the context data. Then, a code template with all the above-mentioned list configuration item fields to be replaced can be found in the existing code template, and the field contents corresponding to these list configuration item fields to be replaced need to be replaced with placeholders, so that the target code template can be determined. In this way, the writing of context data in the target code template can be realized through simple field replacement later.
[0111] It can be understood that, in the embodiments of the present application, using existing list components to generate code templates, and then developing new target list components through the code templates, can effectively improve the development efficiency of the list components and reduce development costs.
[0112] Furthermore, in an embodiment of the present application, placeholders are used to replace the field contents of the list configuration item fields in the business code of an existing list component to obtain a code template for developing a new target list component. This prevents the list configuration item field codes of the existing list component from being reused in other functional modules, reduces the coupling between list components, and does not affect other business functions when modifying the list component.
[0113] Step 430: Replace the placeholder in the target code template with the value of the key-value pair in the context data to obtain the target business code corresponding to the target list component.
[0114] In this step, after finding and determining the target code template, the value of the key-value pair in the context data, that is, the target configuration information of the list configuration item field actually required by the target list component, can be written into the target code template to obtain the target business code corresponding to the target list component.
[0115] Specifically, in the embodiments of the present application, when replacing the placeholders in the target code template to generate the target business code, the specific implementation method can be determined according to the programming language and underlying framework used by the code. For example, in some embodiments, the value of the key-value pair can be inserted into the code string where the placeholder is located in the target code template by string concatenation; in some embodiments, the built-in string formatting function or method can also be used to insert the value of the key-value pair into the placeholder position specified in the target code template; in some embodiments, a special template engine can be used to implement the replacement by defining the replacement rules of the target code template and context data to generate the target business code, and the present application does not limit this.
[0116] It can be understood that in the embodiments of the present application, the target business code corresponding to the target list component is generated by perfecting and replacing the code template, so that the target business code corresponding to each business requirement can be quickly generated. Compared with the application method of encapsulating the list-related business logic into an independent component in the related technology, in the embodiments of the present application, for different situations in the business logic, the code template can be judged and the corresponding target business code can be output. There is no need to judge according to conditions at runtime, which can reduce the complexity of the code and thus reduce the difficulty of subsequent maintenance.
[0117] It should be noted that in the embodiments of the present application, after obtaining the target business code corresponding to the target list component, in some embodiments, the function of the target list component can be implemented directly based on the target business code. For example, the target business code can be added to the relevant application underlying code, so that the application can implement the corresponding list function through the target list component; in some embodiments, the developer can also adjust the target business code, such as adding or deleting according to actual needs to obtain an optimized target business code. The present application is limited to this step.
[0118] It can be understood that the method for generating the business code of the list component provided in the embodiment of the present application obtains the context data corresponding to the target list component, and the context data includes at least one key-value pair, in which the key is used to represent the list configuration item field to be replaced, and the value is used to represent the target configuration information corresponding to the list configuration item field to be replaced; through the context data, the target configuration information corresponding to certain list configuration item fields in the target list component can be set. Then, the target code template corresponding to the target list component can be found and determined through the context data, that is, the code template including the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced is a placeholder. Then, the placeholder of the target code template is replaced with the value of the key-value pair to obtain the target business code. The method in the embodiment of the present application can reduce the repetitive work in the code development process, facilitate the rapid generation of the business code of the list component with similar business logic based on the existing list component, and is conducive to improving the development efficiency of the list component and reducing the development cost.
[0119] Specifically, in a possible implementation, obtaining context data corresponding to the target list component includes:
[0120] In response to the code generation instruction of the target object, a front-end scaffolding tool is created;
[0121] Get the context data corresponding to the target list component through the front-end scaffolding tool.
[0122] In the embodiment of the present application, when executing the method for generating the list component business code, a front-end scaffolding tool can be used. Specifically, the front-end scaffolding tool is an automated tool that can help developers quickly generate the initial structure of the project, related code files, and configure the basic environment, thereby improving the development efficiency of the application.
[0123] In the embodiments of the present application, there is no restriction on the specific front-end scaffolding tool selected. For example, in some embodiments, Angular CLI, a front-end scaffolding tool for creating Angular projects, can be used; in some embodiments, Vue CLI, a front-end scaffolding tool for creating Vue projects, can be used; in some embodiments, Next.js, a front-end scaffolding tool provided by a React-based server-side rendering framework, can also be used, and the present application does not limit this. Different front-end scaffolding tools may have different commands and configuration methods, but the specific use process is similar, which can be implemented by referring to the relevant technology, and the present application does not elaborate on this.
[0124] Specifically, in an embodiment of the present application, for the initial stage of the method for generating the business code of the list component, an instruction can be triggered by the target object, which is recorded as a code generation instruction in this application. Here, the target object can be the developer of the list component. When the target object triggers the code generation instruction, a specified front-end scaffolding tool can be created through a command line tool, and then the subsequent method flow can be implemented based on the front-end scaffolding tool. For an embodiment of the present application, the context data corresponding to the target list component can be first obtained through the front-end scaffolding tool.
[0125] It can be understood that in the embodiment of the present application, by using the front-end scaffolding tool, the infrastructure of the project can be quickly built, reducing the cumbersome configuration process, allowing developers to focus more on the development of business logic, which is conducive to improving the generation efficiency of the list component business code and reducing the burden on developers.
[0126] Specifically, in a possible implementation, the code generation instruction is triggered by the following steps:
[0127] Detecting the touch screen operation of the target object on the terminal device, and triggering the code generation instruction according to the touch screen operation;
[0128] Alternatively, voice data of the target object is obtained, voice recognition is performed on the voice data, and a code generation instruction is triggered according to the result of the voice recognition.
[0129] In the embodiments of the present application, there may be multiple ways to implement the triggering code generation instruction. In some embodiments, the code generation instruction may be triggered by the target object through an interactive operation on the terminal device. Here, the target object may be a developer of the list component. The present application does not limit the specific implementation form of the target object and the terminal device interacting to trigger the code generation instruction.
[0130] Exemplarily, for example, the terminal device can receive the target object's interactive instructions to the relevant components, and use the interactive instructions as code generation instructions. Here, the relevant components can be components configured in the underlying system of the terminal device, or components configured in the relevant application software, and their implementation forms can be flexibly set as needed. For example, in some embodiments, the component can be a component with a voice interaction function in the terminal device, which can recognize the voice data of the target object through voice recognition technology, and the target object can interact with the terminal device through voice, such as saying "execute code generation task" to the terminal device, thereby triggering the code generation instruction. For the voice recognition algorithm used in the embodiments of the present application, it can be implemented with reference to the relevant technology, and this application will not go into details.
[0131] In some embodiments, the component may also be a touch component, for example, referring to Figure 5 , Figure 5 The following is a schematic diagram of the interface of a code development software provided in an embodiment of the present application. The code development software may be installed on the terminal device, and the code development software may be used to execute the method for generating the list component business code provided in an embodiment of the present application, and generate and output the target business code. On the interface of the code development software, some button icons corresponding to the operation options may be displayed, such as Figure 5 A task start icon 510 may be included. In an embodiment of the present application, the operation of the target object clicking the task start icon 510 on the screen of the terminal device can cause the code development software to trigger the task of generating the business code of the execution list component, for example, jumping to the relevant data input interface, so that the target object can upload the context data corresponding to the target list component, and this application does not elaborate on this. Of course, it can be understood that in some embodiments, the received operations of the target object such as touching or sliding in the designated screen area of the terminal device can also be used as the triggering condition of the code generation instruction, and this application does not make specific restrictions on this.
[0132] Specifically, in a possible implementation, referring to Figure 6 , the method in the embodiment of the present application also includes:
[0133] Step 610: Obtain original code data of the first list component;
[0134] Step 620: Perform field matching detection on the original code data to determine the list configuration item fields contained in the original code data;
[0135] Step 630: Replace the field content of at least one list configuration item field in the original code data with a placeholder to obtain a code template corresponding to the first list component.
[0136] In an embodiment of the present application, an implementation process for generating a specific code template is also provided. Specifically, when generating a code template, the code data of an existing list component can be obtained first. In an embodiment of the present application, the existing list component is recorded as a first list component, and the code data of the first list component is recorded as original code data. Then, a field matching test can be performed on the original code data to determine the list configuration item fields contained therein. Here, the meaning of the list configuration item field has been introduced in the aforementioned embodiment and will not be repeated here. After determining the list configuration item fields contained in the original code data, the placeholder can be used to replace the field content of at least one list configuration item field in the original code data, thereby obtaining a code template corresponding to the first list component.
[0137] It should be noted that, in the embodiment of the present application, for a first list component, its original code data may include multiple list configuration item fields. When generating a code template based on the original code data, there is no limit on the number of list configuration item fields that use placeholders to replace field contents. In some embodiments, placeholders can be used to replace all list configuration item fields contained in the original code data; in some embodiments, some list configuration item fields can also be selected from the list configuration item fields contained in the original code data for replacement according to actual needs. In the embodiment of the present application, there is no limit on the number and specific type of the selected partial list configuration item fields. It can be understood that, in the embodiment of the present application, for a first list component, it can correspond to one or more code templates.
[0138] In the embodiment of the present application, when generating a code template, a batch of first list components can be obtained, which can greatly increase the number of code targets and facilitate the subsequent generation requirements of various types of list component business codes.
[0139] Specifically, in a possible implementation, performing field matching detection on the original code data to determine the list configuration item fields contained in the original code data includes:
[0140] Extracting a first field contained in the original code data;
[0141] The first field is matched with the reference field to determine the list configuration item field included in the original code data; wherein the reference field is a preset list configuration item field.
[0142] In an embodiment of the present application, when determining the list configuration item field contained in the original code data, the original code data can be matched based on the reference field to achieve this. Here, the reference field refers to a pre-set list configuration item field, which can be set according to the assembly language and project requirements used by the code. The present application does not limit the specific form and number of the reference field. Then, for the original code data, the field contained therein can be extracted and recorded as the first field. The list configuration item field contained in the original code data is determined by matching the reference field with the first field.
[0143] Specifically, in a possible implementation, matching the first field with the reference field to determine the list configuration item field included in the original code data includes:
[0144] Calculate the similarity between the reference field and the first field;
[0145] If the similarity between the reference field and the first field is greater than or equal to a preset threshold, the first field is determined to be a list configuration item field contained in the original code data; or, if the similarity between any reference field and the first field is less than the preset threshold, it is determined that the first field does not belong to the list configuration item field.
[0146] In the embodiment of the present application, when matching the first field through the reference field, a similarity matching method may be used. Similarity matching is a technology used to retrieve and match a given item, and its purpose is to find items similar to the given item in the data set.
[0147] For the application in the embodiment of the present application, the reference field is a given item. When the reference field and the first field are compared by similarity matching, the similarity between the reference field and the first field can be calculated. Here, the similarity is used to characterize the degree of similarity between the reference field and the first field. The higher the similarity value, the more similar the reference field and the first field are. Therefore, a threshold value of similarity can be set accordingly, which is recorded as the preset threshold value. The calculated similarity is compared with the preset threshold value. If the similarity between the reference field and the first field is greater than or equal to the preset threshold value, it can be considered that the first field matches the reference field, and the first field can be determined as the list configuration item field contained in the original code data. Relatively speaking, if the similarity between a first field and all reference fields is less than the preset threshold value, it can be determined that the first field does not belong to the list configuration item field.
[0148] Here, it should be noted that in the embodiments of the present application, there is no restriction on the numerical representation of similarity. For example, in some embodiments, a percentage can be used to characterize the size of the similarity, and 100% can be set as the maximum value of the similarity. When the similarity between the reference field and the first field reaches 100%, it means that the two are completely consistent. The preset threshold can be set to 90%. When the similarity between the reference field and the first field is greater than or 90%, it can be determined that the two match. Of course, the embodiment of the present application also does not limit the size of the preset threshold, which can be flexibly set according to actual needs.
[0149] Specifically, in a possible implementation manner, calculating the similarity between the reference field and the first field includes:
[0150] Extracting a first feature vector corresponding to the reference field and a second feature vector corresponding to the first field;
[0151] determining a first length of the first eigenvector and a second length of the second eigenvector;
[0152] Obtaining a first value according to a product of the first length and the second length, and obtaining a second value according to an inner product of the first eigenvector and the second eigenvector;
[0153] The similarity is obtained according to the quotient of the second value and the first value.
[0154] In an embodiment of the present application, the similarity between the reference field and the first field can be determined by a cosine similarity algorithm. First, the feature data of the reference field and the feature data of the first field are extracted by a feature extraction algorithm, where the feature data of both of them can be vector data, the reference field corresponds to the first feature vector, and the first field corresponds to the second feature vector. Then, the vector length of the first feature vector, recorded as the first length, and the length of the second feature vector, recorded as the second length, can be determined. Next, the product of the first length and the second length is calculated as the first numerical value, and the inner product of the first feature vector and the second feature vector is calculated as the second numerical value, and then the quotient of the first numerical value and the second numerical value is calculated as the similarity between the first feature vector and the second feature vector, that is, the similarity between the reference field and the first field.
[0155] It should be noted that, in the embodiment of the present application, for the feature extraction of the reference field and the first field, a sequence to sequence (i.e., Seq2seq model) model can be used to implement it. The sequence to sequence model is one of the more commonly used models in sequence tasks, and it is good at processing a series of data with continuous relationships such as voice data, text data, and video data. Specifically, the model framework of the sequence to sequence model generally includes two parts, an encoder part and a decoder part. In the embodiment of the present application, the encoder part can be used to implement the extraction of feature data. The encoder in the sequence to sequence model can be implemented by a recurrent neural network (RNN), such as the commonly used long short-term memory network (LSTM). Of course, it can be understood that the above-mentioned encoder type can be flexibly adjusted as needed, and this application does not limit this.
[0156] Specifically, in a possible implementation, performing field matching detection on the original code data to determine the list configuration item fields contained in the original code data includes:
[0157] Create a corresponding regular expression based on the reference field; the reference field is the pre-set list configuration item field
[0158] The original code data is subjected to field matching detection through regular expressions to determine the list configuration item fields contained in the original code data.
[0159] In an embodiment of the present application, when matching the first field by the reference field, a regular matching method can be used. Regular matching is a technique for finding string matches that match a certain pattern in a text. By using specific grammatical rules, a corresponding regular expression can be created to specify the data you want to find. A regular expression is a text string composed of specific characters and operators (also called metacharacters and operators), which are used to describe the rules for matching strings of a certain pattern.
[0160] Specifically, in the embodiment of the present application, when the reference field and the first field are compared by regular matching, a corresponding regular expression can be created according to the reference field, and each reference field can correspond to at least one regular expression. Then, it can be detected whether the first field matches each regular expression. If it is found that the first field matches the regular expression, it can be determined as a list configuration item field; if the first field does not match all regular expressions, it can be determined that the first field does not belong to the list configuration item field.
[0161] Specifically, in a possible implementation, performing field matching detection on the original code data to determine the list configuration item fields contained in the original code data includes:
[0162] Building an automaton-based matching tree model according to a reference field; wherein the reference field is a pre-set list configuration item field;
[0163] Input characters in the original code data into a matching tree model to determine a target character combination in the original code data that matches a reference field;
[0164] According to the target character combination, the list configuration item field contained in the original code data is determined.
[0165] In the embodiment of the present application, when matching the original code data by reference fields, the strategy of automaton search can also be adopted. Specifically, in the embodiment of the present application, a matching tree model based on automaton can be constructed. Here, AC automaton (Aho-Corasick automaton) can be selected to build the matching tree model. The matching tree model based on AC automaton is an efficient string matching algorithm, which utilizes the ideas of dictionary tree (Trie tree) and finite state automaton to construct multiple pattern strings into a matching tree, thereby realizing efficient matching of multi-pattern strings in text.
[0166] In the process of building the matching tree model, first, all reference fields can be built into a dictionary tree. Here, the dictionary tree is a tree containing multiple nodes, each node represents a character in a reference field, and the path from the root node to the leaf node is a pattern string (reference field); then, the dictionary tree can be transformed to mark all non-root nodes as ordinary nodes, repeated nodes or end nodes, where repeated nodes indicate that the node appears multiple times in a certain pattern string, and end nodes indicate that the node is the end node of a certain pattern string. Next, the transformed dictionary tree is constructed into a finite state automaton (FSM), namely AC automaton, and its construction process mainly includes state transfer and failure pointer construction. State transfer refers to jumping to the next state according to the current matching character and current state in the process of matching text strings; failure pointer refers to jumping to a new state to continue matching when it cannot match in the current state.
[0167] After the matching tree model is constructed, the text string can be matched on the automaton. For the embodiment of the present application, the text string that needs to be matched is the original code data. The characters in the original code data can be input into the matching tree model in sequence, one character is matched at a time, and the target character combination identical to the pattern string (i.e., the reference field) is jumped on the automaton according to the current state and the matching character, and the target character combination identical to the pattern string (i.e., the reference field) is determined until the entire original code data is scanned. If the target character combination is finally found in the matching tree model search, it means that the target character combination matches the reference field, and it can be determined as the list configuration item field contained in the original code data. In the embodiment of the present application, there is no restriction on the number and specific content of the searched target character combination.
[0168] Specifically, in a possible implementation, searching and determining the target code template corresponding to the target list component according to the context data includes:
[0169] Determine, according to the context data, a first code template including all list configuration item fields to be replaced;
[0170] A second code template in which field contents of all list configuration item fields to be replaced are placeholders is determined from the first code target, and the second code template is determined as the target code template.
[0171] In an embodiment of the present application, when determining a target code template based on context data, first, the key in all key-value pairs in the context data, that is, the list configuration item field to be replaced, can be determined. According to the list configuration item field to be replaced, a search can be performed in the existing code template to determine a code template containing all the list configuration item fields to be replaced, and record it as the first code template. Then, it can be determined whether the field contents of all the list configuration item fields to be replaced in the first code template are placeholders. If so, the first code template can be recorded as the second code template, and any second code template can be determined as the target code template later.
[0172] In particular, it should be noted that in an embodiment of the present application, a second code template that only contains all list configuration item fields to be replaced and does not contain other list configuration item fields can also be used as a target code template, and the present application does not impose any restrictions on this.
[0173] Specifically, in a possible implementation, referring to Figure 7 , replace the placeholders in the target code template with the values of the key-value pairs in the context data to obtain the target business code corresponding to the target list component, including:
[0174] Step 710: Call the template engine to compile the target code template to obtain the target program function;
[0175] Step 720: Input the value of the key-value pair in the context data as a parameter to the target program function to obtain a result string, and determine the result string as the target business code.
[0176] In the embodiment of the present application, as described above, when replacing the placeholders in the target code template to obtain the target business code corresponding to the target list component, a template engine can be used to implement it. Specifically, in the embodiment of the present application, the template engine can be called to compile the target code template to obtain a target program function. The target program function can receive a data object as a parameter, process special placeholders and logical control structures in its content, and thus generate a result string according to the provided parameters. For the application in the embodiment of the present application, the value of the key-value pair in the context data can be input as a parameter to the target program function, and the target program function can use the parameter to replace the placeholder in the target code template, thereby outputting a result string, which is the desired target business code.
[0177] Below, in conjunction with the specific application implementation process, the method for generating the list component business code provided in this application is introduced and explained in detail.
[0178] Reference Figure 8 , Figure 8A schematic diagram of the implementation principle of a method for generating business code of a list component provided in an embodiment of the present application is shown. In the embodiment of the present application, based on the existing list component, the common code therein can be reused to quickly generate business code of the list component with similar business logic, which can reduce repetitive work in the code development process, help improve the development efficiency of the list component, and reduce development costs.
[0179] In the embodiment of the present application, for the existing list component, there are some general codes and codes that are strongly related to its own business, among which the codes that are strongly related to the list component's own business are generally configured by the list configuration item field. Therefore, the template syntax can be used to replace this part of the content, and the field content of the list configuration item field is replaced with a placeholder. In this way, a code template can be obtained, which includes the general code and the list configuration item field after the placeholder is replaced. In actual applications, the context data corresponding to the target list component to be generated can be used to replace the placeholder, so that the target business code corresponding to the target list component can be obtained.
[0180] For details, please refer to Fig. 9 , Fig. 9 A specific flow chart of a method for generating a list component business code provided in an embodiment of the present application is shown. In an embodiment of the present application, the automatic generation of the list component business code can be implemented based on a front-end scaffolding tool and a template engine. Specifically, the template engine used here can be a JavaScript template engine.
[0181] First, you can obtain the original code data of some existing list components, use placeholders to replace the field content of the list configuration item field, and get a code template. The code template uses the syntax corresponding to the template engine to describe the text structure and replacement logic. For the target list component to be generated, you can collect its corresponding context data.
[0182] In the front-end scaffolding tool, execute the relevant code generation instructions, obtain the code template and context data, and then parse the code template and compile it into an executable JavaScript function. The compilation of the JavaScript template engine is the process of converting a code template containing special tags and placeholders into an executable JavaScript function (i.e., the target program function). This function can receive a data object as a parameter, process special placeholders and logical control structures internally, and dynamically generate the final result string based on the provided parameters. The purpose of the compilation process is to convert the tags and logical control structures in the template string into executable code, so as to facilitate the repeated generation of output results using different parameters later. Then, you can run the compiled JavaScript function (i.e., the target program function), input the context data for rendering, and output the result string that replaces the placeholders with the values of the key-value pairs in the context data. The result string is the required target business code.
[0183] Reference Fig.10 The embodiment of the present application also provides a device for generating a list component service code, the device comprising:
[0184] The acquisition unit 1010 is used to acquire context data corresponding to the target list component; wherein the context data includes at least one key-value pair, the key in the key-value pair is used to represent the list configuration item field to be replaced, and the value in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced;
[0185] A search unit 1020 is used to search and determine the target code template corresponding to the target list component according to the context data; wherein the target code template includes the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced in the target code template is a placeholder;
[0186] The replacement unit 1030 is used to replace the placeholder in the target code template according to the value of the key-value pair in the context data to obtain the target business code corresponding to the target list component.
[0187] Optionally, the acquisition unit is specifically used for:
[0188] In response to the code generation instruction of the target object, a front-end scaffolding tool is created;
[0189] Get the context data corresponding to the target list component through the front-end scaffolding tool.
[0190] Optionally, the device further includes a trigger unit; the trigger unit is specifically used for:
[0191] Detecting the touch screen operation of the target object on the terminal device, and triggering the code generation instruction according to the touch screen operation;
[0192] Alternatively, voice data of the target object is obtained, voice recognition is performed on the voice data, and a code generation instruction is triggered according to the result of the voice recognition.
[0193] Optionally, the device further includes a generating unit; the generating unit is specifically configured to:
[0194] Get the original code data of the first list component;
[0195] Perform field matching detection on the original code data to determine the list configuration item fields contained in the original code data;
[0196] The field content of at least one list configuration item field in the original code data is replaced by the placeholder to obtain a code template corresponding to the first list component.
[0197] Optionally, the generating unit is specifically used for:
[0198] Extracting a first field contained in the original code data;
[0199] The first field is matched with the reference field to determine the list configuration item field included in the original code data; wherein the reference field is a preset list configuration item field.
[0200] Optionally, the generating unit is specifically used for:
[0201] Calculate the similarity between the reference field and the first field;
[0202] If the similarity between the reference field and the first field is greater than or equal to a preset threshold, the first field is determined to be a list configuration item field contained in the original code data; or, if the similarity between any reference field and the first field is less than the preset threshold, it is determined that the first field does not belong to the list configuration item field.
[0203] Optionally, the generating unit is specifically used for:
[0204] Extracting a first feature vector corresponding to the reference field and a second feature vector corresponding to the first field;
[0205] determining a first length of the first eigenvector and a second length of the second eigenvector;
[0206] Obtaining a first value according to a product of the first length and the second length, and obtaining a second value according to an inner product of the first eigenvector and the second eigenvector;
[0207] The similarity is obtained according to the quotient of the second value and the first value.
[0208] Optionally, the generating unit is specifically used for:
[0209] Create a corresponding regular expression based on the reference field; the reference field is a pre-set list configuration item field;
[0210] The original code data is subjected to field matching detection through regular expressions to determine the list configuration item fields contained in the original code data.
[0211] Optionally, the generating unit is specifically used for:
[0212] Building an automaton-based matching tree model according to a reference field; wherein the reference field is a pre-set list configuration item field;
[0213] Input characters in the original code data into a matching tree model to determine a target character combination in the original code data that matches a reference field;
[0214] According to the target character combination, the list configuration item field contained in the original code data is determined.
[0215] Optionally, the searching unit is specifically used for:
[0216] Determine, according to the context data, a first code template including all list configuration item fields to be replaced;
[0217] A second code template in which field contents of all list configuration item fields to be replaced are placeholders is determined from the first code target, and the second code template is determined as the target code template.
[0218] Optionally, the replacement unit is specifically used for:
[0219] Calling the template engine to compile the target code template to obtain the target program function;
[0220] The value of the key-value pair in the context data is input as a parameter to the target program function to obtain a result string, and the result string is determined as the target business code.
[0221] It is understandable that if Figure 4 The contents of the embodiment of the method for generating the service code of the list component shown in the figure are applicable to the embodiment of the device for generating the service code of the list component. The functions specifically implemented by the embodiment of the device for generating the service code of the list component are the same as those of the embodiment of the method for generating the service code of the list component shown in the figure. Figure 4 The method for generating the list component business code shown in the embodiment is the same as that in the embodiment shown in the embodiment, and the beneficial effects achieved are the same as those in the embodiment shown in the embodiment. Figure 4 The beneficial effects achieved by the embodiment of the method for generating the list component business code shown are also the same.
[0222] The present application also discloses an electronic device, including:
[0223] at least one processor;
[0224] at least one memory for storing at least one program;
[0225] When at least one program is executed by at least one processor, the at least one processor implements Figure 4 An embodiment of a method for generating a list component business code is shown.
[0226] It is understandable that if Figure 4 The contents of the embodiment of the method for generating the service code of the list component shown in the figure are applicable to the embodiment of the electronic device. The functions specifically implemented by the embodiment of the electronic device are similar to those in the embodiment of the list component. Figure 4 The method for generating the list component business code shown in the embodiment is the same as that in the embodiment shown in the embodiment, and the beneficial effects achieved are the same as those in the embodiment shown in the embodiment. Figure 4 The beneficial effects achieved by the embodiment of the method for generating the list component business code shown are also the same.
[0227] The electronic device of the embodiment of the present application may be a terminal device, a computer device or a server device.
[0228] For example, refer to Fig.11 , Fig.11 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Taking the electronic device as a terminal device as an example, Fig.11 In the embodiment, the electronic device 1100 may include an RF (Radio Frequency) circuit 1110, a memory 1120 including one or more computer-readable storage media, an input unit 1130, a display unit 1140, a sensor 1150, an audio circuit 1160, a short-range wireless transmission module 1170, a processor 1180 including one or more processing cores, and a power supply 1190. Those skilled in the art will appreciate that Fig.11 The device structure shown in the figure does not constitute a limitation on the terminal device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0229] The RF circuit 1110 can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is handed over to one or more processors 1180 for processing; in addition, the data related to the uplink is sent to the base station. Generally, the RF circuit 1110 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a subject identity module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, etc. In addition, the RF circuit 1110 can also communicate with the network and other devices through wireless communication. Wireless communication can use any communication standard or protocol, including but not limited to GSM (Global System of Mobile communication), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), etc.
[0230] The memory 1120 can be used to store software programs and modules (or units). The processor 1180 executes various functional applications and data processing by running the software programs and modules (or units) stored in the memory 1120. The memory 1120 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function), etc.; the data storage area may store data created according to the use of the electronic device 1100 (such as audio data, a phone book), etc. In addition, the memory 1120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 1120 may also include a memory controller to provide the processor 1180 and the input unit 1130 with access to the memory 1120. Although Fig.11 The RF circuit 1110 is shown, but it is understandable that it is not an essential component of the electronic device 1100 and can be omitted as needed without changing the essence of the invention.
[0231] The input unit 1130 can be used to receive input digital or character information, and generate keyboard, mouse, joystick, optical or trackball signal input related to object setting and function control. Specifically, the input unit 1130 may include a touch-sensitive surface 1131 and other input devices 1132. The touch-sensitive surface 1131, also known as a touch display screen or touch pad, can collect touch operations of an object on or near it (such as operations of an object using a finger, stylus or any other suitable object or accessory on or near the touch-sensitive surface 1131), and drive the corresponding connection device according to a pre-set program. Optionally, the touch-sensitive surface 1131 may include a touch detection device and a touch controller. Among them, the touch detection device detects the touch orientation of the object, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into touch point coordinates, and then sends it to the processor 1180, and can receive instructions sent by the processor 1180 and execute them. In addition, the touch-sensitive surface 1131 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface 1131, the input unit 1130 may further include other input devices 1132. Specifically, the other input devices 1132 may include, but are not limited to, one or more of a physical keyboard, a function key (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, and the like.
[0232] The display unit 1140 can be used to display information input by an object or information provided to an object and to control various graphic object interfaces of the electronic device 1100. These graphic object interfaces can be composed of graphics, texts, icons, videos and any combination thereof. The display unit 1140 may include a display panel 1141. Optionally, the display panel 1141 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 1131 may be covered on the display panel 1141. When the touch-sensitive surface 1131 detects a touch operation on or near it, it is transmitted to the processor 1180 to determine the type of touch event. Subsequently, the processor 1180 provides a corresponding visual output on the display panel 1141 according to the type of touch event. Although in Fig.11 In the embodiment, the touch-sensitive surface 1131 and the display panel 1141 are implemented as two independent components to implement input and output functions, but in some embodiments, the touch-sensitive surface 1131 and the display panel 1141 can be integrated to implement input and output functions.
[0233] The electronic device 1100 may also include at least one sensor 1150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 1141 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 1141 or the backlight when the electronic device 1100 is moved to the ear. As a type of motion sensor, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc. that can also be configured in the electronic device 1100, they will not be repeated here.
[0234] The audio circuit 1160, the speaker 1161, and the microphone 1162 can provide an audio interface between the object and the electronic device 1100. The audio circuit 1160 can transmit the electrical signal converted from the received audio data to the speaker 1161, which is converted into a sound signal for output; on the other hand, the microphone 1162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1160 and converted into audio data, and then the audio data is processed by the output processor 1180 and sent to another electronic device through the RF circuit 1110, or the audio data is output to the memory 1120 for further processing. The audio circuit 1160 may also include an earplug jack to provide communication between an external headset and the electronic device 1100.
[0235] The short-range wireless transmission module 1170 may be a WIFI (wireless fidelity) module, a Bluetooth module, an infrared module, etc. The electronic device 1100 may transmit information with wireless transmission modules provided on other devices through the short-range wireless transmission module 1170 .
[0236] The processor 1180 is the control center of the electronic device 1100. It uses various interfaces and lines to connect various parts of the entire device. By running or executing software programs or modules stored in the memory 1120, and calling data stored in the memory 1120, it executes various functions of the electronic device 1100 and processes data, thereby controlling the device as a whole. Optionally, the processor 1180 may include one or more processing cores; optionally, the processor 1180 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, object interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 1180.
[0237] The electronic device 1100 also includes a power supply 1190 (such as a battery) for supplying power to various components. Optionally, the power supply 1190 can be logically connected to the processor 1180 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 1190 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0238] Although not shown, the electronic device 1100 may also include a camera, a Bluetooth module, etc., which will not be described in detail here.
[0239] The present application also discloses a computer-readable storage medium in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to implement the following Figure 4 An embodiment of a method for generating a list component business code is shown.
[0240] Understandably, Figure 4 The contents of the embodiment of the method for generating the list component business code shown in the figure are applicable to the embodiment of the computer-readable storage medium. The functions specifically implemented by the embodiment of the computer-readable storage medium are similar to those of the embodiment of the computer-readable storage medium. Figure 4 The method for generating the list component business code shown in the embodiment is the same as that of Figure 4 The beneficial effects achieved by the embodiment of the method for generating the list component business code shown are also the same.
[0241] The embodiment of the present application further discloses a computer program product or a computer program, the computer program product or the computer program comprising computer instructions, the computer instructions being stored in the above-mentioned computer-readable storage medium; Fig.11 The processor of the electronic device shown can read the computer instruction from the above-mentioned computer readable storage medium, and the processor executes the computer instruction so that the computer device executes Figure 4 An embodiment of a method for generating a list component business code is shown.
[0242] Understandably, Figure 4 The contents of the embodiment of the method for generating the list component business code shown in the figure are applicable to the computer program product or computer program embodiment, and the functions specifically implemented by the computer program product or computer program embodiment are the same as those in the embodiment of the present invention. Figure 4 The method for generating the list component business code shown in the embodiment is the same as that of Figure 4 The beneficial effects achieved by the embodiment of the method for generating the list component business code shown are also the same.
[0243] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the application is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part described as a larger operation is performed independently.
[0244] In addition, although the present application is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present application. More specifically, in view of the properties, functions, and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional techniques of the engineer. Therefore, those skilled in the art can implement the present application set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present application, which is determined by the full scope of the attached claims and their equivalents.
[0245] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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 various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
[0246] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be embodied in any computer-readable storage medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, apparatus, or device and execute instructions), or in conjunction with such instruction execution system, apparatus, or device. For purposes of this specification, a "computer-readable storage medium" may be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device, or in conjunction with such instruction execution system, apparatus, or device.
[0247] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0248] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0249] Although the embodiments of the present application have been shown and described, those skilled in the art will appreciate that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present application, and that the scope of the present application is defined by the claims and their equivalents.
[0250] The above is a specific description of the preferred implementation of the present application, but the present application is not limited to the embodiments. Technical personnel familiar with the field can make various equivalent modifications or substitutions without violating the spirit of the present application. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present application.
Claims
1. A method for generating a list component business code, characterized in that: The method comprises: Acquire context data corresponding to the target list component; wherein the context data includes at least one key-value pair, the key in the key-value pair is used to represent the list configuration item field to be replaced, and the value in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced; According to the context data, searching and determining the target code template corresponding to the target list component; wherein the target code template includes the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced in the target code template is a placeholder; The placeholder in the target code template is replaced by the value of the key-value pair in the context data to obtain the target business code corresponding to the target list component.
2. The method for generating a list component service code according to claim 1, characterized in that: The obtaining of context data corresponding to the target list component includes: In response to the code generation instruction of the target object, a front-end scaffolding tool is created; The context data corresponding to the target list component is obtained through the front-end scaffolding tool.
3. The method for generating a list component service code according to claim 2, characterized in that: The code generation instruction is triggered by the following steps: Detecting a touch screen operation of the target object on the terminal device, and triggering the code generation instruction according to the touch screen operation; Alternatively, voice data of the target object is acquired, voice recognition is performed on the voice data, and the code generation instruction is triggered according to a result of the voice recognition.
4. The method for generating a list component service code according to any one of claims 1 to 3, characterized in that: The method further comprises: Get the original code data of the first list component; Performing field matching detection on the original code data to determine the list configuration item field contained in the original code data; The field content of at least one list configuration item field in the original code data is replaced by a placeholder to obtain a code template corresponding to the first list component.
5. The method for generating a list component service code according to claim 4, characterized in that: The performing field matching detection on the original code data to determine the list configuration item field contained in the original code data includes: Extracting a first field contained in the original code data; The first field is matched with a reference field to determine the list configuration item field included in the original code data; wherein the reference field is a preset list configuration item field.
6. The method for generating a list component service code according to claim 5, characterized in that: The matching the first field by the reference field to determine the list configuration item field contained in the original code data includes: Calculating the similarity between the reference field and the first field; If the similarity between the reference field and the first field is greater than or equal to a preset threshold, the first field is determined to be a list configuration item field contained in the original code data; or, if the similarity between any of the reference fields and the first field is less than a preset threshold, it is determined that the first field does not belong to a list configuration item field.
7. The method for generating a list component service code according to claim 6, characterized in that: The calculating the similarity between the reference field and the first field includes: Extracting a first feature vector corresponding to the reference field and a second feature vector corresponding to the first field; determining a first length of the first eigenvector and a second length of the second eigenvector; Obtaining a first value according to the product of the first length and the second length, and obtaining a second value according to the inner product of the first eigenvector and the second eigenvector; The similarity is obtained according to the quotient of the second value and the first value.
8. The method for generating a list component service code according to claim 4, characterized in that: The performing field matching detection on the original code data to determine the list configuration item field contained in the original code data includes: Create a corresponding regular expression according to the reference field; wherein the reference field is a preset list configuration item field; The original code data is subjected to field matching detection by using the regular expression to determine the list configuration item field contained in the original code data.
9. The method for generating a list component service code according to claim 4, characterized in that: The performing field matching detection on the original code data to determine the list configuration item field contained in the original code data includes: Constructing an automaton-based matching tree model according to a reference field; wherein the reference field is a preset list configuration item field; Input characters in the original code data into the matching tree model to determine a target character combination in the original code data that matches the reference field; According to the target character combination, the list configuration item field included in the original code data is determined.
10. The method for generating a list component service code according to claim 1, characterized in that: The step of searching and determining the target code template corresponding to the target list component according to the context data includes: Determine, according to the context data, a first code template including all the list configuration item fields to be replaced; A second code template in which field contents of all the to-be-replaced list configuration item fields are placeholders is determined from the first code target, and the second code template is determined as a target code template.
11. The method for generating a list component service code according to claim 1, characterized in that: The step of replacing the placeholder in the target code template by the value of the key-value pair in the context data to obtain the target service code corresponding to the target list component includes: Calling a template engine to compile the target code template to obtain a target program function; The values of the key-value pairs in the context data are input as parameters to the target program function to obtain a result string, and the result string is determined as the target service code.
12. A device for generating a list component service code, characterized in that: The device comprises: An acquisition unit, configured to acquire context data corresponding to a target list component; wherein the context data includes at least one key-value pair, the key in the key-value pair is used to represent the list configuration item field to be replaced, and the value in the key-value pair is used to represent the target configuration information corresponding to the list configuration item field to be replaced; A search unit, configured to search and determine, according to the context data, a target code template corresponding to the target list component; wherein the target code template includes the list configuration item field to be replaced, and the field content of the list configuration item field to be replaced in the target code template is a placeholder; The replacement unit is used to replace the placeholder in the target code template by the value of the key-value pair in the context data to obtain the target business code corresponding to the target list component.
13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for generating the list component business code according to any one of claims 1 to 11 is implemented.
14. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for generating a list component business code according to any one of claims 1 to 11 is implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method for generating a list component business code according to any one of claims 1 to 11 is implemented.
Citation Information
Cited By
Rich text processing method and device based on artificial intelligence, equipment and medium
CN121723978A