Front-end page generation method and device and medium
Through the front-end page generation method, the page parsing and component parsing engine are used to automatically render and refactor, which solves the problems of long compilation time, large workload and low development efficiency in front-end page development, and achieves fast rendering and efficient development.
Patent Information
- Application Number
- CN202411250100.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-12-06
AI Technical Summary
The existing front-end page development has problems such as long compilation time, large workload and low development efficiency, especially when the front-end project scale is expanded and the framework switches, it requires a lot of code reconstruction.
A front-end page generation method is proposed. By obtaining component descriptions and page descriptions, the page resolution engine and component resolution engine are used to parse component attributes, and the web page language is generated based on the template rendering engine to realize automated and rapid rendering and code reconstruction.
It realizes automatic and rapid rendering after modification of the front-end page, which reduces time consumption, avoids code refactoring, improves development efficiency, and simplifies the page construction process.
Smart Images

Figure CN119088392A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a front-end page generation method, device and medium. Background Art
[0002] In the process of Internet application development, the front-end page is an important component. At present, the front-end development framework usually uses Angular, Vue, React, etc. With the development of Internet technology, the complexity of the front-end page is getting higher and higher, and the following problems have emerged:
[0003] 1. Long compilation time. As the front-end project grows, the packaging time of the front-end project will also increase to several minutes. After making some modifications to the front-end project, the project needs to be packaged and deployed, which consumes a lot of time.
[0004] 2. The workload is large. With the development of time, new front-end frameworks will also appear. When we need to switch from one front-end framework to another, we need to refactor all the codes, which is a huge workload.
[0005] 3. Low development efficiency. When manually coding and developing front-end pages, the components we need are limited. Our functions are to arrange and combine limited components. In this project, a large amount of repeated component code is written, and the development efficiency is relatively low. Summary of the invention
[0006] In order to solve the above problems, this application proposes a front-end page generation method, including:
[0007] Obtaining a component description and a page description generated based on the component description;
[0008] Based on the page parsing engine, calling the component parsing engine, parsing the component description contained in the page description, and obtaining corresponding component attributes;
[0009] Based on the template rendering engine, rendering is performed according to the component attributes to generate a corresponding web page language, and rendering is performed based on the web page language to generate a front-end page.
[0010] In one example, obtaining a component description and a page description generated based on the component description specifically includes:
[0011] Obtaining a component description, wherein the component description includes at least a component attribute type, required information, and optional information;
[0012] Based on the current business scenario, the corresponding page description is generated through multi-level nesting of multiple component descriptions.
[0013] In one example, based on the page parsing engine, the component parsing engine is called to parse the component description contained in the page description to obtain corresponding component properties, specifically including:
[0014] Based on the page parsing engine, determine each component description nested in the page description;
[0015] Select each component description in turn according to the nested level, and call its corresponding component parsing engine to parse the component description to obtain the corresponding component attributes;
[0016] Combine the resulting component properties according to the nesting level.
[0017] In one example, before calling the corresponding component parsing engine to parse the component description, the method further includes:
[0018] Determine the first component parsing engine corresponding to the currently parsed component description, and determine, based on the nested levels, the second component parsing engine corresponding to the parsed component description belonging to the same level, and the third component parsing engine corresponding to the parsed component description of the previous level corresponding to the currently parsed component description;
[0019] If the degree of association between the first component parsing engine and the second component parsing engine, or the degree of association between the first component parsing engine and the third component parsing engine is lower than a preset degree, an alarm is issued; wherein the degree of association is obtained based on big data analysis of historical data.
[0020] In one example, the component attribute type includes at least one of a form component, a navigation component, a media component, an interaction component, and a layout component;
[0021] The required information includes: at least one of id and type; the optional information includes: at least one of require and visible.
[0022] In one example, calling a component parsing engine to parse the component description contained in the page description specifically includes:
[0023] Call the component parsing engine to determine the pre-set mapping relationship;
[0024] Based on the mapping relationship, traverse the page description until a description content that meets the mapping relationship is found;
[0025] According to the mapping relationship, the description content is mapped to corresponding attribute content, and a corresponding code statement is generated according to the attribute content.
[0026] In one example, each component description is selected in turn according to the nested level, including:
[0027] Generate a corresponding tree structure based on the nested levels, wherein if the first component description nests the second component description within itself, the first component description is used as the parent node of the second component description; and the component description that appears earlier in the same level is used as the node closer to the left in the tree structure;
[0028] A pre-order traversal is performed on the tree structure, and corresponding component descriptions are selected in sequence based on the order of the pre-order traversal.
[0029] In one example, rendering is performed based on a template rendering engine according to the component attributes, specifically including:
[0030] For the tree structure, every time a new subtree is traversed, incremental rendering is performed on the basis of historical rendering for the newly parsed component attributes in the subtree;
[0031] The result of the incremental rendering is recorded, the component description corresponding to the incremental rendering is marked, and the incremental rendering is highlighted.
[0032] On the other hand, the present application also proposes a front-end page generation device, including:
[0033] at least one processor; and,
[0034] a memory communicatively connected to the at least one processor; wherein,
[0035] The memory stores instructions that can be executed 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 front-end page generation method as described in any of the above examples.
[0036] On the other hand, the present application also proposes a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as: a front-end page generation method as described in any of the above examples.
[0037] The front-end page generation method proposed in this application can bring the following beneficial effects:
[0038] Even after the user modifies the front-end page, the page parsing engine can automatically and quickly render the new page, eliminating the need for the user to manually adjust subsequent content, thus reducing time consumption.
[0039] A template rendering engine based on the new framework is provided. For the new front-end framework, there is no need to adjust the original business logic or refactor the code. You only need to rewrite the component description and page description, and the subsequent code reconstruction can be completed in an automated way, thereby improving work efficiency.
[0040] It provides a description structure for components. When developing front-end pages, you can complete the page construction through simple descriptions, without having to repeatedly write duplicate codes in page properties, saving users' workload and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0042] Figure 1 This is a flow chart of a method for generating a front-end page in an embodiment of the present application;
[0043] Figure 2 This is a schematic diagram of a front-end page generation method in one scenario in an embodiment of the present application;
[0044] Figure 3 This is a schematic diagram of a front-end page generating device in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0046] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0047] like Figure 1 As shown, the embodiment of the present application provides a front-end page generation method, including:
[0048] S101: Obtain a component description and a page description generated based on the component description.
[0049] Component description refers to the components that may appear in the front-end page, which are described in the corresponding data format (for example, JSON Schema). The page description contains multiple component descriptions, that is, the front-end page is obtained by combining the components corresponding to the multiple component descriptions.
[0050] Specifically, a component description is obtained, and the component description includes at least component attribute type, required information, and optional information. The component attribute type includes at least one of form components (e.g., input boxes, text boxes), navigation components (e.g., navigation bars, menus), media components (e.g., images, video players), interactive components (e.g., buttons, progress bars), and layout components (e.g., panels, cards).
[0051] The required information includes: at least one of id and type, which are used to indicate the unique identifier of the component and the behavior type of the component respectively; the optional information includes: at least one of require and visible, which are used to indicate whether the component is required or visible respectively. Of course, there may be corresponding required or optional information for different components. For example, for a button component, buttonType may also be included to specify the function or style of the button.
[0052] Based on the current business scenario, the corresponding page description is generated through multi-level nesting of multiple component descriptions. For example, in a business scenario, a list and a button need to be added to a front-end page. The code is generated based on the corresponding data format so that the list and the button are nested inside the page. At this time, the page belongs to a higher level, while the list and the button belong to the same lower level.
[0053] S102: Based on the page parsing engine, call the component parsing engine to parse the component description contained in the page description to obtain corresponding component attributes.
[0054] like Figure 1 and Figure 2 As shown, the page parsing engine and the component parsing engine are pre-set, and can parse the page description and the component description respectively, and parse the corresponding data formats into corresponding attributes. Among them, each component description corresponds to a component attribute, and each page description is composed of multiple corresponding component attributes.
[0055] Specifically, based on the page parsing engine, each component description nested in the page description is determined. According to the nesting level, each component description is selected in turn, and its corresponding component parsing engine is called to parse the component description to obtain the corresponding component attribute. According to the nesting level, the obtained component attributes are combined.
[0056] For example, in a single front-end page (for example, which can be the main page), the page-bearing component is described as the highest-level component, in which a navigation bar component and a video player component are nested, and a list component and a button component are nested in the navigation bar component.
[0057] At this time, the corresponding component parsing engine can be called in the order of page bearing component-navigation bar component-list component-button component-video player component, parsed, and combined in this order. The component parsing engine corresponding to each component can be determined by keyword recognition.
[0058] Furthermore, before parsing by the component parsing engine, the first component parsing engine corresponding to the currently parsed component description may be determined, for example, by using keywords in the currently parsed component description to determine the corresponding first component parsing engine.
[0059] According to the nested levels, a second component parsing engine corresponding to the parsed component description belonging to the same level and a third component parsing engine corresponding to the parsed component description of the previous level corresponding to the currently parsed component description are determined.
[0060] Still using the above example for explanation, when the currently parsed component description is a button component, the parsed component description belonging to the same level can be a list component, and the parsed component description of the previous level can be a navigation bar component.
[0061] At this time, if the degree of association between the first component parsing engine and the second component parsing engine, or the degree of association between the first component parsing engine and the third component parsing engine is lower than the preset degree, it means that the currently parsed component description is very likely to not match other component descriptions, which may be due to code writing errors in the component description or incorrect selection of the component parsing engine, so an alarm is issued at this time.
[0062] The degree of association is obtained by performing big data analysis based on historical data. For example, the degree of association is determined by performing big data analysis based on historical data to determine the ratio of the number of simultaneous occurrences of each component description to the total number of occurrences of each component description. The higher the degree of association, the greater the possibility that the two component descriptions appear at the same time.
[0063] S103: Based on the template rendering engine, rendering is performed according to the component attributes to generate a corresponding web page language, and rendering is performed based on the web page language to generate a front-end page.
[0064] The page parsing engine completes the parsing of the page description to component attributes. The component attributes are passed to the template rendering engine to generate the component's web page language HTML, which is then rendered into the front-end interface.
[0065] Even after the user modifies the front-end page, the page parsing engine can automatically and quickly render the new page, eliminating the need for the user to manually adjust subsequent content, thus reducing time consumption.
[0066] A template rendering engine based on the new framework is provided. For the new front-end framework, there is no need to adjust the original business logic or refactor the code. You only need to rewrite the component description and page description, and the subsequent code reconstruction can be completed in an automated way, thereby improving work efficiency.
[0067] It provides a description structure for components. When developing front-end pages, you can complete the page construction through simple descriptions, without having to repeatedly write duplicate codes in page properties, saving users' workload and improving development efficiency.
[0068] In one embodiment, a corresponding mapping relationship is pre-set in the component parsing engine. When the component parsing engine is called for parsing, the page description is traversed based on the mapping relationship until a description content that meets the mapping relationship is found, and then the description content is mapped to the corresponding attribute content according to the mapping relationship, and the corresponding code statement is generated according to the attribute content.
[0069] For example, for a button component, the content in the component description is "buttonType":"danger", which means "the button type is a dangerous type", and the parsed component attribute is "background":"red", which means "the background color of the button is red".
[0070] In one embodiment, a corresponding tree structure can be generated based on the nested hierarchy, wherein if a first component description nests a second component description within itself, the first component description is used as the parent node of the second component description; and the component description that appears earlier in the same hierarchy is used as the node closer to the left in the tree structure.
[0071] Still taking the above example, the root node at this time is the page bearing component, and its child nodes are the navigation bar component and the video player component from left to right. The child nodes of the navigation bar component are the list component and the button component from left to right, thus generating the corresponding tree structure.
[0072] At this time, when parsing the component description, a pre-order traversal can be performed on the tree structure, and based on the order of the pre-order traversal, the corresponding component descriptions are selected in sequence. The order of the pre-order traversal also conforms to the order of appearance of the component descriptions in the page description.
[0073] Based on this, when rendering, the components that are at the front of the parsing order may be modified, thereby affecting the modification of subsequent components. At this time, if all component properties are still parsed at one time before rendering, it may affect work efficiency.
[0074] Based on this, for the tree structure, every time a new subtree is traversed, incremental rendering is performed on the basis of historical rendering for the newly parsed component properties in the subtree.
[0075] For example, when the first subtree traversed is: page bearing component - navigation bar component - list component, this subtree is the latest subtree, and the historical rendering is 0. Incremental rendering is to render the parsed content in this subtree to obtain the corresponding front-end page. At this time, the user can pause rendering based on needs, and then adjust the previous code to re-render.
[0076] When the user thinks that there is no problem with this part of the code, the rendering of the next subtree can be continued. At this time, the newly parsed component attributes in the new subtree are the component attributes corresponding to the button component. Then, further incremental rendering is performed based on the historical rendering that has been obtained. When the user thinks that there is no problem with the rendering of this part, the rendering of the next subtree, that is, the video player component, is continued until the entire tree structure is rendered.
[0077] Record the results of incremental rendering, that is, display the front-end page to the user and mark the component description corresponding to the incremental rendering, for example, highlight the component description to the user to let the user know which component description is currently being rendered. Highlight the incremental rendering, for example, adjust the background color of the incremental rendering by highlighting, so that the user can quickly understand the current rendering result.
[0078] like Figure 3 As shown, the embodiment of the present application also provides a front-end page generation device, including:
[0079] at least one processor; and,
[0080] a memory communicatively connected to the at least one processor; wherein,
[0081] The memory stores instructions that can be executed 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 front-end page generation method described in any of the above embodiments.
[0082] The embodiment of the present application further provides a non-volatile computer storage medium storing computer executable instructions, wherein the computer executable instructions are configured as: the front-end page generation method described in any of the above embodiments.
[0083] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0084] The devices and media provided in the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have similar beneficial technical effects as the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0085] 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 a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0086] The present application is described with reference to the 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 the 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 processes in the flowchart and / or block diagram. 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.
[0087] These computer program instructions may also be stored in a computer-readable memory capable of directing 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 an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0088] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0089] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0090] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0091] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0092] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0093] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A front-end page generation method, characterized in that: include: Obtaining a component description and a page description generated based on the component description; Based on the page parsing engine, calling the component parsing engine, parsing the component description contained in the page description, and obtaining corresponding component attributes; Based on the template rendering engine, rendering is performed according to the component attributes to generate a corresponding web page language, and rendering is performed based on the web page language to generate a front-end page.
2. The method according to claim 1, characterized in that Obtaining a component description and a page description generated based on the component description, specifically including: Obtaining a component description, wherein the component description includes at least a component attribute type, required information, and optional information; Based on the current business scenario, the corresponding page description is generated through multi-level nesting of multiple component descriptions.
3. The method according to claim 2, characterized in that Based on the page parsing engine, the component parsing engine is called to parse the component description contained in the page description to obtain corresponding component properties, including: Based on the page parsing engine, determine each component description nested in the page description; Select each component description in turn according to the nested level, and call its corresponding component parsing engine to parse the component description to obtain the corresponding component attributes; Combine the resulting component properties according to the nesting level.
4. The method according to claim 3, characterized in that Before calling the corresponding component parsing engine to parse the component description, the method further includes: Determine the first component parsing engine corresponding to the currently parsed component description, and determine, based on the nested levels, the second component parsing engine corresponding to the parsed component description belonging to the same level, and the third component parsing engine corresponding to the parsed component description of the previous level corresponding to the currently parsed component description; If the degree of association between the first component parsing engine and the second component parsing engine, or the degree of association between the first component parsing engine and the third component parsing engine is lower than a preset degree, an alarm is issued; wherein the degree of association is obtained based on big data analysis of historical data.
5. The method according to claim 2, characterized in that: The component attribute type includes at least one of a form component, a navigation component, a media component, an interaction component, and a layout component; The required information includes: at least one of id and type; the optional information includes: at least one of require and visible.
6. The method according to claim 1, characterized in that Calling a component parsing engine to parse the component description contained in the page description, specifically including: Call the component parsing engine to determine the pre-set mapping relationship; Based on the mapping relationship, traverse the page description until a description content that meets the mapping relationship is found; According to the mapping relationship, the description content is mapped to corresponding attribute content, and a corresponding code statement is generated according to the attribute content.
7. The method according to claim 3, characterized in that Select each component description in turn according to the nested level, including: Generate a corresponding tree structure based on the nested levels, wherein if the first component description nests the second component description within itself, the first component description is used as the parent node of the second component description; and the component description that appears earlier in the same level is used as the node closer to the left in the tree structure; A pre-order traversal is performed on the tree structure, and corresponding component descriptions are selected in sequence based on the order of the pre-order traversal.
8. The method according to claim 7, characterized in that Based on the template rendering engine, rendering is performed according to the component attributes, specifically including: For the tree structure, every time a new subtree is traversed, incremental rendering is performed on the basis of historical rendering for the newly parsed component attributes in the subtree; The result of the incremental rendering is recorded, the component description corresponding to the incremental rendering is marked, and the incremental rendering is highlighted.
9. A front-end page generation device, characterized in that: include: at least one processor; as well as, a memory communicatively connected 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 front-end page generation method as described in any one of claims 1 to 8.
10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions are configured as: a front-end page generation method as described in any one of claims 1 to 8.
Citation Information
Cited By
Multi-tab page component cache management method and system, terminal and medium
CN121301676A
A method, system, terminal, and medium for managing cached multi-tab page components.
CN121301676B
H5 page generation method based on attribute dependency relationship and computer equipment
CN121832943A
