Page generation method and device, storage medium and electronic equipment
By selecting and generating components from the component library and automatically building pages using the component documentation, the problem of low efficiency in front-end page development is solved, and efficient component reuse and high-quality code management are achieved.
Patent Information
- Application Number
- CN202310397565.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-12
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-04-12
AI Technical Summary
In existing technologies, the development of complex front-end pages requires the manual development of functional components, which leads to low efficiency, low component reusability, and difficulty in quickly integrating duplicate code, resulting in project maintenance difficulties.
By acquiring the business functions of the target page, components are selected and generated from the component library. The page is automatically built using the component's documentation, including rating and encapsulating historical code data to generate a high-quality component library.
It improves the efficiency of front-end page generation, enhances component reusability and code cohesion, and reduces maintenance difficulty.
Smart Images

Figure CN116501317B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method and apparatus for generating pages, a storage medium, and an electronic device. Background Technology
[0002] Existing technologies explore low-code and no-code development platforms; however, these platforms often support relatively limited functionality and scenarios. In developing complex front-end functionalities, developers must manually complete the required tasks based on their chosen front-end framework and UI components. Furthermore, if the existing codebase contains a large amount of duplicate code, current technical solutions cannot quickly integrate this duplicate code.
[0003] In developing complex front-end pages, the issue of extracting common components is inevitable. Simply piling up code can lead to unmaintainability, non-reusability, and poor readability later on. However, without standardized methods and specifications for component extraction, current technologies can also result in low component reusability and duplicate extraction of the same components.
[0004] There is currently no effective solution to the problem that the front-end page generation efficiency is relatively low because corresponding functional components need to be manually developed in related technologies. Summary of the Invention
[0005] The main objective of this application is to provide a method, apparatus, storage medium, and electronic device for generating pages, in order to solve the problem in related technologies where corresponding functional components need to be manually developed for front-end pages, resulting in low efficiency in generating front-end pages.
[0006] To achieve the above objectives, according to one aspect of this application, a method for generating a page is provided. The method includes: obtaining a page generation request for a target page, wherein the page generation request includes at least a business function corresponding to the target page; based on the business function corresponding to the target page, obtaining a target component and its documentation from a target component library, wherein the target component library includes multiple components and documentation for each component, the components in the target component library are obtained based on code data corresponding to historical pages, and the documentation explains how to use the component; and generating the target page based on the target component and its documentation.
[0007] Furthermore, based on the business function corresponding to the target page, obtaining the target component and its description document from the target component library includes: obtaining multiple first components and a score corresponding to each first component from the target component library based on the business function corresponding to the target page; selecting the target component from the multiple first components based on the score corresponding to each first component, and obtaining the description document of the target component from the target component library.
[0008] Furthermore, before obtaining the target component and its documentation from the target component library based on the business function corresponding to the target page, the method further includes: obtaining code data corresponding to multiple historical pages; extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data; encapsulating the multiple target code data to obtain multiple second components, and obtaining documentation corresponding to each second component based on each target code data; and constructing the target component library based on the multiple second components and their corresponding documentation.
[0009] Furthermore, after encapsulating the multiple target code data to obtain multiple second components, the method further includes: scoring the independence of each second component based on the number of Hypertext Transfer Protocol interfaces called in the target code data corresponding to each second component, to obtain a first score; scoring the extensibility of each second component based on the number of slots, the number of variables of target attributes, and the number of functions that can be bound in the target code data corresponding to each second component, to obtain a second score, wherein the target attributes represent the ability of the variables to receive external input data; scoring the usability of each second component based on the number of variables of the required target attributes and the number of functions that need to be bound in the target code data corresponding to each second component, to obtain a third score; and calculating the score value corresponding to each second component based on the first score, the second score, and the third score.
[0010] Furthermore, extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data includes: filtering the code data corresponding to each historical page to obtain multiple initial code data in the code data template; for each initial code data, processing the event functions and variables in the initial code data to obtain processed initial code data; and determining the multiple target code data based on the processed initial code data.
[0011] Further, the event functions and variables in the initial code data are processed to obtain processed initial code data, including: statistically analyzing the target event functions and target variables in the initial code data, wherein the target event functions include the first event function bound to the template and the second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; filtering the initial code data based on the target event functions and target variables to obtain first code data, wherein the first code data includes the target event functions and the target variables; based on the... The target event function processes the first code data to obtain the second code data. The function type includes at least two types: closed-class event functions and open-class event functions. The closed-class event functions are event functions called internally within the first code data, and the open-class event functions are event functions passed from the parent component of the first code data. The attributes of the target variable in the second code data are changed according to the variable type of the target variable to obtain the processed initial code data. The variable type includes at least two types: open-class variables and closed-class variables. Open-class variables are modifiable variables, and closed-class variables are read-only variables.
[0012] Further, processing the first code data according to the function type of the target event function to obtain the second code data includes: obtaining the function type of the target event function and obtaining the variables of the open class event function call; deleting the variables of the open class event function call in the first code data to obtain the processed first code data; and modifying the open class event function in the processed first code data to obtain the second code data.
[0013] Further, modifying the attributes of the target variable in the second code data according to the variable type of the target variable to obtain the processed initial code data includes: obtaining the variable type of the target variable; changing the attributes of the closed-class variables in the second code data to the target attributes to obtain the processed second code data; classifying the open-class variables in the processed second code data to obtain open synchronization-class variables and open-closed-class variables, wherein the open synchronization-class variables are variables that need to be synchronized to the parent component when the open synchronization-class variables change, and the open-closed-class variables are variables that do not need to be synchronized to the parent component when the open-closed-class variables change; and modifying the open synchronization-class variables in the processed second code data to obtain the processed initial code data.
[0014] Furthermore, the encapsulation of the plurality of target code data to obtain a plurality of second components includes: optimizing the plurality of target code data according to preset rules to obtain optimized plurality of target code data; and encapsulating the optimized plurality of target code data to obtain the plurality of second components.
[0015] To achieve the above objectives, according to another aspect of this application, a page generation apparatus is provided. The apparatus includes: a first acquisition unit, configured to acquire a page generation request for a target page, wherein the page generation request includes at least a business function corresponding to the target page; a second acquisition unit, configured to acquire a target component and its documentation from a target component library based on the business function corresponding to the target page, wherein the target component library includes multiple components and a documentation for each component, the components in the target component library are obtained based on code data corresponding to historical pages, and the documentation explains how to use the component; and a generation unit, configured to generate the target page based on the target component and its documentation.
[0016] Furthermore, the second acquisition unit includes: an acquisition subunit, configured to acquire multiple first components and a score value corresponding to each first component from the target component library based on the business function corresponding to the target page; and a selection subunit, configured to select the target component from the multiple first components based on the score value corresponding to each first component, and acquire the description document of the target component from the target component library.
[0017] Furthermore, the apparatus further includes: a third acquisition unit, configured to acquire code data corresponding to multiple historical pages before acquiring a target component and its documentation from a target component library based on the business function corresponding to the target page; an extraction unit, configured to extract code data corresponding to a target function from the code data corresponding to each historical page to obtain multiple target code data; an encapsulation unit, configured to encapsulate the multiple target code data to obtain multiple second components, and to obtain documentation corresponding to each second component based on each target code data; and a construction unit, configured to construct the target component library based on the multiple second components and the documentation corresponding to each second component.
[0018] Furthermore, the device further includes: a first scoring unit, configured to, after encapsulating multiple second components based on the multiple target code data to obtain multiple second components, score the independence of each second component based on the number of Hypertext Transfer Protocol interfaces called in the target code data corresponding to each second component, to obtain a first score; a second scoring unit, configured to, based on the number of slots, the number of variables of target attributes, and the number of functions that can be bound in the target code data corresponding to each second component, to obtain a second score, wherein the target attributes represent that the variables can receive externally input data; a third scoring unit, configured to, based on the number of variables of required target attributes and the number of functions that need to be bound in the target code data corresponding to each second component, to obtain a third score; and a calculation unit, configured to, based on the first score, the second score, and the third score, calculate to obtain a score value corresponding to each second component.
[0019] Furthermore, the extraction unit includes: a filtering subunit, used to filter the code data corresponding to each historical page to obtain multiple initial code data in the code data template; a processing subunit, used to process the event functions and variables in each initial code data to obtain processed initial code data; and a determining subunit, used to determine the multiple target code data based on the processed initial code data.
[0020] Further, the processing subunit includes: a statistics module, used to count the target event functions and target variables in the initial code data, wherein the target event functions include a first event function bound to the template and a second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; a filtering module, used to filter the initial code data according to the target event functions and target variables to obtain first code data, wherein the first code data includes the target event functions and the target variables; and a processing module, used to process the target event functions... A function type processes the first code data to obtain second code data. The function type includes at least two types: closed-class event functions and open-class event functions. The closed-class event functions are event functions called internally within the first code data, and the open-class event functions are event functions passed from the parent component that calls the first code data. A modification module is used to modify the attributes of the target variable in the second code data according to the variable type of the target variable to obtain the processed initial code data. The variable type includes at least two types: open-class variables and closed-class variables. The open-class variables are modifiable variables, and the closed-class variables are read-only variables.
[0021] Further, the processing module includes: a first acquisition submodule, used to acquire the function type of the target event function and acquire the variables of the open class event function call; a processing submodule, used to delete the variables of the open class event function call in the first code data to obtain the processed first code data; and a modification submodule, used to modify the open class event function in the processed first code data to obtain the second code data.
[0022] Further, the modification module includes: a second acquisition submodule, used to acquire the variable type of the target variable; a modification submodule, used to change the attribute of the closed-class variable in the second code data to the target attribute, to obtain the processed second code data; a classification submodule, used to classify the open-class variables in the processed second code data to obtain open synchronization-class variables and open-closed-class variables, wherein the open synchronization-class variables are variables that need to be synchronized to the parent component when the open synchronization-class variables change, and the open-closed-class variables are variables that do not need to be synchronized to the parent component when the open-closed-class variables change; and a modification submodule, used to modify the open synchronization-class variables in the processed second code data to obtain the processed initial code data.
[0023] Furthermore, the encapsulation unit includes: an optimization subunit, used to optimize the plurality of target code data according to preset rules to obtain optimized plurality of target code data; and an encapsulation subunit, used to encapsulate the optimized plurality of target code data to obtain the plurality of second components.
[0024] To achieve the above objectives, according to another aspect of this application, a computer-readable storage medium is also provided, the storage medium storing a program, wherein, when the program is executed, the device where the storage medium is located controls the execution of the page generation method described in any one of the above claims.
[0025] To achieve the above objectives, according to one aspect of this application, an electronic device is provided, the electronic device including one or more processors and a memory, the memory being used to store the page generation method implemented by the one or more processors as described in any of the above claims.
[0026] This application employs the following steps: obtaining a page generation request for the target page, wherein the page generation request includes at least the business functions corresponding to the target page; based on the business functions corresponding to the target page, obtaining a target component and its documentation from a target component library, wherein the target component library includes multiple components and documentation for each component, the components in the target component library are derived from code data corresponding to historical pages, and the documentation explains how to use the components; and generating the target page based on the target component and its documentation. This solves the problem in related technologies where corresponding functional components need to be manually developed for front-end pages, resulting in low efficiency in front-end page generation. In this solution, when a page needs to be generated, a target component and its documentation are selected from the target component library according to the business functions required by the page, and then the corresponding page is generated based on the documentation and the target component, avoiding the need for manual development of corresponding functional components, thereby improving the efficiency of front-end page generation. Attached Figure Description
[0027] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0028] Figure 1 This is a flowchart of a page generation method provided according to an embodiment of this application;
[0029] Figure 2 This is a flowchart of an optional page generation method provided according to an embodiment of this application;
[0030] Figure 3 This is a schematic diagram of a page generation apparatus according to an embodiment of this application;
[0031] Figure 4 This is a schematic diagram of an electronic device provided according to an embodiment of this application. Detailed Implementation
[0032] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0033] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0034] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0035] It should be noted that all information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are information and data authorized by the user or fully authorized by all parties. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain the relevant information after receiving consent information from the aforementioned user or organization.
[0036] The present invention will now be described in conjunction with preferred implementation steps. Figure 1 This is a flowchart of a page generation method provided according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0037] Step S101: Obtain the page generation request of the target page, wherein the page generation request includes at least the business function corresponding to the target page.
[0038] Specifically, obtain the page generation request for the page to be generated (i.e., the target page mentioned above). The page generation request needs to include the business function corresponding to the page to be generated. For example, if the target page is a search page, then the corresponding required business function is the search function.
[0039] It should be noted that the above page can be a Vue-based page.
[0040] Step S102: Based on the business function corresponding to the target page, obtain the target component and its documentation from the target component library. The target component library includes multiple components and their corresponding documentation. The components in the target component library are obtained based on the code data corresponding to the historical page, and the documentation is used to explain how to use the components.
[0041] Specifically, based on the business function corresponding to the target page, the target component corresponding to the business function is selected from the target component library, along with the documentation for the selected target component. It should be noted that the documentation can be in plain text format (Markdown, .md). Markdown is a markup language that facilitates reading and understanding by developers. The documentation explains how to use the component; for example, it records which functions of the component must be bound, and which variables need to be passed in from the parent component.
[0042] It should be noted that the target component library includes multiple components and documentation for each component. The components in the target component library are extracted and encapsulated from the existing page code data.
[0043] Step S103: Generate the target page based on the target component and its documentation.
[0044] Specifically, the layout and modifications are performed based on the target component and its documentation to obtain the target page described above.
[0045] In summary, when a page needs to be generated, the target component and its documentation are selected from the target component library based on the required business functions. Then, the corresponding page is generated based on the target component's documentation and the target component itself. This avoids the need to manually develop the corresponding functional components, thereby improving the efficiency of generating front-end pages.
[0046] To improve the rationality of selecting target components, in the page generation method provided in this application embodiment, obtaining target components and their description documents from the target component library based on the business function corresponding to the target page includes: obtaining multiple first components and the score value corresponding to each first component from the target component library based on the business function corresponding to the target page; selecting a target component from the multiple first components based on the score value corresponding to each first component, and obtaining the description document of the target component from the target component library.
[0047] Specifically, based on the business function, multiple first components matching the business function and their corresponding scores are selected from the target component library. The target component is then selected based on these scores; for example, the first component with the highest score is chosen as the target component. Finally, the documentation for the target component is retrieved from the target component library. Selecting the most suitable target component based on its score improves the rationality of determining the target component.
[0048] For the page generation method provided in this application embodiment, obtaining the target component library is crucial. Therefore, before obtaining the target component and its documentation from the target component library based on the business function corresponding to the target page, the method further includes: obtaining code data corresponding to multiple historical pages; extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data; encapsulating the multiple target code data to obtain multiple second components, and obtaining the documentation corresponding to each second component based on each target code data; and constructing the target component library based on the multiple second components and the documentation corresponding to each second component.
[0049] Specifically, the process involves acquiring existing historical pages and their corresponding code data, then selecting the code data corresponding to the target function from these historical pages. For example, if the search function needs to be encapsulated as an independent component, the code data corresponding to the search function would be selected from the historical pages. The code data corresponding to the target function mainly includes JS and CSS parts. JS is used to handle various dynamic effects on the page, which can be used to implement page-to-user interaction functions; CSS is used to statically format the page, allowing it to be displayed with a specific layout.
[0050] After obtaining multiple target code data corresponding to the target function, these target code data are encapsulated to obtain multiple second components and corresponding documentation for the second components. Finally, the target component library mentioned above is constructed based on these second components and documentation.
[0051] In summary, by automatically generating usable components that conform to Vue syntax requirements and their corresponding usage documentation from the code data of already implemented historical pages, component reusability is improved, as well as the efficiency of generating subsequent pages.
[0052] Since different pages may contain components with the same function, in order to facilitate the selection of higher quality components later, in the page generation method provided in this application embodiment, after encapsulating multiple second components based on multiple target code data, the method further includes: scoring the independence of each second component based on the number of Hypertext Transfer Protocol interfaces called in the target code data corresponding to each second component to obtain a first score; scoring the extensibility of each second component based on the number of slots, the number of variables of target attributes, and the number of functions that can be bound in the target code data corresponding to each second component to obtain a second score, wherein the target attributes represent the ability of variables to receive external input data; scoring the usability of each second component based on the number of variables of target attributes required and the number of functions that need to be bound in the target code data corresponding to each second component to obtain a third score; and calculating the score value corresponding to each second component based on the first score, the second score, and the third score.
[0053] Specifically, the evaluation of component quality is mainly based on three aspects: independence, scalability, and ease of use.
[0054] Independence is primarily evaluated by the number of HTTP (Hypertext Transfer Protocol) calls in the code data. Generally, a count of 0 is optimal, and the fewer the calls, the higher the score. In other words, the fewer the calls to the HTTP interface, the better the independence of the component.
[0055] For extensibility, the evaluation is mainly based on the number of slots in the code data, the number of variables in the props (target properties), and the number of functions that can be bound. Generally speaking, the more of these, the higher the score. In other words, the more slots, props (target properties), and functions that can be bound, the higher the extensibility of the component.
[0056] It should be noted that the props property is used to pass data or methods from the parent component to the child component for use.
[0057] Usability is primarily evaluated based on the number of props variables that must be entered in the code data and the number of functions that must be bound. Generally, the less data, the higher the score. In other words, the fewer the number of props variables that must be entered and the fewer the number of functions that must be bound, the better the independence of the component.
[0058] By calculating the amount of the above data, we can obtain the independence score, scalability score, and usability score of the second component. These scores can accurately evaluate the merits of the current component, making it easier to select a better component to generate the corresponding page.
[0059] Accurately and quickly extracting the code data corresponding to the target function is crucial. Therefore, in the page generation method provided in this application embodiment, extracting the code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data includes: filtering the code data corresponding to each historical page to obtain multiple initial code data in the code data template; for each initial code data, processing the event functions and variables in the initial code data to obtain processed initial code data; and determining multiple target code data based on the processed initial code data.
[0060] Specifically, the code data for each historical page is filtered, and the code data that needs to be encapsulated into components within the template (i.e., the template mentioned above) is extracted to obtain the initial code data. Then, the event functions and variables in the initial code data are modified, deleted, etc., to obtain the processed initial code data. Finally, the target code data is obtained based on the processed initial code data. It should be noted that the event functions and variables in the code data are the JavaScript and CSS code mentioned above. Through the above steps, the efficiency of obtaining the code data corresponding to the target function is improved.
[0061] In an optional embodiment, the event functions and variables in the initial code data are processed to obtain processed initial code data, including: statistically analyzing the target event functions and target variables in the initial code data, wherein the target event functions include a first event function bound to the template and a second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; filtering the initial code data based on the target event functions and target variables to obtain first code data, wherein the first code data includes target event functions and target variables; processing the first code data based on the function type of the target event functions to obtain second code data, wherein the function types include at least: closed-class event functions and open-class event functions, wherein closed-class event functions are event functions called internally within the first code data, and open-class event functions are event functions passed in by the parent component that calls the first code data; and modifying the attributes of the target variables in the second code data based on the variable types of the target variables to obtain processed initial code data, wherein the variable types include at least: open-class variables and closed-class variables, open-class variables are modifiable variables, and closed-class variables are read-only variables.
[0062] Specifically, the target event functions and target variables in the initial code data are statistically analyzed. Generally, the target event functions need to be analyzed for the first event function bound within the template, as well as the second event function called by the first event function. The target variables need to be analyzed for variables directly used within the template (i.e., the variables bound within the template mentioned above), variables called by the first event function, and variables called by the second event function, etc.
[0063] Then, based on the target event function and target variable in the statistics, other event functions and variables in the initial code data are deleted to obtain the first code data mentioned above. It should be noted that hook functions such as `created()` and `mounted()` within the template can also be deleted.
[0064] After obtaining the first code data, it is processed according to the function type of the target event function to obtain the second code data. Here, the function types of the target event function are mainly divided into two categories: closed event functions and open event functions. Closed event functions refer to functions used internally within the template, while open event functions refer to event functions passed from the parent component of the first code data; that is, when the component corresponding to the first code data is a child component, the event function passed from the parent component (i.e., the aforementioned parent component). Generally, closed event functions used internally within the template do not need to be changed. However, open event functions, which are event functions passed from the parent component, will change depending on the parent component. Therefore, open event functions need to be modified to obtain the aforementioned second code data.
[0065] Target variables are also divided into two main categories: open variables and closed variables. Open variables are variables that can be both read and written, while closed variables are read-only variables. The attributes of the target variables in the second code data are modified according to their variable types to obtain the processed initial code data.
[0066] The above steps enable a simple and rapid transformation process, thereby improving the efficiency of obtaining the processed initial code data. Furthermore, the above steps provide a standard method for extracting components, making it possible to reuse components in the future.
[0067] In an optional embodiment, processing the first code data according to the function type of the target event function to obtain the second code data includes: obtaining the function type of the target event function and obtaining the variables of the open class event function call; deleting the variables of the open class event function call in the first code data to obtain the processed first code data; and modifying the open class event function in the processed first code data to obtain the second code data.
[0068] The closed-class event functions are functions used inside the template and do not need to be changed. However, the open-class event functions are event functions passed from the parent component and will change depending on the parent component. Therefore, the open-class event functions need to be modified to obtain the second code data mentioned above.
[0069] First, obtain the variables for the open class event function calls. Since the open class event functions change with the parent component, the corresponding variables for the open class event function calls are also uncertain. Therefore, delete these variables to obtain the first code data after the above processing.
[0070] The modified open-class event functions in the processed first code data are then further modified, primarily by: deleting the function bodies of the open-class event functions and changing them to trigger custom events so that they can be triggered subsequently based on the parent component; simultaneously, determining whether these open-class event functions pass multiple parameters, and if so, packaging the passed parameters so that multiple parameters are passed in a single data packet. Finally, the modified second code data is obtained.
[0071] In an optional embodiment, the page generation method provided in this application, which modifies the attribute of the target variable in the second code data according to the variable type of the target variable to obtain processed initial code data, includes: obtaining the variable type of the target variable; changing the attribute of the closed-class variable in the second code data to the target attribute to obtain processed second code data; classifying the open-class variables in the processed second code data to obtain open synchronization-class variables and open closed-class variables, wherein the open synchronization-class variables are variables that need to be synchronized to the parent component when the open synchronization-class variables change, and the open closed-class variables are variables that do not need to be synchronized to the parent component when the open closed-class variables change; and modifying the open synchronization-class variables in the processed second code data to obtain processed initial code data.
[0072] Specifically, the target variables are divided into closed-class variables and open-class variables. Closed-class variables are read-only variables, so the properties of these variables are changed to props properties (i.e., the target properties mentioned above).
[0073] Open variables are further divided into open synchronous variables and open closed variables. Open synchronous variables are those that need to be synchronized to the parent component when they change, while open closed variables are those that do not need to be synchronized to the parent component when they change. The main modification involves the open synchronous variables, specifically changing their properties to computed properties and setting setter and getter functions for them. The getter function assigns the corresponding props to the corresponding open synchronous variable, and the setter function triggers the parent component's update event. Therefore, this effectively splits one variable into two: the props variable receives changes within the parent component and synchronizes them to the child component, while the computed variable listens for changes in variables within the child component and notifies the parent component to update via a custom event.
[0074] It should be noted that the computed property is a computed property, which is used to perform calculations and cache variables.
[0075] In summary, the modification of the above variables ensures their independence and reusability.
[0076] To improve the quality of the target components, the page generation method provided in this application embodiment encapsulates multiple target code data to obtain multiple second components, including: optimizing multiple target code data according to preset rules to obtain optimized multiple target code data; and encapsulating the optimized multiple target code data to obtain multiple second components.
[0077] Specifically, after obtaining the target code data corresponding to the target function, this target code data can be optimized according to some preset rules, and then the optimized target code data can be encapsulated into a corresponding second component. For example, component styles can be restricted: the `important` keyword should not be used in CSS, CSS styles written in `style` should not appear in the component, and CSS should be extracted to `index.scss`. Additionally, a `.is-styled` class attribute can be used to control whether default properties are enabled. Furthermore, to increase the convenience of adding user-defined functions, a slot can be placed within the component, allowing users to insert fully customized content.
[0078] In summary, optimizing the target code data can effectively improve the quality and usability of components.
[0079] In an alternative embodiment, the following can be employed: Figure 2 The flowchart shown illustrates the modification and unification of components on existing pages, improving the maintainability of subsequent pages. Specifically, it includes:
[0080] Step 1. First, select the part of the original page template that needs to be encapsulated into a component, delete all the rest, and copy this part of the template code to the automatic generation platform. At the same time, upload the original page to the platform as well.
[0081] Step 2. The platform analyzes the original page based on Vue's characteristics and compares it with the part of the template selected by the user. It extracts the JS and CSS parts required by the template and automatically generates a component that conforms to Vue's syntax specifications according to the above method, and simultaneously generates a corresponding documentation.
[0082] Step 3. If a system has multiple implementations of the same functionality in different parts of the existing code, Step 2 can be executed on these modules separately to generate different components with similar functions. The platform will score the generated components based on three dimensions: independence (the number of direct HTTP API calls within the component, ideally 0, the fewer the calls, the higher the score), extensibility (the number of slots, props, and bindable functions, the more the better), and usability (the number of required props and bindable functions, the fewer the better). Users can choose the component with the highest score. If the generated components do not score highly, users can narrow down the template scope and repeat Step 2 to generate components with smaller dimensions.
[0083] Step 4. After selecting the relatively good components generated in Step 3, we can now use these components to rewrite other pages that have the same functionality. This allows the same functionality to be provided by a single basic component within the system, thereby improving code cohesion and reusability, and reducing the difficulty of subsequent modifications and testing workload.
[0084] The page generation method provided in this application involves obtaining a page generation request for a target page, wherein the page generation request includes at least the business function corresponding to the target page; based on the business function corresponding to the target page, obtaining a target component and its documentation from a target component library, wherein the target component library includes multiple components and documentation for each component, the components in the target component library are obtained based on code data corresponding to historical pages, and the documentation explains how to use the components; and generating the target page based on the target component and its documentation. This solves the problem in related technologies where corresponding functional components need to be manually developed for front-end pages, resulting in low efficiency in front-end page generation. In this solution, when a page needs to be generated, a target component and its documentation are selected from the target component library according to the business function required by the page, and then the corresponding page is generated based on the documentation and the target component, avoiding the need for manual development of corresponding functional components, thereby improving the efficiency of front-end page generation.
[0085] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0086] This application also provides a page generation apparatus. It should be noted that the page generation apparatus of this application can be used to execute the page generation method provided in this application. The page generation apparatus provided in this application will be described below.
[0087] Figure 3 This is a schematic diagram of a page generation apparatus according to an embodiment of this application. Figure 3 As shown, the device includes: a first acquisition unit 301, a second acquisition unit 302, and a generation unit 303.
[0088] The first acquisition unit 301 is used to acquire the page generation request of the target page, wherein the page generation request includes at least the business function corresponding to the target page;
[0089] The second acquisition unit 302 is used to acquire target components and their documentation from the target component library based on the business functions corresponding to the target page. The target component library includes multiple components and documentation for each component. The components in the target component library are obtained based on the code data corresponding to the historical page. The documentation is used to explain how to use the components.
[0090] The generation unit 303 is used to generate the target page based on the target component and the target component's documentation.
[0091] The page generation apparatus provided in this application embodiment obtains a page generation request for a target page through a first acquisition unit 301, wherein the page generation request includes at least the business function corresponding to the target page; a second acquisition unit 302 obtains a target component and its documentation from a target component library based on the business function corresponding to the target page, wherein the target component library includes multiple components and documentation for each component, the components in the target component library are obtained based on code data corresponding to historical pages, and the documentation explains how to use the components; a generation unit 303 generates the target page based on the target component and its documentation, thus solving the problem in related technologies where corresponding functional components need to be manually developed for front-end pages, resulting in low efficiency in generating front-end pages. In this solution, when a page needs to be generated, a target component and its documentation are selected from the target component library according to the business function required by the page, and then the corresponding page is generated based on the documentation and the target component, avoiding the need for manual development of corresponding functional components, thereby improving the efficiency of generating front-end pages.
[0092] Optionally, in the page generation apparatus provided in this application embodiment, the second acquisition unit includes: an acquisition subunit, configured to acquire multiple first components and a score value corresponding to each first component from a target component library based on the business function corresponding to the target page; and a selection subunit, configured to select a target component from the multiple first components based on the score value corresponding to each first component, and acquire a description document of the target component from the target component library.
[0093] Optionally, in the page generation apparatus provided in this application embodiment, the apparatus further includes: a third acquisition unit, configured to acquire code data corresponding to multiple historical pages before acquiring target components and their documentation from a target component library based on the business function corresponding to the target page; an extraction unit, configured to extract code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data; an encapsulation unit, configured to encapsulate the multiple target code data to obtain multiple second components, and to obtain documentation corresponding to each second component based on each target code data; and a construction unit, configured to construct a target component library based on the multiple second components and their corresponding documentation.
[0094] Optionally, in the page generation apparatus provided in this application embodiment, the apparatus further includes: a first scoring unit, configured to, after encapsulating multiple second components based on multiple target code data to obtain multiple second components, score the independence of each second component based on the number of Hypertext Transfer Protocol interfaces called in the target code data corresponding to each second component, to obtain a first score; a second scoring unit, configured to, based on the number of slots, the number of variables of target attributes, and the number of functions that can be bound in the target code data corresponding to each second component, to obtain a second score, wherein the target attributes represent the variables' ability to receive externally input data; a third scoring unit, configured to, based on the number of variables of target attributes required in the target code data corresponding to each second component and the number of functions that need to be bound, to score the usability of each second component, to obtain a third score; and a calculation unit, configured to, based on the first score, the second score, and the third score, calculate to obtain a score value corresponding to each second component.
[0095] Optionally, in the page generation apparatus provided in this application embodiment, the extraction unit includes: a filtering subunit, used to filter the code data corresponding to each historical page to obtain multiple initial code data in the template of code data; a processing subunit, used to process the event functions and variables in each initial code data to obtain processed initial code data; and a determining subunit, used to determine multiple target code data based on the processed initial code data.
[0096] Optionally, in the page generation apparatus provided in this application embodiment, the processing subunit includes: a statistics module, used to count the target event functions and target variables in the initial code data, wherein the target event functions include a first event function bound to the template and a second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; a filtering module, used to filter the initial code data according to the target event functions and target variables to obtain first code data, wherein the first code data includes target event functions and target variables; and a processing module, used to process the target event functions and target variables according to the target event functions and target variables. The event function is used to process the first code data to obtain the second code data. The function types include at least two types: closed-class event functions and open-class event functions. Closed-class event functions are those called internally by the first code data, while open-class event functions are those passed from the parent component that calls the first code data. The modification module is used to modify the attributes of the target variable in the second code data according to the variable type of the target variable, obtaining the processed initial code data. The variable types include at least two types: open-class variables and closed-class variables. Open-class variables are modifiable variables, while closed-class variables are read-only variables.
[0097] Optionally, in the page generation apparatus provided in this application embodiment, the processing module includes: a first acquisition submodule, used to acquire the function type of the target event function and acquire the variables of the open class event function call; a processing submodule, used to delete the variables of the open class event function call in the first code data to obtain the processed first code data; and a modification submodule, used to modify the open class event function in the processed first code data to obtain the second code data.
[0098] Optionally, in the page generation apparatus provided in this application embodiment, the modification module includes: a second acquisition submodule, used to acquire the variable type of the target variable; a modification submodule, used to change the attribute of the closed-class variable in the second code data to the target attribute, thereby obtaining the processed second code data; a classification submodule, used to classify the open-class variables in the processed second code data to obtain open synchronization-class variables and open-closed-class variables, wherein the open synchronization-class variables are variables that need to be synchronized to the parent component when the open synchronization-class variables change, and the open-closed-class variables are variables that do not need to be synchronized to the parent component when the open-closed-class variables change; and a modification submodule, used to modify the open synchronization-class variables in the processed second code data to obtain the processed initial code data.
[0099] Optionally, in the page generation apparatus provided in this application embodiment, the encapsulation unit includes: an optimization subunit, used to optimize multiple target code data according to preset rules to obtain multiple optimized target code data; and an encapsulation subunit, used to encapsulate the multiple optimized target code data to obtain multiple second components.
[0100] The page generation device includes a processor and a memory. The first acquisition unit 301, the second acquisition unit 302, and the generation unit 303 mentioned above are all stored in the memory as program units. The processor executes the program units stored in the memory to realize the corresponding functions.
[0101] The processor contains a kernel, which retrieves the corresponding program unit from memory. One or more kernels can be configured, and the generation of the target page is achieved by adjusting kernel parameters.
[0102] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0103] This invention provides a computer-readable storage medium storing a program that, when executed by a processor, implements a method for generating pages.
[0104] This invention provides a processor for running a program, wherein the program executes a page generation method during runtime.
[0105] like Figure 4 As shown, this embodiment of the invention provides an electronic device, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs the following steps: obtaining a page generation request for a target page, wherein the page generation request includes at least a business function corresponding to the target page; based on the business function corresponding to the target page, obtaining a target component and its documentation from a target component library, wherein the target component library includes multiple components and documentation for each component, the components in the target component library are obtained based on code data corresponding to historical pages, and the documentation explains how to use the components; and generating a target page based on the target component and its documentation.
[0106] Optionally, based on the business function corresponding to the target page, obtaining the target component and its documentation from the target component library includes: obtaining multiple first components and the score value corresponding to each first component from the target component library based on the business function corresponding to the target page; selecting the target component from the multiple first components based on the score value corresponding to each first component, and obtaining the documentation of the target component from the target component library.
[0107] Optionally, before obtaining the target component and its documentation from the target component library based on the business function corresponding to the target page, the method further includes: obtaining code data corresponding to multiple historical pages; extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data; encapsulating the multiple target code data to obtain multiple second components, and obtaining the documentation corresponding to each second component based on each target code data; and constructing the target component library based on the multiple second components and the documentation corresponding to each second component.
[0108] Optionally, after encapsulating multiple target code data to obtain multiple second components, the method further includes: scoring the independence of each second component based on the number of Hypertext Transfer Protocol interfaces called in the target code data corresponding to each second component, to obtain a first score; scoring the extensibility of each second component based on the number of slots, the number of variables of target attributes, and the number of functions that can be bound in the target code data corresponding to each second component, to obtain a second score, wherein the target attributes represent the variables' ability to receive external input data; scoring the usability of each second component based on the number of variables of target attributes required and the number of functions that need to be bound in the target code data corresponding to each second component, to obtain a third score; and calculating the score value corresponding to each second component based on the first score, the second score, and the third score.
[0109] Optionally, extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data includes: filtering the code data corresponding to each historical page to obtain multiple initial code data in the code data template; for each initial code data, processing the event functions and variables in the initial code data to obtain processed initial code data; and determining multiple target code data based on the processed initial code data.
[0110] Optionally, the event functions and variables in the initial code data are processed to obtain processed initial code data, including: target event functions and target variables in the initial code data, wherein the target event functions include a first event function bound to the template and a second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; the initial code data is filtered based on the target event functions and target variables to obtain first code data, wherein the first code data includes target event functions and target variables; the first code data is processed based on the function type of the target event functions to obtain second code data, wherein the function types include at least: closed-class event functions and open-class event functions, wherein closed-class event functions are event functions called internally by the first code data, and open-class event functions are event functions passed in by the parent component that calls the first code data; the attributes of the target variables in the second code data are changed based on the variable types of the target variables to obtain processed initial code data, wherein the variable types include at least: open-class variables and closed-class variables, open-class variables are variables that can be modified, and closed-class variables are read-only variables.
[0111] Optionally, processing the first code data according to the function type of the target event function to obtain the second code data includes: obtaining the function type of the target event function and obtaining the variables of the open class event function call; deleting the variables of the open class event function call in the first code data to obtain the processed first code data; and modifying the open class event function in the processed first code data to obtain the second code data.
[0112] Optionally, modifying the attributes of the target variable in the second code data according to the variable type of the target variable to obtain the processed initial code data includes: obtaining the variable type of the target variable; changing the attributes of the closed-class variables in the second code data to the target attributes to obtain the processed second code data; classifying the open-class variables in the processed second code data to obtain open synchronization-class variables and open-closed-class variables, wherein the open synchronization-class variables are variables that need to be synchronized to the parent component when the open synchronization-class variables change, and the open-closed-class variables are variables that do not need to be synchronized to the parent component when the open-closed-class variables change; and modifying the open synchronization-class variables in the processed second code data to obtain the processed initial code data.
[0113] Optionally, encapsulating multiple target code data to obtain multiple second components includes: optimizing multiple target code data according to preset rules to obtain optimized target code data; and encapsulating the optimized target code data to obtain multiple second components. The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0114] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having the following method steps: obtaining a page generation request for a target page, wherein the page generation request includes at least the business function corresponding to the target page; based on the business function corresponding to the target page, obtaining a target component and its documentation from a target component library, wherein the target component library includes multiple components and documentation for each component, the components in the target component library are obtained based on code data corresponding to historical pages, and the documentation explains how to use the components; and generating the target page based on the target component and its documentation.
[0115] Optionally, based on the business function corresponding to the target page, obtaining the target component and its documentation from the target component library includes: obtaining multiple first components and the score value corresponding to each first component from the target component library based on the business function corresponding to the target page; selecting the target component from the multiple first components based on the score value corresponding to each first component, and obtaining the documentation of the target component from the target component library.
[0116] Optionally, before obtaining the target component and its documentation from the target component library based on the business function corresponding to the target page, the method further includes: obtaining code data corresponding to multiple historical pages; extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data; encapsulating the multiple target code data to obtain multiple second components, and obtaining the documentation corresponding to each second component based on each target code data; and constructing the target component library based on the multiple second components and the documentation corresponding to each second component.
[0117] Optionally, after encapsulating multiple target code data to obtain multiple second components, the method further includes: scoring the independence of each second component based on the number of Hypertext Transfer Protocol interfaces called in the target code data corresponding to each second component, to obtain a first score; scoring the extensibility of each second component based on the number of slots, the number of variables of target attributes, and the number of functions that can be bound in the target code data corresponding to each second component, to obtain a second score, wherein the target attributes represent the variables' ability to receive external input data; scoring the usability of each second component based on the number of variables of target attributes required and the number of functions that need to be bound in the target code data corresponding to each second component, to obtain a third score; and calculating the score value corresponding to each second component based on the first score, the second score, and the third score.
[0118] Optionally, extracting code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data includes: filtering the code data corresponding to each historical page to obtain multiple initial code data in the code data template; for each initial code data, processing the event functions and variables in the initial code data to obtain processed initial code data; and determining multiple target code data based on the processed initial code data.
[0119] Optionally, the event functions and variables in the initial code data are processed to obtain processed initial code data, including: target event functions and target variables in the initial code data, wherein the target event functions include a first event function bound to the template and a second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; the initial code data is filtered based on the target event functions and target variables to obtain first code data, wherein the first code data includes target event functions and target variables; the first code data is processed based on the function type of the target event functions to obtain second code data, wherein the function types include at least: closed-class event functions and open-class event functions, wherein closed-class event functions are event functions called internally by the first code data, and open-class event functions are event functions passed in by the parent component that calls the first code data; the attributes of the target variables in the second code data are changed based on the variable types of the target variables to obtain processed initial code data, wherein the variable types include at least: open-class variables and closed-class variables, open-class variables are variables that can be modified, and closed-class variables are read-only variables.
[0120] Optionally, processing the first code data according to the function type of the target event function to obtain the second code data includes: obtaining the function type of the target event function and obtaining the variables of the open class event function call; deleting the variables of the open class event function call in the first code data to obtain the processed first code data; and modifying the open class event function in the processed first code data to obtain the second code data.
[0121] Optionally, modifying the attributes of the target variable in the second code data according to the variable type of the target variable to obtain the processed initial code data includes: obtaining the variable type of the target variable; changing the attributes of the closed-class variables in the second code data to the target attributes to obtain the processed second code data; classifying the open-class variables in the processed second code data to obtain open synchronization-class variables and open-closed-class variables, wherein the open synchronization-class variables are variables that need to be synchronized to the parent component when the open synchronization-class variables change, and the open-closed-class variables are variables that do not need to be synchronized to the parent component when the open-closed-class variables change; and modifying the open synchronization-class variables in the processed second code data to obtain the processed initial code data.
[0122] Optionally, encapsulating multiple target code data to obtain multiple second components includes: optimizing multiple target code data according to preset rules to obtain optimized multiple target code data; and encapsulating the optimized multiple target code data to obtain multiple second components.
[0123] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0124] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.
[0125] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0126] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0127] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0128] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0129] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0130] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0131] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0132] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for generating a page, characterized in that, include: Obtain the page generation request of the target page, wherein the page generation request includes at least the business function corresponding to the target page; Based on the business function corresponding to the target page, the target component and its documentation are obtained from the target component library. The target component library includes multiple components and documentation for each component. The components in the target component library are obtained based on the code data corresponding to the historical page. The documentation is used to explain how to use the component. The target page is generated based on the target component and its documentation. Before retrieving the target component and its documentation from the target component library based on the business function corresponding to the target page, the method further includes: Retrieve code data corresponding to multiple historical pages; Extract the code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data; Extract the code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data, including: Filter the code data corresponding to each historical page to obtain multiple initial code data in the code data template; For each initial code data, the event functions and variables in the initial code data are processed to obtain the processed initial code data; The plurality of target code data are determined based on the processed initial code data; The event functions and variables in the initial code data are processed to obtain the processed initial code data, which includes: The target event functions and target variables in the initial code data are statistically analyzed. The target event functions include the first event function bound to the template and the second event function called by the first event function. The target variables include the variables bound within the template, the variables called by the first event function, and the variables called by the second event function. The initial code data is filtered based on the target event function and the target variable to obtain first code data, wherein the first code data includes the target event function and the target variable; The first code data is processed according to the function type of the target event function to obtain the second code data. The function type includes at least: closed-class event functions and open-class event functions. The closed-class event functions are event functions called internally by the first code data, and the open-class event functions are event functions passed in by the parent component that calls the first code data. The attributes of the target variable in the second code data are changed according to the variable type of the target variable to obtain the processed initial code data. The variable type includes at least: open class variables and closed class variables. The open class variables are variables that can be modified, and the closed class variables are read-only variables.
2. The method according to claim 1, characterized in that, Based on the business function corresponding to the target page, the target component and its documentation are obtained from the target component library, including: Based on the business function corresponding to the target page, obtain multiple first components and the score value corresponding to each first component from the target component library; Based on the score value corresponding to each first component, the target component is selected from the plurality of first components, and the description document of the target component is obtained from the target component library.
3. The method according to claim 1, characterized in that, Before retrieving the target component and its documentation from the target component library based on the business function corresponding to the target page, the method further includes: Based on the multiple target code data, multiple second components are obtained by encapsulation, and based on each target code data, a corresponding documentation for each second component is obtained; The target component library is constructed based on the plurality of second components and the documentation corresponding to each second component.
4. The method according to claim 3, characterized in that, After encapsulating the multiple target code data to obtain multiple second components, the method further includes: The independence of each second component is scored based on the number of times the Hypertext Transfer Protocol interface is called in the target code data corresponding to each second component, and a first score is obtained; The extensibility of each second component is scored based on the number of slots, the number of variables of the target attributes, and the number of functions that can be bound in the target code data corresponding to each second component, to obtain a second score. The target attributes represent the ability of the variables to receive external input data. Based on the number of target attribute variables and the number of functions to be bound in the target code data corresponding to each second component, the usability of each second component is scored to obtain a third score; The score for each second component is calculated based on the first score, the second score, and the third score.
5. The method according to claim 1, characterized in that, The first code data is processed according to the function type of the target event function to obtain the second code data, which includes: Obtain the function type of the target event function and the variables used to call the open class event function; The variables of the open class event function calls in the first code data are deleted to obtain the processed first code data; The open-class event functions in the processed first code data are modified to obtain the second code data.
6. The method according to claim 1, characterized in that, The attributes of the target variable in the second code data are modified according to the variable type of the target variable to obtain the processed initial code data, including: Obtain the variable type of the target variable; The attributes of the enclosed class variables in the second code data are changed to the target attributes to obtain the processed second code data; The open class variables in the processed second code data are classified into open synchronization class variables and open closed class variables. The open synchronization class variables are variables that need to be synchronized to the parent component when the open synchronization class variables change, and the open closed class variables are variables that do not need to be synchronized to the parent component when the open closed class variables change. The open synchronization class variables in the processed second code data are modified to obtain the processed initial code data.
7. The method according to claim 1, characterized in that, Based on the aforementioned target code data, multiple second components are encapsulated to obtain the following: The multiple target code data are optimized according to preset rules to obtain optimized multiple target code data; The optimized target code data is encapsulated to obtain the multiple second components.
8. A page generation apparatus, characterized in that, include: The first acquisition unit is used to acquire a page generation request for a target page, wherein the page generation request includes at least the business function corresponding to the target page; The second acquisition unit is used to acquire a target component and its documentation from a target component library based on the business function corresponding to the target page. The target component library includes multiple components and documentation for each component. The components in the target component library are obtained based on code data corresponding to historical pages. The documentation is used to explain how to use the component. A generation unit is configured to generate the target page based on the target component and the specification document of the target component; The device further includes: a third acquisition unit, used to acquire code data corresponding to multiple historical pages before acquiring the target component and its documentation from the target component library based on the business function corresponding to the target page; and an extraction unit, used to extract code data corresponding to the target function from the code data corresponding to each historical page to obtain multiple target code data. The extraction unit includes: a filtering subunit, used to filter the code data corresponding to each historical page to obtain multiple initial code data in the code data template; a processing subunit, used to process the event functions and variables in each initial code data to obtain processed initial code data; and a determination subunit, used to determine multiple target code data based on the processed initial code data. The processing subunit includes: a statistics module, used to count the target event functions and target variables in the initial code data, wherein the target event functions include a first event function bound to the template and a second event function called by the first event function, and the target variables include: variables bound within the template, variables called by the first event function, and variables called by the second event function; a filtering module, used to filter the initial code data according to the target event functions and target variables to obtain first code data, wherein the first code data includes target event functions and target variables; a processing module, used to process the first code data according to the function type of the target event functions to obtain second code data, wherein the function type includes at least: closed-class event functions and open-class event functions, wherein closed-class event functions are event functions called internally by the first code data, and open-class event functions are event functions passed in by the parent component that calls the first code data; and a modification module, used to modify the attributes of the target variables in the second code data according to the variable type of the target variables to obtain processed initial code data, wherein the variable type includes at least: open-class variables and closed-class variables, open-class variables are variables that can be modified, and closed-class variables are read-only variables.
9. A computer-readable storage medium, characterized in that, The storage medium stores a program, wherein the program, when executed by a processor, implements the page generation method according to any one of claims 1 to 7.
10. An electronic device, characterized in that, It includes one or more processors and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the page generation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Service code generation method and device, electronic equipment and computer readable medium
CN113504908A
Method and device for generating page codes
CN113760276A
