[go: up one dir, main page]

CN116301753A - Webpage engineering file generation method and device, electronic equipment and storage medium - Google Patents

Webpage engineering file generation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116301753A
CN116301753A CN202310274316.9A CN202310274316A CN116301753A CN 116301753 A CN116301753 A CN 116301753A CN 202310274316 A CN202310274316 A CN 202310274316A CN 116301753 A CN116301753 A CN 116301753A
Authority
CN
China
Prior art keywords
webpage
information
file
target component
web page
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
Application number
CN202310274316.9A
Other languages
Chinese (zh)
Inventor
安宁宁
史婷婷
王金鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Baidu com Times Technology Beijing Co Ltd
Original Assignee
Baidu com Times Technology Beijing Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Baidu com Times Technology Beijing Co Ltd filed Critical Baidu com Times Technology Beijing Co Ltd
Priority to CN202310274316.9A priority Critical patent/CN116301753A/en
Publication of CN116301753A publication Critical patent/CN116301753A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/36Software reuse
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The disclosure provides a webpage engineering file generation method, a webpage engineering file generation device, electronic equipment and a storage medium, and relates to the technical field of data processing, in particular to the field of Web front ends. The specific implementation scheme is as follows: calling a webpage engineering development framework, and creating a template file of a webpage engineering file; extracting first attribute information of a first webpage element from a webpage design draft file; determining a target component for realizing the webpage elements contained in the webpage engineering file to be generated from the packaged components based on the extracted first attribute information; setting information of the determined target component based on the extracted first attribute information; and embedding the target component after the information is set into the created template file to generate a webpage engineering file. By applying the scheme provided by the embodiment of the invention, the generation efficiency of the webpage engineering file can be improved.

Description

一种网页工程文件生成方法、装置、电子设备及存储介质A method, device, electronic device and storage medium for generating web page engineering files

技术领域technical field

本公开涉及数据处理技术领域,尤其涉及Web前端技术领域。The present disclosure relates to the field of data processing technology, and in particular to the field of Web front-end technology.

背景技术Background technique

在进行网页开发时,一般先由设计人员向开发人员提供网页设计稿,然后开发人员基于网页设计稿进行代码编写,得到网页工程文件。When developing a webpage, generally, the designer first provides the webpage design draft to the developer, and then the developer writes the code based on the webpage design draft to obtain the webpage project file.

当前可以先将网页设计稿转换为HTML(Hyper Text Markup Language,超文本标记语言)文档,然后开发人员基于HTML文档编写代码,从而得到网页工程文件。虽然上述HTML文档包含与网页设计稿相关的标注信息,可以为开发人员编写代码提供便利,但是依然需要开发人员编写大量代码才能得到网页工程文件。Currently, the webpage design draft can be converted into an HTML (Hyper Text Markup Language, Hypertext Markup Language) document, and then developers write codes based on the HTML document to obtain a webpage project file. Although the above-mentioned HTML document contains annotation information related to the web page design draft, which can provide convenience for developers to write codes, it still requires developers to write a large amount of codes to obtain the web page project file.

发明内容Contents of the invention

本公开提供了一种网页工程文件生成方法、装置、电子设备及存储介质。The disclosure provides a method, device, electronic equipment and storage medium for generating a web page project file.

根据本公开的一方面,提供了一种网页工程文件生成方法,包括:According to an aspect of the present disclosure, a method for generating a web page project file is provided, including:

调用网页工程开发框架,创建网页工程文件的模板文件;Call the webpage project development framework to create a template file for the webpage project file;

从网页设计稿文件中提取第一网页元素的第一属性信息;Extracting the first attribute information of the first webpage element from the webpage design draft file;

基于所提取的第一属性信息,从已封装组件中,确定用于实现待生成的网页工程文件中包含的网页元素的目标组件;Based on the extracted first attribute information, from the packaged components, determine a target component for realizing the webpage elements contained in the webpage project file to be generated;

基于所提取的第一属性信息,对所确定的目标组件进行信息设置;performing information setting on the determined target component based on the extracted first attribute information;

将设置信息后的目标组件嵌入所创建的模板文件中,生成网页工程文件。Embed the target component after the information is set into the created template file to generate a webpage project file.

根据本公开的另一方面,提供了一种网页工程文件生成装置,包括:According to another aspect of the present disclosure, an apparatus for generating a webpage project file is provided, including:

模板文件创建模块,用于调用网页工程开发框架,创建网页工程文件的模板文件;The template file creation module is used to call the web page project development framework and create a template file of the web page project file;

第一属性信息提取模块,用于从网页设计稿文件中提取第一网页元素的第一属性信息;The first attribute information extraction module is used to extract the first attribute information of the first webpage element from the webpage design draft file;

目标组件确定模块,用于基于所提取的第一属性信息,从已封装组件中,确定用于实现待生成的网页工程文件中包含的网页元素的目标组件;A target component determining module, configured to determine a target component for implementing the web page elements contained in the web page project file to be generated from the packaged components based on the extracted first attribute information;

信息设置模块,用于基于所提取的第一属性信息,对所确定的目标组件进行信息设置;An information setting module, configured to perform information setting on the determined target component based on the extracted first attribute information;

文件生成模块,用于将设置信息后的目标组件嵌入所创建的模板文件中,生成网页工程文件。The file generation module is used to embed the target component after information setting into the created template file to generate the web page project file.

根据本公开的另一方面,提供了一种电子设备,包括:According to another aspect of the present disclosure, an electronic device is provided, including:

至少一个处理器;以及at least one processor; and

与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,

所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行前述网页工程文件生成方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the aforementioned method for generating a web page project file.

根据本公开的另一方面,提供了一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行前述网页工程文件生成方法。According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to make the computer execute the aforementioned method for generating a web page project file.

根据本公开的另一方面,提供了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现前述网页工程文件生成方法。According to another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the aforementioned method for generating a web page project file is implemented.

由以上可见,应用本公开实施例提供的方案生成网页工程文件时,首先从网页设计稿文件中提取第一网页元素的第一属性信息,然后基于第一属性信息,从已封装组件中确定用于实现待生成的网页工程文件中包含的网页元素的目标组件,并且,基于所提取的第一属性信息对所确定的目标组件进行信息设置,进而可以将设置信息后的目标组件嵌入所创建的模板文件中,成功生成网页文件。It can be seen from the above that when applying the solution provided by the embodiment of the present disclosure to generate a webpage project file, first extract the first attribute information of the first webpage element from the webpage design draft file, and then determine the packaged components based on the first attribute information. To realize the target component of the web page element contained in the web page project file to be generated, and, based on the extracted first attribute information, perform information setting on the determined target component, and then the target component after the information setting can be embedded into the created In the template file, the web page file is successfully generated.

应当理解,本部分所描述的内容并非旨在标识本公开的实施例的关键或重要特征,也不用于限制本公开的范围。本公开的其它特征将通过以下的说明书而变得容易理解。It should be understood that what is described in this section is not intended to identify key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will be readily understood through the following description.

附图说明Description of drawings

附图用于更好地理解本方案,不构成对本公开的限定。其中:The accompanying drawings are used to better understand the present solution, and do not constitute a limitation to the present disclosure. in:

图1为本公开实施例提供的第一种网页示意图;FIG. 1 is a schematic diagram of a first type of webpage provided by an embodiment of the present disclosure;

图2为本公开实施例提供的第二种网页示意图;FIG. 2 is a schematic diagram of a second type of webpage provided by an embodiment of the present disclosure;

图3为本公开实施例提供的第一种网页工程文件生成方法的流程示意图;FIG. 3 is a schematic flowchart of the first method for generating a webpage project file provided by an embodiment of the present disclosure;

图4为本公开实施例提供的一种模板文件创建流程的示意图;FIG. 4 is a schematic diagram of a template file creation process provided by an embodiment of the present disclosure;

图5为本公开实施例提供的一种信息设置流程的示意图;FIG. 5 is a schematic diagram of an information setting process provided by an embodiment of the present disclosure;

图6为本公开实施例提供的第二种网页工程文件生成方法的流程示意图;FIG. 6 is a schematic flowchart of a second method for generating a webpage project file provided by an embodiment of the present disclosure;

图7为本公开实施例提供的一种网页工程文件生成流程的示意图;FIG. 7 is a schematic diagram of a web page engineering file generation process provided by an embodiment of the present disclosure;

图8为本公开实施例提供的一种网页工程文件生成装置的结构示意图;FIG. 8 is a schematic structural diagram of a device for generating a webpage project file provided by an embodiment of the present disclosure;

图9是用来实现本公开实施例的网页工程文件生成方法的电子设备的框图。Fig. 9 is a block diagram of an electronic device used to implement the method for generating a web page project file according to an embodiment of the present disclosure.

具体实施方式Detailed ways

以下结合附图对本公开的示范性实施例做出说明,其中包括本公开实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。因此,本领域普通技术人员应当认识到,可以对这里描述的实施例做出各种改变和修改,而不会背离本公开的范围和精神。同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and they should be regarded as exemplary only. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.

首先对本公开实施例所提供方案的执行主体进行说明。Firstly, the executive body of the solution provided by the embodiment of the present disclosure will be described.

本公开实施例所提供方案的执行主体为:任意一台具有计算、存储等功能的电子设备。The subject of execution of the solutions provided by the embodiments of the present disclosure is: any electronic device with computing, storage and other functions.

下面对本公开实施例所提供的方案的应用场景进行说明。The application scenarios of the solutions provided by the embodiments of the present disclosure will be described below.

本公开实施例所提供的方案的应用场景为:基于网页设计稿文件生成网页工程文件的场景。The application scenario of the solution provided by the embodiment of the present disclosure is: a scenario of generating a webpage project file based on a webpage design draft file.

在进行网页开发时,一般先由设计人员向开发人员提供网页设计稿,然后开发人员基于网页设计稿进行代码编写,得到网页工程文件。When developing a webpage, generally, the designer first provides the webpage design draft to the developer, and then the developer writes the code based on the webpage design draft to obtain the webpage project file.

运行上述网页工程文件,可以得到还原网页设计稿的网页。Run the above webpage project file to get the webpage that restores the webpage design draft.

参见图1和图2,分别为本公开实施例提供的第一种网页示意图和第二种网页示意图。Referring to FIG. 1 and FIG. 2 , they are schematic diagrams of a first type of webpage and a second type of webpage provided by an embodiment of the present disclosure, respectively.

图1和图2所示的网页可以是运行上述网页工程文件得到的、还原网页设计稿的网页。The webpage shown in FIG. 1 and FIG. 2 may be a webpage obtained by running the above-mentioned webpage project file and restoring the webpage design draft.

在采用现有技术进行网页工程开发时,一方面,虽然开发人员可以基于由网页设计稿转化得到的HTML文档编写代码,但是依然需要编写较多的代码,才能得到网页工程文件;另一方面,很多网页中都包含同样类型的组件,如,图1所示的网页中轮播图1和轮播图2,图1所示的网页中表单1和图2所示的网页中表单2,这些组件类型相同,展现效果相似,导致开发人员编写用于实现上述组件的代码时,出现编写大量重复代码或者类似代码的情况。When using the existing technology to develop webpage projects, on the one hand, although developers can write codes based on HTML documents converted from webpage design drafts, they still need to write more codes to obtain webpage project files; on the other hand, Many webpages contain the same type of components, for example, carousel image 1 and carousel image 2 in the webpage shown in Figure 1, form 1 in the webpage shown in Figure 1 and form 2 in the webpage shown in Figure 2, these Components of the same type have similar display effects, which leads to the situation of writing a large amount of repeated code or similar code when developers write the code for implementing the above components.

结合以上两个方面可见,采用现有技术生成网页工程文件时,需要耗费的工作量较大,导致网页工程文件的生成效率较低。Combining the above two aspects, it can be seen that when the existing technology is used to generate the webpage project file, a large workload is required, resulting in low generation efficiency of the webpage project file.

鉴于上述情况,本公开实施例提供了一种网页工程文件生成方法,以提高网页工程文件的生成效率。In view of the foregoing, an embodiment of the present disclosure provides a method for generating a web page project file, so as to improve the generation efficiency of the web page project file.

下面再对本公开实施例提供的网页工程文件生成方法进行详细说明。The method for generating a webpage project file provided by the embodiment of the present disclosure will be described in detail below.

参见图3,为公开实施例提供的第一种网页工程文件生成方法的流程示意图,上述方法包括以下步骤S301-步骤S305。Referring to FIG. 3 , it is a schematic flowchart of the first method for generating a web page project file provided by the disclosed embodiment. The above method includes the following steps S301 - S305.

步骤S301:调用网页工程开发框架,创建网页工程文件的模板文件。Step S301: calling the webpage project development framework to create a template file of the webpage project file.

网页工程开发框架也可以称为Web开发框架,可以由工作人员根据实际情况灵活选用,本公开实施例对此不做限定。The web page engineering development framework can also be called a web development framework, which can be flexibly selected by the staff according to the actual situation, which is not limited in the embodiments of the present disclosure.

例如,上述网页工程开发框架可以是Vue.js+Node.js、Spring+Node.js、React.js+Deno.js等。For example, the above-mentioned webpage engineering development framework may be Vue.js+Node.js, Spring+Node.js, React.js+Deno.js, etc.

本步骤中,所创建的模板文件可以包括入口文件、主页文件、配置文件、页面路由文件等实现网页所需的各种文件的模板文件。In this step, the created template file may include template files of various files needed to realize the web page, such as an entry file, a home page file, a configuration file, and a page routing file.

具体的,可以通过以下方式创建网页工程文件的模板文件。Specifically, the template file of the webpage project file can be created in the following manner.

一种实施方式中,电子设备可以响应于工作人员输入的模板文件创建指令,调用网页工程开发框架,在预先设定的默认路径下创建网页工程文件的模板文件。In one embodiment, the electronic device may respond to the template file creation instruction input by the staff, call the webpage project development framework, and create the template file of the webpage project file under the preset default path.

另一种实施方式中,电子设备可以获取工作人员输入的路径和模板文件的文件名称,然后调用网页工程开发框架,基于上述路径和文件名称创建网页工程文件的模板文件。具体实施方式详见后续实施例,这里暂不详述。In another implementation manner, the electronic device may obtain the path and the file name of the template file input by the staff, and then invoke the web page project development framework to create a template file of the web page project file based on the above path and file name. For specific implementation details, refer to subsequent embodiments, which will not be described in detail here.

需要说明的是,本公开实施例并不严格限定上述步骤S301的执行时机,具体的,上述步骤S301可以在步骤S305执行之前的任意时刻执行。It should be noted that the embodiment of the present disclosure does not strictly limit the execution timing of the above-mentioned step S301, specifically, the above-mentioned step S301 may be executed at any time before the execution of the step S305.

例如,上述步骤S301可以在步骤S302-步骤S304之前执行,也可以在步骤S302-步骤S304之后执行,还可以与步骤S302-步骤S304并行执行。For example, the above step S301 may be performed before step S302-step S304, may also be performed after step S302-step S304, and may also be performed in parallel with step S302-step S304.

步骤S302:从网页设计稿文件中提取第一网页元素的第一属性信息。Step S302: Extract the first attribute information of the first webpage element from the webpage design draft file.

网页设计稿文件也可以被称为网页UI(User Interface,用户界面)稿、网页原型稿等。The webpage design draft file may also be called a webpage UI (User Interface, user interface) draft, a webpage prototype draft, and the like.

本公开实施例不限定网页设计稿文件的文件类型,网页设计稿文件可以是任意记录有用于构建网页的网页元素,以及网页元素的属性信息的文件。The embodiment of the present disclosure does not limit the file type of the web page design draft file, and the web page design draft file may be any file in which web page elements used to construct web pages and attribute information of the web page elements are recorded.

例如,网页设计稿文件可以是PSD(Photoshop Document,Photoshop文档)文件、AI(Adobe Illustrator)文件、Sketch文件等。For example, the web design draft file may be a PSD (Photoshop Document, Photoshop document) file, an AI (Adobe Illustrator) file, a Sketch file, or the like.

上述网页元素也可以被称为网页组件、网页部件等,具体可以是导航栏、表单、轮播图、搜索框、复选框、下拉框、列表、页脚等各种构建网页所需的元素。The above-mentioned webpage elements can also be called webpage components, webpage components, etc., and can be specifically various elements needed to build webpages such as navigation bars, forms, carousels, search boxes, check boxes, drop-down boxes, lists, and page footers. .

根据网页设计稿文件的文件类型的不同,网页元素在网页设计稿文件种的呈现形式不同。大多数情况下,网页元素在网页设计稿文件中以图层的形式呈现,例如,1个或多个图层用于表示1个网页元素。According to the different file types of the web page design draft files, the presentation forms of the web page elements in the web page design draft files are different. In most cases, webpage elements are presented in the form of layers in the webpage design draft file, for example, one or more layers are used to represent one webpage element.

网页元素的属性信息可以是网页元素的元素标识、位置、尺寸、颜色、边框格式、透明度、激活状态、所展示的内容等各种与网页元素相关的信息。The attribute information of the webpage element may be various information related to the webpage element, such as the element identification, position, size, color, frame format, transparency, activation status, and displayed content of the webpage element.

本步骤中,可以基于网页设计稿文件的文件类型,采用已有的网页元素提取工具从网页设计稿文件中提取第一网页元素的第一属性信息。In this step, the first attribute information of the first webpage element may be extracted from the webpage design draft file by using an existing webpage element extraction tool based on the file type of the webpage design draft file.

例如,若网页设计稿文件为PSD文件,则可以采用PSD.rb等工具对PSD文件进行信息提取,得到PSD文件中记录的各图层对应的图层信息,作为第一网页元素的第一属性信息。For example, if the web page design draft file is a PSD file, you can use tools such as PSD.rb to extract information from the PSD file, and obtain the layer information corresponding to each layer recorded in the PSD file as the first attribute of the first web page element information.

又如,若网页设计稿文件为Sketch文件,则可以采用Sketch-to-html等插件对Sketch文件进行信息提取,得到Sketch文件中记录的各图层对应的图层信息,作为第一网页元素的第一属性信息。As another example, if the web page design draft file is a Sketch file, you can use plug-ins such as Sketch-to-html to extract information from the Sketch file, and obtain the layer information corresponding to each layer recorded in the Sketch file, as the first web page element. First attribute information.

其中,第一属性信息可以是具有目录结构的JSON(JavaScript Object Notation,JS对象简谱)数据,其中,JSON数据中每一节点对应于一个第一网页元素的第一属性信息;当然也可以是HTML等格式的数据,本公开对此不做限定。Wherein, the first attribute information may be JSON (JavaScript Object Notation, JS Object Notation) data with a directory structure, wherein each node in the JSON data corresponds to the first attribute information of a first webpage element; of course, it may also be HTML and other formats, which are not limited in this disclosure.

网页设计稿文件为其他类型的文件时,第一属性信息的提取方式与上述方式类似,这里不再一一举例。When the webpage design draft file is another type of file, the method of extracting the first attribute information is similar to the above method, and no more examples are given here.

步骤S303:基于所提取的第一属性信息,从已封装组件中,确定用于实现待生成的网页工程文件中包含的网页元素的目标组件。Step S303: Based on the extracted first attribute information, from the packaged components, determine a target component for realizing the webpage elements contained in the webpage project file to be generated.

上述已封装组件为预先封装的、用于实现各类网页元素的组件。The above-mentioned packaged components are pre-packaged components used to implement various web page elements.

需要说明的是,受网页设计稿文件的文件类型、从网页设计稿文件中提取信息的方式等影响,前述第一网页元素不一定与待生成的网页工程文件中包含的网页元素一一对应。It should be noted that, affected by the file type of the web page design draft file and the method of extracting information from the web page design draft file, the aforementioned first web page element does not necessarily correspond to the web page elements contained in the web page project file to be generated.

例如,可以是一个第一网页元素对应于一个待生成的网页工程文件中包含的网页元素,也可以是多个第一元素元素对应于一个待生成的网页工程文件中包含的网页元素。For example, one first webpage element may correspond to a webpage element contained in a webpage project file to be generated, or multiple first element elements may correspond to webpage elements contained in a webpage project file to be generated.

鉴于上述情况,可以采用以下方式确定用于实现待生成的网页工程文件中包含的网页元素的目标组件。In view of the above situation, the following manner can be used to determine the target component used to realize the webpage elements contained in the webpage project file to be generated.

一种实施方式中,在第一网页元素与待生成的网页工程文件中包含的网页元素一一对应的情况下,可以针对每一第一网页元素,读取其对应的第一属性信息中包含的元素标识,然后从已封装组件中确定上述元素标识对应的目标组件,作为用于实现待生成的网页工程文件中包含的网页元素的目标组件。In one embodiment, in the case of a one-to-one correspondence between the first web page element and the web page elements contained in the web page project file to be generated, for each first web page element, the corresponding first attribute information contained in the The element identification, and then determine the target component corresponding to the above element identification from the encapsulated components, as the target component for realizing the web page elements contained in the web page project file to be generated.

其中,可以将已封装组件中组件标识与上述元素标识相同的组件确定为目标组件,也可以根据预先记录的元素标识与已封装组件之间的对应关系,确定上述元素标识对应的目标组件。Among the packaged components, the component whose component ID is the same as the above-mentioned element ID can be determined as the target component, or the target component corresponding to the above-mentioned element ID can be determined according to the correspondence between the pre-recorded element ID and the packaged component.

另一种实施方式中,在第一网页元素与待生成的网页工程文件中包含的网页元素不是一一对应的情况下,可以先基于所提取的第一属性信息,确定待生成的网页工程文件中包含的第二网页元素,然后基于第二网页元素的第二属性信息,从已封装组件中确定用于实现第二网页元素的目标组件。具体实施方式详见后续图6所示实施例中步骤S603-步骤S605,这里暂不详述。In another embodiment, when the first webpage element is not in one-to-one correspondence with the webpage elements contained in the webpage project file to be generated, the webpage project file to be generated can be determined first based on the extracted first attribute information The second webpage element contained in the second webpage element, and then based on the second attribute information of the second webpage element, determine the target component for realizing the second webpage element from the packaged components. For specific implementation details, refer to step S603-step S605 in the subsequent embodiment shown in FIG. 6 , which will not be described in detail here.

步骤S304:基于所提取的第一属性信息,对所确定的目标组件进行信息设置。Step S304: Based on the extracted first attribute information, perform information setting on the determined target component.

从设置目标组件所依据的信息量的角度来说,本步骤中,可以基于所提取的全部第一属性信息对目标组件进行信息设置,也可以基于所提取的部分第一属性信息对目标组件进行信息设置。From the perspective of the amount of information on which the target component is set, in this step, the target component can be set based on all the first attribute information extracted, or the target component can be set based on part of the extracted first attribute information. information settings.

由前述说明可知,第一属性信息可以包含与第一网页元素相关的各种信息,设置目标组件所需的信息可能只是其中的一部分信息,也可能是全部信息。It can be seen from the foregoing description that the first attribute information may include various information related to the first webpage element, and the information required for setting the target component may be only a part of the information, or may be all of the information.

例如,组件A需要采用第一属性信息中的位置信息和尺寸信息进行信息设置,组件B需要采用第一属性信息中的边框格式和透明度进行信息色设置等。For example, component A needs to use the position information and size information in the first attribute information to set information, and component B needs to use the frame format and transparency in the first attribute information to set information color, etc.

从设置目标组件所依据的信息类型角度来说,可以通过以下方式对所确定的目标组件进行信息设置。From the perspective of the type of information on which the target component is set, information can be set for the determined target component in the following manner.

一种实施方式中,在第一网页元素与待生成的网页工程文件中包含的网页元素一一对应的情况下,针对每一第一网页元素,可以分别基于描述该第一网页元素的第一属性信息中包含的各类信息,对该第一网页元素对应的目标组件进行信息设置。In one embodiment, in the case of a one-to-one correspondence between the first webpage element and the webpage elements contained in the webpage project file to be generated, for each first webpage element, it may be based on the first Various types of information contained in the attribute information are used to set the information of the target component corresponding to the first webpage element.

另一种实施方式中,在第一网页元素与待生成的网页工程文件中包含的网页元素不是一一对应的情况下,可以先基于所提取的第一属性信息,确定出待生成的网页工程文件中包含的第二网页元素,然后基于所确定的第二网页元素对应的第二属性信息对目标组件进行信息设置。具体实施方式详见后续图6所示实施例,这里暂不详述。In another embodiment, when the first webpage element is not in one-to-one correspondence with the webpage elements contained in the webpage project file to be generated, the webpage project to be generated can be determined first based on the extracted first attribute information. The second webpage element included in the file, and then perform information setting on the target component based on the determined second attribute information corresponding to the second webpage element. For specific implementation details, refer to the embodiment shown in FIG. 6 , which will not be described in detail here.

从对目标组件的进行信息设置的流程的角度来说,可以通过以下方式对所确定的目标组件进行信息设置。From the perspective of the flow of information setting for the target component, the information setting for the determined target component can be performed in the following manner.

具体的,可以基于第一网页元素之间的次序关系,依次遍历各第一网页元素对应的第一属性信息,基于遍历到的目标属性信息,对其描述的网页元素对应的目标组件进行信息设置,在该网页元素存在子元素的情况下,将存在的子元素的属性信息确定为新的目标属性信息,返回基于遍历到的目标属性信息,对其描述的网页元素对应的目标组件进行信息设置的步骤。Specifically, based on the order relationship between the first webpage elements, the first attribute information corresponding to each first webpage element may be traversed sequentially, and based on the traversed target attribute information, information may be set for the target component corresponding to the described webpage element , in the case that the web page element has sub-elements, determine the attribute information of the existing sub-elements as the new target attribute information, return the target attribute information based on the traversal, and set the information of the target component corresponding to the web page element described by it A step of.

其中,上述次序关系可以基于第一网页元素在网页设计稿文件中被记录的先后顺序确定。Wherein, the above sequence relationship may be determined based on the order in which the first webpage elements are recorded in the webpage design draft file.

该实施方式的详细流程详见后续实施例,这里暂不详述。For the detailed process of this embodiment, refer to the subsequent embodiments, and will not be described in detail here.

步骤S305:将设置信息后的目标组件嵌入所创建的模板文件中,生成网页工程文件。Step S305: Embedding the target component after information setting into the created template file to generate a web page project file.

本步骤中,可以采用以下方式将设置信息后的目标组件嵌入所创建的模板文件中,生成网页工程文件。In this step, the following method can be used to embed the target component after information setting into the created template file to generate a webpage project file.

一种实施方式中,可以从所创建的模板文件中,确定用于承载目标组件的目标模板文件,将目标组件嵌入目标模板文件,生成网页工程文件。In one embodiment, the target template file for carrying the target component may be determined from the created template files, and the target component may be embedded in the target template file to generate a webpage project file.

另一种实施方式中,可以从所创建的模板文件中,确定用于承载第一目标组件的第一模板文件和用于承载第二目标组件的第二模板文件,将第一目标组件嵌入第一模板文件中,生成第一网页工程文件,并将第二目标组件嵌入第二模板文件中,生成第二网页工程文件。In another embodiment, the first template file for carrying the first target component and the second template file for carrying the second target component may be determined from the created template files, and the first target component may be embedded into the second target component. In a template file, a first web page project file is generated, and the second target component is embedded into the second template file to generate a second web page project file.

其中,第一目标组件为:基于网页元素的样式信息进行信息设置的目标组件,第二目标组件为:基于网页元素的内容信息进行信息设置的目标组件。Wherein, the first target component is: a target component for setting information based on the style information of the webpage element, and the second target component is: a target component for setting information based on the content information of the webpage element.

上述样式信息可以包括前述提及的位置、尺寸、透明度等,上述内容信息可以包括网页元素所需展示的文本、所需展示的图片的图片地址等。The above-mentioned style information may include the above-mentioned position, size, transparency, etc., and the above-mentioned content information may include the text to be displayed by the web page element, the picture address of the picture to be displayed, and the like.

下面对确定第一模板文件和第二模板文件的方式进行说明。The manner of determining the first template file and the second template file will be described below.

具体的,可以读取所创建模板文件中包含的文件类型标识,确定文件类型标识与第一目标组件的组件标识相匹配的目标文件,作为第一模板文件,并确定文件类型标识与第二目标组件的组件标识相匹配的目标文件,作为第二模板文件。Specifically, it is possible to read the file type identifier contained in the created template file, determine the target file whose file type identifier matches the component identifier of the first target component, as the first template file, and determine the file type identifier and the second target component The component ID matches the target file, as the second template file.

这样可以基于目标组件的类型,有条理的确定用于承载不同目标组件的模板文件,从而将目标组件嵌入对应的模板文件中,生成不同类别的独立网页工程文件,提高了各个单独的网页工程文件的可复用性。In this way, template files for carrying different target components can be determined in an orderly manner based on the type of the target component, so that the target components can be embedded in the corresponding template files to generate different types of independent web page project files, which improves the efficiency of each individual web page project file. of reusability.

由以上可见,应用本公开实施例提供的方案生成网页工程文件时,首先从网页设计稿文件中提取第一网页元素的第一属性信息,然后基于第一属性信息,从已封装组件中确定用于实现待生成的网页工程文件中包含的网页元素的目标组件,并且,基于所提取的第一属性信息对所确定的目标组件进行信息设置,进而可以将设置信息后的目标组件嵌入所创建的模板文件中,成功生成网页文件。It can be seen from the above that when applying the solution provided by the embodiment of the present disclosure to generate a webpage project file, first extract the first attribute information of the first webpage element from the webpage design draft file, and then determine the packaged components based on the first attribute information. To realize the target component of the web page element contained in the web page project file to be generated, and, based on the extracted first attribute information, perform information setting on the determined target component, and then the target component after the information setting can be embedded into the created In the template file, the web page file is successfully generated.

其中,本公开实施例所提供的方案是基于模板文件和已封装的组件生成第一网页文件的,具体的,基于从网页设计稿文件中提取的信息对组件进行设置,将设置信息后的模板组件嵌入模板文件即可生成网页文件。这样实现了从网页设计稿到网页工程文件的一站式自动转化,相较于开发人员基于包含标注的HTML文档编写代码的得到网页工程文件,省去了代码编写所需耗费的时间,有效减少了生成网页工程文件时的工作量和开发成本,提高了网页工程文件的生成效率。Among them, the solution provided by the embodiment of the present disclosure is to generate the first webpage file based on the template file and the packaged components. Specifically, the components are set based on the information extracted from the webpage design draft file, and the template after the information is set Components are embedded in template files to generate web page files. In this way, the one-stop automatic conversion from the web design draft to the web project file is realized. Compared with the web project file obtained by the developer who writes the code based on the HTML document containing the markup, it saves the time spent on code writing and effectively reduces the The workload and development cost of generating the web page project file are reduced, and the generation efficiency of the web page project file is improved.

本公开的一个实施例中,上述网页设计稿文件可以是记录有已封装组件能够实现的网页元素的属性信息的文件。In an embodiment of the present disclosure, the above-mentioned webpage design draft file may be a file that records attribute information of webpage elements that can be realized by the packaged components.

这样有利于使得网页设计稿文件中记录的网页元素均有对应的已封装组件可以实现,防止出现因已封装组件与网页设计稿文件中记录的网页元素不匹配,导致网页工程文件生成失败或者生成的网页工程文件中网页元素缺失的情况,提高了生成网页工程文件时的稳定性。This is beneficial to make the webpage elements recorded in the webpage design draft file have corresponding packaged components that can be realized, and prevent the occurrence of the mismatch between the packaged components and the webpage elements recorded in the webpage design draft file, resulting in failure to generate the webpage project file It improves the stability when generating web page project files when the web page elements are missing in the web page project files.

本公开的一个实施例中,上述已封装组件可以是由用户自行封装的组件。这样可以使得已封装组件的种类更加丰富多样、能够实现更多实际场景中所需实现的网页元素,提高了方案的泛用性。In an embodiment of the present disclosure, the above packaged components may be components packaged by users themselves. In this way, the types of packaged components can be enriched and varied, more webpage elements that need to be implemented in actual scenarios can be realized, and the versatility of the solution can be improved.

下面对步骤S301中创建模板文件的另一种实施方式进行说明。Another implementation manner of creating a template file in step S301 will be described below.

具体的,电子设备可以获取工作人员输入的路径和模板文件的文件名称,然后调用网页工程开发框架,基于上述路径和文件名称创建网页工程文件的模板文件。Specifically, the electronic device can obtain the path and the file name of the template file input by the staff, and then invoke the webpage project development framework to create a template file of the webpage project file based on the path and filename.

下面结合图4,对本实施方式所示的模板文件创建流程进行说明。The template file creation process shown in this embodiment will be described below with reference to FIG. 4 .

参见图4,为本公开实施例提供的一种模板文件创建流程的示意图,上述流程包括以下步骤S401-步骤S405。Referring to FIG. 4 , it is a schematic diagram of a template file creation process provided by an embodiment of the present disclosure. The above process includes the following steps S401 - S405.

步骤S401:获得输入的路径、名称。Step S401: Obtain the input path and name.

上述路径和名称即为工作人员输入的路径和模板文件的文件名称。The above path and name are the path and the file name of the template file entered by the staff.

步骤S402:进行路径拼接,得到模板文件的目标路径。Step S402: Concatenate the paths to obtain the target path of the template file.

具体的,可以将预设的路径前缀与所获得的路径和名称进行拼接,得到目标路径。Specifically, the preset path prefix may be spliced with the obtained path and name to obtain the target path.

例如,预设的路径前缀为server/action,所获得的路径和名称分别为components和school,那么进行路径拼接,可以得到的目标路径即为:server/action/components/school。For example, the preset path prefix is server/action, and the obtained path and name are components and school respectively. Then, after path concatenation, the target path that can be obtained is: server/action/components/school.

步骤S403:在目标路径下创建空文件。Step S403: Create an empty file under the target path.

步骤S404:加载配置文件,确定目标路径对应的模板内容。Step S404: Load the configuration file, and determine the template content corresponding to the target path.

配置(Config)文件中可以记录有模板文件和路径前缀之间的对应关系,因此,可以确定目标路径中的路径前缀,然后基于Config文件中记录的上述对应关系,确定目标路径对应的模板内容。The corresponding relationship between the template file and the path prefix can be recorded in the configuration (Config) file. Therefore, the path prefix in the target path can be determined, and then the template content corresponding to the target path can be determined based on the above-mentioned corresponding relationship recorded in the Config file.

步骤S405:加载模板内容,将模板内容写入所创建的空文件,得到模板文件。Step S405: Load the template content, write the template content into the created empty file, and obtain the template file.

下面以第一属性信息为JSON数据为例,结合图5对图3所示实施例中步骤S304提及的对目标组件进行信息设置的设置流程进行说明。Taking the first attribute information as JSON data as an example, the setting process of information setting for the target component mentioned in step S304 in the embodiment shown in FIG. 3 will be described below with reference to FIG. 5 .

参见图5,为本公开实施例提供的一种信息设置流程的示意图,上述流程包括以下步骤S501-步骤S508。Referring to FIG. 5 , it is a schematic diagram of an information setting process provided by an embodiment of the present disclosure. The above process includes the following steps S501 - S508.

步骤S501:设置当前节点为JSON数据中的根节点。Step S501: Set the current node as the root node in the JSON data.

JSON数据为树形结构,其中,每一节点对应于一个第一网页元素,因此,将当前节点设置为根节点,通过后续的循环遍历,相当于对JSON数据进行了前序遍历,从而遍历到各个节点对应的第一网页元素。JSON data is a tree structure, in which each node corresponds to a first web page element, therefore, setting the current node as the root node, through the subsequent loop traversal, is equivalent to pre-order traversal of the JSON data, thus traversing to The first webpage element corresponding to each node.

步骤S502:读取当前节点对应的第一属性信息。Step S502: Read the first attribute information corresponding to the current node.

本步骤中,当前节点对应的第一属性信息即为当前节点对应的第一网页元素的第一属性信息。In this step, the first attribute information corresponding to the current node is the first attribute information of the first webpage element corresponding to the current node.

一种情况下,在从JSON数据中读取当前节点对应的第一属性信息时,可以先将当前节点转化为对象,这样便于使用针对对象的操作读取节点对应的第一属性信息。In one case, when reading the first attribute information corresponding to the current node from the JSON data, the current node may be converted into an object first, so that it is convenient to read the first attribute information corresponding to the node by using the operation on the object.

步骤S503:基于第一属性信息对目标组件进行信息设置。Step S503: Perform information setting on the target component based on the first attribute information.

获得第一属性信息之后,可以对其描述的第一网页元素对应的目标组件进行信息设置。After the first attribute information is obtained, information can be set for the target component corresponding to the first web page element described by it.

具体的,可以对节点的节点标识(name)与目标组件的组件标识(name)进行匹配,将所对应的组件标识与当前节点的节点标识相同的组件确定为当前节点对应的目标组件,然后将组件中template内各填充项的默认值替换为当前节点对应的第一属性信息。Specifically, the node identifier (name) of the node can be matched with the component identifier (name) of the target component, and the component whose corresponding component identifier is the same as the node identifier of the current node is determined as the target component corresponding to the current node, and then The default value of each filling item in the template in the component is replaced with the first attribute information corresponding to the current node.

其中,针对template内的position(位置关系)填充项,可以将其默认值设置为relative(相对位置),若节点对应的第一属性信息包含有第一网页元素的尺寸和位置信息,则可以将上述默认值替换为absolute(绝对位置)。Among them, for the position (position relationship) filling item in the template, its default value can be set to relative (relative position), if the first attribute information corresponding to the node contains the size and position information of the first web page element, then you can set The above default value is replaced with absolute (absolute position).

步骤S504:判断当前节点是否存在子节点,若为是,执行步骤S505,若为否,结束流程。Step S504: Determine whether the current node has child nodes, if yes, execute step S505, if no, end the process.

当前节点存在子节点时,表示当前节点对应的第一网页元素存在子元素,因此,可以执行后续步骤,对子元素对应的目标组件进行信息设置。When the current node has sub-nodes, it means that the first webpage element corresponding to the current node has sub-elements. Therefore, subsequent steps may be performed to set information on the target component corresponding to the sub-elements.

步骤S505:设置i=0。Step S505: Set i=0.

步骤S506:判断i是否小于子节点数量,若为是,执行步骤S507,若为否,结束流程。Step S506: Determine whether i is less than the number of child nodes, if yes, execute step S507, if no, end the process.

本步骤用于保证各个子节点均被成功遍历。This step is used to ensure that each child node is successfully traversed.

步骤S507:将当前节点设置为子节点,执行步骤S508,并返回执行步骤S502。Step S507: Set the current node as a child node, execute step S508, and return to execute step S502.

本步骤中,将当前节点设置为子节点,并返回执行步骤S502,可以针对子节点,获得子节点对应的属性信息,并对子节点对应的目标组件进行信息设置。In this step, the current node is set as a sub-node, and the execution returns to step S502. For the sub-node, the attribute information corresponding to the sub-node can be obtained, and the information is set for the target component corresponding to the sub-node.

步骤S508:设置i=i+1,返回执行步骤S506。Step S508: set i=i+1, return to step S506.

可见,上述流程通过节点循环遍历的方式,可以对JSON数据中各节点对应的目标组件进行信息设置,也就是可以对各第一网页元素对应的目标组件进行信息设置。It can be seen that the above process can perform information setting on the target component corresponding to each node in the JSON data through node loop traversal, that is, information setting can be performed on the target component corresponding to each first webpage element.

在图3所示实施例的基础上,基于所提取的第一属性信息确定目标组件时,若第一网页元素与待生成的网页工程文件中包含的网页元素不是一一对应,则可以先基于所提取的第一属性信息,确定待生成的网页工程文件中包含的第二网页元素,然后基于第二网页元素的第二属性信息,从已封装组件中确定用于实现第二网页元素的目标组件。鉴于上述情况,本公开实施例提供了第二种网页工程文件生成方法。On the basis of the embodiment shown in Figure 3, when determining the target component based on the extracted first attribute information, if the first webpage element is not in one-to-one correspondence with the webpage elements contained in the webpage project file to be generated, then it can be based on The extracted first attribute information is used to determine the second webpage element contained in the webpage project file to be generated, and then based on the second attribute information of the second webpage element, it is determined from the packaged components to realize the goal of the second webpage element components. In view of the foregoing, the embodiment of the present disclosure provides a second method for generating a web page project file.

参见图6,为公开实施例提供的第二种网页工程文件生成方法的流程示意图,上述方法包括以下步骤S601-步骤S607。Referring to FIG. 6 , it is a schematic flowchart of a second method for generating a webpage project file provided by the disclosed embodiment. The above method includes the following steps S601 - S607.

步骤S601:调用网页工程开发框架,创建网页工程文件的模板文件。Step S601: calling the webpage project development framework to create a template file of the webpage project file.

步骤S602:从网页设计稿文件中提取第一网页元素的第一属性信息。Step S602: Extract the first attribute information of the first webpage element from the webpage design draft file.

上述步骤S601-步骤S602与前述图3所示实施例中步骤S301-步骤S302相同,这里不再赘述。The above step S601-step S602 is the same as step S301-step S302 in the embodiment shown in FIG. 3 above, and will not be repeated here.

步骤S603:基于所提取的第一属性信息,确定待生成的网页工程文件中包含的第二网页元素。Step S603: Based on the extracted first attribute information, determine the second web page element contained in the web page project file to be generated.

一种实施方式中,可以合并所对应的第一属性信息中元素标识相同的第一网页元素,然后确定合并处理后的第一网页元素为待生成的网页工程文件中包含的第二网页元素。In one embodiment, the corresponding first webpage elements with the same element ID in the first attribute information may be merged, and then the merged first webpage element is determined to be the second webpage element included in the webpage project file to be generated.

如果若干个第一网页元素对应的第一属性信息中元素标识相同,则可以认为这些第一网页元素在实际网页中对应于同一网页元素,因此,可以对这些第一网页元素进行合并处理。If the element identifiers in the first attribute information corresponding to several first webpage elements are the same, it can be considered that these first webpage elements correspond to the same webpage element in the actual webpage, and therefore, these first webpage elements can be merged.

由以上可见,通过将所对应的第一属性信息中元素标识相同的第一网页元素合并为第二网页元素,可以准确的将在实际网页中对应于同一网页元素的第一网页元素确定为第二网页元素,有利于避免后续针对元素标识相同的第一网页元素确定出重复的冗余目标组件,提高了后续确定目标组件时的合理性。It can be seen from the above that by merging the first webpage elements with the same element identifier in the corresponding first attribute information into the second webpage element, the first webpage element corresponding to the same webpage element in the actual webpage can be accurately determined as the second webpage element. The second webpage element helps to avoid repeated redundant target components being determined for the first webpage element with the same element identifier, and improves the rationality of subsequently determining the target component.

另一种实施方式中,可以从第一网页元素中剔除满足预设标准的第一网页元素,然后确定剔除处理后的第一网页元素为待生成的网页工程文件中包含的第二网页元素。In another implementation manner, the first webpage elements satisfying the preset standard may be eliminated from the first webpage elements, and then the eliminated first webpage elements are determined to be the second webpage elements included in the webpage project file to be generated.

上述预设标准可以是第一网页元素对应的第一属性信息为空、第一网页元素对应的第一属性信息内缺少位置和/或尺寸信息、第一网页元素对应的第一属性信息包含的位置和/或尺寸信息超出最大阈值等。The above preset standard may be that the first attribute information corresponding to the first webpage element is empty, the first attribute information corresponding to the first webpage element lacks position and/or size information, and the first attribute information corresponding to the first webpage element contains Position and/or size information exceeds maximum thresholds, etc.

这样可以剔除无法在网页中呈现或者在网页中呈现效果较差的第一网页元素,进而使得剔除处理后所确定的第二网页元素能够正常在网页中被呈现,有利于使得所生成的、包含第二网页元素的网页工程文件能够正常运行。In this way, the first webpage elements that cannot be rendered in the webpage or have a poor rendering effect in the webpage can be eliminated, so that the second webpage elements determined after the elimination process can be normally rendered in the webpage, which is beneficial to make the generated, including The webpage project file of the second webpage element can run normally.

步骤S604:获得所确定的第二网页元素的第二属性信息。Step S604: Obtain second attribute information of the determined second webpage element.

其中,第二属性信息包括:元素标识、样式信息、内容信息以及第二网页元素的子元素的元素信息。Wherein, the second attribute information includes: element identifier, style information, content information, and element information of sub-elements of the second web page element.

可以理解的是,针对仅对应一个第一网页元素的第二网页元素而言,其第二属性信息与其对应的第一网页元素的第一属性信息相同。It can be understood that, for a second webpage element corresponding to only one first webpage element, its second attribute information is the same as the first attribute information of its corresponding first webpage element.

因此,下面针对对应多个第一网页元素的第二网页元素,对上述第二网页元素的第二属性信息中包含的各种信息的获得方式进行说明。Therefore, the following describes how to obtain various information contained in the second attribute information of the second webpage elements corresponding to the second webpage elements corresponding to the plurality of first webpage elements.

1、元素标识1. Element identification

第二网页元素的元素标识可以是其对应的各第一网页元素的元素标识。The element identifier of the second webpage element may be the element identifier of each first webpage element corresponding thereto.

2、样式信息2. Style information

具体的,可以通过以下步骤A-步骤C获得第二网页元素的内容信息:Specifically, the content information of the second web page element can be obtained through the following steps A-C:

步骤A:获得该第二网页元素对应的各第一网页元素的网页区域的区域信息。Step A: Obtain the area information of the web page area of each first web page element corresponding to the second web page element.

其中,本公开实施例不限定区域信息的具体内容,区域信息可以是用于表征第一网页元素的网页区域的位置和尺寸的任意信息。Wherein, the embodiment of the present disclosure does not limit the specific content of the area information, and the area information may be any information used to characterize the position and size of the web page area of the first web page element.

例如,区域信息可以是上述网页区域的两个对角点的坐标,可以是上述网页区域的全部顶点的坐标,可以是上述网页区域的中心点坐标以及长、宽,还可以是上述网页区域的各边与网页边界的间距等。For example, the area information may be the coordinates of two diagonal points of the above-mentioned web page area, the coordinates of all vertices of the above-mentioned web page area, the center point coordinates and the length and width of the above-mentioned web page area, or the coordinates of the above-mentioned web page area. The distance between each side and the border of the page, etc.

步骤B:基于所获得的区域信息,确定覆盖该第二网页元素对应的所有第一网页元素的网页区域的目标区域信息。Step B: Based on the obtained area information, determine target area information covering the web page areas of all first web page elements corresponding to the second web page element.

同样的,本公开实施例也不限定基于所获得的区域信息确定目标区域信息的方式,下面通过举例进行说明。Likewise, the embodiment of the present disclosure also does not limit the manner of determining the target area information based on the obtained area information, which will be described below by using an example.

首先,基于所获得的区域信息可以较易的确定各第一网页元素的网页区域的位置和尺寸,如,若区域信息为顶点坐标,则可以基于顶点坐标计算各边的边长以及位置等。根据区域信息内容的不同,上述确定方式存在稍许不同,这里不再详述。First, based on the obtained area information, the position and size of the web page area of each first web page element can be easily determined. For example, if the area information is vertex coordinates, the length and position of each side can be calculated based on the vertex coordinates. Depending on the content of the area information, the above determination methods are slightly different, and will not be described in detail here.

然后,基于各第一网页元素的网页区域的位置和尺寸,可以确定上述网页区域的各边与网页边界的间距,然后分别从各边中,选择对应的间距最小的目标边,此时各目标边延长线所围成的区域即为覆盖该第二网页元素对应的所有第一网页元素的网页区域。此时,可以获得各边交点的坐标作为目标区域信息。Then, based on the position and size of the webpage area of each first webpage element, the distance between each side of the above-mentioned webpage area and the border of the webpage can be determined, and then from each side, select the corresponding target side with the smallest distance. At this time, each target The area surrounded by the edge extension lines is the web page area that covers all the first web page elements corresponding to the second web page element. At this time, the coordinates of the intersection points of each side can be obtained as target area information.

步骤C:依据目标区域信息,获得该第二网页元素的样式信息。Step C: Obtain the style information of the second webpage element according to the target area information.

得到目标区域信息之后,可以直接将目标区域信息作为第二网页元素的样式信息,当然,在目标区域信息不包含网页区域的边长的情况下,也可以基于目标区域信息先计算出网页区域的边长,然后将目标区域信息和计算得到的网页区域边长一同作为第二网页元素的样式信息。After obtaining the target area information, the target area information can be directly used as the style information of the second web page element. Of course, if the target area information does not include the side length of the web page area, the target area information can also be used to first calculate the width of the web page area. side length, and then use the target area information and the calculated side length of the web page area together as the style information of the second web page element.

可以看出,在第二网页元素对应于多个第一网页元素的情况下,应用本公开实施例提供的方案,可以确定覆盖该第二网页元素对应的所有第一网页元素的网页区域的目标区域信息,进而依据目标区域信息,可以准确的获得第二网页元素的样式信息,保证了合并后的第二网页元素可以正常的在网页中显示。It can be seen that, in the case where the second webpage element corresponds to multiple first webpage elements, by applying the solutions provided by the embodiments of the present disclosure, it is possible to determine the goal of covering the webpage area of all the first webpage elements corresponding to the second webpage element The area information, and further according to the target area information, can accurately obtain the style information of the second web page element, ensuring that the merged second web page element can be normally displayed in the web page.

3、内容信息3. Content information

具体的,可以通过以下步骤D-步骤F获得第二网页元素的内容信息:Specifically, the content information of the second webpage element can be obtained through the following steps D-F:

步骤D:从描述该第二网页元素对应的各第一网页元素的第一属性信息中提取图片地址。Step D: extracting the image address from the first attribute information describing the first webpage elements corresponding to the second webpage element.

上述图片地址可以指向文件存储目录,用于指示图片的存储位置。The above picture address may point to the file storage directory, which is used to indicate the storage location of the picture.

步骤E:获得所提取图片地址所对应图片的图片描述信息。Step E: Obtain the picture description information of the picture corresponding to the extracted picture address.

上述图片描述信息可以通过以下方式获得:The above image description information can be obtained in the following ways:

第一种方式,可以确定所提取图片地址对应的图片,然后对所确定图片进行文本识别,获得图片中的文本,作为图片描述信息。In the first manner, the picture corresponding to the extracted picture address may be determined, and then text recognition is performed on the determined picture to obtain the text in the picture as the picture description information.

其中,可以基于任意的OCR(Optical Character Recognition,光学字符识别)算法对图片进行文本识别,也可以基于预先训练的图片文本识别模型识别图片中的文本。Wherein, the text recognition of the picture may be performed based on any OCR (Optical Character Recognition, optical character recognition) algorithm, or the text in the picture may be recognized based on a pre-trained picture text recognition model.

第二种方式,可以确定所提取图片地址对应的图片,然后根据预先存储的图片与图片描述信息间的对应关系,获得所确定图片对应的图片描述信息。In the second manner, the picture corresponding to the extracted picture address may be determined, and then the picture description information corresponding to the determined picture may be obtained according to the pre-stored correspondence between the picture and the picture description information.

第三种方式,可以确定所提取图片地址对应的图片,然后对上述图片进行文本识别,获得图片中的文本,再对所获得的文本进行关键词提取,将提取所得的关键词填充至已有的描述信息模板中,得到图片描述信息。The third way is to determine the picture corresponding to the address of the extracted picture, then perform text recognition on the above picture to obtain the text in the picture, and then perform keyword extraction on the obtained text, and fill the extracted keywords into the existing The image description information is obtained from the description information template.

其中,可以基于任意的NLP(Natural Language Processing)算法识别文本中的关键词,也可以基于预先训练的关键词提取模型识别文本中的关键词。Among them, keywords in the text can be identified based on any NLP (Natural Language Processing) algorithm, and keywords in the text can also be identified based on a pre-trained keyword extraction model.

步骤F:基于所提取的图片地址和所获得的图片描述信息,获得该第二网页元素的内容信息。Step F: Obtain the content information of the second webpage element based on the extracted image address and the obtained image description information.

一种实施方式中,可以将所提取的图片地址和所获得的图片描述信息直接作为第二网页元素的内容信息。In one embodiment, the extracted picture address and the obtained picture description information can be directly used as the content information of the second webpage element.

另一种实施方式中,在所提取的图片地址和所获得的图片描述信息之外,还可以获得工作人员输入的配置信息,将图片地址、图片描述信息和配置信息一并作为第二网页元素的内容信息。In another embodiment, in addition to the extracted picture address and the obtained picture description information, configuration information input by the staff can also be obtained, and the picture address, picture description information and configuration information can be used together as the second webpage element content information.

其中,上述配置信息可以由工作人员根据实际情况添加,这样可以使得第二网页元素能够适用于不同落地场景。Wherein, the above configuration information can be added by the staff according to the actual situation, so that the second webpage element can be applied to different landing scenarios.

可以看出,在第二网页元素对应于多个第一网页元素的情况下,应用本公开实施例提供的方案,可以全面的获得第二网页元素对应的各第一网页元素的对应的图片和图片描述信息,从而可以实现将第一网页元素的内容信息合并,准确的获得第二网页元素的内容信息。It can be seen that, in the case where the second webpage element corresponds to multiple first webpage elements, by applying the solutions provided by the embodiments of the present disclosure, it is possible to comprehensively obtain the corresponding pictures and corresponding images of each first webpage element corresponding to the second webpage element. Image description information, so that the content information of the first web page element can be combined to accurately obtain the content information of the second web page element.

4、子元素的元素信息4. Element information of child elements

具体的,可以获得第二网页元素对应的各第一网页元素所包含的子元素的元素信息,将所获得的子元素信息作为该第二网页元素的子元素的元素信息。Specifically, the element information of the sub-elements contained in each first web page element corresponding to the second web page element may be obtained, and the obtained sub-element information may be used as the element information of the sub-elements of the second web page element.

步骤S605:基于所获得的第二属性信息,从已封装组件中,确定用于实现第二网页元素的目标组件。Step S605: Based on the obtained second attribute information, determine a target component for implementing the second web page element from the packaged components.

本步骤中,可以针对每一第二网页元素,读取其对应的第二属性信息中包含的元素标识,然后从已封装组件中确定上述元素标识对应的目标组件,作为用于实现第二网页元素的目标组件。In this step, for each second web page element, the element identification contained in its corresponding second attribute information can be read, and then the target component corresponding to the above element identification can be determined from the packaged components as a method for realizing the second web page The element's target component.

步骤S606:基于所获得的第二属性信息,对所确定的目标组件进行信息设置。Step S606: Based on the obtained second attribute information, perform information setting on the determined target component.

本步骤中,可以针对每一第二网页元素,可以分别基于描述该第一网页元素的第一属性信息中包含的样式信息、内容信息和子元素信息,对该第二网页元素对应的目标组件进行信息设置。In this step, for each second webpage element, the target component corresponding to the second webpage element can be performed based on the style information, content information and sub-element information contained in the first attribute information describing the first webpage element respectively. information settings.

对目标组件进行信息设置的具体流程可以在前述介绍的信息设置流程的基础上得到,区别仅为网页元素和网页元素对应的属性信息不同,这里不再赘述。The specific flow of information setting for the target component can be obtained on the basis of the information setting flow introduced above, the only difference is that the attribute information corresponding to the web page element is different from that of the web page element, and will not be repeated here.

步骤S607:将设置信息后的目标组件嵌入所创建的模板文件中,生成网页工程文件。Step S607: Embedding the target component after information setting into the created template file to generate a webpage project file.

上述步骤S607与前述图3所示实施例中步骤S305相同,这里不再赘述。The above step S607 is the same as the step S305 in the aforementioned embodiment shown in FIG. 3 , and will not be repeated here.

由以上可见,应用本公开实施例提供的方案生成网页工程文件时,在从网页设计稿文件中提取第一网页元素的第一属性信息之后,还基于所提取的第一属性信息,确定待生成的网页工程文件中包含的第二网页元素,进而获得第二网页元素的第二属性信息,基于第二属性信息进行组件选取和组件信息设置,最终生成网页工程文件。It can be seen from the above that when applying the solution provided by the embodiments of the present disclosure to generate a webpage project file, after extracting the first attribute information of the first webpage element from the webpage design draft file, it is also determined based on the extracted first attribute information to determine the The second webpage element included in the webpage project file, and then obtain the second attribute information of the second webpage element, perform component selection and component information setting based on the second attribute information, and finally generate the webpage project file.

其中,选取目标组件时是依据第二网页元素的第二属性信息选取的,这样可以使得目标组件与待生成的网页工程文件中包含的第二网页元素一一对应,有利于全面、准确的确定出用于实现各个第二网页元素的目标组件,进而基于所确定的目标组件,有利于生成包含用于实现各第二元素的目标组件的网页工程文件,提高所生成的网页工程文件的准确性。Wherein, when selecting the target component, it is selected according to the second attribute information of the second web page element, which can make the target component correspond to the second web page element contained in the web page project file to be generated, which is conducive to comprehensive and accurate determination The target components for realizing each second web page element are obtained, and then based on the determined target components, it is beneficial to generate a web page project file containing the target components for realizing each second element, and improve the accuracy of the generated web page project file .

下面再结合图7,本公开实施例提供的一种网页工程文件生成流程进行说明。The process of generating a web page project file provided by an embodiment of the present disclosure will be described below with reference to FIG. 7 .

参见图7,为本公开实施例提供的一种网页工程文件生成流程的示意图。Referring to FIG. 7 , it is a schematic diagram of a process for generating a webpage project file provided by an embodiment of the present disclosure.

由图7可见,首先,在已封装组件的基础上,可以依据组件信息获得PSD文件生成规则,进而得到PSD文件的生成规则文档,这样可以依据规则文档生成PSD文件,然后对PSD文件进行信息提取,获得PSDJSON数据,并对PSDJSON数据进行进一步优化,得到包含详细信息的OJSON数据,再基于OJSON数据对已封装组件中的目标组件进行信息设置,最终基于信息设置后的目标组件生成页面模板文件和页面数据文件。It can be seen from Figure 7 that, firstly, on the basis of the packaged components, the PSD file generation rules can be obtained according to the component information, and then the PSD file generation rule document can be obtained, so that the PSD file can be generated according to the rule document, and then the information can be extracted from the PSD file , obtain the PSDJSON data, and further optimize the PSDJSON data to obtain the OJSON data containing detailed information, then set the information of the target component in the packaged component based on the OJSON data, and finally generate the page template file and the target component based on the information setting page data file.

与上述网页工程文件生成方法相对应的,本公开实施例还提供了一种网页工程文件生成装置。Corresponding to the method for generating a web page project file, an embodiment of the present disclosure further provides a device for generating a web page project file.

参见图8,为本公开实施例提供的一种网页工程文件生成装置的结构示意图,上述装置包括以下模块801-模块805。Referring to FIG. 8 , it is a schematic structural diagram of an apparatus for generating a webpage project file provided by an embodiment of the present disclosure. The above apparatus includes the following modules 801 - 805 .

模板文件创建模块801,用于调用网页工程开发框架,创建网页工程文件的模板文件;Template file creation module 801, used to call the web page project development framework to create a template file of the web page project file;

第一属性信息提取模块802,用于从网页设计稿文件中提取第一网页元素的第一属性信息;The first attribute information extraction module 802 is used to extract the first attribute information of the first webpage element from the webpage design draft file;

目标组件确定模块803,用于基于所提取的第一属性信息,从已封装组件中,确定用于实现待生成的网页工程文件中包含的网页元素的目标组件;A target component determining module 803, configured to determine a target component for implementing the web page elements contained in the web page project file to be generated from the packaged components based on the extracted first attribute information;

信息设置模块804,用于基于所提取的第一属性信息,对所确定的目标组件进行信息设置;An information setting module 804, configured to perform information setting on the determined target component based on the extracted first attribute information;

文件生成模块805,用于将设置信息后的目标组件嵌入所创建的模板文件中,生成网页工程文件。The file generating module 805 is configured to embed the target component after information setting into the created template file to generate a webpage project file.

由以上可见,应用本公开实施例提供的方案生成网页工程文件时,首先从网页设计稿文件中提取第一网页元素的第一属性信息,然后基于第一属性信息,从已封装组件中确定用于实现待生成的网页工程文件中包含的网页元素的目标组件,并且,基于所提取的第一属性信息对所确定的目标组件进行信息设置,进而可以将设置信息后的目标组件嵌入所创建的模板文件中,成功生成网页文件。It can be seen from the above that when applying the solution provided by the embodiment of the present disclosure to generate a webpage project file, first extract the first attribute information of the first webpage element from the webpage design draft file, and then determine the packaged components based on the first attribute information. To realize the target component of the web page element contained in the web page project file to be generated, and, based on the extracted first attribute information, perform information setting on the determined target component, and then the target component after the information setting can be embedded into the created In the template file, the web page file is successfully generated.

其中,本公开实施例所提供的方案是基于模板文件和已封装的组件生成第一网页文件的,具体的,基于从网页设计稿文件中提取的信息对组件进行设置,将设置信息后的模板组件嵌入模板文件即可生成网页文件。这样实现了从网页设计稿到网页工程文件的一站式自动转化,相较于开发人员基于包含标注的HTML文档编写代码的得到网页工程文件,省去了代码编写所需耗费的时间,有效减少了生成网页工程文件时的工作量和开发成本,提高了网页工程文件的生成效率。Among them, the solution provided by the embodiment of the present disclosure is to generate the first webpage file based on the template file and the packaged components. Specifically, the components are set based on the information extracted from the webpage design draft file, and the template after the information is set Components are embedded in template files to generate web page files. In this way, the one-stop automatic conversion from the web design draft to the web project file is realized. Compared with the web project file obtained by the developer who writes the code based on the HTML document containing the markup, it saves the time spent on code writing and effectively reduces the The workload and development cost of generating the web page project file are reduced, and the generation efficiency of the web page project file is improved.

本公开的一个实施例中,所述目标组件确定模块803,包括:In one embodiment of the present disclosure, the target component determining module 803 includes:

第二网页元素确定子模块,用于基于所提取的第一属性信息,确定待生成的网页工程文件中包含的第二网页元素;The second webpage element determination submodule is used to determine the second webpage element contained in the webpage project file to be generated based on the extracted first attribute information;

第二属性信息获得子模块,用于获得所确定的第二网页元素的第二属性信息,其中,所述第二属性信息包括:元素标识、样式信息、内容信息以及第二网页元素的子元素的元素信息;The second attribute information obtaining sub-module is used to obtain the determined second attribute information of the second webpage element, wherein the second attribute information includes: element identification, style information, content information and sub-elements of the second webpage element element information;

目标组件确定子模块,用于基于所获得的第二属性信息,从已封装组件中,确定用于实现第二网页元素的目标组件;A target component determining submodule, configured to determine a target component for realizing the second webpage element from the packaged components based on the obtained second attribute information;

所述信息设置模块,具体用于基于所获得的第二属性信息,对所确定的目标组件进行信息设置。The information setting module is specifically configured to perform information setting on the determined target component based on the obtained second attribute information.

由以上可见,应用本公开实施例提供的方案生成网页工程文件时,在从网页设计稿文件中提取第一网页元素的第一属性信息之后,还基于所提取的第一属性信息,确定待生成的网页工程文件中包含的第二网页元素,进而获得第二网页元素的第二属性信息,基于第二属性信息进行组件选取和组件信息设置,最终生成网页工程文件。It can be seen from the above that when applying the solution provided by the embodiments of the present disclosure to generate a webpage project file, after extracting the first attribute information of the first webpage element from the webpage design draft file, it is also determined based on the extracted first attribute information to determine the The second webpage element included in the webpage project file, and then obtain the second attribute information of the second webpage element, perform component selection and component information setting based on the second attribute information, and finally generate the webpage project file.

其中,选取目标组件时是依据第二网页元素的第二属性信息选取的,这样可以使得目标组件与待生成的网页工程文件中包含的第二网页元素一一对应,有利于全面、准确的确定出用于实现各个第二网页元素的目标组件,进而基于所确定的目标组件,有利于生成包含用于实现各第二元素的目标组件的网页工程文件,提高所生成的网页工程文件的准确性。Wherein, when selecting the target component, it is selected according to the second attribute information of the second web page element, which can make the target component correspond to the second web page element contained in the web page project file to be generated, which is conducive to comprehensive and accurate determination The target components for realizing each second web page element are obtained, and then based on the determined target components, it is beneficial to generate a web page project file containing the target components for realizing each second element, and improve the accuracy of the generated web page project file .

本公开的一个实施例中,所述第二网页元素确定子模块,具体用于合并所对应的第一属性信息中元素标识相同的第一网页元素;确定合并处理后的第一网页元素为待生成的网页工程文件中包含的第二网页元素。In an embodiment of the present disclosure, the second webpage element determining submodule is specifically configured to merge the first webpage elements with the same element identifier in the corresponding first attribute information; determine that the merged first webpage element is to be The second web page element included in the generated web page project file.

由以上可见,通过将所对应的第一属性信息中元素标识相同的第一网页元素合并为第二网页元素,可以准确的将在实际网页中对应于同一网页元素的第一网页元素确定为第二网页元素,有利于避免后续针对元素标识相同的第一网页元素确定出重复的冗余目标组件,提高了后续确定目标组件时的合理性。It can be seen from the above that by merging the first webpage elements with the same element identifier in the corresponding first attribute information into the second webpage element, the first webpage element corresponding to the same webpage element in the actual webpage can be accurately determined as the second webpage element. The second webpage element helps to avoid repeated redundant target components being determined for the first webpage element with the same element identifier, and improves the rationality of subsequently determining the target component.

本公开的一个实施例中,在第二网页元素对应多个第一网页元素的情况下,按照以下方式获得该第二网页元素的样式信息:In one embodiment of the present disclosure, when the second webpage element corresponds to multiple first webpage elements, the style information of the second webpage element is obtained in the following manner:

获得该第二网页元素对应的各第一网页元素的网页区域的区域信息;基于所获得的区域信息,确定覆盖该第二网页元素对应的所有第一网页元素的网页区域的目标区域信息;依据所述目标区域信息,获得该第二网页元素的样式信息。Obtain the area information of the web page area of each first web page element corresponding to the second web page element; based on the obtained area information, determine the target area information covering the web page area of all the first web page elements corresponding to the second web page element; The target area information is to obtain the style information of the second webpage element.

可以看出,在第二网页元素对应于多个第一网页元素的情况下,应用本公开实施例提供的方案,可以确定覆盖该第二网页元素对应的所有第一网页元素的网页区域的目标区域信息,进而依据目标区域信息,可以准确的获得第二网页元素的样式信息,保证了合并后的第二网页元素可以正常的在网页中显示。It can be seen that, in the case where the second webpage element corresponds to multiple first webpage elements, by applying the solutions provided by the embodiments of the present disclosure, it is possible to determine the goal of covering the webpage area of all the first webpage elements corresponding to the second webpage element The area information, and further according to the target area information, can accurately obtain the style information of the second web page element, ensuring that the merged second web page element can be normally displayed in the web page.

本公开的一个实施例中,在第二网页元素对应多个第一网页元素的情况下,按照以下方式获得该第二网页元素的内容信息:In one embodiment of the present disclosure, when the second webpage element corresponds to multiple first webpage elements, the content information of the second webpage element is obtained in the following manner:

从描述该第二网页元素对应的各第一网页元素的第一属性信息中提取图片地址;获得所提取图片地址所对应图片的图片描述信息;基于所提取的图片地址和所获得的图片描述信息,获得该第二网页元素的内容信息。Extracting the picture address from the first attribute information describing the first webpage elements corresponding to the second webpage element; obtaining the picture description information of the picture corresponding to the extracted picture address; based on the extracted picture address and the obtained picture description information , to obtain the content information of the second web page element.

可以看出,在第二网页元素对应于多个第一网页元素的情况下,应用本公开实施例提供的方案,可以全面的获得第二网页元素对应的各第一网页元素的对应的图片和图片描述信息,从而可以实现将第一网页元素的内容信息合并,准确的获得第二网页元素的内容信息。It can be seen that, in the case where the second webpage element corresponds to multiple first webpage elements, by applying the solutions provided by the embodiments of the present disclosure, it is possible to comprehensively obtain the corresponding pictures and corresponding images of each first webpage element corresponding to the second webpage element. Image description information, so that the content information of the first web page element can be combined to accurately obtain the content information of the second web page element.

本公开的一个实施例中,所述文件生成模块805,具体用于从所创建的模板文件中,确定用于承载第一目标组件的第一模板文件和用于承载第二目标组件的第二模板文件,其中,所述第一目标组件为:基于网页元素的样式信息进行信息设置的目标组件,所述第二目标组件为:基于网页元素的内容信息进行信息设置的目标组件;将所述第一目标组件嵌入所述第一模板文件中,生成第一网页工程文件,并将所述第二目标组件嵌入第二模板文件中,生成第二网页工程文件。In an embodiment of the present disclosure, the file generating module 805 is specifically configured to determine, from the created template files, the first template file for carrying the first target component and the second template file for carrying the second target component. Template file, wherein the first target component is: a target component for setting information based on the style information of webpage elements, and the second target component is: a target component for setting information based on the content information of webpage elements; Embedding the first target component into the first template file to generate a first web page project file, and embedding the second target component into a second template file to generate a second web page project file.

这样可以基于目标组件的类型,有条理的确定用于承载不同目标组件的模板文件,从而将目标组件嵌入对应的模板文件中,生成不同类别的独立网页工程文件,提高了各个单独的网页工程文件的可复用性。In this way, template files for carrying different target components can be determined in an orderly manner based on the type of the target component, so that the target components can be embedded in the corresponding template files to generate different types of independent web page project files, which improves the efficiency of each individual web page project file. of reusability.

本公开的一个实施例中,所述网页设计稿文件为:记录有所述已封装组件能够实现的网页元素的属性信息的文件。In an embodiment of the present disclosure, the webpage design draft file is: a file recording attribute information of webpage elements that can be implemented by the packaged component.

这样有利于使得网页设计稿文件中记录的网页元素均有对应的已封装组件可以实现,防止出现因已封装组件与网页设计稿文件中记录的网页元素不匹配,导致网页工程文件生成失败或者生成的网页工程文件中网页元素缺失的情况,提高了生成网页工程文件时的稳定性。This is beneficial to make the webpage elements recorded in the webpage design draft file have corresponding packaged components that can be realized, and prevent the occurrence of the mismatch between the packaged components and the webpage elements recorded in the webpage design draft file, resulting in failure to generate the webpage project file It improves the stability when generating web page project files when the web page elements are missing in the web page project files.

根据本公开的实施例,本公开还提供了一种电子设备、一种可读存储介质和一种计算机程序产品。According to the embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.

本公开的一个实施例中,提供了一种电子设备,包括:In one embodiment of the present disclosure, an electronic device is provided, including:

至少一个处理器;以及at least one processor; and

与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,

所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行前述网页工程文件生成方法。The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor can execute the aforementioned method for generating a web page project file.

本公开的一个实施例中,提供了一种存储有计算机指令的非瞬时计算机可读存储介质,其中,所述计算机指令用于使所述计算机执行前述网页工程文件生成方法。In one embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the aforementioned method for generating a web page project file.

本公开的一个实施例中,提供了一种计算机程序产品,包括计算机程序,所述计算机程序在被处理器执行时实现前述网页工程文件生成方法。In one embodiment of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the aforementioned method for generating a web page project file is implemented.

图9示出了可以用来实施本公开的实施例的示例电子设备900的示意性框图。电子设备旨在表示各种形式的数字计算机,诸如,膝上型计算机、台式计算机、工作台、个人数字助理、服务器、刀片式服务器、大型计算机、和其它适合的计算机。电子设备还可以表示各种形式的移动装置,诸如,个人数字处理、蜂窝电话、智能电话、可穿戴设备和其它类似的计算装置。本文所示的部件、它们的连接和关系、以及它们的功能仅仅作为示例,并且不意在限制本文中描述的和/或者要求的本公开的实现。FIG. 9 shows a schematic block diagram of an example electronic device 900 that may be used to implement embodiments of the present disclosure. Electronic device is intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are by way of example only, and are not intended to limit implementations of the disclosure described and/or claimed herein.

如图9所示,设备900包括计算单元901,其可以根据存储在只读存储器(ROM)902中的计算机程序或者从存储单元908加载到随机访问存储器(RAM)903中的计算机程序,来执行各种适当的动作和处理。在RAM 903中,还可存储设备900操作所需的各种程序和数据。计算单元901、ROM 902以及RAM 903通过总线904彼此相连。输入/输出(I/O)接口905也连接至总线904。As shown in FIG. 9 , the device 900 includes a computing unit 901 that can execute according to a computer program stored in a read-only memory (ROM) 902 or loaded from a storage unit 908 into a random-access memory (RAM) 903. Various appropriate actions and treatments. In the RAM 903, various programs and data necessary for the operation of the device 900 can also be stored. The computing unit 901 , ROM 902 , and RAM 903 are connected to each other through a bus 904 . An input/output (I/O) interface 905 is also connected to the bus 904 .

设备900中的多个部件连接至I/O接口905,包括:输入单元906,例如键盘、鼠标等;输出单元907,例如各种类型的显示器、扬声器等;存储单元908,例如磁盘、光盘等;以及通信单元909,例如网卡、调制解调器、无线通信收发机等。通信单元909允许设备900通过诸如因特网的计算机网络和/或各种电信网络与其他设备交换信息/数据。Multiple components in the device 900 are connected to the I/O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a magnetic disk, an optical disk, etc. ; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 909 allows the device 900 to exchange information/data with other devices over a computer network such as the Internet and/or various telecommunication networks.

计算单元901可以是各种具有处理和计算能力的通用和/或专用处理组件。计算单元901的一些示例包括但不限于中央处理单元(CPU)、图形处理单元(GPU)、各种专用的人工智能(AI)计算芯片、各种运行机器学习模型算法的计算单元、数字信号处理器(DSP)、以及任何适当的处理器、控制器、微控制器等。计算单元901执行上文所描述的各个方法和处理,例如前述网页工程文件生成方法。例如,在一些实施例中,前述网页工程文件生成方法可被实现为计算机软件程序,其被有形地包含于机器可读介质,例如存储单元908。在一些实施例中,计算机程序的部分或者全部可以经由ROM 902和/或通信单元909而被载入和/或安装到设备900上。当计算机程序加载到RAM 903并由计算单元901执行时,可以执行上文描述的前述网页工程文件生成方法的一个或多个步骤。备选地,在其他实施例中,计算单元901可以通过其他任何适当的方式(例如,借助于固件)而被配置为执行前述网页工程文件生成方法。The computing unit 901 may be various general-purpose and/or special-purpose processing components having processing and computing capabilities. Some examples of computing units 901 include, but are not limited to, central processing units (CPUs), graphics processing units (GPUs), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processing processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 executes the various methods and processes described above, such as the aforementioned method for generating a webpage project file. For example, in some embodiments, the aforementioned method for generating a web page project file can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 908 . In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 900 via the ROM 902 and/or the communication unit 909 . When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the method for generating the webpage project file described above can be executed. Alternatively, in other embodiments, the computing unit 901 may be configured in any other appropriate way (for example, by means of firmware) to execute the aforementioned method for generating a web page project file.

本文中以上描述的系统和技术的各种实施方式可以在数字电子电路系统、集成电路系统、场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准产品(ASSP)、芯片上系统的系统(SOC)、复杂可编程逻辑设备(CPLD)、计算机硬件、固件、软件、和/或它们的组合中实现。这些各种实施方式可以包括:实施在一个或者多个计算机程序中,该一个或者多个计算机程序可在包括至少一个可编程处理器的可编程系统上执行和/或解释,该可编程处理器可以是专用或者通用可编程处理器,可以从存储系统、至少一个输入装置、和至少一个输出装置接收数据和指令,并且将数据和指令传输至该存储系统、该至少一个输入装置、和该至少一个输出装置。Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips Implemented in a system of systems (SOC), complex programmable logic device (CPLD), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include being implemented in one or more computer programs executable and/or interpreted on a programmable system including at least one programmable processor, the programmable processor Can be special-purpose or general-purpose programmable processor, can receive data and instruction from storage system, at least one input device, and at least one output device, and transmit data and instruction to this storage system, this at least one input device, and this at least one output device an output device.

用于实施本公开的方法的程序代码可以采用一个或多个编程语言的任何组合来编写。这些程序代码可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理器或控制器,使得程序代码当由处理器或控制器执行时使流程图和/或框图中所规定的功能/操作被实施。程序代码可以完全在机器上执行、部分地在机器上执行,作为独立软件包部分地在机器上执行且部分地在远程机器上执行或完全在远程机器或服务器上执行。Program codes for implementing the methods of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special purpose computer, or other programmable data processing devices, so that the program codes, when executed by the processor or controller, make the functions/functions specified in the flow diagrams and/or block diagrams Action is implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.

在本公开的上下文中,机器可读介质可以是有形的介质,其可以包含或存储以供指令执行系统、装置或设备使用或与指令执行系统、装置或设备结合地使用的程序。机器可读介质可以是机器可读信号介质或机器可读储存介质。机器可读介质可以包括但不限于电子的、磁性的、光学的、电磁的、红外的、或半导体系统、装置或设备,或者上述内容的任何合适组合。机器可读存储介质的更具体示例会包括基于一个或多个线的电气连接、便携式计算机盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦除可编程只读存储器(EPROM或快闪存储器)、光纤、便捷式紧凑盘只读存储器(CD-ROM)、光学储存设备、磁储存设备、或上述内容的任何合适组合。In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include one or more wire-based electrical connections, portable computer discs, hard drives, random access memory (RAM), read only memory (ROM), erasable programmable read only memory (EPROM or flash memory), optical fiber, compact disk read only memory (CD-ROM), optical storage, magnetic storage, or any suitable combination of the foregoing.

为了提供与用户的交互,可以在计算机上实施此处描述的系统和技术,该计算机具有:用于向用户显示信息的显示装置(例如,CRT(阴极射线管)或者LCD(液晶显示器)监视器);以及键盘和指向装置(例如,鼠标或者轨迹球),用户可以通过该键盘和该指向装置来将输入提供给计算机。其它种类的装置还可以用于提供与用户的交互;例如,提供给用户的反馈可以是任何形式的传感反馈(例如,视觉反馈、听觉反馈、或者触觉反馈);并且可以用任何形式(包括声输入、语音输入或者、触觉输入)来接收来自用户的输入。To provide for interaction with the user, the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user. ); and a keyboard and pointing device (eg, a mouse or a trackball) through which a user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and can be in any form (including Acoustic input, speech input or, tactile input) to receive input from the user.

可以将此处描述的系统和技术实施在包括后台部件的计算系统(例如,作为数据服务器)、或者包括中间件部件的计算系统(例如,应用服务器)、或者包括前端部件的计算系统(例如,具有图形用户界面或者网络浏览器的用户计算机,用户可以通过该图形用户界面或者该网络浏览器来与此处描述的系统和技术的实施方式交互)、或者包括这种后台部件、中间件部件、或者前端部件的任何组合的计算系统中。可以通过任何形式或者介质的数字数据通信(例如,通信网络)来将系统的部件相互连接。通信网络的示例包括:局域网(LAN)、广域网(WAN)和互联网。The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., as a a user computer having a graphical user interface or web browser through which a user can interact with embodiments of the systems and techniques described herein), or including such backend components, middleware components, Or any combination of front-end components in a computing system. The components of the system can be interconnected by any form or medium of digital data communication, eg, a communication network. Examples of communication networks include: Local Area Network (LAN), Wide Area Network (WAN) and the Internet.

计算机系统可以包括客户端和服务器。客户端和服务器一般远离彼此并且通常通过通信网络进行交互。通过在相应的计算机上运行并且彼此具有客户端-服务器关系的计算机程序来产生客户端和服务器的关系。服务器可以是云服务器,也可以为分布式系统的服务器,或者是结合了区块链的服务器。A computer system may include clients and servers. Clients and servers are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, a server of a distributed system, or a server combined with a blockchain.

应该理解,可以使用上面所示的各种形式的流程,重新排序、增加或删除步骤。例如,本公开中记载的各步骤可以并行地执行也可以顺序地执行也可以不同的次序执行,只要能够实现本公开公开的技术方案所期望的结果,本文在此不进行限制。It should be understood that steps may be reordered, added or deleted using the various forms of flow shown above. For example, each step described in the present disclosure may be executed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in the present disclosure can be achieved, no limitation is imposed herein.

上述具体实施方式,并不构成对本公开保护范围的限制。本领域技术人员应该明白的是,根据设计要求和其他因素,可以进行各种修改、组合、子组合和替代。任何在本公开的精神和原则之内所作的修改、等同替换和改进等,均应包含在本公开保护范围之内。The specific implementation manners described above do not limit the protection scope of the present disclosure. It should be apparent to those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made depending on design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present disclosure shall be included within the protection scope of the present disclosure.

Claims (17)

1. A webpage engineering file generation method comprises the following steps:
calling a webpage engineering development framework, and creating a template file of a webpage engineering file;
extracting first attribute information of a first webpage element from a webpage design draft file;
determining a target component for realizing the webpage elements contained in the webpage engineering file to be generated from the packaged components based on the extracted first attribute information;
setting information of the determined target component based on the extracted first attribute information;
And embedding the target component after the information is set into the created template file to generate a webpage engineering file.
2. The method of claim 1, wherein the determining, from the packaged components, a target component for implementing the web page element included in the web page project file to be generated based on the extracted first attribute information, includes:
determining a second webpage element contained in the webpage engineering file to be generated based on the extracted first attribute information;
obtaining second attribute information of the determined second webpage element, wherein the second attribute information comprises: element identification, style information, content information and element information of sub-elements of the second webpage element;
determining a target component for realizing the second webpage element from the packaged components based on the obtained second attribute information;
the information setting of the determined target component based on the extracted first attribute information includes:
and setting information of the determined target component based on the obtained second attribute information.
3. The method of claim 2, wherein the determining, based on the extracted first attribute information, the second web page element included in the web page project file to be generated includes:
Merging the first webpage elements with the same element identification in the corresponding first attribute information;
and determining the first webpage element after the merging processing as a second webpage element contained in the webpage engineering file to be generated.
4. The method of claim 2, wherein, in case that the second web page element corresponds to a plurality of first web page elements, style information of the second web page element is obtained as follows:
obtaining the area information of the webpage area of each first webpage element corresponding to the second webpage element;
determining target area information of the webpage area covering all the first webpage elements corresponding to the second webpage element based on the obtained area information;
and obtaining style information of the second webpage element according to the target area information.
5. The method of claim 2, wherein in the case that the second web page element corresponds to a plurality of first web page elements, the content information of the second web page element is obtained as follows:
extracting picture addresses from first attribute information describing each first webpage element corresponding to the second webpage element;
obtaining picture description information of a picture corresponding to the extracted picture address;
And obtaining the content information of the second webpage element based on the extracted picture address and the obtained picture description information.
6. The method of any of claims 1-5, wherein the embedding the set-up information target component in the created template file generates a web page engineering file, comprising:
determining a first template file for bearing a first target component and a second template file for bearing a second target component from the created template files, wherein the first target component is: the target component for setting information based on style information of the webpage element, wherein the second target component is as follows: a target component for setting information based on the content information of the webpage element;
embedding the first target component into the first template file to generate a first webpage engineering file, and embedding the second target component into a second template file to generate a second webpage engineering file.
7. The method according to any one of claims 1-5, wherein,
the webpage design draft file is as follows: and recording the file of the attribute information of the webpage element which can be realized by the packaged component.
8. A web page engineering file generating device, comprising:
The template file creating module is used for calling the webpage engineering development framework and creating a template file of the webpage engineering file;
the first attribute information extraction module is used for extracting first attribute information of a first webpage element from the webpage design draft file;
the target component determining module is used for determining a target component for realizing the webpage elements contained in the webpage engineering file to be generated from the packaged components based on the extracted first attribute information;
an information setting module for setting information of the determined target component based on the extracted first attribute information;
the file generation module is used for embedding the target component after the setting information into the created template file to generate the webpage engineering file.
9. The apparatus of claim 8, wherein the target component determination module comprises:
the second webpage element determining submodule is used for determining second webpage elements contained in the webpage engineering file to be generated based on the extracted first attribute information;
a second attribute information obtaining sub-module, configured to obtain the determined second attribute information of the second web page element, where the second attribute information includes: element identification, style information, content information and element information of sub-elements of the second webpage element;
A target component determining sub-module for determining a target component for implementing the second web page element from the packaged components based on the obtained second attribute information;
the information setting module is specifically configured to set information on the determined target component based on the obtained second attribute information.
10. The apparatus of claim 9, wherein,
the second webpage element determining submodule is specifically configured to combine first webpage elements with identical element identifiers in the corresponding first attribute information; and determining the first webpage element after the merging processing as a second webpage element contained in the webpage engineering file to be generated.
11. The apparatus of claim 9, wherein, in case that the second web page element corresponds to the plurality of first web page elements, style information of the second web page element is obtained as follows:
obtaining the area information of the webpage area of each first webpage element corresponding to the second webpage element;
determining target area information of the webpage area covering all the first webpage elements corresponding to the second webpage element based on the obtained area information;
and obtaining style information of the second webpage element according to the target area information.
12. The apparatus of claim 9, wherein in case that the second web page element corresponds to a plurality of first web page elements, the content information of the second web page element is obtained as follows:
extracting picture addresses from first attribute information describing each first webpage element corresponding to the second webpage element;
obtaining picture description information of a picture corresponding to the extracted picture address;
and obtaining the content information of the second webpage element based on the extracted picture address and the obtained picture description information.
13. The device according to any one of claims 8-12, wherein,
the file generation module is specifically configured to determine, from the created template files, a first template file for carrying a first target component and a second template file for carrying a second target component, where the first target component is: the target component for setting information based on style information of the webpage element, wherein the second target component is as follows: a target component for setting information based on the content information of the webpage element; embedding the first target component into the first template file to generate a first webpage engineering file, and embedding the second target component into a second template file to generate a second webpage engineering file.
14. The device according to any one of claims 8-12, wherein,
the webpage design draft file is as follows: and recording the file of the attribute information of the webpage element which can be realized by the packaged component.
15. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-7.
16. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-7.
17. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-7.
CN202310274316.9A 2023-03-17 2023-03-17 Webpage engineering file generation method and device, electronic equipment and storage medium Pending CN116301753A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310274316.9A CN116301753A (en) 2023-03-17 2023-03-17 Webpage engineering file generation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310274316.9A CN116301753A (en) 2023-03-17 2023-03-17 Webpage engineering file generation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116301753A true CN116301753A (en) 2023-06-23

Family

ID=86825360

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310274316.9A Pending CN116301753A (en) 2023-03-17 2023-03-17 Webpage engineering file generation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116301753A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106293690A (en) * 2015-06-29 2017-01-04 阿里巴巴集团控股有限公司 A kind of method and device of formation component object
US20170090734A1 (en) * 2014-05-14 2017-03-30 Pagecloud Inc. Methods and systems for web content generation
CN110795666A (en) * 2019-10-18 2020-02-14 腾讯科技(深圳)有限公司 Webpage generation method, device, terminal and storage medium
CN112528619A (en) * 2020-12-23 2021-03-19 微医云(杭州)控股有限公司 Page template file generation method and device, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170090734A1 (en) * 2014-05-14 2017-03-30 Pagecloud Inc. Methods and systems for web content generation
CN106293690A (en) * 2015-06-29 2017-01-04 阿里巴巴集团控股有限公司 A kind of method and device of formation component object
CN110795666A (en) * 2019-10-18 2020-02-14 腾讯科技(深圳)有限公司 Webpage generation method, device, terminal and storage medium
CN112528619A (en) * 2020-12-23 2021-03-19 微医云(杭州)控股有限公司 Page template file generation method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
US11734939B2 (en) Vision-based cell structure recognition using hierarchical neural networks and cell boundaries to structure clustering
CN113204615B (en) Entity extraction methods, devices, equipment and storage media
CN110096275B (en) Page processing method and device
US20250156411A1 (en) Large language model-based question processing method and apparatus, electronic device, and storage medium
CN115809325A (en) Document processing model training method, document processing method, device and equipment
CN119066177A (en) A policy interpretation method, device, equipment, medium and product
JP7309811B2 (en) Data annotation method, apparatus, electronics and storage medium
CN114495147A (en) Identification method, device, equipment and storage medium
CN113407745A (en) Data annotation method and device, electronic equipment and computer readable storage medium
CN117407468A (en) Method and device for displaying generated content, electronic equipment and storage medium
CN114254585B (en) Font generation method and device, electronic equipment and storage medium
CN114398138B (en) Interface generation method, device, computer equipment and storage medium
US9996511B2 (en) Free form website structure design
CN114492331B (en) Rich text editing method, device, electronic device, storage medium and product
CN114912046A (en) Method and device for generating page
CN112947916B (en) Method, apparatus, device and storage medium for implementing online canvas
CN120031015A (en) Method, device, electronic device and medium for generating presentation based on large model
CN116301753A (en) Webpage engineering file generation method and device, electronic equipment and storage medium
CN118552969A (en) Image detection method, image recognition method, device, electronic device, storage medium and program product based on large language model
CN114416030B (en) Data processing method, device, equipment, storage medium and program product
CN114880242A (en) Test case extraction method, device, equipment and medium
CN114489639A (en) File generation method, device, device and storage medium
CN114500505A (en) Text processing method, apparatus and electronic device
CN113343636B (en) Method, device, electronic equipment and storage medium for setting marking line width
US12175574B2 (en) Image creation with positioning of recreated text and shapes

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