CN118519619A - Application method and device of front-end scaffold - Google Patents
Application method and device of front-end scaffold Download PDFInfo
- Publication number
- CN118519619A CN118519619A CN202410758671.8A CN202410758671A CN118519619A CN 118519619 A CN118519619 A CN 118519619A CN 202410758671 A CN202410758671 A CN 202410758671A CN 118519619 A CN118519619 A CN 118519619A
- Authority
- CN
- China
- Prior art keywords
- target
- page
- target basic
- scaffold
- project
- 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
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/20—Software design
- G06F8/24—Object-oriented
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/73—Program documentation
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Library & Information Science (AREA)
- Stored Programmes (AREA)
Abstract
本申请公开了一种前端脚手架的应用方法及装置,该方法应用于通用前端脚手架,该方法包括:当通用前端脚手架接收到创建指令时,基于通用前端脚手架提供的前端框架选项,确定出目标前端框架;基于通用前端脚手架提供的基础工程选项,确定出目标基础工程选项;基于目标前端框架和目标基础工程选项,从通用前端脚手架提供的选项映射地图中,确定出目标基础工程地址;目标基础功能地址用于指示通过目标基础工程选项实现的基础功能的代码存储地址;通过下载代码指令,从目标基础工程地址,拉取目标基础工程;基于目标基础工程,创建前端页面。该方法能够提供一种适配于多种前端框架的前端脚手架,从而提升开发效率。
The present application discloses a method and device for applying a front-end scaffold, which is applied to a general front-end scaffold, and the method includes: when the general front-end scaffold receives a creation instruction, based on the front-end framework option provided by the general front-end scaffold, a target front-end framework is determined; based on the basic engineering option provided by the general front-end scaffold, a target basic engineering option is determined; based on the target front-end framework and the target basic engineering option, a target basic engineering address is determined from an option mapping map provided by the general front-end scaffold; the target basic function address is used to indicate the code storage address of the basic function implemented by the target basic engineering option; by downloading code instructions, the target basic engineering is pulled from the target basic engineering address; based on the target basic engineering, a front-end page is created. The method can provide a front-end scaffold adapted to a variety of front-end frameworks, thereby improving development efficiency.
Description
技术领域Technical Field
本申请涉及数据开发技术领域,尤其涉及一种前端脚手架的应用方法及装置。The present application relates to the field of data development technology, and in particular to an application method and device of a front-end scaffold.
背景技术Background Art
前端脚手架是一个工具集,用于快速搭建和开发前端项目,旨在提高前端开发效率和规范化项目结构。前端脚手架通常包含项目初始化、构建、打包、部署等一系列工程化的流程和工具,帮助开发者快速搭建某种前端框架的项目的基础结构。Front-end scaffolding is a tool set for quickly building and developing front-end projects, aiming to improve front-end development efficiency and standardize project structure. Front-end scaffolding usually includes a series of engineering processes and tools such as project initialization, construction, packaging, and deployment, helping developers quickly build the infrastructure of a front-end framework project.
随着前端工程化的发展,在前端开发领域中,前端脚手架逐渐走进人们的视野中,前端脚手架可以帮助开发者快速搭建项目结构、自动化工作流程、提供配置项等,从而提高了开发效率,且保证了前端项目的规范性和一致性。With the development of front-end engineering, front-end scaffolding has gradually come into people's view in the field of front-end development. Front-end scaffolding can help developers quickly build project structure, automate workflow, provide configuration items, etc., thereby improving development efficiency and ensuring the standardization and consistency of front-end projects.
目前,脚手架工具都由前端框架开发者提供,如果在前端开发过程中,选择不同的前端开发框架进行开发时,则需要安装对应的脚手架工具,并且各个脚手架工具的使用方法均不同,缺乏一种适用于大部分前端框架的前端脚手架,导致基于不同前端框架进行开发时的开发效率差。At present, scaffolding tools are provided by front-end framework developers. If different front-end development frameworks are selected for development during the front-end development process, corresponding scaffolding tools need to be installed, and the usage methods of each scaffolding tool are different. There is a lack of a front-end scaffolding suitable for most front-end frameworks, resulting in poor development efficiency when developing based on different front-end frameworks.
发明内容Summary of the invention
有鉴于此,本申请实施例提供了一种前端脚手架的应用方法及装置,旨在提供一种适配于多种前端框架的前端脚手架,从而提升开发效率。In view of this, an embodiment of the present application provides an application method and device of a front-end scaffold, aiming to provide a front-end scaffold that is compatible with a variety of front-end frameworks, thereby improving development efficiency.
第一方面,本申请实施例提供了一种前端脚手架的应用方法,应用于通用前端脚手架,所述方法包括:In a first aspect, an embodiment of the present application provides an application method of a front-end scaffold, which is applied to a general front-end scaffold, and the method includes:
当所述通用前端脚手架接收到创建指令时,基于所述通用前端脚手架提供的前端框架选项,确定出目标前端框架;When the universal front-end scaffold receives a creation instruction, a target front-end framework is determined based on the front-end framework options provided by the universal front-end scaffold;
基于所述通用前端脚手架提供的基础工程选项,确定出目标基础工程选项;Determine target basic engineering options based on the basic engineering options provided by the general front-end scaffolding;
基于所述目标前端框架和所述目标基础工程选项,从所述通用前端脚手架提供的选项映射地图中,确定出目标基础工程地址;所述目标基础功能地址用于指示通过所述目标基础工程选项实现的基础功能的代码存储地址;所述选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系;Based on the target front-end framework and the target basic engineering options, the target basic engineering address is determined from the option mapping map provided by the general front-end scaffolding; the target basic function address is used to indicate the code storage address of the basic function implemented by the target basic engineering option; the option mapping map includes the mapping relationship between different front-end frameworks and different basic engineering options and different basic engineering addresses;
通过下载代码指令,从所述目标基础工程地址,拉取目标基础工程;Pull the target basic project from the target basic project address by downloading code instructions;
基于所述目标基础工程,创建前端页面。Create the front-end page based on the target basic project.
可选地,所述基础工程选项包括构建工具、用户界面组件库、路由封装选项、请求服务封装选项以及数据管理库封装选项。Optionally, the basic engineering options include building tools, user interface component libraries, routing encapsulation options, request service encapsulation options, and data management library encapsulation options.
可选地,所述前端页面包括快速开发页面,所述基于所述目标基础工程,创建前端页面,包括:Optionally, the front-end page includes a rapid development page, and the creating of the front-end page based on the target basic project includes:
基于所述目标基础工程,通过创建页面命令中的预设参数,创建快速开发页面,所述快速开发页面是由所述通用前端脚手架提供的页面模式。Based on the target basic project, a rapid development page is created by using preset parameters in a create page command, and the rapid development page is a page mode provided by the general front-end scaffolding.
可选地,所述创建快速开发页面包括:Optionally, the creating a quick development page includes:
基于所述目标前端框架,从所述通用前端脚手架提供的页面模板映射地图中,确定出所述快速开发页面对应的快速开发页面模板;所述页面模板映射地图中包括不同前端框架与不同页面模板之间的映射关系;所述快速开发页面模板中包括表格组件和表单组件,以及表格组件和表单组件分别对应的基础交互操作;Based on the target front-end framework, a rapid development page template corresponding to the rapid development page is determined from the page template mapping map provided by the general front-end scaffolding; the page template mapping map includes mapping relationships between different front-end frameworks and different page templates; the rapid development page template includes a table component and a form component, as well as basic interaction operations corresponding to the table component and the form component respectively;
基于所述快速开发页面模板和结构化数据配置文件,得到所述快速开发页面。The rapid development page is obtained based on the rapid development page template and the structured data configuration file.
可选地,所述创建页面命令中包括所述快速开发页面的路由地址,所述方法还包括:Optionally, the create page command includes a routing address of the rapid development page, and the method further includes:
通过基于所述快速开发页面模板和所述快速开发页面的路由地址,生成对应的代码文件,将所述代码文件存储于所述目标基础工程对应的文件夹中。A corresponding code file is generated based on the rapid development page template and the routing address of the rapid development page, and the code file is stored in a folder corresponding to the target basic project.
可选地,所述方法还包括:Optionally, the method further comprises:
通过获取命令从所述目标基础工程对应的文件夹中读取存储文件,基于所述目标基础工程为所述存储文件划分存储位置。The storage file is read from the folder corresponding to the target basic project by obtaining a command, and a storage location is divided for the storage file based on the target basic project.
可选地,所述基于所述目标基础工程,创建前端页面之前,所述方法还包括:Optionally, before creating the front-end page based on the target basic project, the method further includes:
通过命令行指令启动子进程,所述子进程用于安装所述目标基础工程的相关依赖和启动服务器。A subprocess is started through a command line instruction, and the subprocess is used to install the relevant dependencies of the target basic project and start the server.
第二方面,本申请实施例提供了一种前端脚手架的应用装置,部署于通用前端脚手架,所述装置包括:In a second aspect, an embodiment of the present application provides an application device of a front-end scaffold, which is deployed on a general front-end scaffold, and the device includes:
第一确定模块,用于当所述通用前端脚手架接收到创建指令时,基于所述通用前端脚手架提供的前端框架选项,确定出目标前端框架;A first determination module is used to determine a target front-end framework based on the front-end framework options provided by the general front-end scaffolding when the general front-end scaffolding receives a creation instruction;
第二确定模块,用于基于所述通用前端脚手架提供的基础工程选项,确定出目标基础工程选项;A second determination module is used to determine a target basic engineering option based on the basic engineering options provided by the general front-end scaffolding;
第三确定模块,用于基于所述目标前端框架和所述目标基础工程选项,从所述通用前端脚手架提供的选项映射地图中,确定出目标基础工程地址;所述目标基础功能地址用于指示通过所述目标基础工程选项实现的基础功能的代码存储地址;所述选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系;A third determination module is used to determine a target basic engineering address from an option mapping map provided by the general front-end scaffold based on the target front-end framework and the target basic engineering option; the target basic function address is used to indicate a code storage address of a basic function implemented by the target basic engineering option; the option mapping map includes a mapping relationship between different front-end frameworks and different basic engineering options and different basic engineering addresses;
拉取模块,用于通过下载代码指令,从所述目标基础工程地址,拉取目标基础工程;A pulling module, used to pull the target basic project from the target basic project address by downloading code instructions;
创建模块,用于基于所述目标基础工程,创建前端页面。A creation module is used to create a front-end page based on the target basic project.
第三方面,本申请实施例提供了一种前端脚手架的应用设备,所述设备包括:In a third aspect, an embodiment of the present application provides an application device for a front-end scaffold, the device comprising:
存储器,用于存储计算机程序;Memory for storing computer programs;
处理器,用于执行所述计算机程序,以使所述设备执行前述第一方面所述的前端脚手架的应用方法。The processor is used to execute the computer program so that the device executes the front-end scaffolding application method described in the first aspect above.
第四方面,本申请实施例提供了一种计算机存储介质,所述计算机可读存储介质上存储有计算机程序,当所述计算机程序被运行时,运行所述计算机程序的设备实现前述第一方面所述的前端脚手架的应用方法。In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which a computer program is stored. When the computer program is executed, the device executing the computer program implements the application method of the front-end scaffolding described in the first aspect.
相较于现有技术,本申请实施例具有以下有益效果:Compared with the prior art, the embodiments of the present application have the following beneficial effects:
本申请实施例提供了一种前端脚手架的应用方法及装置,该方法应用于通用前端脚手架,该方法可以包括:当通用前端脚手架接收到创建指令时,可以基于通用前端脚手架提供的前端框架选项,从中选择出目标前端框架。然后,可以基于通用前端脚手架提供的基础工程选项,从中确定出目标基础工程选项。选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系。因此,可以在确定出目标前端框架和目标基础工程选项后,可以根据目标前端框架和目标基础工程选项,从通用前端脚手架提供的选项映射地图中,确定出用于通过目标基础工程选项实现的基础工程的代码存储地址,即目标基础工程地址。之后,可以通过下载代码指令,从映射出的目标基础工程地址中,拉取到目标基础工程,从而可以基于目标基础工程,创建前端页面。由此,通过通用前端脚手架完成了项目初始化,可以基于通用前端脚手架提供的目标基础工程,继续进行前端开发。The embodiment of the present application provides an application method and device of a front-end scaffold, which is applied to a general front-end scaffold. The method may include: when the general front-end scaffold receives a creation instruction, a target front-end framework can be selected from the front-end framework options provided by the general front-end scaffold. Then, the target basic engineering options can be determined based on the basic engineering options provided by the general front-end scaffold. The option mapping map includes different front-end frameworks and different basic engineering options, and the mapping relationship between different basic engineering addresses. Therefore, after determining the target front-end framework and the target basic engineering options, the code storage address of the basic engineering implemented by the target basic engineering option, i.e., the target basic engineering address, can be determined from the option mapping map provided by the general front-end scaffold according to the target front-end framework and the target basic engineering options. Afterwards, the target basic engineering can be pulled from the mapped target basic engineering address by downloading the code instruction, so that the front-end page can be created based on the target basic engineering. Thus, the project initialization is completed through the general front-end scaffold, and the front-end development can be continued based on the target basic engineering provided by the general front-end scaffold.
可见,通用前端脚手架中提供了选项映射地图,其中包含有各个前端框架和不同基础工程选项,与目标基础工程地址的映射关系,使得通用前端脚手架提供的基础工程可以适用于多种前端框架,并且能够通过目标基础工程选项实现对应的基础工程,从而基于目标基础工程可以继续进行前端开发,无需安装多种前端框架对应的脚手架,进而提升了开发效率。It can be seen that the general front-end scaffolding provides an option mapping map, which contains various front-end frameworks and different basic project options, and the mapping relationship with the target basic project address, so that the basic project provided by the general front-end scaffolding can be applied to a variety of front-end frameworks, and the corresponding basic project can be implemented through the target basic project options, so that the front-end development can continue based on the target basic project, without installing scaffolding corresponding to a variety of front-end frameworks, thereby improving development efficiency.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为更清楚地说明本实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
图1为本申请实施例提供的一种前端脚手架的应用方法的应用场景;FIG1 is an application scenario of an application method of a front-end scaffold provided in an embodiment of the present application;
图2为本申请实施例提供的一种前端脚手架的应用方法的流程图;FIG2 is a flow chart of a method for applying a front-end scaffold provided in an embodiment of the present application;
图3为本申请实施例提供的一种前端脚手架的应用方法的示意图;FIG3 is a schematic diagram of an application method of a front-end scaffold provided in an embodiment of the present application;
图4为本申请实施例提供的一种前端脚手架的应用装置的结构示意图。FIG. 4 is a schematic structural diagram of an application device of a front-end scaffold provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the 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 the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
目前,脚手架工具可以实现项目初始化、插件管理和项目配置,项目初始化是指可以通过脚手架工具快速创建一个对应框架的项目的基础结构,包括目录结构、配置文件等。插件管理是指脚手架工具支持插件系统,开发者可以通过插件扩展项目功能,例如添加路由、状态管理等。项目配置是指允许开发者通过脚手架工具对项目进行自定义配置,包括构建工具配置、编译器Babel配置等,以满足项目的特定需求。Currently, scaffolding tools can realize project initialization, plug-in management and project configuration. Project initialization means that the infrastructure of a project corresponding to a framework can be quickly created through scaffolding tools, including directory structure, configuration files, etc. Plug-in management means that scaffolding tools support plug-in systems, and developers can use plug-ins to extend project functions, such as adding routes and state management. Project configuration means that developers are allowed to customize the project through scaffolding tools, including build tool configuration, compiler Babel configuration, etc., to meet the specific needs of the project.
目前,脚手架工具都由前端框架开发者提供,如果在前端开发过程中,选择不同的前端开发框架进行开发时,则需要安装对应的脚手架工具,并且各个脚手架工具的使用方法均不同,缺乏一种适用于大部分前端框架的前端脚手架,导致基于不同前端框架进行开发时的开发效率差。At present, scaffolding tools are provided by front-end framework developers. If different front-end development frameworks are selected for development during the front-end development process, corresponding scaffolding tools need to be installed, and the usage methods of each scaffolding tool are different. There is a lack of a front-end scaffolding suitable for most front-end frameworks, resulting in poor development efficiency when developing based on different front-end frameworks.
基于此,为了解决上述问题,在本申请实施例中,当通用前端脚手架接收到创建指令时,可以基于通用前端脚手架提供的前端框架选项,从中选择出目标前端框架。然后,可以基于通用前端脚手架提供的基础工程选项,从中确定出目标基础工程选项。选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系。因此,可以在确定出目标前端框架和目标基础工程选项后,可以根据目标前端框架和目标基础工程选项,从通用前端脚手架提供的选项映射地图中,确定出用于通过目标基础工程选项实现的基础工程的代码存储地址,即目标基础工程地址。之后,可以通过下载代码指令,从映射出的目标基础工程地址中,拉取到目标基础工程,从而可以基于目标基础工程,创建前端页面。由此,通过通用前端脚手架完成了项目初始化,可以基于通用前端脚手架提供的目标基础工程,继续进行前端开发。通用前端脚手架中提供了选项映射地图,其中包含有各个前端框架和不同基础工程选项,与目标基础工程地址的映射关系,使得通用前端脚手架提供的基础工程可以适用于多种前端框架,并且能够通过目标基础工程选项实现对应的基础工程,从而基于目标基础工程可以继续进行前端开发,无需安装多种前端框架对应的脚手架,进而提升了开发效率。Based on this, in order to solve the above problems, in an embodiment of the present application, when the universal front-end scaffold receives a creation instruction, the target front-end framework can be selected from the front-end framework options provided by the universal front-end scaffold. Then, the target basic engineering options can be determined based on the basic engineering options provided by the universal front-end scaffold. The option mapping map includes different front-end frameworks and different basic engineering options, and the mapping relationship between different basic engineering addresses. Therefore, after determining the target front-end framework and the target basic engineering options, the code storage address for the basic engineering implemented by the target basic engineering option, i.e., the target basic engineering address, can be determined from the option mapping map provided by the universal front-end scaffold according to the target front-end framework and the target basic engineering options. Afterwards, the target basic engineering can be pulled from the mapped target basic engineering address by downloading the code instruction, so that the front-end page can be created based on the target basic engineering. Thus, the project initialization is completed by the universal front-end scaffold, and the front-end development can be continued based on the target basic engineering provided by the universal front-end scaffold. The general front-end scaffolding provides an option mapping map, which contains various front-end frameworks and different basic project options, and the mapping relationship with the target basic project address, so that the basic project provided by the general front-end scaffolding can be applied to multiple front-end frameworks, and the corresponding basic project can be implemented through the target basic project options, so that the front-end development can continue based on the target basic project, without installing scaffolding corresponding to multiple front-end frameworks, thereby improving development efficiency.
举例来说,本申请实施例的场景之一,可以是应用到如图1所示的场景中。该场景包括终端101,其中,终端101中运行有通用前端脚手架,以基于通用前端脚手架提供的选项映射地图中,确定出目标基础工程地址,以拉取到目标基础工程,进而可以基于目标基础工程,创建前端页面。For example, one of the scenarios of the embodiment of the present application can be applied to the scenario shown in Figure 1. The scenario includes a terminal 101, wherein a general front-end scaffold is running in the terminal 101, so as to determine the target basic project address based on the option mapping map provided by the general front-end scaffold, so as to pull the target basic project, and then create a front-end page based on the target basic project.
首先,在上述应用场景中,虽然将本申请实施例提供的实施方式的动作描述由终端101执行;但是,本申请实施例在执行主体方面不受限制,只要执行了本申请实施例提供的实施方式所公开的动作即可。First, in the above application scenario, although the action description of the implementation method provided in the embodiment of the present application is executed by the terminal 101; however, the embodiment of the present application is not limited in terms of the execution subject, as long as the actions disclosed in the implementation method provided in the embodiment of the present application are executed.
其次,上述场景仅是本申请实施例提供的一个场景示例,本申请实施例并不限于此场景。Secondly, the above scenario is only an example scenario provided by the embodiment of the present application, and the embodiment of the present application is not limited to this scenario.
下面结合附图,通过实施例来详细说明本申请实施例中前端脚手架的应用方法及装置的具体实现方式。The following describes in detail the specific implementation of the application method and device of the front-end scaffold in the embodiment of the present application through embodiments in conjunction with the accompanying drawings.
参见图2,该图为本申请实施例提供的一种前端脚手架的应用方法的流程图,该方法应用于通用前端脚手架,结合图2所示,具体可以包括:Referring to FIG. 2 , which is a flow chart of a method for applying a front-end scaffold provided in an embodiment of the present application, the method is applied to a general front-end scaffold, and in combination with FIG. 2 , it may specifically include:
S201:当通用前端脚手架接收到创建指令时,基于通用前端脚手架提供的前端框架选项,确定出目标前端框架。S201: When the general front-end scaffold receives a creation instruction, a target front-end framework is determined based on the front-end framework options provided by the general front-end scaffold.
通用前端脚手架是本申请实施例提供的一种脚手架工具,通过该通用前端脚手架可以用于项目初始化。具体地,该通用前端脚手架中提供了构建工具、用户界面组件(UserInterface,UI)库、路由封装选项、请求服务封装选项以及数据管理库封装选项,以供用户根据通用前端脚手架提供的上述基础工程选项进行选择。其中,构建工具中包括基础构建工具,例如,打包工具webpack、模块打包器Rollup以及流程自动化工具Grunt等。UI库中包括基础组件,例如,按钮、导航栏、弹出框、标签页以及下拉菜单等基础组件。路由封装选项中包括通用前端脚手架提供的默认两级路由,并且提供路由鉴权接口,可以由开发者自定义路由鉴权方法,并且在需要三级路由的情况下,可以由开发者自行扩展。其中,路由鉴权接口是指在前端应用程序中通过特定的接口实现对路由访问权限的鉴定和控制,用于确定用户是否具有权限访问某个页面或路由。The general front-end scaffold is a scaffolding tool provided by an embodiment of the present application, and the general front-end scaffold can be used for project initialization. Specifically, the general front-end scaffold provides a construction tool, a user interface component (UserInterface, UI) library, a route encapsulation option, a request service encapsulation option, and a data management library encapsulation option for users to select according to the above-mentioned basic engineering options provided by the general front-end scaffold. Among them, the construction tool includes basic construction tools, such as packaging tools webpack, module packager Rollup, and process automation tools Grunt, etc. The UI library includes basic components, such as buttons, navigation bars, pop-up boxes, tabs, and drop-down menus. The route encapsulation option includes the default two-level routing provided by the general front-end scaffold, and provides a route authentication interface, which can be customized by the developer. The route authentication method, and in the case of requiring a three-level route, can be expanded by the developer. Among them, the route authentication interface refers to the identification and control of route access rights implemented through a specific interface in the front-end application, which is used to determine whether the user has permission to access a certain page or route.
请求服务封装选项是指通用前端脚手架提供了基于传统网络请求技术(XMLHttpRequest,XHR)和基于网路请求应用程序接口Fetch的多种请求库以供开发者进行选择。通过封装请求服务,可以隐藏底层实现细节,简化接口调用,并提供更高层次的抽象,有助于代码的可维护性和扩展性。然后,可以通用前端脚手架可以根据所选择的请求库自动生成请求服务封装代码,请求服务封装代码可以包括:基础请求封装、接口鉴权(与路由鉴权类似,鉴权方法可以由开发者自定义)、报错处理机制(封装有常见错误码的处理,可以修改该报错处理机制,还可以扩展该报错处理机制),以及文件上传或下载功能封装(可显示上传下载进度,支持大文件断点续传,即在文件传输过程中发生中断的情况下,能够记录已经传输的部分,并在连接恢复后从中断处继续传输)。The request service encapsulation option means that the general front-end scaffolding provides a variety of request libraries based on traditional network request technology (XMLHttpRequest, XHR) and network request application interface Fetch for developers to choose from. By encapsulating the request service, the underlying implementation details can be hidden, the interface call can be simplified, and a higher level of abstraction can be provided, which is conducive to the maintainability and extensibility of the code. Then, the general front-end scaffolding can automatically generate the request service encapsulation code according to the selected request library. The request service encapsulation code may include: basic request encapsulation, interface authentication (similar to routing authentication, the authentication method can be customized by the developer), error handling mechanism (encapsulation of common error code processing, the error handling mechanism can be modified, and the error handling mechanism can be extended), and file upload or download function encapsulation (can display the upload and download progress, support breakpoint continuation of large files, that is, in the event of an interruption during the file transfer process, it can record the part that has been transferred and continue the transfer from the interruption point after the connection is restored).
数据管理库封装选项是指通用前端脚手架提供的数据管理库的选项,即用于管理项目中数据的库,便于开发者通过简便的方式处理数据的获取、存储、更新和展示等操作,便于开发者更好地组织和管理项目中的数据。然后,可以通过开发者选择的数据管理库自动生成数据管理封装代码,该状态管理库提供的基础功能包括:数据存储、数据获取、数据持久化。并且,数据管理库中提供了单一的数据流向,可以按照各个页面的命名进行数据隔离,避免数据流混乱造成问题定位困难。同时,基于上述基础工程选项,保证了通用前端脚手架的完整性。The data management library encapsulation option refers to the option of the data management library provided by the general front-end scaffolding, that is, the library used to manage the data in the project, which is convenient for developers to handle data acquisition, storage, update and display in a simple way, so as to facilitate developers to better organize and manage the data in the project. Then, the data management encapsulation code can be automatically generated through the data management library selected by the developer. The basic functions provided by the state management library include: data storage, data acquisition, and data persistence. In addition, a single data flow is provided in the data management library, and data can be isolated according to the naming of each page to avoid difficulties in locating problems caused by confusion in data flow. At the same time, based on the above basic engineering options, the integrity of the general front-end scaffolding is guaranteed.
另外,通用前端脚手架还提供了快速开发页面模式,可以快速开发表格表单功能,通过一个指令即可根据用户选择的UI库,在封装有常规表格表单的搜索、分页、新增、编辑以及删除功能的快速开发页面模板中,自动生成对应的代码文件。对于具有相似功能的页面,无需重复开发,可以直接使用自动生成的代码文件,只需要根据实际业务需求,通过配置相应的结构化数据配置文件json文件即可得到功能完整的前端页面,完成了整个页面的开发。In addition, the general front-end scaffolding also provides a rapid development page mode, which can quickly develop table form functions. Through one instruction, the corresponding code files can be automatically generated in the rapid development page template that encapsulates the search, paging, adding, editing and deleting functions of the regular table form according to the UI library selected by the user. For pages with similar functions, there is no need to repeat the development. You can directly use the automatically generated code files. You only need to configure the corresponding structured data configuration file json file according to the actual business needs to get a fully functional front-end page, completing the development of the entire page.
作为一种示例,在安装通用前端脚手架之后,首先可以通过通用前端脚手架进行项目初始化,即搭建初始项目工程。其中,通用前端脚手架可以发布于软件包管理工具npm,全局安装后便可应用于前端项目中。并且,在本申请实施例提供的通用前端脚手架中可以用于控制台选择的工具为命令行交互工具inquirer、可以用于处理控制台命令的工具为用于创建命令行界面的库commander,通用前端脚手架中的模板工具为嵌入式脚本语言JavaScript模板ejs。在通用前端脚手架中通过commander封装指令,例如,可以对创建指令create,创建页面指令create page,创建快速开发页面指令create page fast均使用commander接收用户指令。As an example, after installing the general front-end scaffolding, you can first initialize the project through the general front-end scaffolding, that is, build the initial project project. Among them, the general front-end scaffolding can be published on the software package management tool npm, and can be applied to the front-end project after global installation. In addition, in the general front-end scaffolding provided in the embodiment of the present application, the tool that can be used for console selection is the command line interaction tool inquirer, the tool that can be used to process console commands is the library commander for creating a command line interface, and the template tool in the general front-end scaffolding is the embedded scripting language JavaScript template ejs. In the general front-end scaffolding, the instructions are encapsulated by the commander. For example, the creation instruction create, the page creation instruction create page, and the creation of a rapid development page instruction create page fast can all use the commander to receive user instructions.
创建指令是指用于创建前端项目的指令,创建指令可以为create,通用前端脚手架接收到create指令后,可以通过inquirer提供控制台框架选项,即前端框架选项React、Angular、Vue2以及Vue3等不同种类的前端框架。由此,开发者可以从前端框架选项中选择一个前端框架,作为目标前端框架,以根据该目标前端框架确定出对应的基础工程,并基于该目标前端框架进行前端开发。The creation instruction is an instruction for creating a front-end project. The creation instruction can be create. After receiving the create instruction, the universal front-end scaffold can provide console framework options through inquirer, that is, front-end framework options React, Angular, Vue2, Vue3 and other different types of front-end frameworks. Therefore, the developer can select a front-end framework from the front-end framework options as the target front-end framework, determine the corresponding basic project according to the target front-end framework, and perform front-end development based on the target front-end framework.
另外,在通用前端脚手架中还支持开发者扩展前端框架,若当前前端框架中不包含开发者所需的前端框架时,可以有开发者自行扩展所需的前端框架。同时,通用前端脚手架中还支持由开发者自定义基础工程地址。其中,基础工程地址是指项目地址,可以由开发者自定义,也可以通过通用前端脚手架中获取。In addition, the general front-end scaffolding also supports developers to expand the front-end framework. If the current front-end framework does not contain the front-end framework required by the developer, the developer can expand the required front-end framework by himself. At the same time, the general front-end scaffolding also supports developers to customize the basic project address. Among them, the basic project address refers to the project address, which can be customized by the developer or obtained through the general front-end scaffolding.
S202:基于通用前端脚手架提供的基础工程选项,确定出目标基础工程选项。S202: Determine target basic engineering options based on the basic engineering options provided by the general front-end scaffolding.
基础工程选项是指由通用前端脚手架提供的用于构建项目基础工程的选项,例如,构建工具、UI库、路由封装选项、请求服务封装选项以及数据管理库封装选项等。目标基础工程选项是指由开发者从通用前端脚手架提供的基础工程选项中选择出的基础工程选项,例如,从请求服务封装选项中选择基于XHR的请求库作为目标基础工程选项中的请求库。Basic project options refer to the options provided by the general front-end scaffolding for building the basic project of the project, such as build tools, UI libraries, routing encapsulation options, request service encapsulation options, and data management library encapsulation options. Target basic project options refer to the basic project options selected by the developer from the basic project options provided by the general front-end scaffolding, for example, selecting an XHR-based request library from the request service encapsulation options as the request library in the target basic project options.
例如,在确定出目标前端框架之后,通用前端脚手架可以根据目标前端框架提供对应的构建工具以及UI库选项等。并且,通用前端脚手架还提供有基于XHR和基于Fetch的多种请求库选项、层叠样式表(Cascading Style Sheets,css)编译器选项等。开发者可以根据个人开发习惯或者实际项目要求进行选择。For example, after determining the target front-end framework, the general front-end scaffolding can provide corresponding building tools and UI library options according to the target front-end framework. In addition, the general front-end scaffolding also provides multiple request library options based on XHR and Fetch, Cascading Style Sheets (css) compiler options, etc. Developers can choose according to their personal development habits or actual project requirements.
S203:基于目标前端框架和目标基础工程选项,从通用前端脚手架提供的选项映射地图中,确定出目标基础工程地址;目标基础功能地址用于指示通过目标基础工程选项实现的基础功能的代码存储地址;选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系。S203: Based on the target front-end framework and the target basic engineering options, the target basic engineering address is determined from the option mapping map provided by the general front-end scaffolding; the target basic function address is used to indicate the code storage address of the basic function implemented by the target basic engineering option; the option mapping map includes different front-end frameworks and different basic engineering options, and the mapping relationship between different basic engineering addresses.
目标基础工程地址是指从通用前端脚手架提供的选项映射地图中确定出的基础工程地址,用于指示通过目标基础工程选项实现的基础功能的代码存储地址。其中,通过目标基础工程选项实现的基础功能是指基于开发者选择的基础工程选项可以提供项目中的基础工具以构建出初始软件项目,例如,构建工具、请求封装以及编译器等。The target basic project address refers to the basic project address determined from the option mapping map provided by the general front-end scaffold, which is used to indicate the code storage address of the basic functions implemented by the target basic project options. Among them, the basic functions implemented by the target basic project options refer to the basic tools in the project that can be provided based on the basic project options selected by the developer to build the initial software project, such as build tools, request packaging, and compilers.
选项映射地图是由通用前端脚手架提供的,包括不同种前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系。例如,选项映射地图中包括当前端框架为Vue3框架时和构建工具为webpack时,基础工程地址为A;当前端框架为Vue2框架时和构建工具为vite时,基础工程地址为B。当目标前端框架为Vue3,且构建工具为webpack时,则可以从选项映射地图中确定出目标基础工程地址为A。The option mapping map is provided by the general front-end scaffolding, including different front-end frameworks and different basic project options, and the mapping relationship between different basic project addresses. For example, the option mapping map includes that when the front-end framework is the Vue3 framework and the build tool is webpack, the basic project address is A; when the front-end framework is the Vue2 framework and the build tool is vite, the basic project address is B. When the target front-end framework is Vue3 and the build tool is webpack, the target basic project address can be determined from the option mapping map as A.
因此,可以根据开发者选择的目标前端框架和目标基础工程选项,从选项映射地图中确定出基础工程地址,若开发者自定义基础工程地址,则可以省略该步骤,直接使用开发者提供的基础工程地址进行前端开发。Therefore, the basic project address can be determined from the option mapping map according to the target front-end framework and target basic project options selected by the developer. If the developer customizes the basic project address, this step can be omitted and the basic project address provided by the developer can be directly used for front-end development.
S204:通过下载代码指令,从目标基础工程地址,拉取目标基础工程。S204: Pull the target basic project from the target basic project address by downloading code instructions.
下载代码指令是指用于从基础工程地址中下载对应的基础工程代码的指令,例如,下载代码指令可以为download-git-repo。在通用前端脚手架确定出目标基础工程地址的情况下,可以通过上述下载代码指令拉取对应的目标基础工程。目标基础工程是指一个软件项目中的基础架构或基础设施部分,用于为软件项目提供基础设施,如路由封装、请求服务封装以及数据管理库封装等,以及提供UI库可以被整个项目共享和复用,还可以提供基础工具,如构建工具等。The download code instruction refers to an instruction for downloading the corresponding basic project code from the basic project address. For example, the download code instruction can be download-git-repo. When the general front-end scaffolding determines the target basic project address, the corresponding target basic project can be pulled through the above download code instruction. The target basic project refers to the infrastructure or infrastructure part of a software project, which is used to provide infrastructure for the software project, such as routing encapsulation, request service encapsulation, and data management library encapsulation, as well as providing a UI library that can be shared and reused by the entire project. It can also provide basic tools, such as build tools.
在拉取到目标基础工程之后,可以通过commander的创建子进程命令行child_process自动开启子进程,以安装目标基础工程的相关依赖并启动服务器,以在本地运行该项目。需要说明的是,在安装依赖和启动服务器的过程中可以在子进程中进行异步执行,避免阻塞,提升运行效率。After pulling the target basic project, you can use the commander's command line child_process to automatically start a child process to install the relevant dependencies of the target basic project and start the server to run the project locally. It should be noted that during the process of installing dependencies and starting the server, asynchronous execution can be performed in the child process to avoid blocking and improve operation efficiency.
S205:基于目标基础工程,创建前端页面。S205: Create a front-end page based on the target basic project.
最后,在获取到目标基础工程后,便完成了项目初始化,然后就可以基于目标基础工程,继续创建前端页面。Finally, after obtaining the target basic project, the project initialization is completed, and then you can continue to create the front-end page based on the target basic project.
另外,通用前端脚手架提供的快速开发页面模式封装于基础工程中,均放置于开源平台,开发者可以根据项目需求进行扩展。In addition, the rapid development page mode provided by the general front-end scaffolding is encapsulated in the basic project and placed on the open source platform, so developers can expand it according to project requirements.
可参照图3,图3为本申请实施例提供的一种前端脚手架的应用方法的示意图,在接收到创建指令之后,可以从通用前端脚手架中选择目标前端框架,也可以由开发者自定义框架,从而根据开发者自定义的框架创建对应的项目。Please refer to Figure 3, which is a schematic diagram of an application method of a front-end scaffolding provided in an embodiment of the present application. After receiving the creation instruction, the target front-end framework can be selected from the general front-end scaffolding, or the developer can customize the framework, thereby creating a corresponding project based on the developer's customized framework.
在基于目标基础工程,创建前端页面的过程中,所创建的前端页面可以分为两种模式,第一种,可以基于目标基础工程创建基础页面,即仅提供目标前端框架的最基础页面,不提供封装与数据处理功能;第二种,可以基于目标基础工程创建快速开发页面。在创建页面时,可以通过创建页面命令中的预设参数区分上述两种情况,以确定出目前新建的页面是基础页面还是快速开发页面。其中,创建页面命令可以为create page,预设参数可以为fast,当创建页面命令为create page fast时,则认为当前新建的页面为快速开发页面。In the process of creating front-end pages based on the target basic project, the front-end pages created can be divided into two modes. The first mode is to create basic pages based on the target basic project, that is, only the most basic pages of the target front-end framework are provided, and no encapsulation and data processing functions are provided; the second mode is to create rapid development pages based on the target basic project. When creating a page, the above two situations can be distinguished by the preset parameters in the create page command to determine whether the newly created page is a basic page or a rapid development page. Among them, the create page command can be create page, and the preset parameter can be fast. When the create page command is create page fast, the newly created page is considered to be a rapid development page.
在创建快速开发页面时,首先可以根据创建页面命令中的预设参数进行判断,然后可以为该快速开发页面创建路由地址。如create page fast<二级路由(菜单命名)><一级路由(父菜单)>[-d指定路径],其中,二级路由地址可以选择填写,不作为必填项。由于路由地址不可重复,开发者输入的一级路由地址和二级路由地址可以被通用前端脚手架作为页面的唯一标识,后续均可按照该标识进行模块划分等。When creating a fast development page, you can first make a judgment based on the preset parameters in the create page command, and then create a routing address for the fast development page. For example, create page fast <secondary routing (menu name)><first-level routing (parent menu)> [-d specified path], where the second-level routing address is optional and not required. Since the routing address cannot be repeated, the first-level routing address and second-level routing address entered by the developer can be used as the unique identifier of the page by the general front-end scaffolding, and the module division can be performed according to the identifier later.
需要说明的是,在创建快速开发页面时,若已经指定路径则在指定路径下生成文件夹,若没有指定路径,则默认放在视图views文件夹下。同时,可以在views/一级路由/二级路由/配置config,在配置文件中生成配置文件config,并且开发者没有额外开发需求时,在创建快速开发页面之后,配置config文件,即可完成页面创建,得到快速开发页面。同时,快速开发页面中还需要配置其他功能时,可以在生成的页面中由开发者自行扩展开发。It should be noted that when creating a quick development page, if the path has been specified, a folder will be generated under the specified path. If the path is not specified, it will be placed in the view folder by default. At the same time, you can generate a configuration file config in the configuration file in views/first-level routing/second-level routing/config, and if the developer has no additional development requirements, after creating the quick development page, configure the config file to complete the page creation and get the quick development page. At the same time, if other functions need to be configured in the quick development page, the developer can expand and develop them in the generated page.
作为一种示例,当通用前端脚手架接收到新建页面(创建页面命令)或新建组件命令后,以创建快速开发页面为例,具体的实施方式可以包括:As an example, when the general front-end scaffold receives a new page (create page command) or a new component command, taking the creation of a rapid development page as an example, the specific implementation method may include:
首先,可以创建服务server文件,即创建一个用于处理服务器处理请求的服务器文件,并在这个服务文件中进行请求的封装操作。然后,可以基于目标前端框架,从通用前端脚手架提供的页面模板映射地图中,确定出快速开发页面对应的快速开发页面模板,即通用前端脚手架提供的ejs模板。其中,页面模板映射地图中包括不同前端框架与不同页面模板之间的映射关系。快速开发页面模板中包括表格组件和表单组件,以及表格组件和表单组件分别对应的基础交互操作,例如,增加、删除、修改、查询,以及分页等功能。例如,当前端框架为Vue2时,对应的页面模板为A模板;当前端框架为Vue3时,对应的页面模板为B模板。First, you can create a service server file, that is, create a server file for processing server processing requests, and perform request encapsulation operations in this service file. Then, based on the target front-end framework, you can determine the rapid development page template corresponding to the rapid development page from the page template mapping map provided by the general front-end scaffolding, that is, the ejs template provided by the general front-end scaffolding. Among them, the page template mapping map includes the mapping relationship between different front-end frameworks and different page templates. The rapid development page template includes table components and form components, as well as the basic interactive operations corresponding to the table components and form components, such as adding, deleting, modifying, querying, and paging functions. For example, when the front-end framework is Vue2, the corresponding page template is template A; when the front-end framework is Vue3, the corresponding page template is template B.
需要说明是,由开发者自行扩展的前端框架,此时可以由开发者自行扩展对应的页面模板。It should be noted that for the front-end framework extended by the developer himself, the developer can extend the corresponding page template at this time.
由于创建页面命令中包括快速开发页面的路由地址,并且该路由地址可以作为快速开发页面的唯一标识,用于模块划分,在基于快速开发页面模板生成代码的过程中,可以基于快速开发页面模板和快速开发页面的路由地址生成对应的代码文件,即可以将快速开发页面模板中的占位符替换为该唯一标识,然后可以通过开发服务端应用程序node文件处理模块生成对应的文件,若接收到指定路径,则将该文件存储于指定路径,否则,将该文件存储于默认文件夹下,即将代码文件存储于目标基础工程对应的文件夹中。Since the create page command includes the routing address of the rapid development page, and the routing address can be used as a unique identifier of the rapid development page for module division, in the process of generating code based on the rapid development page template, the corresponding code file can be generated based on the rapid development page template and the routing address of the rapid development page, that is, the placeholder in the rapid development page template can be replaced with the unique identifier, and then the corresponding file can be generated by developing the server-side application node file processing module. If a specified path is received, the file is stored in the specified path, otherwise, the file is stored in the default folder, that is, the code file is stored in the folder corresponding to the target basic project.
然后,在基于快速开发模板生成代码的过程中,以目标基础工程中的前端框架为Vue且构建工具为webpack为例,可以创建数据流处理store,以存储和管理项目中的状态数据,统一管理数据的获取、修改和更新等。目标基础工程可以通过获取命令require从目标基础工程对应的文件夹中读取存储文件,即读取本地store文件,从目标基础工程中引入开发者选择的数据管理库,统一管理存储文件中的数据,并且,可以按照生成的代码文件的路由地址为存储文件划分存储位置,即可以按照代码文件的唯一标识在存储文件中为生成的代码文件单独设置一个存储位置,实现了按照路由地址的分模块隔离。其他页面的模块划分可以由开发者根据实际项目需求进行确定,对此,本申请不具体限其他页面的存储文件中的存储位置划分。Then, in the process of generating code based on the rapid development template, taking the front-end framework in the target basic project as Vue and the construction tool as webpack as an example, a data flow processing store can be created to store and manage the status data in the project, and uniformly manage the acquisition, modification and update of data. The target basic project can read the storage file from the folder corresponding to the target basic project by obtaining the command require, that is, read the local store file, introduce the data management library selected by the developer from the target basic project, and uniformly manage the data in the storage file. In addition, the storage location can be divided for the storage file according to the routing address of the generated code file, that is, a storage location can be set separately for the generated code file in the storage file according to the unique identifier of the code file, realizing the module isolation according to the routing address. The module division of other pages can be determined by the developer according to the actual project requirements. In this regard, this application is not specifically limited to the storage location division in the storage files of other pages.
之后,可以目标基础工程可以通过require读取本地所有路由文件,以将这些路由文件映射到菜单上,从而在创建快速开发页面中实现创建路由。作为一种示例,菜单可以为一个网站的导航菜单或其他形式的菜单,便于开发者在网络或应用程序中浏览不同的页面或功能。在创建路由之后,可以通过写入方法fs.writeFile写入应用程序编程接口(Application Programming Interface,API)文件,即将定义API接口的数据以某种格式写入到文件中,以实现持久化存储并且便于后续读取处理。After that, the target infrastructure project can read all local route files through require to map these route files to the menu, so as to create routes in the creation of the quick development page. As an example, the menu can be a navigation menu of a website or other forms of menus, which is convenient for developers to browse different pages or functions on the network or in applications. After creating the route, the application programming interface (API) file can be written through the writing method fs.writeFile, that is, the data defining the API interface is written to the file in a certain format to achieve persistent storage and facilitate subsequent reading and processing.
并且,在接口配置过程中,server服务引入了服务接口配置文件service/api.json文件中对应的接口对象,以生成快速开发页面中对应的对象,封装有对应的增删改查接口。例如,查询接口"query":"",删除接口"deleteItem":"",新增接口"create":"",以及修改接口"edit":""。In addition, during the interface configuration process, the server service introduces the corresponding interface objects in the service interface configuration file service/api.json to generate the corresponding objects in the quick development page, which encapsulate the corresponding add, delete, modify and query interfaces. For example, the query interface "query":"", the delete interface "deleteItem":"", the new interface "create":"", and the modification interface "edit":"".
并且,server服务会在对应的store文件中引入,将请求服务数据写入对应的数据管理模块,即在存储文件中设置的存储位置。若此时开发者没有额外的需求,可以直接根据确定出的快速开发页面模板,并配置同时生成的结构化数据json配置文件,即可获得快速开发页面。其中,json配置文件只有一套,所有前端框架统一。可见,根据快速开发页面模板,以及相应地命令,可以自定生成完整页面或组件,只需完成后续json文件的配置,对于后台管理类包括多种表格表单项的系统来说,提升了创建快捷性。In addition, the server service will be introduced in the corresponding store file, and the request service data will be written to the corresponding data management module, that is, the storage location set in the storage file. If the developer has no additional requirements at this time, he can directly obtain the rapid development page according to the determined rapid development page template and configure the structured data json configuration file generated at the same time. Among them, there is only one set of json configuration files, and all front-end frameworks are unified. It can be seen that according to the rapid development page template and the corresponding commands, a complete page or component can be generated by itself. It only needs to complete the configuration of the subsequent json file. For systems with background management classes including multiple table form items, the creation efficiency is improved.
另外,目标基础工程还提供了增删改查封装功能,例如,编辑弹框后数据回显、删除新增后刷新列表、搜索项改变后表格刷新等操作均已依赖于组件通信,例如,Vue3中可以使用钩子函数hooks进行调用,Vue2中可以使用事件总线eventbus实现。In addition, the target infrastructure project also provides encapsulation functions for adding, deleting, modifying and checking. For example, data echo after editing the pop-up window, refreshing the list after deleting or adding, and refreshing the table after the search item changes. These operations all rely on component communication. For example, hooks can be used for calling in Vue3, and event bus eventbus can be used for implementation in Vue2.
在完成上述接口配置之后,可以创建快速开发页面,可以在基于快速开发模板生成代码的过程中,通过目标基础工程封装可配置表格项的表格组件,并且能够封装可配置表单项的表单组件,使用对应的config文件配置生成表格组件和表单组件。然后,可以创建用于配置页面的json文件,例如,在表格配置过程中,自动生成以下配置,如:After completing the above interface configuration, you can create a quick development page. In the process of generating code based on the quick development template, you can encapsulate the table component of the configurable table items through the target basic project, and you can encapsulate the form component of the configurable form items, and use the corresponding config file to configure the generated table component and form component. Then, you can create a json file for configuring the page. For example, in the process of table configuration, the following configuration is automatically generated, such as:
contentTableConfig={contentTableConfig={
title:'用户列表',title:'User List',
pageName:'courceSource',pageName:'courceSource',
propList:[propList:[
{prop:'name',label:'用户名',minWidth:'100'},{prop:'name',label:'Username',minWidth:'100'},
],],
showIndexColumn:true,showIndexColumn:true,
showSelectColumn:trueshowSelectColumn:true
}}
上述代码结构介绍了用于配置内容表格的一些参数,例如,配置的标题、配置的页面名、配置列表的数组等信息。The above code structure introduces some parameters used to configure the content table, such as the configured title, configured page name, array of configured lists, and other information.
开发者在此配置过程中,只需要配置Label:表格列;prop:与后端字段对应的字段名,上述所提供的可配置功能,可以在目标基础工程的类型脚本ts文件中体现。During this configuration process, developers only need to configure Label: table column; prop: field name corresponding to the backend field. The configurable functions provided above can be reflected in the type script ts file of the target basic project.
例如,在表单配置过程中,自动生成以下配置,如:For example, during the form configuration process, the following configuration is automatically generated, such as:
searchFormConfig={searchFormConfig={
pageName:"courceSource",pageName:"courceSource",
formItems:[{formItems:[{
field:"code",field:"code",
type:"input",type:"input",
label:"编码",label:"Encoding",
placeHolder:"请输入编码",placeHolder:"Please enter the code",
maxlength:20maxlength:20
}],}],
itemTextAlign:'left',itemTextAlign:'left',
labelWidth:"60px",labelWidth:"60px",
itemStyle:{padding:'10px 30px 10px 0'},itemStyle:{padding:'10px 30px 10px 0'},
colLayout:{span:8}colLayout:{span:8}
};};
上述代码结构介绍了用于配置内容表单的一些参数,例如,配置的页面名称、包含表单项配置的数组、表单项文本内容的对齐方式、表单项标签的宽度,表单的样式设置等信息。与上述表格配置相同,上述所提供的可配置功能,可以在目标基础工程的类型脚本ts文件中体现。The above code structure introduces some parameters for configuring the content form, such as the configured page name, the array containing the form item configuration, the alignment of the form item text content, the width of the form item label, the style settings of the form, etc. Similar to the above table configuration, the configurable functions provided above can be reflected in the type script ts file of the target basic project.
需要说明的是,除了上述目标基础工程提供功能之外,对于由用户自定义的表格表单项,对应的页面文件中包括自定义插槽,对应地,自动生成文档中包括相关注释以提示插槽位置,用于开发者自定义表格表单项。It should be noted that in addition to the functions provided by the above-mentioned target basic project, for table form items customized by users, the corresponding page file includes custom slots, and correspondingly, the automatically generated document includes relevant comments to prompt the slot location for developers to customize table form items.
另外,创建组件与上述创建快速开发页面的功能类似,不同点在于,创建组件时不自动生成路由,默认生成路径为组件component。In addition, creating a component is similar to creating the quick development page mentioned above. The difference is that the route is not automatically generated when creating a component, and the default generated path is component.
以上为本申请实施例提供的一种前端脚手架的应用方法,该方法应用于通用前端脚手架,该方法可以包括:当通用前端脚手架接收到创建指令时,可以基于通用前端脚手架提供的前端框架选项,从中选择出目标前端框架。然后,可以基于通用前端脚手架提供的基础工程选项,从中确定出目标基础工程选项。选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系。因此,可以在确定出目标前端框架和目标基础工程选项后,可以根据目标前端框架和目标基础工程选项,从通用前端脚手架提供的选项映射地图中,确定出用于通过目标基础工程选项实现的基础工程的代码存储地址,即目标基础工程地址。之后,可以通过下载代码指令,从映射出的目标基础工程地址中,拉取到目标基础工程,从而可以基于目标基础工程,创建前端页面。由此,通过通用前端脚手架完成了项目初始化,可以基于通用前端脚手架提供的目标基础工程,继续进行前端开发。The above is an application method of a front-end scaffold provided by an embodiment of the present application, which is applied to a general front-end scaffold. The method may include: when the general front-end scaffold receives a creation instruction, the target front-end framework can be selected from the front-end framework options provided by the general front-end scaffold. Then, the target basic engineering options can be determined based on the basic engineering options provided by the general front-end scaffold. The option mapping map includes different front-end frameworks and different basic engineering options, and the mapping relationship between different basic engineering addresses. Therefore, after determining the target front-end framework and the target basic engineering options, the code storage address of the basic engineering implemented by the target basic engineering option, i.e., the target basic engineering address, can be determined from the option mapping map provided by the general front-end scaffold according to the target front-end framework and the target basic engineering options. Afterwards, the target basic engineering can be pulled from the mapped target basic engineering address by downloading the code instruction, so that the front-end page can be created based on the target basic engineering. Thus, the project initialization is completed by the general front-end scaffold, and the front-end development can be continued based on the target basic engineering provided by the general front-end scaffold.
可见,通用前端脚手架中提供了选项映射地图,其中包含有各个前端框架和不同基础工程选项,与目标基础工程地址的映射关系,使得通用前端脚手架提供的基础工程可以适用于多种前端框架,并且能够通过目标基础工程选项实现对应的基础工程,从而基于目标基础工程可以继续进行前端开发,无需安装多种前端框架对应的脚手架,进而提升了开发效率。It can be seen that the general front-end scaffolding provides an option mapping map, which contains various front-end frameworks and different basic project options, and the mapping relationship with the target basic project address, so that the basic project provided by the general front-end scaffolding can be applied to a variety of front-end frameworks, and the corresponding basic project can be implemented through the target basic project options, so that the front-end development can continue based on the target basic project, without installing scaffolding corresponding to a variety of front-end frameworks, thereby improving development efficiency.
以上为本申请实施例提供前端脚手架的应用方法的一些具体实现方式,基于此,本申请还提供了对应的装置。下面将从功能模块化的角度对本申请实施例提供的装置进行介绍。The above are some specific implementations of the front-end scaffolding application method provided in the embodiment of the present application. Based on this, the present application also provides a corresponding device. The device provided in the embodiment of the present application will be introduced from the perspective of functional modularization.
参见图4,该图为本申请实施例提供的一种前端脚手架的应用装置400的结构示意图,该装置部署于通用前端脚手架,该装置400可以包括:Referring to FIG. 4 , this figure is a schematic diagram of the structure of a front-end scaffold application device 400 provided in an embodiment of the present application. The device is deployed on a general front-end scaffold. The device 400 may include:
第一确定模块401,用于当所述通用前端脚手架接收到创建指令时,基于所述通用前端脚手架提供的前端框架选项,确定出目标前端框架;The first determination module 401 is used to determine a target front-end framework based on the front-end framework options provided by the general front-end scaffolding when the general front-end scaffolding receives a creation instruction;
第二确定模块402,用于基于所述通用前端脚手架提供的基础工程选项,确定出目标基础工程选项;A second determination module 402 is used to determine a target basic engineering option based on the basic engineering options provided by the general front-end scaffolding;
第三确定模块403,用于基于所述目标前端框架和所述目标基础工程选项,从所述通用前端脚手架提供的选项映射地图中,确定出目标基础工程地址;所述目标基础功能地址用于指示通过所述目标基础工程选项实现的基础功能的代码存储地址;所述选项映射地图中包括不同前端框架和不同基础工程选项,与不同基础工程地址之间的映射关系;The third determination module 403 is used to determine the target basic engineering address from the option mapping map provided by the general front-end scaffold based on the target front-end framework and the target basic engineering option; the target basic function address is used to indicate the code storage address of the basic function implemented by the target basic engineering option; the option mapping map includes the mapping relationship between different front-end frameworks and different basic engineering options and different basic engineering addresses;
拉取模块404,用于通过下载代码指令,从所述目标基础工程地址,拉取目标基础工程;The pulling module 404 is used to pull the target basic project from the target basic project address by downloading code instructions;
创建模块405,用于基于所述目标基础工程,创建前端页面。The creation module 405 is used to create a front-end page based on the target basic project.
可选地,所述基础工程选项包括构建工具、用户界面组件库、路由封装选项、请求服务封装选项以及数据管理库封装选项。Optionally, the basic engineering options include construction tools, user interface component libraries, routing encapsulation options, request service encapsulation options, and data management library encapsulation options.
可选地,所述前端页面包括快速开发页面,所述创建模块405,包括:Optionally, the front-end page includes a quick development page, and the creation module 405 includes:
创建单元,用于基于所述目标基础工程,通过创建页面命令中的预设参数,创建快速开发页面,所述快速开发页面是由所述通用前端脚手架提供的页面模式。A creation unit is used to create a rapid development page based on the target basic project by using preset parameters in a page creation command, wherein the rapid development page is a page mode provided by the general front-end scaffolding.
可选地,所述第一创建单元包括:Optionally, the first creating unit includes:
确定单元,用于基于所述目标前端框架,从所述通用前端脚手架提供的页面模板映射地图中,确定出所述快速开发页面对应的快速开发页面模板;所述页面模板映射地图中包括不同前端框架与不同页面模板之间的映射关系;所述快速开发页面模板中包括表格组件和表单组件,以及表格组件和表单组件分别对应的基础交互操作;A determination unit, configured to determine, based on the target front-end framework, a rapid development page template corresponding to the rapid development page from a page template mapping map provided by the general front-end scaffold; the page template mapping map includes a mapping relationship between different front-end frameworks and different page templates; the rapid development page template includes a table component and a form component, and basic interaction operations corresponding to the table component and the form component respectively;
获得单元,用于基于所述快速开发页面模板和结构化数据配置文件,得到所述快速开发页面。The obtaining unit is used to obtain the rapid development page based on the rapid development page template and the structured data configuration file.
可选地,所述创建页面命令中包括所述快速开发页面的路由地址,所述装置还包括:Optionally, the create page command includes a routing address of the rapid development page, and the device further includes:
生成单元,用于通过基于所述快速开发页面模板和所述快速开发页面的路由地址,生成对应的代码文件,将所述代码文件存储于所述目标基础工程对应的文件夹中。The generating unit is used to generate a corresponding code file based on the rapid development page template and the routing address of the rapid development page, and store the code file in a folder corresponding to the target basic project.
可选地,所述装置还包括:Optionally, the device further comprises:
读取单元,用于通过获取命令从所述目标基础工程对应的文件夹中读取存储文件,基于所述目标基础工程为所述存储文件划分存储位置。The reading unit is used to read the storage file from the folder corresponding to the target basic project through an acquisition command, and divide the storage location for the storage file based on the target basic project.
可选地,所述装置还包括:Optionally, the device further comprises:
启动单元,用于通过命令行指令启动子进程,所述子进程用于安装所述目标基础工程的相关依赖和启动服务器。The startup unit is used to start a subprocess through a command line instruction, and the subprocess is used to install the relevant dependencies of the target basic project and start the server.
本申请实施例还提供了对应的设备以及计算机存储介质,用于实现本申请实施例提供的方案。The embodiments of the present application also provide corresponding devices and computer storage media for implementing the solutions provided by the embodiments of the present application.
其中,所述设备包括存储器和处理器,所述存储器用于存储计算机程序,所述处理器用于执行所述计算机程序,以使所述设备执行本申请任一实施例所述的前端脚手架的应用方法。Among them, the device includes a memory and a processor, the memory is used to store a computer program, and the processor is used to execute the computer program so that the device executes the application method of the front-end scaffolding described in any embodiment of the present application.
所述计算机存储介质中存储有计算机程序,当所述代码被运行时,运行所述计算机程序的设备实现本申请任一实施例所述的前端脚手架的应用方法。The computer storage medium stores a computer program. When the code is executed, the device executing the computer program implements the front-end scaffolding application method described in any embodiment of the present application.
本申请实施例中提到的“第一”、“第二”(若存在)等名称中的“第一”、“第二”只是用来做名字标识,并不代表顺序上的第一、第二。The "first" and "second" in the names such as "first" and "second" (if any) mentioned in the embodiments of the present application are only used as name identifiers and do not represent the first or second in order.
通过以上的实施方式的描述可知,本领域的技术人员可以清楚地了解到上述实施例方法中的全部或部分步骤可借助软件加通用硬件平台的方式来实现。基于这样的理解,本申请的技术方案可以以软件产品的形式体现出来,该计算机软件产品可以存储在存储介质中,如只读存储器(英文:read-only memory,ROM)/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者诸如路由器等网络通信设备)执行本申请各个实施例或者实施例的某些部分所述的方法。Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM)/RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.
需要说明的是,本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于装置实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元提示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。It should be noted that each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device embodiment described above is merely schematic, in which the unit described as a separate component may or may not be physically separated, and the component prompted as a unit may or may not be a physical unit, that is, it may be located in one place, or it may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.
以上所述,仅为本申请的一种具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应该以权利要求的保护范围为准。The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410758671.8A CN118519619A (en) | 2024-06-12 | 2024-06-12 | Application method and device of front-end scaffold |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202410758671.8A CN118519619A (en) | 2024-06-12 | 2024-06-12 | Application method and device of front-end scaffold |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118519619A true CN118519619A (en) | 2024-08-20 |
Family
ID=92274024
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202410758671.8A Pending CN118519619A (en) | 2024-06-12 | 2024-06-12 | Application method and device of front-end scaffold |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118519619A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119668598A (en) * | 2024-11-29 | 2025-03-21 | 广州赛意信息科技股份有限公司 | A front-end application construction method and system based on business function combination |
-
2024
- 2024-06-12 CN CN202410758671.8A patent/CN118519619A/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN119668598A (en) * | 2024-11-29 | 2025-03-21 | 广州赛意信息科技股份有限公司 | A front-end application construction method and system based on business function combination |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7496890B2 (en) | Generation of configuration instructions using an abstraction technique | |
| CN110806873B (en) | Target control determination method, device, electronic equipment and storage medium | |
| CN106843936B (en) | Method for automatically deploying Web application environment | |
| CN110673923A (en) | XWIKI system configuration method, system and computer equipment | |
| US20080127054A1 (en) | Connecting with an application instance | |
| US8250458B2 (en) | Method, system, and software tool for emulating a portal application | |
| US20150020057A1 (en) | Controlling application features | |
| CN112181588A (en) | Application containerization method and device, electronic equipment and storage medium | |
| CN108804100B (en) | Method and device for creating interface element, storage medium and mobile terminal | |
| US20070073724A1 (en) | System and method for automatic or semi-automatic software integration | |
| CN116107563A (en) | Low-code application acquisition method and related device | |
| CN116360779B (en) | Method for constructing micro front end base based on qiankun in Vue CLI application | |
| CN118519619A (en) | Application method and device of front-end scaffold | |
| CN113946323A (en) | Online development method, device, equipment and storage medium based on micro-service system | |
| CN106569854A (en) | Method and system for setting device firmware and realizing factory testing | |
| CN114816418B (en) | Method, device, equipment and medium for building an embedded operating system | |
| CN114595246B (en) | Statement generation method, device, equipment and storage medium | |
| JP5108773B2 (en) | Control actions defined declaratively | |
| CN112615779A (en) | Interface route generation method and device | |
| US20070233717A1 (en) | Generic product configuration framework for building product specific installers | |
| CN115168007B (en) | Methods, devices, and program carriers for cross-platform application migration | |
| CN114816475B (en) | Method, device, equipment and medium for updating embedded operating system | |
| EP1577762A2 (en) | Address support for resources in common-language runtime languages | |
| CN117785271A (en) | Method for calling equipment, instruction management center and equipment calling system | |
| CN117251140A (en) | Multi-level and dynamically scalable software processing methods, systems, chips and equipment |
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 |