A method and device for generating web pages, and storage medium
By generating code files that are adapted to different page layouts and application environments, the problems of low web page development efficiency and multi-application scenario display requirements in the existing technology are solved, and efficient web page adaptive layout and multi-terminal display are achieved.
Patent Information
- Application Number
- CN202010747406.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-29
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-07-29
AI Technical Summary
The development of existing web pages has problems of low efficiency and poor quality, and cannot adapt to the display needs of multiple page layouts and multiple application scenarios.
By obtaining the target web page parameters corresponding to the target task script, a first code file is generated that is suitable for different page layouts, and a second code file is generated that is suitable for different application environments in combination with the target application environment, so as to realize the adaptive layout of the web page and multi-terminal page display.
It improves the efficiency and performance of web page development, meets the needs of web page display in different layouts in multiple application scenarios, and realizes the adaptive layout and multi-terminal display of web pages.
Smart Images

Figure CN114063996B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating a web page, and a storage medium. Background Art
[0002] Under the wave of the Internet, various websites have sprung up like mushrooms after a rain, and the business of various companies has also begun to develop online, so that more customers can be attracted through well-planned and beautiful web pages. In addition, with the rapid development of electronic technology, a large number of development needs for web page display have also emerged, such as desktop browsers, the fifth generation Hypertext Markup Language (Hyper Text Markup Language, H5), WeChat applets, etc.
[0003] However, the development of existing web pages is limited by the technical level of developers, and has the defects of low efficiency and poor quality of web page development. It only supports the fixed-size web page generation mode on the desktop browser side, which not only causes the generated web pages to be unable to adapt to a variety of page layouts, but also cannot meet the development needs of web page display in multiple application scenarios. Summary of the invention
[0004] The embodiments of the present application provide a method and device for generating a web page, and a storage medium, which are mainly used to solve the problem that the generated web page cannot support adaptive layout and cannot be applied to multiple application scenarios during the development process of existing web pages.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for generating a web page, the method comprising:
[0007] Obtaining target web page parameters corresponding to the target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated;
[0008] Generate a first code file according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts;
[0009] Generate a second code file based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments;
[0010] A target page corresponding to the target application environment is generated according to the second code file.
[0011] In a second aspect, an embodiment of the present application provides a device for generating a web page, the device comprising an acquisition unit and a generation unit.
[0012] The acquisition unit is used to acquire target web page parameters corresponding to the target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated;
[0013] The generating unit is configured to generate a first code file according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts; and generate a second code file based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments; and generate a target page corresponding to the target application environment according to the second code file.
[0014] In a third aspect, an embodiment of the present application provides a device for generating a web page, the device comprising a processor and a memory storing instructions executable by the processor, and when the instructions are executed by the processor, the method for generating a web page as described above is implemented.
[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a program stored thereon, which is applied to a device for generating a web page. When the program is executed by a processor, the method for generating a web page as described above is implemented.
[0016] The embodiment of the present application provides a method and device for generating a web page, and a storage medium, wherein the device for generating a web page obtains target web page parameters corresponding to a target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated; a first code file is generated according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts; a second code file is generated based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments; and a target page corresponding to the target application environment is generated according to the second code file. That is to say, in the embodiment of the present application, the device for generating a web page not only generates a source code file that can adapt to page display of different layouts by executing the target compilation task corresponding to the target web page parameter, but also generates a target code file that can display a web page in the target application environment by combining the source code file with the target application environment, thereby realizing the adaptive layout of the web page, and supporting multi-terminal page display, further meeting the development requirements of web page display of different layouts in multiple application scenarios, and having higher web page development efficiency and better performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Schematic diagram of the composition structure of the device for generating a web page proposed in the embodiment of the present application Figure 1 ;
[0018] Figure 2 A schematic diagram of the implementation flow of the method for generating a web page proposed in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of an exemplary data structure of an HTML node proposed in an embodiment of the present application;
[0020] Figure 4 Schematic diagram of the composition structure of the device for generating a web page proposed in the embodiment of the present application Figure 2 ;
[0021] Figure 5 Schematic diagram of the composition structure of the device for generating a web page proposed in the embodiment of the present application Figure 3 . DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. It is understood that the specific embodiments described herein are only used to explain the related applications, rather than to limit the applications. It should also be noted that, for ease of description, only the parts related to the related applications are shown in the drawings.
[0023] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are subject to the following interpretations.
[0024] 1) Hypertext Markup Language (HTML): It is a widely used markup language for describing web documents. It uses tags to mark the various parts of the web page to be displayed. The web page file itself is a text file. That is to say, by adding tags to the text file, you can tell the browser how to display the content (such as how to process text, how to arrange pictures, how to display pictures, etc.).
[0025] 2) Cascading Style Sheets (CSS): usually used to design the style of a web page (for example, if you want the link text to be blue when it is not clicked, and turn red and underlined when the mouse moves over it, this is a style). By setting up a cascading style sheet CSS document, you can uniformly control the display properties of each part of an HTML web page document, making it easier for developers to control the appearance of the web page more effectively.
[0026] 3) JavaScript: A client-side scripting language based on objects and events and relatively safe. It is also a scripting language widely used in client-side Web development, often used to add dynamic functions to HTML web pages, such as responding to various user operations. Furthermore, with JavaScript, you can reconstruct the entire HTML document, and add, remove, change or rearrange items on the page.
[0027] 4) Document Object Model (DOM): It can access and modify the content and structure of a document in a platform- and language-independent way. It is a common method for representing and processing HTML. DOM is actually a document model described in an object-oriented way, defining the objects required to represent and modify documents, the behaviors and properties of these objects, and the relationships between these objects. To change something on the page, JavaScript needs to obtain access to all elements in the HTML document. This access, along with methods and properties for adding, moving, changing, or removing HTML elements, are all obtained through DOM.
[0028] At present, the development of existing web pages is limited by the technical level of developers, and has the defects of low efficiency and poor quality of web page development. In addition, it only supports the fixed-size web page generation mode on the desktop browser side, which not only causes the generated web pages to be unable to adapt to a variety of page layouts, but also cannot meet the development needs of web page display in multiple application scenarios.
[0029] In order to solve the problems existing in the existing mechanism for generating web pages, the embodiments of the present application provide a method and device for generating web pages, and a storage medium. Specifically, the device for generating web pages not only generates a source code file that can adapt to page displays of different layouts by executing a target compilation task corresponding to the target web page parameters, but also combines the source code file with the target application environment to generate a target code file that can display the web page in the target application environment, thereby realizing the adaptive layout of web pages and supporting multi-terminal page display, further meeting the development needs of web page displays of different layouts in multiple application scenarios, and achieving higher web page development efficiency and better performance.
[0030] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0031] An embodiment of the present application provides a method for generating a web page. The method for generating a web page is applied to Figure 1 An apparatus 100 for generating a web page is shown. Figure 1 Schematic diagram of the composition structure of the device for generating a web page proposed in the embodiment of the present application Figure 1 ,like Figure 1 As shown, the device 100 for generating a web page includes: a data configuration module 101, a task control module 102, a design draft data conversion module 103, a data analysis and generation source code module 104, a source code compilation module 105, and a code download module 106. Among them, the data configuration module 101 enters the web page parameters corresponding to the web page to be generated, including: the name of the web page, the design draft source file, the supported CSS language, the supported JavaScript language, the supported application environment and other information into the database, and automatically generates the corresponding compilation task script; the main function of the task control module 102 is to provide interfaces such as starting, pausing and deleting the task process, so as to realize the control of the corresponding task process in the compilation task script generated by the data configuration module 101; the design draft data conversion module 103 mainly traverses all the element information corresponding to the above-mentioned design draft source file in the process of executing the task process corresponding to the compilation task script, and further establishes a virtual DOM tree corresponding to the design draft source file; The source code generation module 104 generates a source code file that can adapt to page displays of different layouts through the above-mentioned virtual DOM tree, and the supported CSS language and supported JavaScript language included in the web page parameters; the source code compilation module 105 combines the source code file generated by the data parsing source code generation module 104 with the application environment supported by the above-mentioned web page parameters to generate a target code file that can display the web page in the application environment; the code download module 106 is after uploading the above-mentioned generated source code file and target code file to the Web server, the source code file and the target code file can be downloaded through the download entrance of the code download module 106, and the web page can be viewed through the preview entrance of the code download module 106.
[0032] Figure 2 This is a schematic diagram of the implementation flow of the method for generating a web page proposed in the embodiment of the present application, such as Figure 2 As shown, in an embodiment of the present application, the method for generating a web page by a device for generating a web page may include the following steps:
[0033] Step 1001, obtaining target web page parameters corresponding to the target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated.
[0034] In an embodiment of the present application, the terminal may first obtain target web page parameters corresponding to the target task script, wherein the target web page parameters include target source files, markup languages, and target application environments, and the target task script is generated according to the web page parameters of the web page to be generated.
[0035] It should be noted that, in an embodiment of the present application, a device for generating web pages can obtain multiple sets of web page parameter information required for generating web pages, and enter these web page parameters into a database. Specifically, the information corresponding to each set of web page parameters is different. When it is necessary to generate a task script, a corresponding set of web page parameters can be obtained from the database, and a task script corresponding to the set of web page parameters can be automatically generated. Accordingly, multiple task scripts can be generated based on multiple sets of web page parameters, wherein each set of web page parameters corresponds to a task script.
[0036] Specifically, in the embodiment of the present application, each set of web page parameters mainly includes information such as design draft source files, markup languages, and application environments. Optionally, the markup languages may be CSS languages and JavaScript languages. Further, the web page parameters also include the name of the corresponding web page to be generated. The data configuration module 101 enters web page parameters such as the name of the web page to be generated, the design draft source files, the supported CSS languages, the supported JavaScript languages, and the supported application environments into the database, and generates the corresponding task script.
[0037] Optionally, in an embodiment of the present application, at least one initial task script can be different task scripts generated based on the same design draft source file and markup language, and different application environments. According to the needs of the developer, if the web page with the same content is to be displayed in different application environments, then multiple task scripts corresponding to different application environments can be generated based on the same design draft source file and different application environments, and further one of the task scripts can be selected to execute according to the needs of the developer to complete the compilation task.
[0038] Optionally, the design draft source file can be a web design file pre-provided by a web designer and read locally by the device generating the web page, or the web design file can be read remotely from other locations through a wired network or a wireless network. At the same time, the design draft source file can also be generated by an image processing tool. For example, the image processing tool can be PhotoShop, Sketch, etc. The design draft source file can be a PSD file in a Photoshop-specific format obtained by processing each material included in the web page to be generated using PhotoShop, or a Sketch file in a Sketch-specific format obtained by processing each material included in the web page using Sketch.
[0039] It should be noted that, in an embodiment of the present application, the task control module 102 is used to determine the target task script and further start the compilation process corresponding to the target task script. Specifically, since different task scripts have different identification information, after receiving the start instruction, the task control module 102 obtains the task identification carried by the start instruction, and can determine the target task script corresponding to the task identification from at least one initial task script based on the task identification, and further start the compilation process corresponding to the target task script; wherein the target task script is generated according to the web page parameters of the web page to be generated.
[0040] Specifically, in an embodiment of the present application, when executing a task script, the information of the compiling page tasks corresponding to all task scripts, the status of the compiling task process, and the received operation instruction related information will be displayed in the corresponding monitoring system list. Optionally, the monitoring system list function can be implemented by a background program operation management system integrated on the device generating the web page, or it can be implemented by other auxiliary devices that have the function of viewing the detailed process information of the executing task script and are independent of the device generating the web page. After viewing the information and status of the compiling process corresponding to the compiling task through the monitoring system list, the user can perform the target operation, such as opening, pausing, and deleting, so that the corresponding task script can be further executed through the task control module 102.
[0041] Further, in an embodiment of the present application, the task control module 102 can also implement the suspension and deletion of the compilation task process. Similarly to receiving the start instruction and determining the target task script from at least one initial task script based on the task identifier carried by the start instruction, the task control module can also receive operation instructions such as the pause instruction or the delete instruction corresponding to the target task script, and then delete the compilation task process corresponding to the target task script, or suspend the compilation process corresponding to the target task script according to the pause instruction during the execution of the compilation task process corresponding to the target task script. Specifically, when receiving the delete instruction corresponding to the target task script and executing the deletion operation, the compilation task process corresponding to the target task script must be in an unstarted or suspended state, and then the target task script and the corresponding compilation task process are deleted.
[0042] It should be noted that, in an embodiment of the present application, after determining the target task script from at least one initial task script according to the start instruction, it is necessary to execute the target task script to start the task process corresponding to the target task script. Specifically, in the process of executing the target task script, it is necessary to first determine the target web page parameters corresponding to the target task script, that is, one of the at least one set of web page parameters mentioned above, that is, the design draft source file corresponding to the target task script, the supported CSS language, the supported JavaScript language, the supported application environment and other information.
[0043] Furthermore, after obtaining the target web page parameters corresponding to the target task script, a code file corresponding to the page may be further generated based on the target parameters.
[0044] Step 1002: Generate a first code file according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts.
[0045] In an embodiment of the present application, after obtaining the target web page parameters corresponding to the target task script, the next compilation task process in the target task script is continued to be executed, that is, a first code file can be generated according to the target source file and markup language in the target web page parameters, wherein the first code file is used to adapt to page displays of different layouts.
[0046] It should be noted that, in an embodiment of the present application, the design draft conversion module 103 and the data parsing source code generation module 104 generate a first code file based on the target source file and the markup language. Specifically, the design draft conversion module 103 can first create a virtual DOM tree corresponding to the target source file, and then the data parsing source code generation module 104 combines the virtual DOM tree generated by the design draft conversion module 103 with the markup language in the target web page parameters to generate a first code file that can adapt to page displays of different layouts.
[0047] Specifically, in an embodiment of the present application, the design draft conversion module 103 first parses the target source file, obtains the initial data corresponding to the target source file, that is, all element information in the target source file, which element information is not limited to lists, buttons, pictures, text or links, etc., traverses all element information in the target source file, creates a virtual DOM node corresponding to each element information, and constructs a virtual DOM tree corresponding to all element information of the target source file based on multiple virtual DOM nodes.
[0048] Optionally, in an embodiment of the present application, in order to better maintain web pages, a virtual DOM tree can be constructed based on JavaScript. Specifically, after the target source file is loaded into the HTML document, the HTML file corresponding to the target source file can be traversed. In the HTML file, each element information of the target source file corresponds to a file tag, and the information of each text tag can be extracted. The virtual DOM node is created using the object literal writing method, that is, the element information corresponding to each file tag is represented in the form of a JavaScript object. Each virtual DOM node contains attribute feature parameters corresponding to each element information, and multiple virtual DOM nodes constitute a virtual DOM tree corresponding to the target source file.
[0049] For example, Figure 3 This is a schematic diagram of an exemplary data structure of an HTML node proposed in an embodiment of the present application, such as Figure 3 As described above, an HTML node of the current page includes more than two hundred attributes and methods, that is, all the element information contained in the page, which is a very large data structure. By traversing all the attributes and methods contained in an HTML node, a virtual DOM node corresponding to each attribute and method can be generated. Each virtual DOM node is a JavaScript object, and multiple virtual DOM nodes constitute a virtual DOM tree. The virtual DOM structure data JavaScript object corresponding to the HTML node of the current page is collected. Optionally, a JSON data file can be further generated and stored in a database.
[0050] Optionally, in an embodiment of the present application, virtual DOM nodes include three types of DOM nodes: document div, image img, and custom components. Among them, the nodes of div document type and img image type correspond to the text content and picture content in the design draft source file, respectively. Sometimes, in response to developer needs, in order to improve the efficiency of web page generation, the technical staff will store some elements in the design draft source file, such as table, button, etc. corresponding element information in advance into the database, that is, these elements are used as components, and each component is assigned a corresponding component identification (Identity document, ID), then read all data of all components, associate the position of the component and the ID of the component, write the component into the database, that is, establish a component library in advance, and the component library includes the ID of the component and the component code corresponding to the component. When generating a web page, when a certain component needs to be referenced to the corresponding position of the web page, it is only necessary to find the component ID corresponding to the position, and then read the component data corresponding to the component ID from the database, and present it on the web page. Therefore, the design draft conversion module 103 parses the target source file, which is parsed into three types of nodes: div, img, and custom components.
[0051] Specifically, in an embodiment of the present application, the data parsing source code generation module 104 traverses each virtual DOM node in the generated virtual DOM tree to construct a target DOM tree, that is, a real DOM tree for rendering a web page. The information corresponding to each DOM node in the real DOM tree corresponds to the information of each virtual DOM node in the virtual DOM tree. When traversing the virtual DOM tree, if a DOM node of the type of a custom component is encountered, it is only necessary to further obtain the corresponding component code from the pre-configured component library according to the ID corresponding to the component.
[0052] Furthermore, in an embodiment of the present application, after the virtual DOM tree is generated, when the current web page needs to be modified and adjusted accordingly, a new virtual DOM tree is generated based on the design draft source file of the modified web page, and based on a specific algorithm, for example, a diff algorithm for comparing the contents of two files is used to compare the new and old virtual DOM trees, the changed virtual DOM nodes of the web page are determined, and then the information corresponding to the changed DOM nodes is applied to the real DOM tree to render and generate a new web page.
[0053] Furthermore, a function code file can be generated based on the real DOM tree and the supported function language. Optionally, the function language can be JavaScript. The information data corresponding to each DOM node of the div or img type in the real DOM tree can be generated based on the JavaScript language to generate the code snippet corresponding to each DOM node. The DOM node of the component type only needs to introduce the corresponding component code from the component library. The code snippet corresponding to each DOM node constitutes the function code file.
[0054] Further, in the embodiment of the present application, since the screens of different sizes require the web page display to realize adaptive layout according to the screen, a style attribute code file can be generated by a preset layout strategy and a style attribute language, wherein the style attribute language is mainly used to control the display effect of the web page when generating the web page, such as: font color, font size and font format, etc. Optionally, the layout rules of different pages can be established by combining the font size of the root element (rem) unit with the viewport (vw) unit, and the established adaptive layout rules are stored as a style attribute code file, i.e., a CSS code file, through a configured style attribute language, such as a CSS language. Then, when the web page is generated, when designing the layout for a certain page, it is only necessary to call the corresponding style attribute code file.
[0055] Further, in the embodiment of the present application, the first code file is formed according to the real DOM tree, the generated function code file and the style attribute code file. Specifically, the first code file is a general source code file that can support the display of different layout pages, that is, the CSS code that enables the web page to be generated to support adaptive layout, and can make the web page to be generated suitable for different page layouts. The general source code file can be uploaded to the server, and the developer can download the general source code file, and further adjust the source code file accordingly based on the development requirements to achieve secondary development.
[0056] Furthermore, in an embodiment of the present application, after the first code file is generated according to the target source file and the markup language, it is necessary to further generate a code file adapted to the target application environment.
[0057] Step 1003: Generate a second code file based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments.
[0058] In an embodiment of the present application, after generating a first code file according to a target source file and a markup language, the source code compiling module 105 may further generate a second code file based on a target application environment and the first code file.
[0059] It should be noted that in the embodiments of the present application, the target application environment can be any application environment with a web page display function, such as: a desktop browser, a mobile phone H5 or a WeChat applet, etc. The embodiments of the present application do not specifically limit the target application environment.
[0060] It should be noted that, in an embodiment of the present application, the source code compilation module 105 can convert the first code file into a second code file corresponding to the target application environment through the compilation configuration information corresponding to the target application environment. Specifically, each application environment has a preset field corresponding to the application environment and different from other application environments. The preset field can be used to distinguish different application environments. The source code compilation module 105 can read the preset field corresponding to the target application environment, parse the preset field, and further determine the compilation configuration information corresponding to the target application environment through the preset field. The source code compilation module 105 can convert the first code file, that is, the source code file, into the second code file corresponding to the target application environment by running the compilation configuration information corresponding to the target application environment. In other words, the second code file can make the web page to be generated suitable for different application environments. For example, web page rendering can be performed on multiple terminals such as desktop browsers, mobile browsers H5, and WeChat applets.
[0061] Exemplarily, after obtaining the first code file, we need to first determine the target application environment. If it is determined that the target application environment is a desktop browser, we obtain the compilation configuration information corresponding to the desktop browser from the database, run the compilation configuration information corresponding to the desktop browser, and convert the first code file into a target code file corresponding to the application environment of the desktop browser, that is, further enabling the web page to be displayed on the desktop browser side; if it is determined that the target application environment is a WeChat applet, we obtain the compilation configuration information corresponding to the WeChat applet from the database, run the compilation configuration information corresponding to the WeChat applet, and convert the first code file into a target code file corresponding to the application environment of the WeChat applet, that is, further enabling the web page to be displayed on the WeChat applet side.
[0062] Furthermore, the source code compilation module 105 can generate second code files corresponding to different application environments by combining the first code file generated by the data parsing source code generation module 104 with different compilation configuration information corresponding to different application environments, thereby obtaining a target code file that can be displayed on web pages in different application environments.
[0063] Furthermore, in an embodiment of the present application, after the source code compiling module 105 converts the first code file into the second code file by determining the compiling configuration information corresponding to the target application environment, it can further generate a target page based on the second code file.
[0064] Step 1004: Generate a target page corresponding to the target application environment according to the second code file.
[0065] In an embodiment of the present application, after the second code file is generated based on the target application environment and the first code file, a target page corresponding to the target application environment may be further generated according to the second code file.
[0066] It should be noted that, in the embodiments of the present application, the second code file can be generated in accordance with different application environments, so the target page can also be a web page displayed in accordance with different application environments, that is, the web page with the same content can be displayed in different application environments. For example, if the second code file is generated in accordance with the application environment of a desktop browser, then the target page can be displayed on the desktop browser side; if the second code file is generated in accordance with the application environment of a mobile phone H5, then the corresponding target page can be displayed on the mobile phone H5.
[0067] It should be noted that, in the embodiment of the present application, the content contained in the target page corresponds to the element information contained in the design draft source file, that is, the design draft source file is converted into the form of a web page that can be displayed in different application environments.
[0068] Further, in an embodiment of the present application, after generating a target page corresponding to the target application environment according to the second file, the first code file and the second code file are uploaded to the Web server, and the address information returned by the server can be received and stored, and the code file can be downloaded and the web page can be previewed by accessing the browser address entry. Specifically, after uploading the first code file and the second code file to the server, the code download module 106 provides a download and preview entry. When it is necessary to download the code file or preview the web page, the download or preview entry is accessed through the code download module 106 to achieve code download and web page rendering.
[0069] The embodiment of the present application provides a method for generating a web page, the method comprising obtaining target web page parameters corresponding to a target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated; generating a first code file according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts; generating a second code file based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments; generating a target page corresponding to the target application environment according to the second code file. That is to say, in the embodiment of the present application, the device for generating a web page not only generates a source code file that can adapt to page displays of different layouts by executing the target compilation task corresponding to the target web page parameters, but also generates a target code file that can display a web page in the target application environment by combining the source code file with the target application environment, thereby realizing the adaptive layout of the web page and supporting multi-terminal page display, further meeting the development requirements of web page display of different layouts in multiple application scenarios, and achieving higher web page development efficiency and better performance.
[0070] Based on the above embodiment, in another embodiment of the present application, the method for generating a web page by the device for generating a web page specifically includes: first, the device for generating a web page can obtain multiple sets of web page parameter information required for generating a web page, such as: the name of the web page, the design draft source file, the supported CSS language, the supported JavaScript language, and the supported application environment, and enter these web page parameter information into a database. When it is necessary to generate a task script, a corresponding set of web page parameters can be obtained from the database, and the corresponding task script can be automatically generated. Further, if the user wants to execute the task script, then according to the user's startup operation, the compilation task process is started in the server background according to the task script corresponding to the startup operation instruction, and then the task script is executed, and the status of the compilation task process corresponding to the task script is automatically changed to in progress. Similarly, if the user wants to pause or delete certain task scripts and the task process corresponding to the script, the program can also automatically delete the script according to the user's deletion and pause operation, delete the process, and modify the web page parameters configured in the database to be deleted. It should be noted that when performing the deletion operation, the status of the compilation task process corresponding to the task script must be in the state of not starting or pausing before the deletion operation can be performed. Specifically, when executing different task scripts and the compilation task process corresponding to the script, or adjusting certain parameters corresponding to the task script, the program will display the information of all updated compilation web page tasks, the status of the corresponding compilation task process when executing the task script, and the user's corresponding operation information in the monitoring system list. The ongoing compilation tasks will display the corresponding information and progress according to each compilation link, so that users can view the task details for process control.
[0071] Furthermore, according to the user's startup operation, the compilation task process corresponding to the target task script is specifically executed as follows: first, the target source file (such as the vector drawing application Sketch) corresponding to the target task script that has been designed by the user interface design (UI) is compiled to obtain the virtual DOM tree corresponding to the target source file, and a JavaScript object notation (JSON) data file is generated to perform the storage task. Specifically, the target source file is first parsed to obtain the original data corresponding to the target source file, that is, all the element information included in the target source file, and the original data is traversed to parse and generate the corresponding virtual DOM tree, that is, encapsulated into a JavaScript object, which is parsed into three DOM nodes of div, img and custom components, each DOM node contains various node attributes and style attributes, and according to the collected DOM structure data JavaScript object corresponding to the target source file, a JSON data file is generated for storage.
[0072] Secondly, the first code file that supports layout adaptation is generated according to the virtual DOM tree data, the CSS language and JavaScript language corresponding to the target source file, that is, the source code file. Specifically, the virtual DOM tree is first looped through to generate the corresponding real DOM tree, and the information of each DOM node in the virtual DOM tree corresponds to the information of each DOM node in the real DOM tree. In the process of traversing the virtual DOM, if a custom component is encountered, the corresponding component library is introduced, and then the corresponding function code file is stored through the configured functional language, such as JavaScript, and the CSS code of the adaptive layout is generated through the rem+vw method, and then the corresponding style attribute code file is stored through the configured style attribute language, such as CSS language. That is to say, the first code file, that is, the source code file that supports adaptive layout, is formed according to the real DOM tree, the function code file and the style attribute code file.
[0073] Finally, according to the previously configured compilation output platform, that is, the corresponding target application environment, the compilation output is automatically compiled, that is, the second code file is generated, and the second code file can be provided to subsequent users for preview or download. Specifically, each application environment has a preset field corresponding to the application environment and different from other application environments. The preset field can be used to distinguish different application environments. The preset field can be parsed, and the compilation configuration information corresponding to the target application environment can be determined through the preset field. By running the compilation configuration information corresponding to the target application environment, the first code file, that is, the source code file, is converted into the second code file corresponding to the target application environment, that is, the target code file. Further, a download and preview entry can be provided for the generated source code and the target code file corresponding to the target application environment. Specifically, the generated first code file and the second code file can be uploaded to the server, and the user can download the source code file and the target code file through the download entry, such as the browser entry; or the target page generated by the target code file can be viewed based on the preview entry, such as the browser entry.
[0074] The embodiment of the present application provides a method for generating a web page. The device for generating the web page not only generates a source code file that can adapt to page displays of different layouts by executing a target compilation task corresponding to target web page parameters, but also combines the source code file with a target application environment to generate a target code file that can display the web page in the target application environment, thereby realizing an adaptive layout of the web page and supporting multi-terminal page display, further meeting the development requirements of web page displays of different layouts in multiple application scenarios, and achieving higher web page development efficiency and better performance.
[0075] Based on the above embodiment, in another embodiment of the present application, Figure 4Schematic diagram of the composition structure of the device for generating web pages proposed in this application Figure 2 ,like Figure 4 As shown, the device 100 for generating a web page proposed in the embodiment of the present application may include an acquisition unit 107, a generation unit 108, an upload unit 109, a receiving unit 110 and a deletion unit 111.
[0076] The acquisition unit 107 is used to acquire target web page parameters corresponding to the target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated;
[0077] The generating unit 108 is configured to generate a first code file according to the target source file and the markup language; wherein the first code file is a cascading style sheet (CSS) code that enables the web page to be generated to be suitable for different page layouts; generate a second code file based on the target application environment and the first code file; wherein the second code file is a code that enables the web page to be generated to be suitable for different application environments; and generate a target page corresponding to the target application environment according to the second code file.
[0078] Furthermore, in an embodiment of the present application, the generating unit 108 is specifically configured to establish a virtual document object model DOM tree corresponding to the target source file; wherein the virtual DOM tree is used to represent the relationship between multiple element information in the target source file through a tree structure; and to generate the first code file according to the virtual DOM tree and the markup language.
[0079] Furthermore, in an embodiment of the present application, the generating unit 108 is further specifically used to obtain initial data corresponding to the target source file; wherein the initial data includes the multiple element information corresponding to the target source file; and traverse the multiple element information to generate multiple virtual DOM nodes corresponding to the multiple element information; wherein one element information corresponds to one virtual DOM node; and construct the virtual DOM tree based on the multiple virtual DOM nodes.
[0080] Further, in an embodiment of the present application, the generating unit 108 is further specifically configured to traverse the multiple virtual DOM nodes in the virtual DOM tree to construct a target DOM tree; and to generate a function code file and a style attribute code file based on the target DOM tree, the function language, and the style attribute language, respectively; and to generate the first code file according to the target DOM tree, the function code file, and the style attribute code file.
[0081] Furthermore, in an embodiment of the present application, the generation unit 108 is also specifically used to generate the function code file based on the function language and the target DOM tree; and to generate the style attribute code file according to a preset layout strategy and the style attribute language; wherein the preset layout strategy is used to establish layout rules for different pages.
[0082] Furthermore, in an embodiment of the present application, the generation unit 108 is also specifically used to read a preset field corresponding to the target application environment; wherein the preset field is used to distinguish different application environments; and determine the compilation configuration information corresponding to the target application environment based on the preset field; and convert the first code file into the second code file through the compilation configuration information.
[0083] Furthermore, in an embodiment of the present application, the uploading unit 109 is used to upload the first code file and the second code file to the server after generating the second code file based on the target application environment and the first code file, so as to realize browser-based code file downloading and web page rendering.
[0084] Furthermore, in an embodiment of the present application, the receiving unit 110 is also used to receive a deletion instruction corresponding to the target task script after receiving the start instruction and determining the target task script from the at least one initial task script based on the task identifier carried by the start instruction.
[0085] Furthermore, in an embodiment of the present application, the deleting unit 111 is used to perform deletion processing according to the deletion instruction.
[0086] In the embodiments of the present application, further, Figure 5 Schematic diagram of the composition structure of the device for generating web pages proposed in this application Figure 3 ,like Figure 5 As shown, the device 100 for generating a web page proposed in an embodiment of the present application may also include a processor 112, a memory 113 storing executable instructions of the processor 112, and further, the device 100 may also include a communication interface 114, and a bus 115 for connecting the processor 112, the memory 113 and the communication interface 114.
[0087] In the embodiment of the present application, the processor 112 can be at least one of an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a central processing unit (CPU), a controller, a microcontroller, and a microprocessor. It can be understood that for different devices, the electronic device used to implement the above-mentioned processor function can also be other, and the embodiment of the present application is not specifically limited. The device 100 can also include a memory 113, which can be connected to the processor 112, wherein the memory 113 is used to store executable program code, the program code includes computer operation instructions, and the memory 113 may include a high-speed RAM memory, and may also include a non-volatile memory, for example, at least two disk memories.
[0088] In the embodiment of the present application, the bus 115 is used to connect the communication interface 114, the processor 112 and the memory 113, and the mutual communication between these devices.
[0089] In the embodiment of the present application, the memory 113 is used to store instructions and data.
[0090] Further, in an embodiment of the present application, the above-mentioned processor 112 is used to obtain target web page parameters corresponding to the target task script; wherein the target web page parameters include a target source file, a markup language and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated; a first code file is generated according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts; a second code file is generated based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments; and a target page corresponding to the target application environment is generated according to the second code file.
[0091] In practical applications, the memory 113 may be a volatile memory, such as a random access memory (RAM); or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or a combination of the above types of memories, and provide instructions and data to the processor 112.
[0092] In addition, each functional module in this embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or software functional modules.
[0093] If the integrated unit is implemented in the form of a software function module and is not sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method of this embodiment. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0094] The embodiment of the present application provides a device for generating a web page, the device obtains the target web page parameters corresponding to the target task script; wherein the target web page parameters include the target source file, the markup language and the target application environment, and the target task script is generated according to the web page parameters of the web page to be generated; a first code file is generated according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts; a second code file is generated based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments; and a target page corresponding to the target application environment is generated according to the second code file. That is to say, in the embodiment of the present application, the device for generating a web page not only generates a source code file that can adapt to page displays of different layouts by executing the target compilation task corresponding to the target web page parameters, but also generates a target code file that can display a web page in the target application environment by combining the source code file with the target application environment, thereby realizing the adaptive layout of the web page and supporting multi-terminal page display, further meeting the development requirements of web page display of different layouts in multiple application scenarios, and having higher web page development efficiency and better performance.
[0095] An embodiment of the present application provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the method for generating a web page as described above is implemented.
[0096] Specifically, the program instructions corresponding to the method for generating a webpage in this embodiment may be stored in a storage medium such as a CD, a hard disk, or a USB flash drive. When the program instructions corresponding to the method for generating a webpage in the storage medium are read or executed by an electronic device, the following steps are included:
[0097] Obtaining target web page parameters corresponding to the target task script; wherein the target web page parameters include a target source file, a markup language, and a target application environment, and the target task script is generated according to the web page parameters of the web page to be generated;
[0098] Generate a first code file according to the target source file and the markup language; wherein the first code file is used to make the web page to be generated suitable for different page layouts;
[0099] Generate a second code file based on the target application environment and the first code file; wherein the second code file is used to make the web page to be generated suitable for different application environments;
[0100] A target page corresponding to the target application environment is generated according to the second code file.
[0101] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of hardware embodiments, software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0102] The present application is described with reference to implementation flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0103] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which is implemented in the implementation flow diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0104] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing the steps in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0105] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for generating a web page, characterized in that: The method comprises: Obtaining target web page parameters corresponding to the target task script; wherein the target web page parameters include web page design files, markup language and target application environment, and the target task script is generated according to the web page parameters of the web page to be generated; the markup language includes style attribute language and function language; Establish a virtual DOM tree corresponding to the web design file; the virtual DOM tree is used to characterize the relationship between multiple element information in the web design file through a tree structure; build a target DOM tree based on the virtual DOM; the target DOM tree is a real DOM tree for rendering web pages; generate a function code file based on the function language and the target DOM tree; generate a style attribute code file according to a preset layout strategy and the style attribute language; generate a first code file according to the target DOM tree, the function code file and the style attribute code file; the preset layout strategy is used to establish layout rules for different pages; the first code file includes cascading style sheet CSS code that makes the web page to be generated suitable for different page layouts; Reading a preset field corresponding to the target application environment; wherein the preset field is used to distinguish different application environments; determining compilation configuration information corresponding to the target application environment according to the preset field; converting the first code file into a second code file according to the compilation configuration information; wherein the second code file is a code that enables the web page to be generated to be suitable for different application environments; A target page corresponding to the target application environment is generated according to the second code file.
2. The method according to claim 1, characterized in that: The step of establishing a virtual DOM tree corresponding to the webpage design file includes: Acquire initial data corresponding to the webpage design file; wherein the initial data includes the plurality of element information corresponding to the webpage design file; Traversing the plurality of element information, generating a plurality of virtual DOM nodes corresponding to the plurality of element information; wherein one element information corresponds to one virtual DOM node; The virtual DOM tree is constructed based on the multiple virtual DOM nodes.
3. The method according to claim 2, characterized in that The step of generating the first code file according to the virtual DOM tree and the markup language includes: Traversing the multiple virtual DOM nodes in the virtual DOM tree to construct the target DOM tree; Based on the target DOM tree, the functional language and the style attribute language, respectively generate a functional code file and a style attribute code file; The first code file is generated according to the target DOM tree, the function code file and the style attribute code file.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: The first code file and the second code file are uploaded to a server to implement browser-based code file downloading and web page rendering.
5. A device for generating a web page, characterized in that: The device comprises an acquisition unit and a generation unit. The acquisition unit is used to acquire target web page parameters corresponding to the target task script; wherein the target web page parameters include web page design files, markup language and target application environment, and the target task script is generated according to the web page parameters of the web page to be generated; the markup language includes style attribute language and function language; The generating unit is used to establish a virtual DOM tree corresponding to the web page design file; the virtual DOM tree is used to characterize the relationship between multiple element information in the web page design file through a tree structure; a target DOM tree is constructed based on the virtual DOM; the target DOM tree is a real DOM tree for rendering web pages; a function code file is generated based on the function language and the target DOM tree; the target DOM tree is a real DOM tree for rendering web pages; a style attribute code file is generated according to a preset layout strategy and the style attribute language; a first code file is generated according to the target DOM tree, the function code file and the style attribute code file; the preset layout strategy is used to establish layout rules for different pages; the first code file includes Cascading Style Sheet CSS code that makes the web page to be generated suitable for different page layouts; The generating unit is further configured to read a preset field corresponding to the target application environment; wherein the preset field is used to distinguish different application environments; determine the compilation configuration information corresponding to the target application environment according to the preset field; and convert the first code file into a second code file according to the compilation configuration information; wherein the second code file is a code that enables the web page to be generated to be suitable for different application environments; The generating unit is further configured to generate a target page corresponding to the target application environment according to the second code file.
6. The device according to claim 5, characterized in that The generating unit is further specifically used to obtain initial data corresponding to the web page design file; wherein the initial data includes the multiple element information corresponding to the web page design file; and traverse the multiple element information to generate multiple virtual DOM nodes corresponding to the multiple element information; wherein one element information corresponds to one virtual DOM node; and construct the virtual DOM tree based on the multiple virtual DOM nodes.
7. The device according to claim 6, characterized in that The markup language includes a style attribute language and a function language. The generating unit is further specifically configured to traverse the plurality of virtual DOM nodes in the virtual DOM tree to construct the target DOM tree; and to generate a function code file and a style attribute code file based on the target DOM tree, the function language and the style attribute language; And generating the first code file according to the target DOM tree, the function code file and the style attribute code file.
8. The device according to claim 5 or 7, characterized in that The device also includes an uploading unit, The uploading unit is used to upload the first code file and the second code file to the server after generating the second code file based on the target application environment and the first code file, so as to realize browser-based code file downloading and web page rendering.
9. The device according to claim 5, characterized in that The device also includes a receiving unit and a deleting unit. The receiving unit is further configured to receive a deletion instruction corresponding to the target task script after receiving the start instruction and determining the target task script from at least one initial task script according to the task identifier carried by the start instruction; The deleting unit is used to perform a deletion process according to the deleting instruction.
10. A device for generating a web page, characterized in that: The device includes a processor and a memory storing instructions executable by the processor. When the instructions are executed by the processor, the method according to any one of claims 1 to 4 is implemented.
11. A computer-readable storage medium having a program stored thereon, applied to a device for generating a web page, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
