CN115268895A - Front-end code and template generation method thereof, electronic device and storage medium - Google Patents
Front-end code and template generation method thereof, electronic device and storage medium Download PDFInfo
- Publication number
- CN115268895A CN115268895A CN202210666081.3A CN202210666081A CN115268895A CN 115268895 A CN115268895 A CN 115268895A CN 202210666081 A CN202210666081 A CN 202210666081A CN 115268895 A CN115268895 A CN 115268895A
- Authority
- CN
- China
- Prior art keywords
- business
- parameters
- page
- variables
- generation
- 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.)
- Pending
Links
Images
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/36—Software reuse
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/10—Requirements analysis; Specification techniques
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
本申请公开了一种前端代码生成方法、前端代码模板生成方法、电子设备及计算机可读存储介质。该方法包括:利用生成参数形成输入页面,生成参数包括组件参数和控制参数,控制参数包括业务控制变量,业务控制变量包括各业务功能代码的开关变量,业务功能代码的开关变量表征业务功能代码是否被需要;显示输入页面;接收用户对输入页面的操作;按照操作修改生成参数;根据开关变量确定被需要的业务功能代码;根据被需要的业务功能代码及生成参数生成业务页面的前端代码文件。通过上述方式,能够提高前端开发人员的编写效率,避免不同前端开发人员的编写习惯对前端代码文件的影响。
The present application discloses a front-end code generation method, a front-end code template generation method, an electronic device and a computer-readable storage medium. The method includes: forming an input page by using generation parameters, the generation parameters include component parameters and control parameters, the control parameters include business control variables, the business control variables include switch variables of each business function code, and the switch variables of the business function code represent whether the business function code is required; display the input page; receive the user's operation on the input page; modify the generation parameters according to the operation; determine the required business function code according to the switch variable; generate the front-end code file of the business page according to the required business function code and generation parameters. Through the above method, the writing efficiency of the front-end developers can be improved, and the influence of the writing habits of different front-end developers on the front-end code files can be avoided.
Description
技术领域technical field
本申请涉及前端开发技术领域,特别是涉及一种前端代码生成方法、前端代码模板生成方法、电子设备及计算机可读存储介质。The present application relates to the technical field of front-end development, in particular to a front-end code generation method, a front-end code template generation method, electronic equipment, and a computer-readable storage medium.
背景技术Background technique
随着互联网的迅速发展,越来越多用户喜欢使用网页浏览方式,软件系统平台越来越趋向于BS(Browser/Server,浏览器/服务器模式)化。然而前端开发中存在大量重复且规则相似的工作,影响开发人员(用户)的编写效率。并且,由于不同前端开发人员的编写习惯不同,导致最终形成的前端代码文件存在差异,导致后期维护成本高。With the rapid development of the Internet, more and more users prefer to use web browsing, and the software system platform tends to be more and more BS (Browser/Server, browser/server mode). However, there are a lot of repetitive work with similar rules in front-end development, which affects the writing efficiency of developers (users). Moreover, due to the different writing habits of different front-end developers, there are differences in the final front-end code files, resulting in high maintenance costs in the later stage.
发明内容Contents of the invention
本申请提供一种前端代码生成方法、前端代码模板生成方法、电子设备及计算机可读存储介质,能够解决前端开发人员的编写效率低、编写习惯不同而影响前端代码文件的问题。The application provides a front-end code generation method, a front-end code template generation method, an electronic device, and a computer-readable storage medium, which can solve the problems of low writing efficiency and different writing habits of front-end developers affecting front-end code files.
为解决上述技术问题,本申请采用的一个技术方案是:提供一种前端代码生成方法。该方法包括:利用生成参数形成输入页面,生成参数包括组件参数和控制参数,控制参数包括业务控制变量,业务控制变量包括各业务功能代码的开关变量,业务功能代码的开关变量表征业务功能代码是否被需要;显示输入页面;接收用户对输入页面的操作;按照操作修改生成参数;根据开关变量确定被需要的业务功能代码;根据被需要的业务功能代码及生成参数生成业务页面的前端代码文件。In order to solve the above technical problems, a technical solution adopted by this application is to provide a front-end code generation method. The method includes: forming an input page by using generation parameters, the generation parameters include component parameters and control parameters, the control parameters include service control variables, the service control variables include switch variables of each service function code, and the switch variable of the service function code represents whether the service function code is required; display the input page; receive the user's operation on the input page; modify the generation parameters according to the operation; determine the required business function code according to the switch variable; generate the front-end code file of the business page according to the required business function code and generation parameters.
为解决上述技术问题,本申请采用的一个技术方案是:提供一种前端代码模板生成方法。该方法包括:收集业务页面包括的页面元素,并对页面元素封装得到组件及组件参数;收集业务页面包括的业务功能,并为各业务功能编写标准代码,得到各业务功能代码;将组件参数和控制参数打包得到生成参数,控制参数包括业务控制变量,业务控制变量包括各业务功能代码的开关变量,业务功能代码的开关变量表征业务功能代码是否被需要。In order to solve the above technical problems, a technical solution adopted by this application is to provide a method for generating a front-end code template. The method includes: collecting page elements included in the business page, and encapsulating the page elements to obtain components and component parameters; collecting business functions included in the business page, and writing standard codes for each business function to obtain each business function code; combining the component parameters and The control parameters are packaged to obtain generation parameters. The control parameters include service control variables, and the service control variables include switch variables of each service function code. The switch variable of the service function code indicates whether the service function code is needed.
为解决上述技术问题,本申请采用的另一个技术方案是:提供一种电子设备,该电子设备包括处理器、与处理器连接的存储器,其中,存储器存储有程序指令;处理器用于执行存储器存储的程序指令以实现上述方法。In order to solve the above technical problems, another technical solution adopted by the present application is to provide an electronic device, which includes a processor and a memory connected to the processor, wherein the memory stores program instructions; the processor is used to execute the memory storage program instructions to implement the above method.
为解决上述技术问题,本申请采用的又一个技术方案是:提供一种计算机可读存储介质,存储有程序指令,该程序指令被执行时能够实现上述方法。In order to solve the above-mentioned technical problems, another technical solution adopted by the present application is to provide a computer-readable storage medium storing program instructions, which can realize the above-mentioned method when executed.
通过上述方式,一方面,本申请由于预先已经生成前端代码模板(业务功能代码以及生成参数),在有业务页面的前端代码文件的生成需求时,用户仅需通过输入页面进行操作以修改生成参数,就可以实现业务页面的前端代码文件的生成。从而,用户无需在每次有前端代码文件的生成需求的时候,重复编写前端代码,能够降低用户的工作量,提高编写效率,避免不同用户的编写习惯引起对前端代码文件的影响。另一方面,由于控制参数中包含各业务功能代码的开关变量,开关变量表征业务功能代码是否被需要,因此用户可以根据需求设置开关变量来选择需要的各功能业务代码。从而,前端代码模板能够迎合用户不同的业务功能需求,通用性高。Through the above method, on the one hand, since the application has generated the front-end code template (business function code and generation parameters) in advance, when there is a need to generate the front-end code file of the business page, the user only needs to operate through the input page to modify the generation parameters , you can realize the generation of the front-end code file of the business page. Therefore, the user does not need to repeatedly write the front-end code every time there is a demand for the generation of the front-end code file, which can reduce the user's workload, improve the writing efficiency, and avoid the influence of different users' writing habits on the front-end code file. On the other hand, since the control parameters include the switch variables of the business function codes, the switch variables indicate whether the business function codes are needed, so the user can set the switch variables according to the needs to select the required function business codes. Therefore, the front-end code template can cater to different business function requirements of users, and has high versatility.
附图说明Description of drawings
图1是本申请前端代码模板生成方法一实施例的流程示意图;Fig. 1 is a schematic flow chart of an embodiment of a method for generating a front-end code template of the present application;
图2是查询列表业务场景下的一业务页面示意图;Fig. 2 is a schematic diagram of a business page in the query list business scenario;
图3是图2对应的添加功能的业务页面的示意图;Fig. 3 is a schematic diagram of the service page corresponding to Fig. 2 for adding functions;
图4是本申请前端代码生成方法一实施例的流程示意图;Fig. 4 is a schematic flow diagram of an embodiment of the front-end code generation method of the present application;
图5是本申请前端代码生成方法另一实施例的流程示意图;Fig. 5 is a schematic flow chart of another embodiment of the front-end code generation method of the present application;
图6是图2所示业务页面对应的公共参数的输入页面A示意图;Fig. 6 is a schematic diagram of the input page A of the public parameters corresponding to the business page shown in Fig. 2;
图7是图2所示业务页面对应的生成参数的输入页面B的示意图;Fig. 7 is a schematic diagram of the input page B corresponding to the generated parameters of the business page shown in Fig. 2;
图8是图3所示业务页面对应的生成参数的输入页面C的一示意图;Fig. 8 is a schematic diagram of an input page C corresponding to the generated parameters of the business page shown in Fig. 3;
图9是图2所示业务页面的最终预览结果的示意图;Fig. 9 is a schematic diagram of the final preview result of the service page shown in Fig. 2;
图10是图3所示业务页面对应的最终的预览结果的示意图;Fig. 10 is a schematic diagram of the final preview result corresponding to the business page shown in Fig. 3;
图11是数据库中数据记录的示意图;Fig. 11 is a schematic diagram of data records in the database;
图12是前端代码文件生成装置的一示意图;Fig. 12 is a schematic diagram of a front-end code file generation device;
图13是目标产品对应的菜单以及数据记录的示意图;Fig. 13 is a schematic diagram of menus and data records corresponding to the target product;
图14是本申请电子设备一实施例的结构示意图;FIG. 14 is a schematic structural diagram of an embodiment of the electronic device of the present application;
图15是本申请计算机可读存储介质一实施例的结构示意图;Fig. 15 is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application;
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
本申请中的术语“第一”、“第二”、“第三”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”、“第三”的特征可以明示或者隐含地包括至少一个该特征。本申请的描述中,“多个”的含义是至少两个,例如两个,三个等,除非另有明确具体的限定。The terms "first", "second", and "third" in this application are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of indicated technical features. Thus, features defined as "first", "second", and "third" may explicitly or implicitly include at least one of these features. In the description of the present application, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.
在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,在不冲突的情况下,本文所描述的实施例可以与其它实施例相结合。Reference herein to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present application. The occurrences of this phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is understood explicitly and implicitly by those skilled in the art that the embodiments described herein can be combined with other embodiments in the absence of conflict.
本申请的前端代码生成方法分为两个阶段,一个是前端代码模板生成阶段,另一个是应用前端代码模板生成前端代码文件的阶段。应用阶段可以应用编写好的前端代码模板,生成前端代码文件。The front-end code generating method of the present application is divided into two stages, one is the stage of generating the front-end code template, and the other is the stage of generating the front-end code file by applying the front-end code template. In the application stage, the prepared front-end code template can be applied to generate the front-end code file.
如下先介绍前端代码模板生成阶段:The front-end code template generation phase is first introduced as follows:
图1是本申请前端代码模板生成方法一实施例的流程示意图。需注意的是,若有实质上相同的结果,本实施例并不以图1所示的流程顺序为限。如图1所示,本实施例可以包括:FIG. 1 is a schematic flowchart of an embodiment of a method for generating a front-end code template of the present application. It should be noted that this embodiment is not limited to the flow sequence shown in FIG. 1 if substantially the same result is obtained. As shown in Figure 1, this embodiment may include:
S11:收集业务页面包括的页面元素,并对页面元素封装得到组件及组件参数。S11: Collect page elements included in the business page, and encapsulate the page elements to obtain components and component parameters.
S12:收集业务页面包括的业务功能,并为各业务功能编写标准代码,得到各业务功能代码。S12: Collect the business functions included in the business page, write standard codes for each business function, and obtain the codes of each business function.
S13:将组件参数和控制参数打包得到生成参数。S13: Packing component parameters and control parameters to obtain generation parameters.
控制参数包括业务控制变量,业务控制变量包括各业务功能代码的开关变量,业务功能代码的开关变量表征业务功能代码是否被需要。The control parameters include service control variables, and the service control variables include switch variables of each service function code, and the switch variables of the service function code represent whether the service function code is needed.
上述S11~S13中,业务页面可以包括添加、删除、修改、查看、查询功能等等业务功能。一业务页面可以包括一业务场景下所有类型的业务功能,以适用于该业务场景。或者,一业务页面可以包括多个业务场景下所有类型的业务功能,以适用于多个业务场景。业务功能代码即实现业务功能逻辑所需的代码。In the above S11-S13, the business page may include business functions such as adding, deleting, modifying, viewing, and querying functions. A business page may include all types of business functions in a business scenario, so as to be applicable to the business scenario. Alternatively, a business page may include all types of business functions in multiple business scenarios, so as to be applicable to multiple business scenarios. The business function code is the code required to realize the business function logic.
生成参数可以包括组件参数和控制参数。组件参数是业务页面包括的组件的参数。业务页面包括的组件可以是列表、表单、文本、图片、音频、视频等等,不同组件中相同属性的参数的名称相同,不同组件的参数和个数可以不同。结合参阅图2和图3对列表组件参数和表单组件参数进行举例说明:Generation parameters may include component parameters and control parameters. Component parameters are parameters of components included in the business page. The components included in the business page can be list, form, text, picture, audio, video, etc. The parameters of the same attribute in different components have the same name, and the parameters and numbers of different components can be different. Refer to Figure 2 and Figure 3 together to illustrate the list component parameters and form component parameters:
图2是查询列表业务场景下的一业务页面示意图,如图2所示,查询列表业务场景下,业务页面包括添加、查看、查询功能。图3是图2对应的添加功能的业务页面的示意图。FIG. 2 is a schematic diagram of a service page in the query list business scenario. As shown in FIG. 2 , in the query list business scenario, the business page includes adding, viewing, and query functions. FIG. 3 is a schematic diagram of a service page for adding functions corresponding to FIG. 2 .
图2中的业务页面分为查询区域和列表区域,图3中的业务页面主要有添加功能输入区。业务页面可以包括列表组件和表单组件。The business page in Figure 2 is divided into a query area and a list area, and the business page in Figure 3 mainly has an input area for adding functions. Business pages can include list components and form components.
列表组件参数:查询功能的后台接口url,列数据参数(Columns)和查询条件参数(formList),列数据参数包括标题、后台返回的数据字段名、列表显示的宽度,查询条件参数包括类型、显示在查询条件输入区左侧的标题、后台接口入参的字段名。具体可以如下表1:List component parameters: background interface url of the query function, column data parameters (Columns) and query condition parameters (formList), column data parameters include title, data field name returned by the background, list display width, query condition parameters include type, display The title on the left side of the query condition input area, and the field name of the background interface entry parameter. The details can be seen in Table 1 as follows:
表1Table 1
图2的查询条件输入区和图3的添加功能输入区都使用了表单组件。基于此,表单组件参数具体可以如下表2:Both the query condition input area in Figure 2 and the added function input area in Figure 3 use form components. Based on this, the form component parameters can be specified in Table 2 as follows:
表2Table 2
控制参数可以包括业务控制变量和页面控制变量。Control parameters may include service control variables and page control variables.
业务控制变量可以包括各业务功能代码的开关变量,业务功能代码的开关变量表征业务功能代码是否被需要。业务功能代码的开关变量为是,意味着该业务功能代码被需要、业务页面包括该业务功能;业务功能代码的开关变量为否,意味着该业务功能代码不被需要、业务页面包括该业务功能。The service control variable may include a switch variable of each service function code, and the switch variable of the service function code represents whether the service function code is needed. If the switch variable of the business function code is Yes, it means that the business function code is required, and the business page includes the business function; if the switch variable of the business function code is No, it means that the business function code is not needed, and the business page includes the business function .
可以理解的是,由于业务页面可以包括适用的业务场景下的所有业务功能,但是并不是该业务场景下的所有业务页面都需要包括所有的业务功能。为各业务功能代码设置开关变量,可以在应用阶段,供用户根据需求选择需要的业务功能代码。例如,日志页面包括查看功能,不包括添加、编辑、删除和查询功能,在应用阶段,用户可以将查看功能的开关变量设置为是,将添加、编辑、删除和查询功能设置为否。从而,提高用户的编写效率。It can be understood that, since a business page may include all business functions in an applicable business scenario, not all business pages in the business scenario need to include all business functions. Set switch variables for each business function code, which can be used in the application stage for users to select the required business function code according to their needs. For example, the log page includes the view function, but does not include the add, edit, delete and query functions. In the application stage, the user can set the switch variable of the view function to Yes, and set the add, edit, delete and query functions to No. Thus, the writing efficiency of the user is improved.
业务控制变量除了可以包括各业务功能代码的开关变量之外,还可以包括实现业务功能逻辑需要用到的变量,即实现业务功能逻辑的业务功能代码运行需要用到的变量。In addition to the switch variables of the business function codes, the business control variables may also include the variables needed to realize the business function logic, that is, the variables needed to realize the operation of the business function codes of the business function logic.
如下对实现业务功能逻辑需要用到的控制变量以及业务功能代码进行举例说明:The control variables and business function codes needed to realize the business function logic are illustrated as follows:
查询功能:交互过程是在查询条件输入区输入查询条件之后,自动请求后台接口,将后台返回的数据填充到业务页面中。因此,实现查询功能需要一个字符变量来存储后台接口的地址,需要两个数组变量分别用来存储列表组件的列数据参数Columns和查询条件参数formList。即,查询功能控制变量包括一个字符变量和两个数组变量。查询功能代码即实现该交互过程逻辑的代码。Query function: The interactive process is to automatically request the background interface after entering the query condition in the query condition input area, and fill the data returned by the background into the business page. Therefore, to implement the query function, a character variable is required to store the address of the background interface, and two array variables are required to store the column data parameter Columns of the list component and the query condition parameter formList respectively. That is, the query function control variables include a character variable and two array variables. The query function code is the code that realizes the logic of the interaction process.
添加功能:交互过程是点击添加按钮,弹出新的窗口展示表单组件的交互,点击确认后检查页面数据字段填写规范,检查不通过则显示出错提示,检查通过后调用添加功能的后台接口进行入库操作。添加功能代码为实现该交互过程的逻辑的代码。Add function: The interaction process is to click the Add button, and a new window will pop up to display the interaction of the form components. After clicking Confirm, check the filling specifications of the page data fields. If the check fails, an error message will be displayed. operate. The added function code is the code for realizing the logic of the interaction process.
编辑功能:交互过程是点击列表操作栏的编辑图标,调用与添加功能相同的窗口,调用查看功能的后台接口后进行数据填充后边界的功能。编辑功能代码为实现该交互过程的逻辑的代码。Edit function: The interactive process is to click the edit icon in the list operation bar, call the same window as the add function, call the background interface of the view function, and then fill the border with data. The editing function code is the code implementing the logic of the interaction process.
查看功能:交互过程是点击列表操作栏的查看图标,调用与添加功能相同的窗口,调用查看功能的后台接口后进行数据填充的功能。由于是查看功能,则不展示原先的表单组件,则直接展示成相应的数据查看的功能(由表单组件参数控制实现)。查看功能代码为实现该交互过程的逻辑的代码。View function: The interactive process is to click the view icon in the list operation bar, call the same window as the add function, and call the background interface of the view function to fill in the data. Since it is a viewing function, the original form component will not be displayed, and the corresponding data viewing function will be directly displayed (realized by the parameter control of the form component). View function code is the code that implements the logic of the interaction process.
删除功能:交互过程是点击列表操作栏的删除图标或者批量删除按钮后,出现二次提示确认框,用户点击确认按钮后,调用删除功能的后台接口删除成功后,关闭确认提示框,刷新页面;用户点击取消按钮后,直接关闭确认提示框。删除功能代码为实现该交互过程的逻辑的代码。Delete function: The interactive process is to click the delete icon in the list operation bar or the batch delete button, and a second prompt confirmation box will appear. After the user clicks the confirm button, the background interface that calls the delete function will be successfully deleted, close the confirmation prompt box, and refresh the page; After the user clicks the Cancel button, the confirmation prompt box is directly closed. The deletion function code is the code implementing the logic of the interaction process.
页面控制变量可以包括业务页面中不同区域的布局模式控制变量、查询模式控制变量、视图模式控制变量等等。例如,图1所示的业务页面,包括查询区域和列表区域的布局模式控制变量,控制变量用于指示查询区域和列表区域呈上下布局或者左右布局。查询模式控制变量可以用于指示查询模式是自动查询或者手动查询。视图模式控制变量用于指示视图模式是表格模式还是卡片模式。The page control variables may include layout mode control variables, query mode control variables, view mode control variables, etc. of different areas in the business page. For example, the business page shown in FIG. 1 includes layout mode control variables of the query area and the list area, and the control variables are used to indicate that the query area and the list area are arranged vertically or horizontally. The query mode control variable can be used to indicate whether the query mode is an automatic query or a manual query. The view mode control variable is used to indicate whether the view mode is table mode or card mode.
在一些实施例中,控制参数还可以包括组件控制变量,组件控制变量用于控制组件的不同参数的布局模式。例如,一行两列、一行一列、字段宽度等等。In some embodiments, the control parameters may also include component control variables, which are used to control the layout mode of different parameters of the component. For example, two columns per row, one column per row, field width, and so on.
在一些实施例中,生成参数还可以包括业务页面的前端代码文件的命名信息,命名信息可以包括中文名称、英文名称。In some embodiments, the generation parameters may also include naming information of the front-end code file of the business page, and the naming information may include Chinese names and English names.
生成参数中业务页面的前端代码文件的命名信息、各业务功能的后台接口(例如新增功能的后台接口、删除功能的后台接口、查看功能的后台接口、编辑功能的后台接口、删除功能的后台接口等等)、开关变量可以统称为业务页面的公共参数。公共参数的格式具体可以如下表3:The naming information of the front-end code file of the business page in the generation parameters, the background interface of each business function (such as the background interface of the new function, the background interface of the deletion function, the background interface of the viewing function, the background interface of the editing function, and the background interface of the deletion function interface, etc.), switch variables can be collectively referred to as the public parameters of the business page. The format of the public parameters can be specified in Table 3 as follows:
表3table 3
通过本实施例的实施,可以生成前端代码模板(业务功能代码和生成参数),以供后续用户有生成前端代码文件的需求时应用。其中,由于生成参数中包括各业务功能代码的开关变量,该开关变量表征业务功能代码是否被需要。因此,在前端代码模板的应用阶段,可以通过需求为各业务功能代码设置开关变量,从而选择需要的业务功能代码。Through the implementation of this embodiment, a front-end code template (service function code and generation parameters) can be generated for subsequent users to apply when they need to generate a front-end code file. Wherein, since the generation parameter includes switch variables of each service function code, the switch variable represents whether the service function code is needed. Therefore, in the application stage of the front-end code template, you can set switch variables for each business function code according to requirements, so as to select the required business function code.
如下介绍前端代码模板的应用阶段:The application phase of the front-end code template is introduced as follows:
图4是本申请前端代码生成方法一实施例的流程示意图。需注意的是,若有实质上相同的结果,本实施例并不以图4所示的流程顺序为限。Fig. 4 is a schematic flowchart of an embodiment of a front-end code generation method of the present application. It should be noted that this embodiment is not limited to the flow sequence shown in FIG. 4 if substantially the same result is obtained.
如图4所示,本实施例可以包括:As shown in Figure 4, this embodiment may include:
S21:利用生成参数形成输入页面。S21: Form an input page by using generation parameters.
生成参数包括组件参数和控制参数,控制参数包括业务控制变量,业务控制变量包括各业务功能代码的开关变量,业务功能代码的开关变量表征业务功能代码是否被需要。The generation parameters include component parameters and control parameters. The control parameters include service control variables. The service control variables include switch variables of each service function code. The switch variable of the service function code indicates whether the service function code is needed.
初始的生成参数可以是收集业务页面包括的页面元素,并对页面元素封装得到组件及组件参数,并将组件参数和控制参数打包得到的。The initial generation parameters may be obtained by collecting page elements included in the business page, encapsulating the page elements to obtain components and component parameters, and packaging component parameters and control parameters.
业务功能代码可以是收集业务页面包括的业务功能,并为业务功能编写标准代码得到的。The business function code can be obtained by collecting the business functions included in the business page and writing standard codes for the business functions.
S22:显示输入页面。S22: Display an input page.
S23:接收用户对输入页面的操作。S23: Receive the user's operation on the input page.
S24:按照操作修改生成参数。S24: Modify the generation parameters according to the operation.
S25:根据开关变量确定被需要的业务功能代码。S25: Determine the required service function code according to the switch variable.
S26:根据被需要的业务功能代码及生成参数生成业务页面的前端代码文件。S26: Generate a front-end code file of the business page according to the required business function code and generation parameters.
在一些实施例中,所有生成参数显示在生成参数的菜单栏,用户可以通过点击、拖动等方式选择某部分的生成参数,接收到用户对该部分的选择指令之后,利用该部分的生成参数形成输入页面,显示输入页面,用户可以根据需求对输入页面操作;根据用户的操作修改该部分的生成参数。In some embodiments, all generation parameters are displayed in the menu bar of generation parameters, and the user can select a certain part of the generation parameters by clicking, dragging, etc. After receiving the user's selection instruction for the part, use the generation parameters of this part Form an input page, display the input page, and the user can operate the input page according to the requirement; modify the generation parameters of this part according to the user's operation.
在一些实施例中,可以以导航形式依次显示不同部分的生成参数的输入页面,接收到用户对当前输入页面的操作之后,显示下一输入页面,以此类推…,以根据用户的操作修改生成参数。In some embodiments, the input pages of different parts of the generation parameters can be displayed sequentially in the form of navigation, and after receiving the user's operation on the current input page, the next input page is displayed, and so on... to modify the generated parameters according to the user's operation parameter.
本实施例的其他详细描述,请参考前面的实施例,在此不赘述。For other detailed descriptions of this embodiment, please refer to the previous embodiments, and details are not repeated here.
通过本实施例的实施,一方面,本申请由于预先已经生成前端代码模板(业务功能代码以及生成参数),在有业务页面的前端代码文件的生成需求时,用户仅需通过输入页面进行操作以修改生成参数,就可以实现业务页面的前端代码文件的生成。从而,用户无需在每次有前端代码文件的生成需求的时候,重复编写前端代码,能够降低用户的工作量,提高编写效率,避免不同用户的编写习惯引起对前端代码文件的影响。另一方面,由于控制参数中包含各业务功能代码的开关变量,开关变量表征业务功能代码是否被需要,因此用户可以根据需求设置开关变量来选择需要的各功能业务代码。从而,前端代码模板能够迎合用户不同的业务功能需求,因此通用性高。Through the implementation of this embodiment, on the one hand, since the application has generated the front-end code template (business function code and generation parameters) in advance, when there is a need to generate the front-end code file of the business page, the user only needs to operate through the input page to By modifying the generation parameters, the generation of the front-end code file of the business page can be realized. Therefore, the user does not need to repeatedly write the front-end code every time there is a demand for the generation of the front-end code file, which can reduce the user's workload, improve the writing efficiency, and avoid the influence of different users' writing habits on the front-end code file. On the other hand, since the control parameters include the switch variables of the business function codes, the switch variables indicate whether the business function codes are needed, so the user can set the switch variables according to the needs to select the required function business codes. Therefore, the front-end code template can cater to different business function requirements of users, so it has high versatility.
图5是本申请前端代码生成方法另一实施例的流程示意图。需注意的是,若有实质上相同的结果,本实施例并不以图5所示的流程顺序为限。本实施例是在S23之后可以包括的步骤,以实现业务页面的预览。如图5所示,本实施例可以包括:Fig. 5 is a schematic flowchart of another embodiment of the front-end code generation method of the present application. It should be noted that this embodiment is not limited to the flow sequence shown in FIG. 5 if substantially the same result is obtained. This embodiment is a step that may be included after S23 to realize the preview of the service page. As shown in Figure 5, this embodiment may include:
S31:根据至少部分组件参数生成模拟数据。S31: Generate simulation data according to at least some component parameters.
S32:根据模拟数据和生成参数生成并显示业务页面的预览结果。S32: Generate and display a preview result of the business page according to the simulated data and generation parameters.
例如,可以根据列表组件参数生成列表组件中列对应的模拟数据,根据模拟数据和生成参数形成业务页面的预览结果并显示。For example, simulated data corresponding to columns in the list component can be generated according to the parameters of the list component, and a preview result of the business page can be formed and displayed according to the simulated data and generated parameters.
通过本实施例的实施,本申请可以在接收用户对输入页面的操作之后,实时显示与操作相关的业务页面的预览结果。Through the implementation of this embodiment, after receiving the user's operation on the input page, the application can display the preview result of the service page related to the operation in real time.
如下结合图6~8,以一个例子的形式对本申请的应用阶段进行说明:The application stage of this application is described in the form of an example in conjunction with Figures 6-8 as follows:
图6是图2所示业务页面对应的公共参数的输入页面A示意图。如图6所示,输入页面A包括前端代码文件的命名信息、业务功能代码的开关变量和业务功能的后台接口。命名信息包括前端代码文件的英文名称和中文名称。业务功能代码的开关变量,包括查询功能代码、添加功能代码、查看功能代码、删除功能代码、编辑功能代码的开关变量(是或否)和后台接口,业务功能的后台接口包括查询功能、添加功能、查看功能代码、删除功能、编辑功能代码的后台接口。FIG. 6 is a schematic diagram of an input page A of public parameters corresponding to the service page shown in FIG. 2 . As shown in Figure 6, the input page A includes the naming information of the front-end code file, the switch variable of the business function code and the background interface of the business function. The naming information includes the English name and Chinese name of the front-end code file. Switch variables of business function codes, including query function codes, add function codes, view function codes, delete function codes, edit function code switch variables (yes or no) and background interfaces, business function background interfaces include query functions, add functions , View the function code, delete the function code, edit the background interface of the function code.
图7是图2所示业务页面对应的生成参数的输入页面B的示意图。FIG. 7 is a schematic diagram of an input page B of generating parameters corresponding to the service page shown in FIG. 2 .
其中B1是页面控制变量的输入区,用户可以对B1操作,选择布局模式是上下布局还是左右布局,选择查询模式是自动查询还是手动查询,选择视图模式是表格模式还是卡片模式。B2是列表以及查询表单组件参数的输入区,用户可以对B2操作,输入需求的列表组件参数以表单组件参数;B3是业务页面的预览结果显示区。Among them, B1 is the input area for page control variables. Users can operate B1, select the layout mode whether it is a top-down layout or left-right layout, select the query mode whether it is automatic query or manual query, and select the view mode whether it is a table mode or a card mode. B2 is the input area for list and query form component parameters. Users can operate B2 and input required list component parameters and form component parameters; B3 is the preview result display area of the business page.
图8是图3所示业务页面对应的生成参数的输入页面C的一示意图。FIG. 8 is a schematic diagram of an input page C of generating parameters corresponding to the service page shown in FIG. 3 .
其中C1是菜单栏,用户可以对C1操作,输入需求的组件控制变量,以及选择待设置的表单组件参数,选择之后显示在C3,C3是表单组件参数的输入区,用户可以对C3操作,输入需求的表单组件参数。C2是业务页面的预览结果显示区。Among them, C1 is the menu bar. Users can operate C1, input required component control variables, and select form component parameters to be set. After selection, they will be displayed on C3. C3 is the input area for form component parameters. Users can operate C3 and input Required form component parameters. C2 is the preview result display area of the business page.
完成对用户需求的生成参数的修改之后,可以生成模拟数据,根据模拟数据和生成参数,生成业务页面最终的预览结果。图9是图2所示业务页面的最终预览结果的示意图。图10是图3所示业务页面对应的最终的预览结果的示意图。After the modification of the generation parameters of the user requirements is completed, the simulation data can be generated, and the final preview result of the business page can be generated according to the simulation data and the generation parameters. FIG. 9 is a schematic diagram of the final preview result of the service page shown in FIG. 2 . FIG. 10 is a schematic diagram of the final preview result corresponding to the business page shown in FIG. 3 .
进一步地,业务页面的前端代码文件的框架可以是Vue、react、angular、ejs,还可以是Jade、Jst等等。在Vue的框架下,前端代码文件可以分为视图层(template)、数据层(data)、逻辑交互层(method)和接口处理层。视图层可以包括页面控制变量和组件控制变量,数据层可以包括组件参数和业务控制变量,逻辑交互层可以包括业务功能代码;接口处理层包括业务功能的接口参数,包括接口类型,接口地址等等。Further, the framework of the front-end code file of the business page can be Vue, react, angular, ejs, Jade, Jst, etc. Under the framework of Vue, the front-end code files can be divided into view layer (template), data layer (data), logic interaction layer (method) and interface processing layer. The view layer can include page control variables and component control variables, the data layer can include component parameters and business control variables, the logic interaction layer can include business function codes; the interface processing layer includes interface parameters of business functions, including interface type, interface address, etc. .
进一步地,在一些实施例中,可以将一业务页面对应的生成参数和模拟数据作为一数据记录存入数据库,方便后续再次使用。后续使用过程中,数据库支持数据记录的编辑、复制、下载、删除、在线预览等功能。图11是数据库中数据记录的示意图,图11中数据记录的名称为所属前端代码文件的中文名称和英文名称。Further, in some embodiments, the generation parameters and simulation data corresponding to a business page can be stored as a data record in the database for subsequent reuse. During subsequent use, the database supports functions such as editing, copying, downloading, deleting, and online preview of data records. Fig. 11 is a schematic diagram of data records in the database. The names of the data records in Fig. 11 are the Chinese and English names of the front-end code files to which they belong.
进一步地,图12是前端代码文件生成装置的一示意图。如图12所示,该装置可以包括应用层和服务层,应用层显示输入页面,并接收用户的操作;服务层用于显示生成参数的输入页面,接收用户对输入页面的操作之后,修改生成参数,服务层随机生成模拟数据并发送至应用层;应用层显示业务页面的预览结果,接收用户对预览结果的操作,将业务页面的生成参数和模拟数据作为一数据记录存入数据库。数据库可以供数据的保存和读取,方便后续业务页面对应的生成参数和模拟数据的再次使用。Further, FIG. 12 is a schematic diagram of a device for generating a front-end code file. As shown in Figure 12, the device may include an application layer and a service layer. The application layer displays the input page and receives user operations; the service layer is used to display the input page for generating parameters, and after receiving the user's operation on the input page, modify the generated parameter, the service layer randomly generates simulation data and sends it to the application layer; the application layer displays the preview result of the business page, receives the user's operation on the preview result, and stores the generated parameter and simulation data of the business page as a data record in the database. The database can be used for data storage and reading, which facilitates the re-use of subsequent business page corresponding generation parameters and simulation data.
进一步地,在一些实施例中,可以将与目标产品相关的数据记录组织形成若干个级别的菜单,一数据记录对应一个级别的菜单项;基于若干个级别的菜单下的数据记录,生成目标产品的前端代码文件。图13是目标产品对应的菜单以及数据记录的示意图。图13中的区域P1中为菜单栏,区域P2中为菜单项“历史记录”下的数据记录。Further, in some embodiments, the data records related to the target product can be organized into several levels of menus, one data record corresponds to one level of menu items; based on the data records under the several levels of menus, the target product The front-end code file. Fig. 13 is a schematic diagram of menus and data records corresponding to the target product. The area P1 in FIG. 13 is the menu bar, and the area P2 is the data record under the menu item "History Record".
图14是本申请电子设备一实施例的结构示意图。如图14所示,该电子设备包括处理器21、与处理器21耦接的存储器22。FIG. 14 is a schematic structural diagram of an embodiment of an electronic device of the present application. As shown in FIG. 14 , the electronic device includes a
其中,存储器22存储有用于实现上述任一实施例的方法的程序指令;处理器21用于执行存储器22存储的程序指令以实现上述方法实施例的步骤。其中,处理器21还可以称为CPU(Central Processing Unit,中央处理单元)。处理器21可能是一种集成电路芯片,具有信号的处理能力。处理器21还可以是通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现场可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。Wherein, the
图15是本申请计算机可读存储介质一实施例的结构示意图。如图15所示,本申请实施例的计算机可读存储介质30存储有程序指令31,该程序指令31被执行时实现本申请上述实施例提供的方法。其中,该程序指令31可以形成程序文件以软件产品的形式存储在上述计算机可读存储介质30中,以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施方式方法的全部或部分步骤。而前述的计算机可读存储介质30包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质,或者是计算机、服务器、手机、平板等终端设备。FIG. 15 is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application. As shown in FIG. 15 , the computer-
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated. to another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。以上仅为本申请的实施方式,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units. The above is only the implementation mode of this application, and does not limit the scope of patents of this application. Any equivalent structure or equivalent process conversion made by using the contents of this application specification and drawings, or directly or indirectly used in other related technical fields, All are included in the scope of patent protection of the present application in the same way.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210666081.3A CN115268895A (en) | 2022-06-09 | 2022-06-09 | Front-end code and template generation method thereof, electronic device and storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202210666081.3A CN115268895A (en) | 2022-06-09 | 2022-06-09 | Front-end code and template generation method thereof, electronic device and storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN115268895A true CN115268895A (en) | 2022-11-01 |
Family
ID=83759497
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202210666081.3A Pending CN115268895A (en) | 2022-06-09 | 2022-06-09 | Front-end code and template generation method thereof, electronic device and storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN115268895A (en) |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130239027A1 (en) * | 2012-03-12 | 2013-09-12 | Apple Inc. | Apparatus and method for generating wiki previews |
| CN106648555A (en) * | 2015-10-28 | 2017-05-10 | 阿里巴巴集团控股有限公司 | Page generation method and device |
| CN110968311A (en) * | 2018-09-30 | 2020-04-07 | 北京嘀嘀无限科技发展有限公司 | Front-end page construction method, device and electronic device |
| CN111241454A (en) * | 2020-01-21 | 2020-06-05 | 优信拍(北京)信息科技有限公司 | Method, system and device for generating webpage code |
| CN112905178A (en) * | 2021-03-03 | 2021-06-04 | 京东方科技集团股份有限公司 | Method, device, equipment and medium for generating business function page |
-
2022
- 2022-06-09 CN CN202210666081.3A patent/CN115268895A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130239027A1 (en) * | 2012-03-12 | 2013-09-12 | Apple Inc. | Apparatus and method for generating wiki previews |
| CN106648555A (en) * | 2015-10-28 | 2017-05-10 | 阿里巴巴集团控股有限公司 | Page generation method and device |
| CN110968311A (en) * | 2018-09-30 | 2020-04-07 | 北京嘀嘀无限科技发展有限公司 | Front-end page construction method, device and electronic device |
| CN111241454A (en) * | 2020-01-21 | 2020-06-05 | 优信拍(北京)信息科技有限公司 | Method, system and device for generating webpage code |
| CN112905178A (en) * | 2021-03-03 | 2021-06-04 | 京东方科技集团股份有限公司 | Method, device, equipment and medium for generating business function page |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7970944B2 (en) | System and method for platform and language-independent development and delivery of page-based content | |
| US9645977B2 (en) | Systems and methods for configuring a header and layout of a mobile version of a conventional website | |
| US9519701B2 (en) | Generating information models in an in-memory database system | |
| US20150227494A1 (en) | Creating and editing dynamic graphics via a web interface | |
| CN113779469B (en) | Website page modification method and device, electronic device, and storage medium | |
| JP2013519932A (en) | Method and system for structuring information with a sharable user interface | |
| CN113900725B (en) | Interface configuration method, device, computer equipment and storage medium | |
| US20250123816A1 (en) | Application development platforms and methods, devices, and storage mediums | |
| CN110059278A (en) | Web page configuration method, server and computer readable storage medium | |
| CN115048136A (en) | Method, device, equipment and storage medium for generating report page | |
| CN111209028B (en) | Data processing method and device, electronic equipment and storage medium | |
| CN114047855B (en) | Form editing method and device and terminal equipment | |
| CN103098055B (en) | Recursive Navigation in Mobile CRM | |
| CN109522473B (en) | Method for recommending associated information, terminal and server thereof | |
| CN114118045A (en) | Report data retrieval method, device, storage medium and computer equipment | |
| CN116595284B (en) | Webpage system operation method, device, equipment, storage medium and program | |
| CN118656110A (en) | Page configuration method and device | |
| CN115268895A (en) | Front-end code and template generation method thereof, electronic device and storage medium | |
| CN115952777A (en) | Drop page design method and device, electronic equipment and storage medium | |
| KR20220001219A (en) | Digital book service method and digital book using the method | |
| CN116450962B (en) | Page display method, device, equipment and storage medium based on distributed system | |
| CN118012459B (en) | Upgrading method and device of low-code service system | |
| CN116663515B (en) | A method and device for generating a dynamic declaration form | |
| CN114721679B (en) | Application program updating method and device, electronic equipment and storage medium | |
| CN119883862A (en) | Webpage card debugging method and device, computer equipment and storage medium |
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 |