CN116679912A - Code generation method, apparatus, device, storage medium, and computer program - Google Patents
Code generation method, apparatus, device, storage medium, and computer program Download PDFInfo
- Publication number
- CN116679912A CN116679912A CN202310481551.3A CN202310481551A CN116679912A CN 116679912 A CN116679912 A CN 116679912A CN 202310481551 A CN202310481551 A CN 202310481551A CN 116679912 A CN116679912 A CN 116679912A
- Authority
- CN
- China
- Prior art keywords
- code
- appearance
- component
- target
- name
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/31—Programming languages or programming paradigms
- G06F8/313—Logic programming, e.g. PROLOG programming language
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/447—Target code generation
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
本申请公开了一种代码生成方法、装置、设备、存储介质及计算机程序,属于计算机技术领域。所述方法包括:获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,基于该业务逻辑代码,确定目标应用在目标开发框架下的无渲染代码,对该无渲染代码和至少一个外观代码进行组织,以得到目标应用在目标开发框架下的完整代码。由于该至少一个外观代码指示目标应用的至少一种外观,并且该至少一种外观与至少一种终端类型对应,因此,最终得到的完整代码能够在保证目标应用与目标开发框架相适应的同时,还能够保证目标应用的外观能够适应不同的终端设备。
The application discloses a code generation method, device, equipment, storage medium and computer program, belonging to the field of computer technology. The method includes: acquiring the business logic code of the target application and at least one appearance code of the target application under the target development framework, determining the non-rendering code of the target application under the target development framework based on the business logic code, and determining the non-rendering code of the target application under the target development framework and at least one appearance code to obtain the complete code of the target application under the target development framework. Since the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one type of terminal, the finally obtained complete code can ensure that the target application is compatible with the target development framework, It can also ensure that the appearance of the target application can adapt to different terminal devices.
Description
技术领域Technical Field
本申请涉及计算机技术领域,特别涉及一种代码生成方法、装置、设备、存储介质及计算机程序。The present application relates to the field of computer technology, and in particular to a code generation method, apparatus, device, storage medium and computer program.
背景技术Background Art
JavaScript(简称“JS”)是一种具有函数优先的轻量级、解释型或即时编译型的编程语言。该语言被广泛应用于全球广域网(world wide web,Web)应用的开发。JavaScript ("JS" for short) is a lightweight, interpreted or just-in-time compiled programming language with function-first behavior. This language is widely used in the development of world wide web (Web) applications.
在Web应用开发过程中,为了提升代码的编写效率,技术人员通常使用基于JS的开发框架对Web应用进行设计,比如,Vue、React等等。然而,在对Web应用进行设计时,技术人员编写的Web应用代码包括业务逻辑代码和外观代码,但由于Web应用通常需要适配手机、电脑等不同的终端设备,而不同的终端设备所对应的Web应用的外观不同。在这种情况下,对于具有相同业务逻辑的Web应用,技术人员需要重复编写针对不同终端的Web应用的代码,使得Web应用具有与终端设备相适应的外观,这会导致技术人员将大量的时间花费在代码的书写上,从而大大增加了人力成本与时间成本。In the process of Web application development, in order to improve the efficiency of code writing, technicians usually use JS-based development frameworks to design Web applications, such as Vue, React, etc. However, when designing Web applications, the Web application code written by technicians includes business logic code and appearance code, but because Web applications usually need to adapt to different terminal devices such as mobile phones and computers, and the appearance of Web applications corresponding to different terminal devices is different. In this case, for Web applications with the same business logic, technicians need to repeatedly write the code for Web applications for different terminals so that the Web applications have an appearance that is compatible with the terminal devices. This will cause technicians to spend a lot of time writing code, which greatly increases labor costs and time costs.
发明内容Summary of the invention
本申请提供了一种代码生成方法、装置、设备、存储介质及计算机程序,可以解决相关技术中应用开发的效率较低的问题。所述技术方案如下:The present application provides a code generation method, apparatus, device, storage medium and computer program, which can solve the problem of low efficiency of application development in related technologies. The technical solution is as follows:
第一方面,提供了一种代码生成方法,所述方法包括:获取目标应用的业务逻辑代码和所述目标应用在目标开发框架下的至少一个外观代码,所述业务逻辑代码指示所述目标应用的功能,所述至少一个外观代码指示所述目标应用的至少一种外观,所述至少一种外观与至少一种终端类型对应;基于所述业务逻辑代码,确定所述目标应用在所述目标开发框架下的无渲染代码;对所述无渲染代码和所述至少一个外观代码进行组织,以得到所述目标应用在所述目标开发框架下的完整代码。In a first aspect, a code generation method is provided, the method comprising: obtaining a business logic code of a target application and at least one appearance code of the target application under a target development framework, the business logic code indicating a function of the target application, the at least one appearance code indicating at least one appearance of the target application, the at least one appearance corresponding to at least one terminal type; determining a rendering-free code of the target application under the target development framework based on the business logic code; and organizing the rendering-free code and the at least one appearance code to obtain a complete code of the target application under the target development framework.
通过获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,从而基于该业务逻辑代码和该至少一个外观代码,确定目标应用在目标开发框架下的完整代码。由于该至少一个外观代码指示目标应用的至少一种外观,并且该至少一种外观与至少一种终端类型对应,因此,该完整代码能够在保证目标应用与目标开发框架相适应的同时,还能够保证目标应用的外观能够适应不同的终端设备。换句话说,本申请提供的一种代码生成方法能够自动生成目标应用在目标框架下的完整代码,无需技术人员重复编写针对不同终端和不同开发框架的目标应用的代码,从而大大提升代码编写的效率,有效节约人力成本和时间成本。By obtaining the business logic code of the target application and at least one appearance code of the target application under the target development framework, the complete code of the target application under the target development framework is determined based on the business logic code and the at least one appearance code. Since the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one terminal type, the complete code can ensure that the target application is compatible with the target development framework while also ensuring that the appearance of the target application can adapt to different terminal devices. In other words, the code generation method provided in the present application can automatically generate the complete code of the target application under the target framework, without the need for technicians to repeatedly write the code for the target application for different terminals and different development frameworks, thereby greatly improving the efficiency of code writing and effectively saving manpower and time costs.
获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码的实现方式包括多种,接下来对其中的两种方式进行介绍。There are multiple implementation methods for obtaining the business logic code of the target application and at least one appearance code of the target application under the target development framework, and two of them are introduced below.
第一种实现方式,云平台能够显示代码编写界面,该代码编写界面用于编写目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,响应于代码编写完成操作,云平台能够获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码。In the first implementation method, the cloud platform can display a code writing interface, which is used to write the business logic code of the target application and at least one appearance code of the target application under the target development framework. In response to the code writing completion operation, the cloud platform can obtain the business logic code of the target application and at least one appearance code of the target application under the target development framework.
第二种实现方式,技术人员可以在其他具有代码编写功能的云平台上完成对目标应用的业务逻辑代码和该至少一个外观代码的编写,进而将该目标应用的业务逻辑代码和该至少一个外观代码发送给云平台,云平台接收该目标应用的业务逻辑代码和该至少一个外观代码。In the second implementation method, the technicians can complete the writing of the business logic code and the at least one appearance code of the target application on other cloud platforms with code writing functions, and then send the business logic code and the at least one appearance code of the target application to the cloud platform, and the cloud platform receives the business logic code and the at least one appearance code of the target application.
也就是说,该目标应用的业务逻辑代码和该至少一个外观代码可以是技术人员在云平台上编写后直接得到的,也可以是技术人员在其他具有代码编写功能的云平台编写完成后发送给云平台的。当然,在实际应用中,云平台还可以通过其他的方式获取到目标应用的业务逻辑代码和该至少一个外观代码。That is, the business logic code of the target application and the at least one appearance code can be obtained directly after being written by the technician on the cloud platform, or can be sent to the cloud platform after being written by the technician on other cloud platforms with code writing functions. Of course, in actual applications, the cloud platform can also obtain the business logic code of the target application and the at least one appearance code in other ways.
可选地,上述业务逻辑代码为柯里化函数形式,该业务逻辑代码和该至少一个外观代码为JavaScript语言。Optionally, the business logic code is in the form of a curried function, and the business logic code and the at least one appearance code are in JavaScript language.
可以按照下述步骤(1)-(2)确定目标应用在目标开发框架下的无渲染代码。The rendering-free code of the target application under the target development framework can be determined by following the steps (1)-(2) below.
(1)确定该业务逻辑代码中的至少一个逻辑函数的函数名、至少一个逻辑函数分别对应的至少一个参数的参数名以及该至少一个参数中每个参数的属性名。(1) Determine the function name of at least one logic function in the business logic code, the parameter name of at least one parameter corresponding to the at least one logic function, and the attribute name of each parameter in the at least one parameter.
业务逻辑代码包括逻辑代码注释和逻辑代码本体,在这种情况下,可以从逻辑代码本体中获取该至少一个逻辑函数的函数名,从逻辑代码注释中获取至少一个逻辑函数分别对应的至少一个参数的参数名以及每个参数的属性名。The business logic code includes logic code comments and logic code body. In this case, the function name of the at least one logic function can be obtained from the logic code body, and the parameter name of at least one parameter corresponding to the at least one logic function and the attribute name of each parameter can be obtained from the logic code comments.
云平台可以从业务逻辑代码本体中确定第一位置,该第一位置处的代码中包含该至少一个逻辑函数的函数名,从该第一位置处的代码中获取该至少一个逻辑函数的函数名。The cloud platform can determine a first position from the business logic code body, where the code at the first position contains the function name of the at least one logic function, and obtain the function name of the at least one logic function from the code at the first position.
云平台存储有第一字符串,在这种情况下,云平台可以按照相关算法,从业务逻辑代码中搜索第一字符串,将该第一字符串所在的位置确定为第一位置,将该第一位置处的代码中除第一字符串之外的代码作为至少一个逻辑函数的函数名。The cloud platform stores a first string. In this case, the cloud platform can search for the first string from the business logic code according to the relevant algorithm, determine the location of the first string as the first location, and use the code at the first location except the first string as the function name of at least one logical function.
需要说明的是,在实际应用中,该第一字符串还可以通过其他方式确定。比如,技术人员也可以在云平台中输入第一字符串,以使云平台获取到该第一字符串。在技术人员输入第一字符串的情况下,云平台能够显示第一字符串输入界面,响应于第一字符串输入完成操作,获取技术人员输入的第一字符串。It should be noted that, in actual applications, the first string can also be determined by other means. For example, the technician can also input the first string in the cloud platform so that the cloud platform can obtain the first string. When the technician inputs the first string, the cloud platform can display the first string input interface, complete the operation in response to the first string input, and obtain the first string input by the technician.
基于上文描述,该至少一个逻辑函数的函数名可以是云平台自行从业务逻辑代码本体中确定的。在实际应用中,该至少一个逻辑函数的函数名也可以通过其他方式确定。比如,技术人员可以直接在云平台中输入该至少一个逻辑函数的函数名,以使云平台能够获取该至少一个逻辑函数的函数名。Based on the above description, the function name of the at least one logic function can be determined by the cloud platform from the business logic code body. In practical applications, the function name of the at least one logic function can also be determined by other means. For example, a technician can directly input the function name of the at least one logic function in the cloud platform so that the cloud platform can obtain the function name of the at least one logic function.
为了便于云平台对逻辑代码注释进行识别,该逻辑代码注释的格式为目标格式。在这种情况下,云平台中事先存储有目标格式,云平台能够根据该目标格式,按照相关算法,从该逻辑代码注释中确定至少一个逻辑函数分别对应的至少一个参数的参数名以及至少一个参数的属性名。In order to facilitate the cloud platform to identify the logic code annotation, the format of the logic code annotation is a target format. In this case, the cloud platform stores the target format in advance, and the cloud platform can determine the parameter name of at least one parameter and the attribute name of at least one parameter corresponding to at least one logic function from the logic code annotation according to the target format and the relevant algorithm.
(2)基于该至少一个逻辑函数的函数名、至少一个参数的参数名、至少一个参数中每个参数的属性名和业务逻辑代码的存储路径,对目标开发框架对应的无渲染模板进行填充,以得到该目标应用在目标开发框架下的无渲染代码。(2) Based on the function name of the at least one logic function, the parameter name of the at least one parameter, the attribute name of each parameter in the at least one parameter, and the storage path of the business logic code, the rendering-free template corresponding to the target development framework is filled to obtain the rendering-free code of the target application under the target development framework.
目标开发框架对应的无渲染模板包括第一待填充区域,该第一待填充区域包括逻辑函数导入子区域、逻辑代码路径子区域、初始化子区域、API对象创建区域、挂载与更新区域以及API对象已创建区域。在这种情况下,可以将该至少一个逻辑函数的函数名写入逻辑函数导入子区域,将业务逻辑代码的存储路径写入逻辑代码路径子区域,将至少一个参数中具有目标属性名的参数作为第一参数,该目标属性名指示具有该目标属性名的参数为数据模型,基于第一参数对初始化子区域进行填充,将第一参数的参数名以及至少一个逻辑函数中第一逻辑函数的函数名写入API对象创建区域,该第一逻辑函数为不具有目标参数名的逻辑函数,该目标参数名指示具有该目标参数名的逻辑函数为接口函数。若至少一个逻辑函数中存在挂载函数,则将挂载函数的函数名在目标框架下的代码写入挂载与更新区域。将至少一个逻辑函数中除第一逻辑函数之外的逻辑函数的函数名写入API对象已创建区域,以实现对目标开发框架对应的无渲染模板进行填充。The non-rendering template corresponding to the target development framework includes a first area to be filled, and the first area to be filled includes a logic function import sub-area, a logic code path sub-area, an initialization sub-area, an API object creation area, a mount and update area, and an API object created area. In this case, the function name of the at least one logic function can be written into the logic function import sub-area, the storage path of the business logic code can be written into the logic code path sub-area, the parameter with the target attribute name in at least one parameter is used as the first parameter, and the target attribute name indicates that the parameter with the target attribute name is a data model, and the initialization sub-area is filled based on the first parameter, and the parameter name of the first parameter and the function name of the first logic function in at least one logic function are written into the API object creation area, and the first logic function is a logic function without a target parameter name, and the target parameter name indicates that the logic function with the target parameter name is an interface function. If there is a mount function in at least one logic function, the code of the function name of the mount function under the target framework is written into the mount and update area. The function names of the logic functions other than the first logic function in at least one logic function are written into the API object created area to achieve the filling of the non-rendering template corresponding to the target development framework.
基于第一参数对初始化子区域进行填充的实现过程包括:确定该第一参数在目标框架下的初始化代码,将该初始化代码写入初始化子区域。The implementation process of filling the initialization sub-area based on the first parameter includes: determining the initialization code of the first parameter in the target framework, and writing the initialization code into the initialization sub-area.
云平台中存储有目标属性名与目标框架下的初始化代码的对应关系,基于该第一参数包括的属性名中与目标属性名相同的属性名,从目标属性名与目标框架下的初始化代码的对应关系中,能够确定第一参数在目标框架下的初始化代码。The cloud platform stores the correspondence between the target attribute name and the initialization code under the target framework. Based on the attribute name included in the first parameter that is the same as the target attribute name, the initialization code of the first parameter under the target framework can be determined from the correspondence between the target attribute name and the initialization code under the target framework.
需要说明的是,上述目标属性名、目标参数名和挂载函数的函数名是事先设置的。该目标属性名可以设置为model,该目标参数名可以设置为api,挂载函数的函数名可以设置为mounted。当然,在实际应用中,还可以将目标属性名、目标参数名和挂载函数的函数名设置为其他名称。It should be noted that the above target attribute name, target parameter name and function name of the mount function are set in advance. The target attribute name can be set to model, the target parameter name can be set to api, and the function name of the mount function can be set to mounted. Of course, in actual applications, the target attribute name, target parameter name and function name of the mount function can also be set to other names.
在实际应用中,在对目标开发框架对应的无渲染模板进行填充之前,云平台需要确定目标开发框架。在这种情况下,云平台可以显示开发框架选择界面,该开发框架选择界面用于选择目标开发框架,响应于开发框架选择完成操作,云平台能够确定目标开发框架。也就是说,云平台在显示开发框架选择界面之后,技术人员能够在该开发框架选择界面选择一个开发框架作为目标开发框架,在选择完成之后,技术人员可以触发开发框架选择完成操作。云平台响应于开发框架选择完成操作,确定目标开发框架。In actual applications, before filling in the non-rendering template corresponding to the target development framework, the cloud platform needs to determine the target development framework. In this case, the cloud platform can display a development framework selection interface, which is used to select the target development framework. In response to the development framework selection completion operation, the cloud platform can determine the target development framework. That is, after the cloud platform displays the development framework selection interface, the technician can select a development framework as the target development framework in the development framework selection interface. After the selection is completed, the technician can trigger the development framework selection completion operation. In response to the development framework selection completion operation, the cloud platform determines the target development framework.
由于存在多个开发框架,在不同的开发框架下,得到目标应用在目标开发框架下的完整代码方式不同,接下来对其中的两种开发框架对应的实现方式进行介绍。Since there are multiple development frameworks, different development frameworks have different ways of obtaining the complete code of the target application under the target development framework. Next, the corresponding implementation methods of two of the development frameworks are introduced.
第一种情况,目标开发框架为Vue框架,目标应用为Web应用,该目标应用包括至少一个组件,该至少一个外观代码指示该至少一个组件的至少一种外观。在这种情况下,可以基于该至少一个外观代码,确定至少一个组件中包含的子组件的组件名以及该至少一个组件的属性名,基于至少一个组件的属性名、该子组件的组件名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充,以得到目标应用在目标开发框架下的完整代码。In the first case, the target development framework is the Vue framework, the target application is a Web application, the target application includes at least one component, and the at least one appearance code indicates at least one appearance of the at least one component. In this case, based on the at least one appearance code, the component name of the subcomponent contained in the at least one component and the attribute name of the at least one component can be determined, and based on the attribute name of the at least one component, the component name of the subcomponent and the storage path of the non-rendering code, the code adaptation template corresponding to the target development framework is filled to obtain the complete code of the target application under the target development framework.
该至少一个外观代码中每个外观代码包括外观代码注释,在这种情况下,可以从该外观代码注释中获取至少一个组件中的子组件的组件名以及该至少一个组件的属性名。Each appearance code in the at least one appearance code includes an appearance code comment. In this case, the component name of the subcomponent in the at least one component and the attribute name of the at least one component can be obtained from the appearance code comment.
为了便于云平台对外观代码注释进行识别,该外观代码注释的格式为目标格式。在这种情况下,云平台中事先存储有目标格式,云平台能够根据该目标格式,按照相关算法,从该外观代码注释中确定至少一个组件中的子组件的组件名以及该至少一个组件的属性名。In order to facilitate the cloud platform to identify the appearance code annotation, the format of the appearance code annotation is a target format. In this case, the cloud platform stores the target format in advance, and the cloud platform can determine the component name of the subcomponent in the at least one component and the attribute name of the at least one component from the appearance code annotation according to the target format and the relevant algorithm.
可选地,该目标格式为jsdoc格式。当然,该逻辑代码注释的格式还可以是其他类型的格式。Optionally, the target format is jsdoc format. Of course, the format of the logic code comment can also be other types of formats.
目标开发框架对应的代码适配模板包括第二待填充区域,该第二待填充区域包括无渲染代码路径子区域、组件属性子区域和子组件子区域。在这种情况下,基于至少一个组件的属性名、至少一个组件中包含的子组件的组件名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充的实现过程包括:将无渲染代码的存储路径写入无渲染代码路径子区域,将至少一个组件的属性名写入组件属性子区域,基于至少一个组件中包含的子组件的组件名,对子组件子区进行填充。The code adaptation template corresponding to the target development framework includes a second area to be filled, and the second area to be filled includes a non-rendering code path sub-area, a component attribute sub-area, and a sub-component sub-area. In this case, based on the attribute name of at least one component, the component name of the sub-component contained in at least one component, and the storage path of the non-rendering code, the implementation process of filling the code adaptation template corresponding to the target development framework includes: writing the storage path of the non-rendering code into the non-rendering code path sub-area, writing the attribute name of at least one component into the component attribute sub-area, and filling the sub-component sub-area based on the component name of the sub-component contained in at least one component.
可选地,云平台中存储有子组件填充代码模板,该子组件填充代码模板包括名称区域和路径区域。在这种情况下,基于至少一个组件中包含的子组件的组件名,对子组件子区进行填充的实现过程包括:对于至少一个组件中包含的任意一个子组件来说,将该子组件的组件名写入子组件填充代码模板的名称区域,将该子组件完整代码的存储路径写入子组件填充代码模板的路径区域,以得到该子组件对应的填充代码。对至少一个组件中包含的每个子组件都按照相同的方式,能够得到每个子组件对应的填充代码,将该每个子组件对应的填充代码写入子组件子区域,以实现对子组件子区域的填充。Optionally, a subcomponent filling code template is stored in the cloud platform, and the subcomponent filling code template includes a name area and a path area. In this case, based on the component name of the subcomponent contained in at least one component, the implementation process of filling the subcomponent subarea includes: for any subcomponent contained in at least one component, the component name of the subcomponent is written into the name area of the subcomponent filling code template, and the storage path of the complete code of the subcomponent is written into the path area of the subcomponent filling code template to obtain the filling code corresponding to the subcomponent. For each subcomponent contained in at least one component, the filling code corresponding to each subcomponent can be obtained in the same manner, and the filling code corresponding to each subcomponent is written into the subcomponent subarea to achieve the filling of the subcomponent subarea.
为了便于技术人员提高应用的开发效率和代码质量,目标开发框架还具有相应的工具库代码。在这种情况下,目标开发框架对应的代码适配模板还包括工具库路径子区域,云平台能够将目标开发框架对应的工具库代码的存储路径写入工具库路径子区。In order to facilitate technical personnel to improve the development efficiency and code quality of applications, the target development framework also has corresponding tool library codes. In this case, the code adaptation template corresponding to the target development framework also includes a tool library path sub-area, and the cloud platform can write the storage path of the tool library code corresponding to the target development framework into the tool library path sub-area.
第二种情况,目标开发框架为React框架,目标应用为Web应用,该目标应用包括至少一个组件,该至少一个外观代码指示该至少一个组件的至少一种外观。在这种情况下,可以基于该至少一个外观代码确定该至少一个组件的属性名,确定业务逻辑代码中的至少一个逻辑函数的函数名,基于该至少一个组件的属性名、至少一个逻辑函数的函数名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充,以得到目标应用在目标开发框架下的完整代码。In the second case, the target development framework is the React framework, the target application is a Web application, the target application includes at least one component, and the at least one appearance code indicates at least one appearance of the at least one component. In this case, the attribute name of the at least one component can be determined based on the at least one appearance code, the function name of at least one logic function in the business logic code can be determined, and the code adaptation template corresponding to the target development framework can be filled based on the attribute name of the at least one component, the function name of the at least one logic function, and the storage path of the non-rendering code, so as to obtain the complete code of the target application under the target development framework.
该至少一个外观代码中每个外观代码包括外观代码本体,或者,包括外观代码本体和外观代码注释。在外观代码包括外观代码本体的情况下,从该外观代码本体中获取至少一个组件的属性名,在外观代码包括外观代码本体和外观代码注释的情况下,从该外观代码本体或者该外观代码注释中获取至少一个组件的属性名。Each of the at least one appearance code includes an appearance code body, or includes an appearance code body and an appearance code comment. When the appearance code includes the appearance code body, the attribute name of at least one component is obtained from the appearance code body; when the appearance code includes the appearance code body and the appearance code comment, the attribute name of at least one component is obtained from the appearance code body or the appearance code comment.
云平台可以从外观代码本体中确定第二位置,该第二位置处的代码中包含该至少一个组件的属性名,从该第一位置处的代码中获取该至少一个组件的属性名。The cloud platform may determine a second position from the appearance code body, where the code at the second position includes the attribute name of the at least one component, and obtain the attribute name of the at least one component from the code at the first position.
可选地,云平台存储有第二字符串,在这种情况下,云平台可以按照相关算法,从外观代码本体中搜索第二字符串,将该第二字符串所在的位置确定为第二位置,将该第二位置处的代码中除第二字符串之外的代码作为至少一个组件的属性名。Optionally, the cloud platform stores a second string. In this case, the cloud platform can search for the second string from the appearance code body according to a relevant algorithm, determine the location of the second string as the second position, and use the code at the second position except the second string as the attribute name of at least one component.
需要说明的是,在实际应用中,该第二字符串还可以通过其他方式确定。比如,技术人员也可以在云平台中输入第二字符串,以使云平台获取到该第二字符串。在技术人员输入第二字符串的情况下,云平台能够显示第二字符串输入界面,响应于第二字符串输入完成操作,获取技术人员输入的第二字符串。比如,云平台能够显示第二字符串指定界面,技术人员能够在该第二字符串指定界面输入第二字符串,在输入完成之后,技术人员能够触发第二字符串输入完成操作。云平台响应于技术人员触发的第二字符串输入完成操作,获取技术人员输入的第二字符串。It should be noted that, in actual applications, the second string can also be determined by other means. For example, the technician can also enter the second string in the cloud platform so that the cloud platform can obtain the second string. When the technician enters the second string, the cloud platform can display the second string input interface, and in response to the second string input completion operation, obtain the second string entered by the technician. For example, the cloud platform can display the second string designation interface, and the technician can enter the second string in the second string designation interface. After the input is completed, the technician can trigger the second string input completion operation. In response to the second string input completion operation triggered by the technician, the cloud platform obtains the second string entered by the technician.
基于上文描述,该至少一个组件的属性名可以是云平台自行从外观代码本体中确定的。在实际应用中,该至少一个组件的属性名也可以通过其他方式确定。比如,技术人员可以直接在云平台中输入该至少一个组件的属性名,以使云平台能够获取该至少一个组件的属性名。Based on the above description, the attribute name of the at least one component can be determined by the cloud platform from the appearance code body. In actual applications, the attribute name of the at least one component can also be determined by other methods. For example, a technician can directly input the attribute name of the at least one component in the cloud platform so that the cloud platform can obtain the attribute name of the at least one component.
React开发框架对应的代码适配模板包括第三待填充区域,该第三待填充区域包括无渲染代码路径子区域、组件属性子区域和逻辑函数子区域。在这种情况下,基于该至少一个组件的属性名、至少一个逻辑函数的函数名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充的实现过程包括:将无渲染代码的存储路径写入无渲染代码路径子区域,将至少一个组件的属性名写入组件属性子区域,将至少一个逻辑函数的函数名写入逻辑函数子区域。The code adaptation template corresponding to the React development framework includes a third area to be filled, and the third area to be filled includes a non-rendering code path sub-area, a component attribute sub-area, and a logic function sub-area. In this case, based on the attribute name of the at least one component, the function name of the at least one logic function, and the storage path of the non-rendering code, the implementation process of filling the code adaptation template corresponding to the target development framework includes: writing the storage path of the non-rendering code into the non-rendering code path sub-area, writing the attribute name of at least one component into the component attribute sub-area, and writing the function name of at least one logic function into the logic function sub-area.
为了便于技术人员提高应用的开发效率和代码质量,目标开发框架还具有相应的工具库代码。在这种情况下,目标开发框架对应的代码适配模板还包括工具库路径子区域,云平台能够将目标开发框架对应的工具库代码的存储路径写入工具库路径子区。In order to facilitate technical personnel to improve the development efficiency and code quality of applications, the target development framework also has corresponding tool library codes. In this case, the code adaptation template corresponding to the target development framework also includes a tool library path sub-area, and the cloud platform can write the storage path of the tool library code corresponding to the target development framework into the tool library path sub-area.
第二方面,提供了一种代码生成装置,所述代码生成装置具有实现上述第一方面中代码生成方法行为的功能。所述代码生成装置包括至少一个模块,该至少一个模块用于实现上述第一方面所提供的代码生成方法。In a second aspect, a code generation device is provided, wherein the code generation device has the function of implementing the code generation method in the first aspect. The code generation device includes at least one module, and the at least one module is used to implement the code generation method provided in the first aspect.
第三方面,提供了一种计算设备集群,所述计算设备集群包括至少一个计算设备,每个计算设备包括处理器和存储器,所述至少一个计算设备的处理器用于执行所述至少一个计算设备的存储器中存储的指令,以使得所述计算设备集群执行上述第一方面所提供的代码生成方法。In a third aspect, a computing device cluster is provided, the computing device cluster comprising at least one computing device, each computing device comprising a processor and a memory, the processor of the at least one computing device being used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the code generation method provided in the first aspect above.
可选地,每个计算设备还可以包括通信总线,该通信总线用于每个计算设备的处理器与存储器之间建立连接。Optionally, each computing device may further include a communication bus, which is used to establish a connection between the processor and the memory of each computing device.
第四方面,提供了一种计算机可读存储介质,所述存储介质内存储有指令,当所述指令在计算设备集群上运行时,使得计算设备集群执行上述第一方面所述的代码生成方法的步骤。In a fourth aspect, a computer-readable storage medium is provided, wherein the storage medium stores instructions, and when the instructions are executed on a computing device cluster, the computing device cluster executes the steps of the code generation method described in the first aspect.
第五方面,提供了一种包含指令的计算机程序产品,当所述指令在计算设备集群上运行时,使得计算设备集群执行上述第一方面所述的代码生成方法的步骤。In a fifth aspect, a computer program product comprising instructions is provided. When the instructions are executed on a computing device cluster, the computing device cluster executes the steps of the code generation method described in the first aspect.
上述第二方面、第三方面、第四方面和第五方面所获得的技术效果与第一方面中对应的技术手段获得的技术效果近似,在这里不再赘述。The technical effects obtained by the above-mentioned second, third, fourth and fifth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
图1是本申请实施例提供的一种代码生成方法的流程图;FIG1 is a flow chart of a code generation method provided by an embodiment of the present application;
图2是本申请实施例提供的一种代码编写界面的示意图;FIG2 is a schematic diagram of a code writing interface provided in an embodiment of the present application;
图3是本申请实施例提供的另一种代码编写界面的示意图;FIG3 is a schematic diagram of another code writing interface provided in an embodiment of the present application;
图4是本申请实施例提供的一种第一字符串指定界面的示意图;FIG4 is a schematic diagram of a first character string specifying interface provided in an embodiment of the present application;
图5是本申请实施例提供的一种Vue框架对应的无渲染模板的示意图;FIG5 is a schematic diagram of a non-rendering template corresponding to a Vue framework provided in an embodiment of the present application;
图6是本申请实施例提供的另一种Vue框架对应的无渲染模板的示意图;FIG6 is a schematic diagram of a non-rendering template corresponding to another Vue framework provided in an embodiment of the present application;
图7是本申请实施例提供的一种React框架对应的无渲染模板的示意图;FIG7 is a schematic diagram of a non-rendering template corresponding to a React framework provided in an embodiment of the present application;
图8是本申请实施例提供的另一种React框架对应的无渲染模板的示意图;FIG8 is a schematic diagram of a non-rendering template corresponding to another React framework provided in an embodiment of the present application;
图9是本申请实施例提供的一种开发框架选择界面的示意图;FIG9 is a schematic diagram of a development framework selection interface provided in an embodiment of the present application;
图10是本申请实施例提供的一种子组件填充代码模板的示意图;FIG10 is a schematic diagram of a subcomponent filling code template provided in an embodiment of the present application;
图11是本申请实施例提供的一种Vue框架对应的代码适配模板的示意图;11 is a schematic diagram of a code adaptation template corresponding to a Vue framework provided in an embodiment of the present application;
图12是本申请实施例提供的另一种Vue框架对应的代码适配模板的示意图;12 is a schematic diagram of a code adaptation template corresponding to another Vue framework provided in an embodiment of the present application;
图13是本申请实施例提供的一种React框架对应的代码适配模板的示意图;FIG13 is a schematic diagram of a code adaptation template corresponding to a React framework provided in an embodiment of the present application;
图14是本申请实施例提供的另一种React框架对应的代码适配模板的示意图;FIG14 is a schematic diagram of a code adaptation template corresponding to another React framework provided in an embodiment of the present application;
图15是本申请实施例提供的一种计算机设备的结构示意图;FIG15 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application;
图16是本申请实施例提供的一种计算设备集群的架构图;FIG16 is an architecture diagram of a computing device cluster provided in an embodiment of the present application;
图17是本申请实施例提供的一种计算设备之间的连接示意图;FIG17 is a schematic diagram of a connection between computing devices provided in an embodiment of the present application;
图18是本申请实施例提供的一种代码生成装置的结构示意图。FIG18 is a schematic diagram of the structure of a code generation device provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
为了便于理解,在对本申请实施例提供的代码生成方法进行详细地解释说明之前,先对本申请实施例涉及的名词以及应用场景进行介绍。For ease of understanding, before explaining in detail the code generation method provided in the embodiment of the present application, the nouns and application scenarios involved in the embodiment of the present application are first introduced.
JavaScript(简称“JS”):是一种编程语言,它是一种直译式脚本语言,它本身不直接生成可执行的代码,而是将编译好的代码作为字节码传递给编译器,由编译器将字节码转换为可执行的机器码,从而实现对网页或者应用程序的控制。JavaScript通常用于编写客户端脚本,也就是在浏览器中运行的脚本。除了在浏览器中运行,JavaScript还可以用于开发Web应用。JavaScript ("JS" for short): is a programming language. It is a translated scripting language. It does not generate executable code directly. Instead, it passes the compiled code as bytecode to the compiler, which converts the bytecode into executable machine code to control the web page or application. JavaScript is usually used to write client-side scripts, that is, scripts that run in the browser. In addition to running in the browser, JavaScript can also be used to develop web applications.
Web应用:是一种通过Web技术访问的应用程序,它可以在Web浏览器中运行,并使用Web服务器来提供动态、交互式的Web内容。用户可以通过Web浏览器方便地访问和使用应用程序,无需安装其他软件或下载安装包。Web application: is an application program accessed through Web technology. It can run in a Web browser and use a Web server to provide dynamic and interactive Web content. Users can easily access and use the application through a Web browser without installing other software or downloading installation packages.
用户界面(user interface,UI)组件库:一种用于开发Web应用的组件库,是Web应用设计系统的一部分。UI组件库包含各种UI组件,如按钮、标签、表格、输入框、复选框、下拉框、日期选择框、按钮表格、菜单、面包屑、树、对话框、滑块、开关等等。在Web应用设计过程中可以根据需要对UI组件进行组合,以解决各种设计问题。UI组件库可以方便设计师和开发者在开发Web应用程序时共享界面设计,提高工作效率,同时也能提升产品的品牌感和一致性。因此,UI组件库具备通用性、灵活性、复用性的基本特征。其中,通用性意味着UI组件库中的组件足够基础和常见且不带业务属性,参与设计环节的每个人都应该知道这个组件的功能及目的,同时具备一定扩展性。灵活性是指要求组件的组合需灵活,在不同场景下可以通过互相组合来快速搭建交互框架原型图,并根据不同页面结构的演变来适应新的业务需求。复用性是指UI组件库中的组件能够适用于多个业务或产品,在设计过程和研发过程中都可以高频复用。User interface (UI) component library: A component library used to develop web applications and is part of the web application design system. The UI component library contains various UI components, such as buttons, labels, tables, input boxes, check boxes, drop-down boxes, date selection boxes, button tables, menus, breadcrumbs, trees, dialog boxes, sliders, switches, etc. In the process of web application design, UI components can be combined as needed to solve various design problems. The UI component library can facilitate designers and developers to share interface designs when developing web applications, improve work efficiency, and also enhance the brand sense and consistency of products. Therefore, the UI component library has the basic characteristics of versatility, flexibility, and reusability. Among them, versatility means that the components in the UI component library are basic and common enough without business attributes. Everyone involved in the design process should know the function and purpose of this component, and it has a certain degree of scalability. Flexibility means that the combination of components must be flexible. In different scenarios, they can be combined to quickly build interactive framework prototypes, and adapt to new business needs according to the evolution of different page structures. Reusability means that the components in the UI component library can be applied to multiple businesses or products, and can be reused frequently during the design process and R&D process.
React:全称为React.js,是一种基于JavaScript的框架。它是一个开源的Web应用开发框架,旨在提供一种简单、灵活和可扩展的方式来创建Web应用。React被广泛应用于Web前端开发,目前已经成为了构建Web应用的主流框架之一。React: React.js is a JavaScript-based framework. It is an open source web application development framework that aims to provide a simple, flexible, and scalable way to create web applications. React is widely used in web front-end development and has become one of the mainstream frameworks for building web applications.
Vue:全称为Vue.js,是一种基于JavaScript的框架。它是一个开源的Web应用开发框架框架,是一种用于构建用户界面的渐进式JavaScript框架。Vue被广泛应用于Web前端开发,目前已经成为了构建Web应用的主流框架之一。Vue: The full name is Vue.js, which is a framework based on JavaScript. It is an open source web application development framework and a progressive JavaScript framework for building user interfaces. Vue is widely used in web front-end development and has become one of the mainstream frameworks for building web applications.
面向生命周期编程:是一种编程范式。在Web应用开发框架下,Web应用的各个组件都具有创建,挂载,更新,销毁的生命周期,面向生命周期编程是为了使Web应用的各个组件在不同的生命周期阶段中正确地执行。在面向生命周期编程中,对象的创建、销毁和管理是编程的重点,程序员需要考虑如何在不同的生命周期阶段中正确地管理对象,以确保程序的正确性和稳定性。换句话说,所谓面向生命周期编程,是指基于Web应用开发框架开发一个Web前端UI组件时,按照Web应用开发框架定义的生命周期,将UI组件的相关逻辑代码注册到指定的生命周期钩子函数里。生命周期钩子函数是一种在组件挂载和卸载过程中触发的函数,用于执行一些清理操作或事件处理。生命周期钩子函数按照组件生命周期的过程分为挂载阶段、更新阶段和销毁阶段,按照不同阶段触发不同的操作。通常,当组件卸载时,所有的生命周期钩子函数都会被调用一次,以确保组件被正确地清理。以Vue框架的生命周期为例,生命周期钩子函数包括:beforeCreate、created、beforeMount、mounted、beforeUnmount、unmounted等,一个UI组件的逻辑代码可能被拆分到生命周期钩子函数里。由于面向生命周期编程是分阶段进行的,因此,某个阶段出现的错误会被带到下一阶段,从而使得错误的影响范围扩大,导致Web应用的开发过程相对较为复杂和缓慢。Lifecycle-oriented programming: is a programming paradigm. Under the Web application development framework, each component of a Web application has a life cycle of creation, mounting, updating, and destruction. Lifecycle-oriented programming is to enable each component of a Web application to execute correctly in different life cycle stages. In lifecycle-oriented programming, the creation, destruction, and management of objects are the focus of programming. Programmers need to consider how to correctly manage objects in different life cycle stages to ensure the correctness and stability of the program. In other words, lifecycle-oriented programming means that when developing a Web front-end UI component based on the Web application development framework, the relevant logic code of the UI component is registered in the specified life cycle hook function according to the life cycle defined by the Web application development framework. The life cycle hook function is a function triggered during the mounting and unmounting process of a component, which is used to perform some cleanup operations or event processing. The life cycle hook function is divided into the mounting phase, the updating phase, and the destruction phase according to the process of the component life cycle, and different operations are triggered according to different phases. Usually, when a component is unmounted, all life cycle hook functions are called once to ensure that the component is properly cleaned up. Taking the life cycle of the Vue framework as an example, the life cycle hook functions include: beforeCreate, created, beforeMount, mounted, beforeUnmount, unmounted, etc. The logic code of a UI component may be split into life cycle hook functions. Since life cycle-oriented programming is carried out in stages, errors in one stage will be carried over to the next stage, thereby expanding the scope of the error's impact, making the development process of Web applications relatively complex and slow.
面向业务逻辑编程:是在前端开发实践的过程中,尤其在开发大型应用的时候,为了解决面向生命周期编程所引发的问题,提出新的编程范式。面向业务逻辑编程旨在使用结构化的方式描述和处理业务逻辑。面向业务逻辑编程的主要目标是提高代码的可读性、可维护性和可扩展性,使其易于理解和修改。其中,React框架提供面向业务逻辑编程的API称作Hooks API,而Vue框架提供的API称作Composition API,其他正在崛起的新兴前端开发框架,比如Svelte、SolidJS框架也提供类似的API。因此,面向业务逻辑编程正逐步取代面向生命周期编程,成为Web前端开发框架的主流编程范式。Business logic-oriented programming: In the process of front-end development practice, especially when developing large-scale applications, a new programming paradigm is proposed to solve the problems caused by lifecycle-oriented programming. Business logic-oriented programming aims to describe and process business logic in a structured way. The main goal of business logic-oriented programming is to improve the readability, maintainability and extensibility of the code, making it easy to understand and modify. Among them, the API for business logic programming provided by the React framework is called Hooks API, and the API provided by the Vue framework is called Composition API. Other emerging front-end development frameworks that are emerging, such as Svelte and SolidJS frameworks, also provide similar APIs. Therefore, business logic-oriented programming is gradually replacing lifecycle-oriented programming and becoming the mainstream programming paradigm of Web front-end development frameworks.
无渲染组件(Renderless Component):是一种用于开发组件的设计模式,它将组件的功能逻辑(业务逻辑)与前端渲染分离开来,使得组件的代码更加简洁、易于维护。无渲染组件的核心思想是将组件的逻辑代码(业务逻辑代码)和渲染代码(外观代码)分开编写,使得组件的代码可以复用。这种设计模式有助于提高代码的可读性和可维护性,使得组件的代码更加简洁。Renderless Component: It is a design pattern for developing components. It separates the functional logic (business logic) of the component from the front-end rendering, making the component code more concise and easier to maintain. The core idea of renderless components is to write the logic code (business logic code) and rendering code (appearance code) of the component separately, so that the component code can be reused. This design pattern helps to improve the readability and maintainability of the code, making the component code more concise.
接下来对本申请实施例的应用场景进行介绍。Next, the application scenarios of the embodiments of the present application are introduced.
在Web应用开发过程中,为了提升代码的编写效率,技术人员通常使用基于JS的开发框架对Web应用进行设计,比如,Vue、React等等。In the process of Web application development, in order to improve the efficiency of code writing, technicians usually use JS-based development frameworks to design Web applications, such as Vue, React, and so on.
然而,在对Web应用进行设计时,技术人员编写的Web应用代码包括业务逻辑代码和外观代码,但由于Web应用通常需要适配手机、电脑、车载终端等不同的终端设备,而不同的终端设备所对应的Web应用的外观不同。换句话说,对于同一个Web应用来说,在不同的终端设备下该Web应用都有相应的版本,比如,个人计算机(personal computer,PC)端的版本、手机端的版本、车载终端的版本等等。并且,为了保证设计出的Web应用与主流开发框架相适应,对同一个Web应用来说,技术人员也需要在不同的开发框架下对该Web应用进行设计。也就是说,对一个Web应用来说,在不同的开发框架下该Web应用都需要有相应的版本,比如,基于Vue框架的版本、基于React框架的版本等等。However, when designing a Web application, the Web application code written by the technician includes business logic code and appearance code, but because Web applications usually need to adapt to different terminal devices such as mobile phones, computers, and vehicle-mounted terminals, and the appearance of Web applications corresponding to different terminal devices is different. In other words, for the same Web application, the Web application has corresponding versions under different terminal devices, such as the version on the personal computer (PC), the version on the mobile phone, the version on the vehicle terminal, and so on. In addition, in order to ensure that the designed Web application is compatible with the mainstream development framework, for the same Web application, the technician also needs to design the Web application under different development frameworks. In other words, for a Web application, the Web application needs to have corresponding versions under different development frameworks, such as a version based on the Vue framework, a version based on the React framework, and so on.
因此,为了保证设计出的Web应用与主流开发框架相适应的同时,还能够与不同的终端设备相适应。在不同的开发框架和不同的终端设备下,同一个Web应用具有基于Vue框架的PC端的版本、基于Vue框架的手机端的版本、基于Vue框架的车载终端的版本版本、基于React框架的PC端的版本、基于React框架的手机端的版本、基于React框架的车载终端的版本等。如此一来,对于同一个Web应用来说,需要开发多个版本以适配不同的开发框架和不同的终端设备。Therefore, in order to ensure that the designed Web application is compatible with the mainstream development framework, it can also be adapted to different terminal devices. Under different development frameworks and different terminal devices, the same Web application has a PC version based on the Vue framework, a mobile phone version based on the Vue framework, a car terminal version based on the Vue framework, a PC version based on the React framework, a mobile phone version based on the React framework, a car terminal version based on the React framework, etc. In this way, for the same Web application, multiple versions need to be developed to adapt to different development frameworks and different terminal devices.
由于在针对不同的开发框架和不同的终端设备进行Web应用开发时所需要的技术知识不同,因此,需要不同的技术人员来开发和维护不同的版本的Web应用,比如,需要懂React框架的技术人员来开发和维护基于React框架的版本,需要懂Vue框架的技术人员来开发和维护基于Vue框架的版本,需要懂PC端交互的技术人员来开发和维护PC端的版本,需要懂手机端交互的技术人员来开发和维护手机端的版本,需要懂车载终端交互的技术人员来开发和维护车载终端的版本。这种情况下,对于具有相同业务逻辑的Web应用,技术人员需要重复编写针对不同终端和不同开发框架的Web应用的代码,使得Web应用与主流开发框架相适应,并且具有与终端设备相适应的外观,这会导致技术人员将大量的时间花费在代码的书写上,从而大大增加了人力成本与时间成本。Since different technical knowledge is required for developing Web applications for different development frameworks and different terminal devices, different technicians are needed to develop and maintain different versions of Web applications. For example, technicians who understand the React framework are needed to develop and maintain the version based on the React framework, technicians who understand the Vue framework are needed to develop and maintain the version based on the Vue framework, technicians who understand PC-side interaction are needed to develop and maintain the PC-side version, technicians who understand mobile-side interaction are needed to develop and maintain the mobile-side version, and technicians who understand vehicle-mounted terminal interaction are needed to develop and maintain the vehicle-mounted terminal version. In this case, for Web applications with the same business logic, technicians need to repeatedly write the code for Web applications for different terminals and different development frameworks so that the Web applications are compatible with the mainstream development framework and have an appearance that is compatible with the terminal device. This will cause technicians to spend a lot of time writing code, which greatly increases labor costs and time costs.
基于此,本申请实施例提供了一种代码生成方法,能够获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,从而基于该业务逻辑代码和该至少一个外观代码,确定目标应用在目标开发框架下的完整代码。由于该至少一个外观代码指示目标应用的至少一种外观,并且该至少一种外观与至少一种终端类型对应,因此,该完整代码能够在保证目标应用与目标开发框架相适应的同时,还能够保证目标应用的外观能够适应不同的终端设备。换句话说,本申请实施例提供的代码生成方法能够自动生成目标应用在目标框架下的完整代码,无需技术人员重复编写针对不同终端和不同开发框架的目标应用的代码,从而大大提升代码编写的效率,有效节约人力成本和时间成本。Based on this, the embodiment of the present application provides a code generation method, which can obtain the business logic code of the target application and at least one appearance code of the target application under the target development framework, so as to determine the complete code of the target application under the target development framework based on the business logic code and the at least one appearance code. Since the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one terminal type, the complete code can ensure that the target application is compatible with the target development framework while also ensuring that the appearance of the target application can adapt to different terminal devices. In other words, the code generation method provided by the embodiment of the present application can automatically generate the complete code of the target application under the target framework, without the need for technicians to repeatedly write the code for the target application for different terminals and different development frameworks, thereby greatly improving the efficiency of code writing and effectively saving manpower and time costs.
本申请实施例提供的代码生成方法的执行主体为云平台,也就是说,该云平台可以提供代码生成服务。该云平台可以是由多台物理服务器组成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(content delivery network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器,或者是一个云计算服务中心。The execution subject of the code generation method provided in the embodiment of the present application is a cloud platform, that is, the cloud platform can provide code generation services. The cloud platform can be a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms, or a cloud computing service center.
需要说明的是,本申请实施例描述的应用场景以及执行主体是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着新应用场景的出现和设备的演变,本申请实施例提供的技术方案对于类似的技术问题,同样适用。It should be noted that the application scenarios and execution entities described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the emergence of new application scenarios and the evolution of equipment, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
图1是本申请实施例提供的一种代码生成方法的流程图。请参考图1,该方法包括如下步骤。Fig. 1 is a flow chart of a code generation method provided by an embodiment of the present application. Referring to Fig. 1 , the method comprises the following steps.
步骤101:获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,该业务逻辑代码指示目标应用的功能,该至少一个外观代码指示目标应用的至少一种外观,该至少一种外观与至少一种终端类型对应。Step 101: Obtain a business logic code of a target application and at least one appearance code of the target application in a target development framework, wherein the business logic code indicates a function of the target application, and the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one terminal type.
获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码的实现方式包括多种,接下来对其中的两种方式进行介绍。There are multiple implementation methods for obtaining the business logic code of the target application and at least one appearance code of the target application under the target development framework, and two of them are introduced below.
第一种实现方式,云平台能够显示代码编写界面,该代码编写界面用于编写目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,响应于代码编写完成操作,云平台能够获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码。In the first implementation method, the cloud platform can display a code writing interface, which is used to write the business logic code of the target application and at least one appearance code of the target application under the target development framework. In response to the code writing completion operation, the cloud platform can obtain the business logic code of the target application and at least one appearance code of the target application under the target development framework.
在云平台显示代码编写界面之后,技术人员能够在该代码编写界面进行目标应用的业务逻辑代码和该至少一个外观代码的编写。在编写完成之后,技术人员触发代码编写完成操作,该云平台响应于代码编写完成操作,获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码。After the cloud platform displays the code writing interface, the technician can write the business logic code and the at least one appearance code of the target application in the code writing interface. After the writing is completed, the technician triggers the code writing completion operation, and the cloud platform responds to the code writing completion operation to obtain the business logic code of the target application and the at least one appearance code of the target application under the target development framework.
示例地,技术人员在该代码编写界面先进行目标应用的业务逻辑代码的编写,在业务逻辑代码编写完成之后,触发业务逻辑代码编写完成操作。云平台响应于业务逻辑代码编写完成操作,获取该业务逻辑代码,并且对该代码编写界面进重置,以便于技术人员继续编写目标应用在目标开发框架下的外观代码。进而,技术人员在该代码编写界面进行至少一个外观代码的编写,在至少一个外观代码的编写完成之后,触发至少一个外观代码的编写完成操作,云平台响应于该至少一个外观代码的编写完成操作,获取该至少一个外观代码。For example, the technician first writes the business logic code of the target application in the code writing interface, and after the business logic code is written, the business logic code writing completion operation is triggered. In response to the business logic code writing completion operation, the cloud platform obtains the business logic code and resets the code writing interface to facilitate the technician to continue writing the appearance code of the target application under the target development framework. Furthermore, the technician writes at least one appearance code in the code writing interface, and after the at least one appearance code is written, the at least one appearance code writing completion operation is triggered, and the cloud platform obtains the at least one appearance code in response to the at least one appearance code writing completion operation.
由于技术人员能够编写至少一个外观代码,在这种情况下,每当技术人员编写完成一个外观代码之后,可以触发编写下一个外观代码的操作,也可以触发至少一个外观代码的编写完成操作。若技术人员触发编写下一个外观代码的操作,则云平台响应于下一个外观代码的操作,保存当前代码编写界面中的外观代码,并且对该代码编写界面进重置,以便于技术人员继续编写下一个外观代码。若技术人员触发至少一个外观代码的编写完成操作,云平台响应于该至少一个外观代码的编写完成操作,将当前代码编写界面中的外观代码和之前保存的外观代码作为该至少一个外观代码。Since the technician can write at least one appearance code, in this case, every time the technician finishes writing an appearance code, the operation of writing the next appearance code can be triggered, and the operation of completing the writing of at least one appearance code can also be triggered. If the technician triggers the operation of writing the next appearance code, the cloud platform responds to the operation of writing the next appearance code, saves the appearance code in the current code writing interface, and resets the code writing interface so that the technician can continue to write the next appearance code. If the technician triggers the operation of completing the writing of at least one appearance code, the cloud platform responds to the operation of completing the writing of the at least one appearance code, and uses the appearance code in the current code writing interface and the previously saved appearance code as the at least one appearance code.
若技术人员触发编写下一个外观代码的操作,说明技术人员还需要编写一个外观代码,因此,云平台可以响应于下一个外观代码的操作,保存当前代码编写界面中的外观代码,并且对该代码编写界面进重置,以便于技术人员继续编写下一个外观代码。若技术人员触发至少一个外观代码的编写完成操作,说明技术人员已经编写完所有的外观代码,因此,云平台可以响应于该至少一个外观代码的编写完成操作,将当前代码编写界面中的外观代码和之前保存的外观代码作为该至少一个外观代码。If the technician triggers the operation of writing the next appearance code, it means that the technician still needs to write an appearance code. Therefore, the cloud platform can respond to the operation of the next appearance code, save the appearance code in the current code writing interface, and reset the code writing interface to facilitate the technician to continue writing the next appearance code. If the technician triggers the operation of completing the writing of at least one appearance code, it means that the technician has finished writing all the appearance codes. Therefore, the cloud platform can respond to the operation of completing the writing of at least one appearance code and use the appearance code in the current code writing interface and the previously saved appearance code as the at least one appearance code.
例如,云平台可以显示如图2所示的代码编写界面,技术人员在编写完目标应用的业务逻辑代码后,可以触发业务逻辑代码编写完成的操作。然后,技术人员可以在代码编写界面继续编写至少一个外观代码,当技术人员编写完成一个外观代码之后,可以在如图3所示的界面触发编写下一个外观代码的操作,也可以触发至少一个外观代码的编写完成操作。For example, the cloud platform can display the code writing interface shown in Figure 2. After the technician finishes writing the business logic code of the target application, the operation of completing the writing of the business logic code can be triggered. Then, the technician can continue to write at least one appearance code in the code writing interface. After the technician finishes writing an appearance code, the operation of writing the next appearance code can be triggered in the interface shown in Figure 3, and the operation of completing the writing of at least one appearance code can also be triggered.
需要说明的是,上述在代码编写界面先进行业务逻辑代码的编写,再进行外观代码的编写的过程仅仅是一种示例,在实际应用中,也可以先进行至少一个外观代码的编写,再进行目标应用的业务逻辑代码的编写,本申请实施例对此不做限定。It should be noted that the above process of first writing the business logic code and then writing the appearance code in the code writing interface is only an example. In actual applications, you can also first write at least one appearance code and then write the business logic code of the target application. The embodiments of the present application are not limited to this.
第二种实现方式,技术人员可以在其他具有代码编写功能的云平台上完成对目标应用的业务逻辑代码和该至少一个外观代码的编写,进而将该目标应用的业务逻辑代码和该至少一个外观代码发送给云平台,云平台接收该目标应用的业务逻辑代码和该至少一个外观代码。In the second implementation method, the technicians can complete the writing of the business logic code and the at least one appearance code of the target application on other cloud platforms with code writing functions, and then send the business logic code and the at least one appearance code of the target application to the cloud platform, and the cloud platform receives the business logic code and the at least one appearance code of the target application.
也就是说,该目标应用的业务逻辑代码和该至少一个外观代码可以是技术人员在云平台上编写后直接得到的,也可以是技术人员在其他具有代码编写功能的云平台编写完成后发送给云平台的。当然,在实际应用中,云平台还可以通过其他的方式获取到目标应用的业务逻辑代码和该至少一个外观代码,本申请实施例对此不做限定。That is to say, the business logic code and the at least one appearance code of the target application can be directly obtained by the technician after writing on the cloud platform, or can be sent to the cloud platform after the technician writes on other cloud platforms with code writing functions. Of course, in actual applications, the cloud platform can also obtain the business logic code and the at least one appearance code of the target application in other ways, which is not limited in the embodiments of the present application.
在一些实施例中,上述业务逻辑代码为柯里化函数形式,该业务逻辑代码和该至少一个外观代码为JavaScript语言。In some embodiments, the business logic code is in the form of a curried function, and the business logic code and the at least one appearance code are in JavaScript language.
作为一种示例,当目标应用为待办(TODO)组件时,该待办组件的业务逻辑代码可以为下文所示的代码,该业务逻辑代码表示待办组件具有删除待办事项和添加待办事项的功能。As an example, when the target application is a to-do (TODO) component, the business logic code of the to-do component may be the code shown below, and the business logic code indicates that the to-do component has the functions of deleting to-do items and adding to-do items.
步骤102:基于业务逻辑代码,确定目标应用在目标开发框架下的无渲染代码。Step 102: Based on the business logic code, determine the rendering-free code of the target application under the target development framework.
在一些实施例中,可以按照下述步骤(1)-(2)确定目标应用在目标开发框架下的无渲染代码。In some embodiments, the rendering-free code of the target application under the target development framework may be determined according to the following steps (1)-(2).
(1)确定该业务逻辑代码中的至少一个逻辑函数的函数名、至少一个逻辑函数分别对应的至少一个参数的参数名以及该至少一个参数中每个参数的属性名。(1) Determine the function name of at least one logic function in the business logic code, the parameter name of at least one parameter corresponding to the at least one logic function, and the attribute name of each parameter in the at least one parameter.
在一些实施例中,业务逻辑代码包括逻辑代码注释和逻辑代码本体,在这种情况下,可以从逻辑代码本体中获取该至少一个逻辑函数的函数名,从逻辑代码注释中获取至少一个逻辑函数分别对应的至少一个参数的参数名以及每个参数的属性名。In some embodiments, the business logic code includes logic code comments and a logic code body. In this case, the function name of the at least one logic function can be obtained from the logic code body, and the parameter name of at least one parameter corresponding to the at least one logic function and the attribute name of each parameter can be obtained from the logic code comments.
云平台可以从业务逻辑代码本体中确定第一位置,该第一位置处的代码中包含该至少一个逻辑函数的函数名,从该第一位置处的代码中获取该至少一个逻辑函数的函数名。The cloud platform can determine a first position from the business logic code body, where the code at the first position contains the function name of the at least one logic function, and obtain the function name of the at least one logic function from the code at the first position.
示例地,云平台存储有第一字符串,在这种情况下,云平台可以按照相关算法,从业务逻辑代码中搜索第一字符串,将该第一字符串所在的位置确定为第一位置,将该第一位置处的代码中除第一字符串之外的代码作为至少一个逻辑函数的函数名。For example, the cloud platform stores a first string. In this case, the cloud platform can search for the first string from the business logic code according to the relevant algorithm, determine the location of the first string as the first position, and use the code at the first position except the first string as the function name of at least one logical function.
例如,以上述业务逻辑代码为例,该第一字符串可以为export{},云平台确定将该第一字符串所在的位置确定为第一位置,该第一位置处的代码为export{addTag,removeTag},则该该第一位置处的代码中除第一字符串之外的代码为addTag和removeTag,因此可以将addTag和removeTag作为至少一个逻辑函数的函数名。For example, taking the above-mentioned business logic code as an example, the first string can be export{}, the cloud platform determines the location of the first string as the first position, and the code at the first position is export{addTag, removeTag}. Then, the code at the first position except the first string is addTag and removeTag, so addTag and removeTag can be used as the function name of at least one logical function.
需要说明的是,上述第一字符串事先存储在云平台中仅仅是一种示例,在实际应用中,该第一字符串还可以通过其他方式确定,本申请实施例对此不做限定。例如,技术人员也可以在云平台中输入第一字符串,以使云平台获取到该第一字符串。在技术人员输入第一字符串的情况下,云平台能够显示第一字符串输入界面,响应于第一字符串输入完成操作,获取技术人员输入的第一字符串。比如,云平台能够显示如图4所示的第一字符串指定界面,技术人员能够在该第一字符串指定界面输入第一字符串,在输入完成之后,技术人员能够触发第一字符串输入完成操作。云平台响应于技术人员触发的第一字符串输入完成操作,获取技术人员输入的第一字符串。It should be noted that the above-mentioned first string is stored in the cloud platform in advance is only an example. In actual applications, the first string can also be determined by other means, and the embodiments of the present application do not limit this. For example, the technician can also enter the first string in the cloud platform so that the cloud platform can obtain the first string. In the case where the technician enters the first string, the cloud platform can display the first string input interface, and in response to the first string input completion operation, obtain the first string entered by the technician. For example, the cloud platform can display the first string designation interface as shown in Figure 4, and the technician can enter the first string in the first string designation interface. After the input is completed, the technician can trigger the first string input completion operation. The cloud platform responds to the first string input completion operation triggered by the technician and obtains the first string entered by the technician.
基于上文描述,该至少一个逻辑函数的函数名可以是云平台自行从业务逻辑代码本体中确定的。在实际应用中,该至少一个逻辑函数的函数名也可以通过其他方式确定。例如,技术人员可以直接在云平台中输入该至少一个逻辑函数的函数名,以使云平台能够获取该至少一个逻辑函数的函数名,本申请实施例对此不做限定。技术人员在云平台中输入至少一个逻辑函数的函数名的实现过程与上述技术人员在云平台中输入第一字符串的实现过程类似,详细实现过程请参考上文中的相关内容,此处不再赘述。Based on the above description, the function name of the at least one logic function can be determined by the cloud platform itself from the business logic code body. In practical applications, the function name of the at least one logic function can also be determined by other means. For example, a technician can directly enter the function name of the at least one logic function in the cloud platform so that the cloud platform can obtain the function name of the at least one logic function. This embodiment of the present application is not limited to this. The implementation process of the technician entering the function name of at least one logic function in the cloud platform is similar to the implementation process of the above-mentioned technician entering the first string in the cloud platform. For the detailed implementation process, please refer to the relevant content above, which will not be repeated here.
为了便于云平台对逻辑代码注释进行识别,在一些实施例中,该逻辑代码注释的格式为目标格式。在这种情况下,云平台中事先存储有目标格式,云平台能够根据该目标格式,按照相关算法,从该逻辑代码注释中确定至少一个逻辑函数分别对应的至少一个参数的参数名以及至少一个参数的属性名。In order to facilitate the cloud platform to identify the logic code annotation, in some embodiments, the format of the logic code annotation is a target format. In this case, the cloud platform stores the target format in advance, and the cloud platform can determine the parameter name of at least one parameter and the attribute name of at least one parameter corresponding to at least one logic function from the logic code annotation according to the target format and the relevant algorithm.
在一些实施例中,该目标格式为jsdoc格式。当然,该逻辑代码注释的格式还可以是其他类型的格式,本申请实施例对此不做限定。示例地,在目标格式为jsdoc格式的情况下,至少一个逻辑函数中每个逻辑函数都分别对应一个逻辑代码子注释。云平台能够按照相关算法,从每个逻辑函数对应的逻辑代码子注释中确定该每个逻辑函数对应的至少一个参数的参数名以及每个参数的属性名。In some embodiments, the target format is a jsdoc format. Of course, the format of the logic code comment can also be other types of formats, which is not limited in the embodiments of the present application. For example, when the target format is a jsdoc format, each logic function in at least one logic function corresponds to a logic code sub-comment. The cloud platform can determine the parameter name of at least one parameter corresponding to each logic function and the attribute name of each parameter from the logic code sub-comment corresponding to each logic function according to the relevant algorithm.
继续以上述业务逻辑代码为例,该业务逻辑代码包括addTag和removeTag两个逻辑函数。其中,addTag对应的逻辑代码子注释如下文所示。Continuing with the above business logic code as an example, the business logic code includes two logic functions, addTag and removeTag. The logic code sub-comment corresponding to addTag is shown below.
/**/**
*@param{object}text-参数名为text的参数的数据类型为object*@param{object}text-the data type of the parameter named text is object
*@param{boolean}text.model-参数text包括属性名为model的属性,该model属性的数据类型为boolean*@param{boolean}text.model - The parameter text includes an attribute named model, and the data type of the model attribute is boolean
*@param{string}text.value-参数text包括属性名为value的属性,该value属性的数据类型为string,也即是,该参数text的值的数据类型为字符串。*@param{string}text.value-The parameter text includes an attribute with the attribute name value, and the data type of the value attribute is string, that is, the data type of the value of the parameter text is string.
*@param{object}props-参数名为props的参数的数据类型为object*@param{object}props-The data type of the parameter named props is object
*@param{object}refs-参数名为refs的参数的数据类型为object*@param{object}refs-The data type of the parameter named refs is object
*@param{function}emit-参数名为emit的参数的数据类型为function*@param{function}emit-The data type of the parameter named emit is function
*@param{object}api-参数名为api的参数的数据类型为object*@param{object}api-the data type of the parameter named api is object
*/*/
在addTag对应的逻辑代码子注释中,云平台可以确定addTag对应的至少一个参数的参数名为text、props、refs、emit和api,其中,参数text的属性名包括model和value,其他参数没有属性。In the logic code sub-annotation corresponding to addTag, the cloud platform can determine that the parameter name of at least one parameter corresponding to addTag is text, props, refs, emit, and api, where the attribute name of the parameter text includes model and value, and other parameters have no attributes.
removeTag对应的逻辑代码子注释如下文所示。The logic code sub-comments corresponding to removeTag are shown below.
/**/**
*@param{object}props-参数名为props的参数的数据类型为object*@param{object}props-The data type of the parameter named props is object
*@param{object}refs-参数名为refs的参数的数据类型为object*@param{object}refs-The data type of the parameter named refs is object
*@param{function}emit-参数名为emit的参数的数据类型为function*@param{function}emit-The data type of the parameter named emit is function
*/*/
在removeTag对应的逻辑代码子注释中,云平台可以确定removeTag对应的至少一个参数的参数名为props,refs和emit,这些参数没有属性。In the logic code sub-comment corresponding to removeTag, the cloud platform can determine that the parameter names of at least one parameter corresponding to removeTag are props, refs, and emit, and these parameters have no attributes.
(2)基于该至少一个逻辑函数的函数名、至少一个参数的参数名、至少一个参数中每个参数的属性名和业务逻辑代码的存储路径,对目标开发框架对应的无渲染模板进行填充,以得到该目标应用在目标开发框架下的无渲染代码。(2) Based on the function name of the at least one logic function, the parameter name of the at least one parameter, the attribute name of each parameter in the at least one parameter, and the storage path of the business logic code, the rendering-free template corresponding to the target development framework is filled to obtain the rendering-free code of the target application under the target development framework.
在一些实施例中,目标开发框架对应的无渲染模板包括第一待填充区域,该第一待填充区域包括逻辑函数导入子区域、逻辑代码路径子区域、初始化子区域、API对象创建区域、挂载与更新区域以及API对象已创建区域。在这种情况下,可以将该至少一个逻辑函数的函数名写入逻辑函数导入子区域,将业务逻辑代码的存储路径写入逻辑代码路径子区域,将至少一个参数中具有目标属性名的参数作为第一参数,该目标属性名指示具有该目标属性名的参数为数据模型,基于第一参数对初始化子区域进行填充,将第一参数的参数名以及至少一个逻辑函数中第一逻辑函数的函数名写入API对象创建区域,该第一逻辑函数为不具有目标参数名的逻辑函数,该目标参数名指示具有该目标参数名的逻辑函数为接口函数。若至少一个逻辑函数中存在挂载函数,则将挂载函数的函数名在目标框架下的代码写入挂载与更新区域。将至少一个逻辑函数中除第一逻辑函数之外的逻辑函数的函数名写入API对象已创建区域,以实现对目标开发框架对应的无渲染模板进行填充。In some embodiments, the non-rendering template corresponding to the target development framework includes a first area to be filled, and the first area to be filled includes a logic function import sub-area, a logic code path sub-area, an initialization sub-area, an API object creation area, a mount and update area, and an API object created area. In this case, the function name of the at least one logic function can be written into the logic function import sub-area, the storage path of the business logic code can be written into the logic code path sub-area, the parameter with the target attribute name in at least one parameter is used as the first parameter, and the target attribute name indicates that the parameter with the target attribute name is a data model, and the initialization sub-area is filled based on the first parameter, and the parameter name of the first parameter and the function name of the first logic function in at least one logic function are written into the API object creation area, and the first logic function is a logic function without a target parameter name, and the target parameter name indicates that the logic function with the target parameter name is an interface function. If there is a mount function in at least one logic function, the code of the function name of the mount function under the target framework is written into the mount and update area. The function names of the logic functions other than the first logic function in at least one logic function are written into the API object created area to achieve the filling of the non-rendering template corresponding to the target development framework.
基于第一参数对初始化子区域进行填充的实现过程包括:确定该第一参数在目标框架下的初始化代码,将该初始化代码写入初始化子区域。The implementation process of filling the initialization sub-area based on the first parameter includes: determining the initialization code of the first parameter in the target framework, and writing the initialization code into the initialization sub-area.
云平台中存储有目标属性名与目标框架下的初始化代码的对应关系,基于该第一参数包括的属性名中与目标属性名相同的属性名,从目标属性名与目标框架下的初始化代码的对应关系中,能够确定第一参数在目标框架下的初始化代码。The cloud platform stores the correspondence between the target attribute name and the initialization code under the target framework. Based on the attribute name included in the first parameter that is the same as the target attribute name, the initialization code of the first parameter under the target framework can be determined from the correspondence between the target attribute name and the initialization code under the target framework.
需要说明的是,上述目标属性名、目标参数名和挂载函数的函数名是事先设置的。该目标属性名可以设置为model,该目标参数名可以设置为api,挂载函数的函数名可以设置为mounted。当然,在实际应用中,还可以将目标属性名、目标参数名和挂载函数的函数名设置为其他名称,本申请实施例对此不做限定。It should be noted that the above target attribute name, target parameter name and function name of the mounting function are set in advance. The target attribute name can be set to model, the target parameter name can be set to api, and the function name of the mounting function can be set to mounted. Of course, in actual applications, the target attribute name, target parameter name and function name of the mounting function can also be set to other names, which is not limited in the embodiments of the present application.
作为一种示例,Vue框架对应的无渲染模板如图5所示,请参考图6,若至少一个逻辑函数的函数名为addTag,removeTag,checkTag,focus,inputEvents,mounted,则可以将该至少一个逻辑函数的函数名写入逻辑函数导入子区域,业务逻辑代码的存储路径写入逻辑代码路径子区域,若addTag的参数text的属性名包括model和value,该参数text为具有目标属性名(model)的参数,因此,可以将addTag的参数text作为第一参数,将第一参数在Vue框架下的初始化代码“parent.text=parent.text||value(”)”写入初始化子区域。若checkTag、focus和removeTag为第一逻辑函数,则将text、checkTag、focus和removeTag写入API对象创建区域。又因为至少一个逻辑函数中存在挂载函数,因此可以将挂载函数的函数名在Vue框架下的代码“onMounted(mounted(api))onUpdated(mounted(api))”写入挂载与更新区域。将addTag和inputEvents写入API对象已创建区域。As an example, the non-rendering template corresponding to the Vue framework is shown in Figure 5. Please refer to Figure 6. If the function name of at least one logic function is addTag, removeTag, checkTag, focus, inputEvents, mounted, the function name of the at least one logic function can be written into the logic function import sub-area, and the storage path of the business logic code can be written into the logic code path sub-area. If the attribute name of the parameter text of addTag includes model and value, the parameter text is a parameter with the target attribute name (model). Therefore, the parameter text of addTag can be used as the first parameter, and the first parameter can be initialized in the Vue framework. “parent.text=parent.text||value(”)” is written into the initialization sub-area. If checkTag, focus and removeTag are the first logical functions, text, checkTag, focus and removeTag are written into the API object creation area. Because there is a mounting function in at least one logical function, the function name of the mounting function can be written into the mounting and update area in the code “onMounted(mounted(api))onUpdated(mounted(api))” under the Vue framework. AddTag and inputEvents are written into the API object created area.
作为另一种示例,React框架对应的无渲染模板如图7所示,请参考图8,若至少一个逻辑函数的函数名为addTag,removeTag,checkTag,focus,inputEvents,mounted,则可以将该至少一个逻辑函数的函数名写入逻辑函数导入子区域,业务逻辑代码的存储路径写入逻辑代码路径子区域,若addTag的参数text的属性名包括model和value,该参数text为具有目标属性名(model)的参数,因此,可以将addTag的参数text作为第一参数,将第一参数在Re act框架下的初始化代码“const text=value(”)”写入初始化子区域。若checkTag、focus、和removeTag为第一逻辑函数,则将text、checkTag、focus、和removeTag写入API对象创建区域。又因为至少一个逻辑函数的函数名中存在挂载函数的函数名,因此可以将挂载函数的函数名在React框架下的代码“onMounted(mounted(api))onUpdated(mounted(api),[context.$mo de])”写入挂载与更新区域。将addTag和inputEvents写入API对象已创建区域。As another example, the non-rendering template corresponding to the React framework is shown in FIG7 . Please refer to FIG8 . If the function name of at least one logic function is addTag, removeTag, checkTag, focus, inputEvents, mounted, the function name of the at least one logic function can be written into the logic function import sub-area, and the storage path of the business logic code can be written into the logic code path sub-area. If the attribute name of the parameter text of addTag includes model and value, the parameter text is a parameter with the target attribute name (model). Therefore, the parameter text of addTag can be used as the first parameter, and the initialization code of the first parameter in the React framework "const text=value(")" is written into the initialization sub-area. If checkTag, focus, and removeTag are the first logic functions, text, checkTag, focus, and removeTag are written into the API object creation area. Because the function name of the mounting function exists in the function name of at least one logic function, the function name of the mounting function can be written into the code "onMounted(mounted(api))onUpdated(mounted(api), [context.$mo de])" to the mount and update area. Write addTag and inputEvents to the API object created area.
在实际应用中,在对目标开发框架对应的无渲染模板进行填充之前,云平台需要确定目标开发框架。在这种情况下,云平台可以显示如图9所示的开发框架选择界面,该开发框架选择界面用于选择目标开发框架,响应于开发框架选择完成操作,云平台能够确定目标开发框架。也就是说,云平台在显示开发框架选择界面之后,技术人员能够在该开发框架选择界面选择一个开发框架作为目标开发框架,在选择完成之后,技术人员可以触发开发框架选择完成操作。云平台响应于开发框架选择完成操作,确定目标开发框架。In actual applications, before filling the non-rendering template corresponding to the target development framework, the cloud platform needs to determine the target development framework. In this case, the cloud platform can display a development framework selection interface as shown in Figure 9, which is used to select the target development framework. In response to the development framework selection completion operation, the cloud platform can determine the target development framework. That is, after the cloud platform displays the development framework selection interface, the technician can select a development framework as the target development framework in the development framework selection interface. After the selection is completed, the technician can trigger the development framework selection completion operation. The cloud platform determines the target development framework in response to the development framework selection completion operation.
步骤103:对无渲染代码和至少一个外观代码进行组织,以得到目标应用在目标开发框架下的完整代码。Step 103: Organize the non-rendering code and at least one appearance code to obtain the complete code of the target application under the target development framework.
由于存在多个开发框架,在不同的开发框架下,得到目标应用在目标开发框架下的完整代码方式不同,接下来对其中的两种开发框架对应的实现方式进行介绍。Since there are multiple development frameworks, different development frameworks have different ways of obtaining the complete code of the target application under the target development framework. Next, the corresponding implementation methods of two of the development frameworks are introduced.
第一种情况,目标开发框架为Vue框架,目标应用为Web应用,该目标应用包括至少一个组件,该至少一个外观代码指示该至少一个组件的至少一种外观。在这种情况下,可以基于该至少一个外观代码,确定至少一个组件中包含的子组件的组件名以及该至少一个组件的属性名,基于至少一个组件的属性名、该子组件的组件名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充,以得到目标应用在目标开发框架下的完整代码。In the first case, the target development framework is the Vue framework, the target application is a Web application, the target application includes at least one component, and the at least one appearance code indicates at least one appearance of the at least one component. In this case, based on the at least one appearance code, the component name of the subcomponent contained in the at least one component and the attribute name of the at least one component can be determined, and based on the attribute name of the at least one component, the component name of the subcomponent and the storage path of the non-rendering code, the code adaptation template corresponding to the target development framework is filled to obtain the complete code of the target application under the target development framework.
该至少一个外观代码中每个外观代码包括外观代码注释,在这种情况下,可以从该外观代码注释中获取至少一个组件中的子组件的组件名以及该至少一个组件的属性名。Each appearance code in the at least one appearance code includes an appearance code comment. In this case, the component name of the subcomponent in the at least one component and the attribute name of the at least one component can be obtained from the appearance code comment.
为了便于云平台对外观代码注释进行识别,在一些实施例中,该外观代码注释的格式为目标格式。在这种情况下,云平台中事先存储有目标格式,云平台能够根据该目标格式,按照相关算法,从该外观代码注释中确定至少一个组件中的子组件的组件名以及该至少一个组件的属性名。In order to facilitate the cloud platform to identify the appearance code annotation, in some embodiments, the format of the appearance code annotation is a target format. In this case, the cloud platform stores the target format in advance, and the cloud platform can determine the component name of the subcomponent in the at least one component and the attribute name of the at least one component from the appearance code annotation according to the target format and the relevant algorithm.
在一些实施例中,该目标格式为jsdoc格式。当然,该逻辑代码注释的格式还可以是其他类型的格式,本申请实施例对此不做限定。In some embodiments, the target format is jsdoc format. Of course, the format of the logic code annotation can also be other types of formats, which are not limited in the embodiments of the present application.
示例地,在目标格式为jsdoc格式的情况下,至少一个外观代码中每个外观代码都分别对应一个外观代码注释。云平台能够按照相关算法,从每个外观代码对应的外观代码注释中至少一个组件中的子组件的组件名以及该至少一个组件的属性名。For example, when the target format is jsdoc format, each appearance code in at least one appearance code corresponds to an appearance code comment. The cloud platform can obtain the component name of the subcomponent in at least one component and the attribute name of the at least one component from the appearance code comment corresponding to each appearance code according to a relevant algorithm.
作为一种示例,该外观代码注释如下文所示。As an example, the appearance code annotation is shown below.
/**/**
*@property{array}tags-至少一个组件的属性名包括tags,该tags属性的数据类型为array(数组)。*@property{array}tags-at least one component's property name includes tags, and the data type of the tags property is array.
*@property{string}newTag-至少一个组件的属性名包括newTag,该tags属性的数据类型为string*@property{string}newTag-at least one component's property name includes newTag, and the data type of the tags property is string
*@module TodoTag-每个组件包含的子组件的组件名包括TodoTag*@module TodoTag - Each component contains subcomponents whose component names include TodoTag
*/*/
在上述外观代码注释中,云平台可以确定至少一个组件的属性名包括tags和newTag,至少一个组件中的子组件的组件名包括TodoTag。In the above appearance code annotation, the cloud platform may determine that the attribute name of at least one component includes tags and newTag, and the component name of the subcomponent in at least one component includes TodoTag.
在一些实施例中,目标开发框架对应的代码适配模板包括第二待填充区域,该第二待填充区域包括无渲染代码路径子区域、组件属性子区域和子组件子区域。在这种情况下,基于至少一个组件的属性名、至少一个组件中包含的子组件的组件名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充的实现过程包括:将无渲染代码的存储路径写入无渲染代码路径子区域,将至少一个组件的属性名写入组件属性子区域,基于至少一个组件中包含的子组件的组件名,对子组件子区进行填充。In some embodiments, the code adaptation template corresponding to the target development framework includes a second area to be filled, and the second area to be filled includes a non-rendering code path sub-area, a component attribute sub-area, and a sub-component sub-area. In this case, based on the attribute name of at least one component, the component name of the sub-component contained in at least one component, and the storage path of the non-rendering code, the implementation process of filling the code adaptation template corresponding to the target development framework includes: writing the storage path of the non-rendering code into the non-rendering code path sub-area, writing the attribute name of at least one component into the component attribute sub-area, and filling the sub-component sub-area based on the component name of the sub-component contained in at least one component.
在一些实施例中,云平台中存储有子组件填充代码模板,该子组件填充代码模板包括名称区域和路径区域。在这种情况下,基于至少一个组件中包含的子组件的组件名,对子组件子区进行填充的实现过程包括:对于至少一个组件中包含的任意一个子组件来说,将该子组件的组件名写入子组件填充代码模板的名称区域,将该子组件完整代码的存储路径写入子组件填充代码模板的路径区域,以得到该子组件对应的填充代码。对至少一个组件中包含的每个子组件都按照相同的方式,能够得到每个子组件对应的填充代码,将该每个子组件对应的填充代码写入子组件子区域,以实现对子组件子区域的填充。In some embodiments, a subcomponent filling code template is stored in the cloud platform, and the subcomponent filling code template includes a name area and a path area. In this case, based on the component name of the subcomponent contained in at least one component, the implementation process of filling the subcomponent subarea includes: for any subcomponent contained in at least one component, the component name of the subcomponent is written into the name area of the subcomponent filling code template, and the storage path of the complete code of the subcomponent is written into the path area of the subcomponent filling code template to obtain the filling code corresponding to the subcomponent. For each subcomponent contained in at least one component, the filling code corresponding to each subcomponent can be obtained in the same manner, and the filling code corresponding to each subcomponent is written into the subcomponent subarea to achieve the filling of the subcomponent subarea.
作为一种示例,请参考图10,该子组件填充代码模板可以是如图10所示的模板,该模板中包括名称区域和路径区域。As an example, please refer to FIG. 10 , the subcomponent filling code template may be the template shown in FIG. 10 , which includes a name area and a path area.
为了便于技术人员提高应用的开发效率和代码质量,目标开发框架还具有相应的工具库代码。在这种情况下,目标开发框架对应的代码适配模板还包括工具库路径子区域,云平台能够将目标开发框架对应的工具库代码的存储路径写入工具库路径子区。In order to facilitate technical personnel to improve the development efficiency and code quality of applications, the target development framework also has corresponding tool library codes. In this case, the code adaptation template corresponding to the target development framework also includes a tool library path sub-area, and the cloud platform can write the storage path of the tool library code corresponding to the target development framework into the tool library path sub-area.
作为一种示例,Vue框架对应的代码适配模板如图11所示,请参考图12,若无渲染代码的存储路径为“../../renderless/Todo/vue”,因此,可以将该无渲染代码的存储路径写入无渲染代码路径子区域,若目标开发框架对应的工具库代码的存储路径为“../common”,因此,可以将该工具库代码的存储路径写入工具库路径子区。若至少一个组件的属性名为newTag和tags,因此,可以将newTag和tags写入组件属性子区域,若每个子组件对应的填充代码为“TodoTag:()=>import('../Tag')”因此,可以将该填充代码写入子组件子区域。As an example, the code adaptation template corresponding to the Vue framework is shown in Figure 11. Please refer to Figure 12. If the storage path of the non-rendering code is "../../renderless/Todo/vue", the storage path of the non-rendering code can be written into the non-rendering code path sub-area. If the storage path of the tool library code corresponding to the target development framework is "../common", the storage path of the tool library code can be written into the tool library path sub-area. If the attribute names of at least one component are newTag and tags, newTag and tags can be written into the component attribute sub-area. If the fill code corresponding to each sub-component is "TodoTag:()=>import('../Tag')", the fill code can be written into the sub-component sub-area.
第二种情况,目标开发框架为React框架,目标应用为Web应用,该目标应用包括至少一个组件,该至少一个外观代码指示该至少一个组件的至少一种外观。在这种情况下,可以基于该至少一个外观代码确定该至少一个组件的属性名,确定业务逻辑代码中的至少一个逻辑函数的函数名,基于该至少一个组件的属性名、至少一个逻辑函数的函数名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充,以得到目标应用在目标开发框架下的完整代码。In the second case, the target development framework is the React framework, the target application is a Web application, the target application includes at least one component, and the at least one appearance code indicates at least one appearance of the at least one component. In this case, the attribute name of the at least one component can be determined based on the at least one appearance code, the function name of at least one logic function in the business logic code can be determined, and the code adaptation template corresponding to the target development framework can be filled based on the attribute name of the at least one component, the function name of the at least one logic function, and the storage path of the non-rendering code, so as to obtain the complete code of the target application under the target development framework.
在一些实施例中,该至少一个外观代码中每个外观代码包括外观代码本体,或者,包括外观代码本体和外观代码注释。在外观代码包括外观代码本体的情况下,从该外观代码本体中获取至少一个组件的属性名,在外观代码包括外观代码本体和外观代码注释的情况下,从该外观代码本体或者该外观代码注释中获取至少一个组件的属性名。In some embodiments, each of the at least one appearance code includes an appearance code body, or includes an appearance code body and an appearance code comment. In the case where the appearance code includes the appearance code body, the attribute name of at least one component is obtained from the appearance code body; in the case where the appearance code includes the appearance code body and the appearance code comment, the attribute name of at least one component is obtained from the appearance code body or the appearance code comment.
云平台可以从外观代码本体中确定第二位置,该第二位置处的代码中包含该至少一个组件的属性名,从该第一位置处的代码中获取该至少一个组件的属性名。The cloud platform may determine a second position from the appearance code body, where the code at the second position includes the attribute name of the at least one component, and obtain the attribute name of the at least one component from the code at the first position.
示例地,云平台存储有第二字符串,在这种情况下,云平台可以按照相关算法,从外观代码本体中搜索第二字符串,将该第二字符串所在的位置确定为第二位置,将该第二位置处的代码中除第二字符串之外的代码作为至少一个组件的属性名。For example, the cloud platform stores a second string. In this case, the cloud platform can search for the second string from the appearance code body according to the relevant algorithm, determine the location of the second string as the second location, and use the code at the second location except the second string as the attribute name of at least one component.
例如,若该第二字符串为const{}=props,云平台将该第二字符串所在的位置确定为第二位置,若该第二位置处的代码为const{addTag,removeTag,value,keydown,input,tags,ref,$mode}=props,则该第二位置处的代码中除第二字符串之外的代码为addTag、removeTag、value、keydown、input、tags、ref和$mode,因此可以将addTag、removeTag、value、keydown、input、tags、ref和$mode作为至少一个组件的属性名。For example, if the second string is const{}=props, the cloud platform determines the location of the second string as the second position. If the code at the second position is const{addTag,removeTag,value,keydown,input,tags,ref,$mode}=props, then the code at the second position except the second string is addTag, removeTag, value, keydown, input, tags, ref and $mode. Therefore, addTag, removeTag, value, keydown, input, tags, ref and $mode can be used as the attribute name of at least one component.
需要说明的是,上述第二字符串事先存储在云平台中仅仅是一种示例,在实际应用中,该第二字符串还可以通过其他方式确定,本申请实施例对此不做限定。例如,技术人员也可以在云平台中输入第二字符串,以使云平台获取到该第二字符串。在技术人员输入第二字符串的情况下,云平台能够显示第二字符串输入界面,响应于第二字符串输入完成操作,获取技术人员输入的第二字符串。比如,云平台能够显示第二字符串指定界面,技术人员能够在该第二字符串指定界面输入第二字符串,在输入完成之后,技术人员能够触发第二字符串输入完成操作。云平台响应于技术人员触发的第二字符串输入完成操作,获取技术人员输入的第二字符串。It should be noted that the above-mentioned second string is stored in the cloud platform in advance is only an example. In actual applications, the second string can also be determined by other means, and the embodiments of the present application do not limit this. For example, the technician can also enter the second string in the cloud platform so that the cloud platform can obtain the second string. In the case where the technician enters the second string, the cloud platform can display the second string input interface, and in response to the second string input completion operation, obtain the second string entered by the technician. For example, the cloud platform can display the second string designation interface, and the technician can enter the second string in the second string designation interface. After the input is completed, the technician can trigger the second string input completion operation. The cloud platform responds to the second string input completion operation triggered by the technician and obtains the second string entered by the technician.
基于上文描述,该至少一个组件的属性名可以是云平台自行从外观代码本体中确定的。在实际应用中,该至少一个组件的属性名也可以通过其他方式确定。例如,技术人员可以直接在云平台中输入该至少一个组件的属性名,以使云平台能够获取该至少一个组件的属性名,本申请实施例对此不做限定。技术人员在云平台中输入至少一个组件的属性名的实现过程与上述技术人员在云平台中输入第一字符串的实现过程类似,详细实现过程请参考上文中的相关内容,此处不再赘述。Based on the above description, the attribute name of the at least one component can be determined by the cloud platform from the appearance code body. In practical applications, the attribute name of the at least one component can also be determined by other means. For example, a technician can directly enter the attribute name of the at least one component in the cloud platform so that the cloud platform can obtain the attribute name of the at least one component. This embodiment of the present application is not limited to this. The implementation process of the technician entering the attribute name of at least one component in the cloud platform is similar to the implementation process of the above-mentioned technician entering the first string in the cloud platform. For the detailed implementation process, please refer to the relevant content above, which will not be repeated here.
从外观代码中确定获取至少一个组件的属性名的实现方式与上述第一种实现方式中从外观代码注释中确定至少一个组件的属性名的实现方式类似,详细实现过程请参考上文中的相关内容,此处不再赘述。The implementation method of determining the attribute name of at least one component from the appearance code is similar to the implementation method of determining the attribute name of at least one component from the appearance code comment in the first implementation method mentioned above. Please refer to the relevant content above for the detailed implementation process, which will not be repeated here.
在一些实施例中,React开发框架对应的代码适配模板包括第三待填充区域,该第三待填充区域包括无渲染代码路径子区域、组件属性子区域和逻辑函数子区域。在这种情况下,基于该至少一个组件的属性名、至少一个逻辑函数的函数名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充的实现过程包括:将无渲染代码的存储路径写入无渲染代码路径子区域,将至少一个组件的属性名写入组件属性子区域,将至少一个逻辑函数的函数名写入逻辑函数子区域。In some embodiments, the code adaptation template corresponding to the React development framework includes a third area to be filled, and the third area to be filled includes a non-rendering code path sub-area, a component attribute sub-area, and a logic function sub-area. In this case, based on the attribute name of the at least one component, the function name of the at least one logic function, and the storage path of the non-rendering code, the implementation process of filling the code adaptation template corresponding to the target development framework includes: writing the storage path of the non-rendering code into the non-rendering code path sub-area, writing the attribute name of at least one component into the component attribute sub-area, and writing the function name of at least one logic function into the logic function sub-area.
为了便于技术人员提高应用的开发效率和代码质量,目标开发框架还具有相应的工具库代码。在这种情况下,目标开发框架对应的代码适配模板还包括工具库路径子区域,云平台能够将目标开发框架对应的工具库代码的存储路径写入工具库路径子区。In order to facilitate technical personnel to improve the development efficiency and code quality of applications, the target development framework also has corresponding tool library codes. In this case, the code adaptation template corresponding to the target development framework also includes a tool library path sub-area, and the cloud platform can write the storage path of the tool library code corresponding to the target development framework into the tool library path sub-area.
作为一种示例,React框架对应的代码适配模板如图13所示,请参考图14,若无渲染代码的存储路径为“../../renderless/Todo/react”,可以将该无渲染代码的存储路径写入无渲染代码路径子区域。若目标开发框架对应的工具库代码的存储路径为“../common/index”,可以将该工具库代码的存储路径写入工具库路径子区。若至少一个组件的属性名为addTag、removeTag、value、keydown、input、tags、ref和$mode,可以将newTag和tags写入组件属性子区域。若至少一个逻辑函数的函数名为addTag,removeTag,inputEvents和text,可以将该至少一个逻辑函数的函数名写入逻辑函数子区域。As an example, the code adaptation template corresponding to the React framework is shown in Figure 13. Please refer to Figure 14. If the storage path of the non-rendering code is "../../renderless/Todo/react", the storage path of the non-rendering code can be written into the non-rendering code path sub-area. If the storage path of the tool library code corresponding to the target development framework is "../common/index", the storage path of the tool library code can be written into the tool library path sub-area. If the attribute name of at least one component is addTag, removeTag, value, keydown, input, tags, ref and $mode, newTag and tags can be written into the component attribute sub-area. If the function name of at least one logic function is addTag, removeTag, inputEvents and text, the function name of the at least one logic function can be written into the logic function sub-area.
本申请实施例通过获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,从而基于该业务逻辑代码和该至少一个外观代码,确定目标应用在目标开发框架下的完整代码。由于该至少一个外观代码指示目标应用的至少一种外观,并且该至少一种外观与至少一种终端类型对应,因此,该完整代码能够在保证目标应用与目标开发框架相适应的同时,还能够保证目标应用的外观能够适应不同的终端设备。换句话说,本申请实施例提供的一种代码生成方法能够自动生成目标应用在目标框架下的完整代码,无需技术人员重复编写针对不同终端和不同开发框架的目标应用的代码,从而大大提升代码编写的效率,有效节约人力成本和时间成本。The embodiment of the present application obtains the business logic code of the target application and at least one appearance code of the target application under the target development framework, thereby determining the complete code of the target application under the target development framework based on the business logic code and the at least one appearance code. Since the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one terminal type, the complete code can ensure that the target application is compatible with the target development framework while also ensuring that the appearance of the target application can adapt to different terminal devices. In other words, a code generation method provided in the embodiment of the present application can automatically generate the complete code of the target application under the target framework, without the need for technical personnel to repeatedly write the code for the target application for different terminals and different development frameworks, thereby greatly improving the efficiency of code writing and effectively saving manpower and time costs.
本申请实施例还提供一种计算设备100。如图15所示,计算设备100包括:总线102、处理器104、存储器106和通信接口108。处理器104、存储器106和通信接口108之间通过总线102通信。计算设备100可以是服务器或终端设备。应理解,本申请不限定计算设备100中的处理器、存储器的个数。The embodiment of the present application also provides a computing device 100. As shown in FIG. 15 , the computing device 100 includes: a bus 102, a processor 104, a memory 106, and a communication interface 108. The processor 104, the memory 106, and the communication interface 108 communicate with each other through the bus 102. The computing device 100 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 100.
总线102可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图15中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。总线102可包括在计算设备100各个部件(例如,存储器106、处理器104、通信接口108)之间传送信息的通路。The bus 102 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, FIG. 15 is represented by only one line, but does not mean that there is only one bus or one type of bus. The bus 102 may include a path for transmitting information between various components of the computing device 100 (e.g., the memory 106, the processor 104, and the communication interface 108).
处理器104可以包括中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、微处理器(micro processor,MP)、数字信号处理器(digital signal processor,DSP)、集成电路等处理器中的任意一种或多种。集成电路如ASIC、PLD或其组合。可选地,上述PLD为CPLD、FPGA、GAL或其任意组合。The processor 104 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), a digital signal processor (DSP), an integrated circuit, etc. The integrated circuit may be an ASIC, a PLD, or a combination thereof. Optionally, the PLD may be a CPLD, an FPGA, a GAL, or any combination thereof.
存储器106可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。存储器106还可以包括非易失性存储器(non-volatilememory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard diskdrive,HDD)或固态硬盘(solid state drive,SSD),或者是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其它介质,但不限于此。存储器106独立存在,并通过总线102与处理器104相连接,或者,存储器106与处理器104集成在一起。The memory 106 may include a volatile memory, such as a random access memory (RAM). The memory 106 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid state drive (SSD), or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 106 exists independently and is connected to the processor 104 through the bus 102, or the memory 106 is integrated with the processor 104.
存储器106中存储有可执行的程序代码,处理器104执行该可执行的程序代码以实现前述代码生成方法。也即,存储器106上存有用于执行代码生成方法的指令。The memory 106 stores executable program codes, and the processor 104 executes the executable program codes to implement the aforementioned code generation method. That is, the memory 106 stores instructions for executing the code generation method.
例如,存储器106中存储有可执行的代码,处理器104执行该可执行的代码以实现如下文图18所示获取模块、确定模块和组织模块的功能。也即,存储器106上存有用于执行本申请实施例提供的代码生成方法的指令。For example, the memory 106 stores executable code, and the processor 104 executes the executable code to implement the functions of the acquisition module, the determination module, and the organization module as shown in Figure 18 below. That is, the memory 106 stores instructions for executing the code generation method provided in the embodiment of the present application.
通信接口108使用例如但不限于网络接口卡、收发器一类的收发模块,来实现计算设备100与其他设备或通信网络之间的通信。网络接口包括有线通信接口,或者还包括无线通信接口。其中,有线通信接口例如以太网接口等。以太网接口为光接口、电接口或其组合。无线通信接口为无线局域网(wireless local area networks,WLAN)接口、蜂窝网络通信接口或其组合等。The communication interface 108 uses a transceiver module such as, but not limited to, a network interface card and a transceiver to implement communication between the computing device 100 and other devices or communication networks. The network interface includes a wired communication interface, or also includes a wireless communication interface. Among them, the wired communication interface is, for example, an Ethernet interface. The Ethernet interface is an optical interface, an electrical interface, or a combination thereof. The wireless communication interface is a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof.
本申请实施例还提供了一种计算设备集群。该计算设备集群包括多个计算设备。计算设备可以是服务器,例如是中心服务器、边缘服务器,或者是本地数据中心中的本地服务器。在一些实施例中,计算设备也可以是台式机、笔记本电脑或者智能手机等终端设备。The embodiment of the present application also provides a computing device cluster. The computing device cluster includes multiple computing devices. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
如图16所示,该计算设备集群包括多个计算设备100。计算设备集群中的多个计算设备100中的存储器106中可以存有相同的用于执行上述代码生成方法的指令。As shown in Fig. 16, the computing device cluster includes multiple computing devices 100. The same instructions for executing the above code generation method may be stored in the memory 106 of the multiple computing devices 100 in the computing device cluster.
在一些可能的实现方式中,该计算设备集群中的多个计算设备100的存储器106中也可以分别存有用于执行上述代码生成方法的部分指令。换言之,该多个计算设备100的组合可以共同执行用于执行上述代码生成方法的全部指令。In some possible implementations, the memory 106 of the multiple computing devices 100 in the computing device cluster may also store partial instructions for executing the above code generation method. In other words, the combination of the multiple computing devices 100 can jointly execute all instructions for executing the above code generation method.
需要说明的是,计算设备集群中不同的计算设备100中的存储器106可以存储不同的指令,用于执行上述代码生成方法的部分功能。也即,不同的计算设备100中的存储器106存储的指令可以实现下文中代码生成装置所包括的部分模块或全部模块的功能。It should be noted that the memory 106 in different computing devices 100 in the computing device cluster may store different instructions for executing part of the functions of the above-mentioned code generation method. That is, the instructions stored in the memory 106 in different computing devices 100 may implement the functions of some or all modules included in the code generation apparatus described below.
在一些可能的实现方式中,计算设备集群中的一个或多个计算设备可以通过网络连接。其中,该网络可以是广域网或局域网等等。图17示出了一种可能的实现方式。如图17所示,两个计算设备100A和100B之间通过网络进行连接。具体地,通过各个计算设备中的通信接口与该网络进行连接。在这一类可能的实现方式中,计算设备100A中的存储器106中存有执行下文中代码生成装置所包括的一部分模块的功能的指令。同时,计算设备100B中的存储器106中存有执行下文中代码生成装置所包括的另一部分模块的功能的指令。In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network or a local area network, etc. FIG. 17 shows a possible implementation. As shown in FIG. 17 , two computing devices 100A and 100B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 106 in the computing device 100A stores instructions for executing the functions of a portion of the modules included in the code generation device hereinafter. At the same time, the memory 106 in the computing device 100B stores instructions for executing the functions of another portion of the modules included in the code generation device hereinafter.
例如,计算设备100A中的存储器106中存有执行下文中代码生成装置所包括的获取模块和确定模块的功能的指令。同时,计算设备100B中的存储器106中存有组织模块的功能的指令。For example, the memory 106 in the computing device 100A stores instructions for executing the functions of the acquisition module and the determination module included in the code generation apparatus described below. Meanwhile, the memory 106 in the computing device 100B stores instructions for the functions of the organization module.
应理解,图17中示出的计算设备100A的功能也可以由多个计算设备100完成。同样,计算设备100B的功能也可以由多个计算设备100完成。It should be understood that the functions of the computing device 100A shown in FIG17 may also be completed by multiple computing devices 100. Similarly, the functions of the computing device 100B may also be completed by multiple computing devices 100.
本申请实施例还提供了另一种计算设备集群。该计算设备集群中各计算设备之间的连接关系可以类似的参考图16和图17所述计算设备集群的连接方式。不同的是,该计算设备集群中的一个或多个计算设备100中的存储器106中可以存有相同的用于执行代码生成方法的指令。The embodiment of the present application also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to the connection mode of the computing device cluster described in Figures 16 and 17. The difference is that the memory 106 in one or more computing devices 100 in the computing device cluster can store the same instructions for executing the code generation method.
在一些可能的实现方式中,该计算设备集群中的一个或多个计算设备100的存储器106中也可以分别存有用于执行代码生成方法的部分指令。换言之,一个或多个计算设备100的组合可以共同执行用于执行代码生成方法的指令。In some possible implementations, the memory 106 of one or more computing devices 100 in the computing device cluster may also store partial instructions for executing the code generation method. In other words, the combination of one or more computing devices 100 may jointly execute instructions for executing the code generation method.
图18是本申请实施例提供的一种代码生成装置的结构示意图,该代码生成装置可以由软件、硬件或者两者的结合实现成为云平台的部分或者全部。参见图18,该装置包括:获取模块1801、确定模块1802和组织模块1803。FIG18 is a schematic diagram of the structure of a code generation device provided in an embodiment of the present application, and the code generation device can be implemented as part or all of the cloud platform by software, hardware or a combination of both. Referring to FIG18 , the device includes: an acquisition module 1801 , a determination module 1802 and an organization module 1803 .
获取模块1801,用于获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,该业务逻辑代码指示目标应用的功能,该至少一个外观代码指示目标应用的至少一种外观,该至少一种外观与至少一种终端类型对应。详细实现过程参考上述各个实施例中对应的内容,此处不再赘述。The acquisition module 1801 is used to acquire the business logic code of the target application and at least one appearance code of the target application under the target development framework, wherein the business logic code indicates the function of the target application, and the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one terminal type. The detailed implementation process refers to the corresponding content in the above-mentioned embodiments, which will not be repeated here.
确定模块1802,用于基于业务逻辑代码,确定目标应用在目标开发框架下的无渲染代码。详细实现过程参考上述各个实施例中对应的内容,此处不再赘述。The determination module 1802 is used to determine the non-rendering code of the target application under the target development framework based on the business logic code. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.
组织模块1803,用于对无渲染代码和至少一个外观代码进行组织,以得到目标应用在目标开发框架下的完整代码。详细实现过程参考上述各个实施例中对应的内容,此处不再赘述。The organization module 1803 is used to organize the non-rendering code and at least one appearance code to obtain the complete code of the target application under the target development framework. The detailed implementation process refers to the corresponding content in the above embodiments, which will not be repeated here.
可选地,确定模块1802具体用于:Optionally, the determination module 1802 is specifically configured to:
确定业务逻辑代码中的至少一个逻辑函数的函数名、至少一个逻辑函数分别对应的至少一个参数的参数名以及至少一个参数中每个参数的属性名;Determine a function name of at least one logic function in the business logic code, a parameter name of at least one parameter corresponding to the at least one logic function, and an attribute name of each parameter in the at least one parameter;
基于至少一个逻辑函数的函数名、至少一个参数的参数名、每个参数的属性名和业务逻辑代码的存储路径,对目标开发框架对应的无渲染模板进行填充,以得到该目标应用在目标开发框架下的无渲染代码。Based on the function name of at least one logical function, the parameter name of at least one parameter, the attribute name of each parameter and the storage path of the business logic code, the renderingless template corresponding to the target development framework is filled to obtain the renderingless code of the target application under the target development framework.
可选地,业务逻辑代码包括逻辑代码注释和逻辑代码本体;Optionally, the business logic code includes logic code comments and logic code body;
确定模块1802具体用于:The determination module 1802 is specifically used for:
从逻辑代码本体中获取至少一个逻辑函数的函数名;Obtaining a function name of at least one logic function from the logic code body;
从逻辑代码注释中获取至少一个逻辑函数分别对应的至少一个参数的参数名以及每个参数的属性名。The parameter name of at least one parameter corresponding to at least one logic function and the attribute name of each parameter are obtained from the logic code annotation.
可选地,目标应用为Web应用,目标开发框架为Vue框架,该目标应用包括至少一个组件,至少一个外观代码指示该至少一个组件的至少一种外观;Optionally, the target application is a Web application, the target development framework is a Vue framework, the target application includes at least one component, and the at least one appearance code indicates at least one appearance of the at least one component;
组织模块具体1803用于:The organization module 1803 is specifically used for:
基于至少一个外观代码,确定该至少一个组件中包含的子组件的组件名以及至少一个组件的属性名;Determine, based on at least one appearance code, a component name of a subcomponent included in the at least one component and an attribute name of at least one component;
基于至少一个组件的属性名、子组件的组件名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充,以得到该目标应用在目标开发框架下的完整代码。Based on the attribute name of at least one component, the component name of the subcomponent and the storage path of the non-rendering code, the code adaptation template corresponding to the target development framework is filled to obtain the complete code of the target application under the target development framework.
可选地,至少一个外观代码中每个外观代码包括外观代码注释;Optionally, each appearance code in the at least one appearance code includes an appearance code annotation;
组织模块1803具体用于:The organization module 1803 is specifically used for:
从外观代码注释中获取子组件的组件名以及至少一个组件的属性名。Get the component name of the child component and at least one component property name from the appearance code comment.
可选地,目标应用为Web应用,目标开发框架为React框架,该目标应用包括至少一个组件,至少一个外观代码指示该至少一个组件的至少一种外观;Optionally, the target application is a Web application, the target development framework is a React framework, the target application includes at least one component, and the at least one appearance code indicates at least one appearance of the at least one component;
组织模块1803具体用于:The organization module 1803 is specifically used for:
基于至少一个外观代码确定至少一个组件的属性名;determining a property name of at least one component based on at least one appearance code;
确定业务逻辑代码中的至少一个逻辑函数的函数名;Determine a function name of at least one logic function in the business logic code;
基于至少一个组件的属性名、至少一个逻辑函数的函数名和无渲染代码的存储路径,对目标开发框架对应的代码适配模板进行填充,以得到目标应用在目标开发框架下的完整代码。Based on the property name of at least one component, the function name of at least one logic function, and the storage path of the non-rendering code, the code adaptation template corresponding to the target development framework is filled to obtain the complete code of the target application under the target development framework.
可选地,至少一个外观代码中每个外观代码包括外观代码本体,或者,包括外观代码本体和外观代码注释;Optionally, each appearance code in the at least one appearance code includes an appearance code body, or includes an appearance code body and an appearance code annotation;
组织模块1803具体用于:The organization module 1803 is specifically used for:
在外观代码包括外观代码本体的情况下,从该外观代码本体中获取至少一个组件的属性名;In the case where the appearance code includes an appearance code body, obtaining an attribute name of at least one component from the appearance code body;
在外观代码包括外观代码本体和外观代码注释的情况下,从该外观代码本体或者外观代码注释中获取至少一个组件的属性名。In the case that the appearance code includes an appearance code body and an appearance code comment, the attribute name of at least one component is obtained from the appearance code body or the appearance code comment.
可选地,业务逻辑代码为柯里化函数形式,该业务逻辑代码和至少一个外观代码为JavaScript语言。Optionally, the business logic code is in the form of a curried function, and the business logic code and at least one appearance code are in JavaScript language.
本申请实施例通过获取目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码,从而基于该业务逻辑代码和该至少一个外观代码,确定目标应用在目标开发框架下的完整代码。由于该至少一个外观代码指示目标应用的至少一种外观,并且该至少一种外观与至少一种终端类型对应,因此,该完整代码能够在保证目标应用与目标开发框架相适应的同时,还能够保证目标应用的外观能够适应不同的终端设备。换句话说,本申请实施例提供的一种代码生成方法能够自动生成目标应用在目标框架下的完整代码,无需技术人员重复编写针对不同终端和不同开发框架的目标应用的代码,从而大大提升代码编写的效率,有效节约人力成本和时间成本。The embodiment of the present application obtains the business logic code of the target application and at least one appearance code of the target application under the target development framework, thereby determining the complete code of the target application under the target development framework based on the business logic code and the at least one appearance code. Since the at least one appearance code indicates at least one appearance of the target application, and the at least one appearance corresponds to at least one terminal type, the complete code can ensure that the target application is compatible with the target development framework while also ensuring that the appearance of the target application can adapt to different terminal devices. In other words, a code generation method provided in the embodiment of the present application can automatically generate the complete code of the target application under the target framework, without the need for technical personnel to repeatedly write the code for the target application for different terminals and different development frameworks, thereby greatly improving the efficiency of code writing and effectively saving manpower and time costs.
需要说明的是:上述实施例提供的代码生成装置在进行代码生成时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的代码生成装置与代码生成方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that: the code generation device provided in the above embodiment only uses the division of the above functional modules as an example when performing code generation. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the code generation device provided in the above embodiment and the code generation method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
图18所示的代码生成装置中的获取模块、确定模块和组织模块均可以通过软件实现,或者可以通过硬件实现,或者通过软硬结合的方式实现。接下来以代码生成装置中的获取模块为例,介绍该获取模块的实现方式。类似的,上述其他模块的实现方式可以参考获取模块的实现方式。The acquisition module, determination module and organization module in the code generation device shown in FIG18 can all be implemented by software, or can be implemented by hardware, or can be implemented by a combination of software and hardware. Next, taking the acquisition module in the code generation device as an example, the implementation method of the acquisition module is introduced. Similarly, the implementation methods of the above-mentioned other modules can refer to the implementation method of the acquisition module.
模块作为软件功能单元的一种举例,获取模块可以包括运行在计算实例上的代码。其中,计算实例可以包括物理主机、虚拟机、容器中的至少一种。进一步地,上述计算实例可以是一台或者多台。例如,获取模块可以包括运行在多个主机/虚拟机/容器上的代码。需要说明的是,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的region中,也可以分布在不同的region中。进一步地,用于运行该代码的多个主机/虚拟机/容器可以分布在相同的AZ中,也可以分布在不同的AZ中,每个AZ包括一个数据中心或多个地理位置相近的数据中心。其中,通常一个region可以包括多个AZ。As an example of a software functional unit, a module may include code running on a computing instance. The computing instance may include at least one of a physical host, a virtual machine, and a container. Furthermore, the computing instance may be one or more. For example, the acquisition module may include code running on multiple hosts/virtual machines/containers. It should be noted that the multiple hosts/virtual machines/containers used to run the code may be distributed in the same region or in different regions. Furthermore, the multiple hosts/virtual machines/containers used to run the code may be distributed in the same AZ or in different AZs, and each AZ includes a data center or multiple data centers with close geographical locations. Generally, a region may include multiple AZs.
同样,用于运行该代码的多个主机/虚拟机/容器可以分布在同一个VPC中,也可以分布在多个VPC中。其中,通常一个VPC设置在一个region内,同一region内两个VPC之间,以及不同region的VPC之间跨区通信需在每个VPC内设置通信网关,经通信网关实现VPC之间的互连。Similarly, multiple hosts/virtual machines/containers used to run the code can be distributed in the same VPC or in multiple VPCs. Usually, a VPC is set up in a region. For cross-region communication between two VPCs in the same region and between VPCs in different regions, a communication gateway needs to be set up in each VPC to achieve interconnection between VPCs through the communication gateway.
模块作为硬件功能单元的一种举例,获取模块可以包括至少一个计算设备,如服务器等。或者,获取模块也可以是利用ASIC实现、或PLD实现的设备等。其中,上述PLD可以是CPLD、FPGA、GAL或其任意组合实现。As an example of a hardware functional unit, the acquisition module may include at least one computing device, such as a server, etc. Alternatively, the acquisition module may also be a device implemented by ASIC or PLD, etc. The PLD may be implemented by CPLD, FPGA, GAL or any combination thereof.
获取模块包括的多个计算设备可以分布在相同的region中,也可以分布在不同的region中。获取模块包括的多个计算设备可以分布在相同的AZ中,也可以分布在不同的AZ中。同样,获取模块包括的多个计算设备可以分布在同一个VPC中,也可以分布在多个VPC中。其中,所述多个计算设备可以是服务器、ASIC、PLD、CPLD、FPGA和GAL等计算设备的任意组合。The multiple computing devices included in the acquisition module can be distributed in the same region or in different regions. The multiple computing devices included in the acquisition module can be distributed in the same AZ or in different AZs. Similarly, the multiple computing devices included in the acquisition module can be distributed in the same VPC or in multiple VPCs. The multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
在其他实施例中,代码生成装置中的获取模块可以用于执行上述代码生成方法中的任意步骤,代码生成装置中的接收模块可以用于执行上述代码生成方法中的任意步骤,代码生成装置中的组织模块可以用于执行上述代码生成方法中的任意步骤,代码生成装置中的获取模块、接收模块以及组织模块负责实现的步骤可根据需要指定,通过代码生成装置中的获取模块、接收模块以及组织模块分别实现上述代码生成方法中不同的步骤,从而实现代码生成装置的全部功能。In other embodiments, the acquisition module in the code generating device can be used to execute any step in the above-mentioned code generating method, the receiving module in the code generating device can be used to execute any step in the above-mentioned code generating method, and the organization module in the code generating device can be used to execute any step in the above-mentioned code generating method. The steps that the acquisition module, receiving module and organization module in the code generating device are responsible for implementing can be specified as needed. The different steps in the above-mentioned code generating method are respectively implemented by the acquisition module, receiving module and organization module in the code generating device, thereby realizing all the functions of the code generating device.
本申请实施例还提供了一种计算机可读存储介质。该计算机可读存储介质可以是计算设备能够存储的任何可用介质或者是包含一个或多个可用介质的数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘)等。该计算机可读存储介质包括指令,该指令指示计算机设备计集群中的计算设备执行本申请实施例提供的代码生成方法。The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct a computing device in a computer device cluster to execute the code generation method provided in the embodiment of the present application.
本申请实施例还提供了一种包含指令的计算机程序产品。该计算机程序产品可以是包含指令的,能够运行在计算设备上或被储存在任何可用介质中的软件或程序产品。当该计算机程序产品在计算设备集群所包括的计算设备上运行时,使得计算设备集群执行本申请实施例提供的代码生成方法。The embodiment of the present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on a computing device included in a computing device cluster, the computing device cluster executes the code generation method provided in the embodiment of the present application.
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意结合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机指令时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络或其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如:同轴电缆、光纤、数据用户线(digital subscriber line,DSL))或无线(例如:红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质,或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如:软盘、硬盘、磁带)、光介质(例如:数字通用光盘(digital versatile disc,DVD))或半导体介质(例如:固态硬盘(solid state disk,SSD))等。值得注意的是,本申请实施例提到的计算机可读存储介质可以为非易失性存储介质,换句话说,可以是非瞬时性存储介质。In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)). It is worth noting that the computer-readable storage medium mentioned in the embodiment of the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.
应当理解的是,本文提及的“多个”是指两个或两个以上。在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,为了便于清楚描述本申请实施例的技术方案,在本申请实施例中,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。It should be understood that the "multiple" mentioned herein refers to two or more. In the description of the embodiments of the present application, unless otherwise specified, "/" means or, for example, A/B can mean A or B; "and/or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of the embodiments of the present application, in the embodiments of the present application, the words "first", "second" and the like are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first", "second" and the like do not limit the quantity and execution order, and the words "first", "second" and the like do not limit them to be necessarily different.
需要说明的是,本申请实施例所涉及的信息(包括但不限于用户设备信息、用户个人信息等)、数据(包括但不限于用于分析的数据、存储的数据、展示的数据等)以及信号,均为经用户授权或者经过各方充分授权的,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。例如,本申请实施例中涉及到的目标应用的业务逻辑代码和目标应用在目标开发框架下的至少一个外观代码都是在充分授权的情况下获取的。It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of the present application are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the business logic code of the target application involved in the embodiments of the present application and at least one appearance code of the target application under the target development framework are obtained with full authorization.
以上所述为本申请提供的实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above-mentioned embodiments are provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims (19)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310481551.3A CN116679912B (en) | 2023-04-27 | 2023-04-27 | Code generation method, apparatus, device, storage medium, and computer program |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310481551.3A CN116679912B (en) | 2023-04-27 | 2023-04-27 | Code generation method, apparatus, device, storage medium, and computer program |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN116679912A true CN116679912A (en) | 2023-09-01 |
| CN116679912B CN116679912B (en) | 2025-05-09 |
Family
ID=87782637
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310481551.3A Active CN116679912B (en) | 2023-04-27 | 2023-04-27 | Code generation method, apparatus, device, storage medium, and computer program |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116679912B (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN118733007A (en) * | 2024-09-03 | 2024-10-01 | 成都精灵云科技有限公司 | Python-based code automatic generation and automatic checking method |
| US12242827B1 (en) | 2024-04-30 | 2025-03-04 | People Center, Inc. | Dynamic user interface customization for no-code application development |
Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109508191A (en) * | 2018-11-22 | 2019-03-22 | 北京腾云天下科技有限公司 | A kind of code generating method and system |
| CN113805881A (en) * | 2021-09-18 | 2021-12-17 | 上海仪电(集团)有限公司中央研究院 | Method and device for converting front end components between different frames |
| CN115951890A (en) * | 2023-03-10 | 2023-04-11 | 成都数之联科技股份有限公司 | Method, system and device for code conversion between different front-end frames |
-
2023
- 2023-04-27 CN CN202310481551.3A patent/CN116679912B/en active Active
Patent Citations (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109508191A (en) * | 2018-11-22 | 2019-03-22 | 北京腾云天下科技有限公司 | A kind of code generating method and system |
| CN113805881A (en) * | 2021-09-18 | 2021-12-17 | 上海仪电(集团)有限公司中央研究院 | Method and device for converting front end components between different frames |
| CN115951890A (en) * | 2023-03-10 | 2023-04-11 | 成都数之联科技股份有限公司 | Method, system and device for code conversion between different front-end frames |
Non-Patent Citations (2)
| Title |
|---|
| ZHUYASEN: "如何一键生成通用的web服务(gin)完整项目代码,让你的开发效率提升10倍", pages 1 - 8, Retrieved from the Internet <URL:《https://blog.csdn.net/zhuyasen/article/details/130141500》> * |
| 陈子豪: "设计图转换组件化HTML代码生成系统的研究与实现", 《中国优秀硕士学位论文全文数据库信息科技辑》, no. 06, 15 June 2021 (2021-06-15), pages 139 - 95 * |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US12242827B1 (en) | 2024-04-30 | 2025-03-04 | People Center, Inc. | Dynamic user interface customization for no-code application development |
| CN118733007A (en) * | 2024-09-03 | 2024-10-01 | 成都精灵云科技有限公司 | Python-based code automatic generation and automatic checking method |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116679912B (en) | 2025-05-09 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US20230244465A1 (en) | Systems and methods for automated retrofitting of customized code objects | |
| US10866791B2 (en) | Transforming non-Apex code to Apex code | |
| US10481884B2 (en) | Systems and methods for dynamically replacing code objects for code pushdown | |
| US20240045850A1 (en) | Systems and methods for database orientation transformation | |
| US11675575B2 (en) | Checking source code validity at time of code update | |
| US9430228B2 (en) | Verification of backward compatibility of software components | |
| US10970052B2 (en) | System and method for enhancing component based development models with auto-wiring | |
| US12159104B2 (en) | Describing changes in a workflow based on changes in structured documents containing workflow metadata | |
| CN116679912B (en) | Code generation method, apparatus, device, storage medium, and computer program | |
| CN117112060A (en) | Component library construction method, device, electronic equipment and storage medium | |
| CN112068879B (en) | Method and device for constructing client application program development framework based on configuration | |
| CN116755669A (en) | Low code development method and tool based on DSL language operation model | |
| US9116713B1 (en) | System and method for expression evaluation in a distributed networking environment | |
| CN112015497B (en) | Skin changing method and device | |
| US9361210B2 (en) | Capturing domain validations and domain element initializations | |
| US8612964B2 (en) | Migrating unified modeling language models across unified modeling language profiles | |
| CN115328458B (en) | Business application development method and device | |
| CN107506299B (en) | Code analysis method and terminal equipment | |
| CN110327626B (en) | Virtual server creation method and device | |
| CN115373656A (en) | Page generation method and device, computer readable medium and electronic equipment | |
| CN117008890B (en) | Extended application development system and method | |
| CN116881218B (en) | A meta-model and model processing method, device and computing device cluster | |
| WO2025007532A1 (en) | Method and system for initializing customizable java engineering | |
| CN120216018A (en) | Compatibility method, device, medium and equipment for multi-version database driver | |
| CN115129363A (en) | Service adaptation-oriented microservice interface metadata model construction method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |