Page generation method, device, electronic device and storage medium
By obtaining and adjusting the box model and margins of page elements, the problem of poor design draft restoration in page development is solved, high-precision page generation is achieved, and the correspondence between the page and the design draft is improved and the generation effect is improved.
Patent Information
- Application Number
- CN202110672318.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-15
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-06-15
AI Technical Summary
In front-end page development, due to insufficient high-level restoration of the design draft, there is a large error between the developed page and the design draft, which affects the page generation effect.
By obtaining the box model and margins of each element in the original graphic file of the page to be generated, adjust the parameters and spacing of the page elements, and generate the target page to ensure a high degree of consistency between the page and the design draft.
It improves the restoration rate of page generation, reduces the error between the page and the design draft, and improves the page generation effect.
Smart Images

Figure CN113391804B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a page generation method, device, electronic device and storage medium. Background Art
[0002] In front-end page development related technologies, page development is carried out based on the design draft; however, due to the lack of high degree of restoration of the design draft, there is a large error between the developed page and the design draft, resulting in poor page generation effect. Summary of the invention
[0003] The present disclosure provides a page generation method, device, electronic device and storage medium to at least solve the problem of large errors between the page developed in the related art and the design draft. The technical solution of the present disclosure is as follows:
[0004] According to a first aspect of an embodiment of the present disclosure, there is provided a page generation method, comprising:
[0005] Obtain the box model corresponding to each element in the original graphic file of the page to be generated, and the outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent element;
[0006] Generate each element on a preset layout page to obtain an initial page corresponding to the page to be generated;
[0007] According to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and adjacent elements are adjusted to obtain a target page corresponding to the page to be generated.
[0008] In an exemplary embodiment, the step of obtaining a box model corresponding to each element in an original graphic file of a page to be generated, and a margin of the box model corresponding to each element, includes:
[0009] Obtaining element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and an adjacent element;
[0010] According to the element parameters corresponding to each element, query the corresponding relationship between the element parameters and the box model to obtain the box model corresponding to each element;
[0011] According to the distance between each element and an adjacent element, the outer margin of the box model corresponding to each element is determined.
[0012] In an exemplary embodiment, adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated includes:
[0013] Generate a page configuration file of the page to be generated according to the box model corresponding to each element and the outer margin of the box model corresponding to each element;
[0014] According to the page configuration file, the element parameters of each element on the initial page and the distance between each element and adjacent elements are adjusted to obtain a target page corresponding to the page to be generated.
[0015] In an exemplary embodiment, after adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated, the method further includes:
[0016] Obtaining element modification data of the original graphic file;
[0017] According to the element modification data, the box model of the element to be modified in the original graphic file is updated to obtain a new box model of the element to be modified;
[0018] According to the new box model of the element to be modified, the element parameters of the element to be modified in the target page are adjusted to obtain a first updated page corresponding to the target page.
[0019] In an exemplary embodiment, after adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated, the method further includes:
[0020] Obtaining newly added data of elements of the original graphic file;
[0021] Determine, according to the element new data, a box model corresponding to the element to be added in the original graphic file and an outer margin of the box model corresponding to the element to be added;
[0022] The element to be added is generated on the target page, and according to the box model corresponding to the element to be added and the outer margin of the box model corresponding to the element to be added, the element parameters of the element to be added in the target page and the distance between the element to be added and the adjacent elements are adjusted to obtain a second updated page corresponding to the target page.
[0023] In an exemplary embodiment, after adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated, the method further includes:
[0024] Acquire a verification file corresponding to the target page; the verification file is used to verify whether there is an error between the target page and the original graphic file;
[0025] Verifying the target page according to the verification file;
[0026] If the target page verification fails, the target page corresponding to the to-be-generated page is regenerated.
[0027] In an exemplary embodiment, the verifying the target page according to the verification file includes:
[0028] According to the verification file, determining whether there is an error between the target page and the original graphic file;
[0029] If there is an error between the target page and the original graphic file, it is determined that the target page verification fails.
[0030] According to a second aspect of an embodiment of the present disclosure, there is provided a page generating device, including:
[0031] an acquisition unit, configured to acquire a box model corresponding to each element in an original graphic file of a page to be generated, and an outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify an element parameter of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify a distance between the corresponding element and an adjacent element;
[0032] A generating unit is configured to generate each element on a preset layout page to obtain an initial page corresponding to the page to be generated;
[0033] The adjustment unit is configured to adjust the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, so as to obtain a target page corresponding to the page to be generated.
[0034] In an exemplary embodiment, the acquisition unit is further configured to execute the acquisition of element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and adjacent elements; query the correspondence between the element parameters and the box model according to the element parameters corresponding to each element, and obtain the box model corresponding to each element; determine the outer margin of the box model corresponding to each element according to the distance between each element and adjacent elements.
[0035] In an exemplary embodiment, the adjustment unit is further configured to generate a page configuration file of the page to be generated based on the box model corresponding to each element and the outer margin of the box model corresponding to each element; and adjust the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the page configuration file to obtain a target page corresponding to the page to be generated.
[0036] In an exemplary embodiment, the page generating device also includes a modification unit, which is configured to execute the acquisition of element modification data of the original graphic file; based on the element modification data, update the box model of the element to be modified in the original graphic file to obtain a new box model of the element to be modified; based on the new box model of the element to be modified, adjust the element parameters of the element to be modified in the target page to obtain a first updated page corresponding to the target page.
[0037] In an exemplary embodiment, the page generating device also includes an updating unit, which is configured to execute the acquisition of new element data of the original graphic file; determine the box model corresponding to the to-be-added element in the original graphic file and the outer margin of the box model corresponding to the to-be-added element based on the new element data; generate the to-be-added element on the target page, and adjust the element parameters of the to-be-added element in the target page and the distance between the to-be-added element and adjacent elements based on the box model corresponding to the to-be-added element and the outer margin of the box model corresponding to the to-be-added element, so as to obtain a second updated page corresponding to the target page.
[0038] In an exemplary embodiment, the page generating device further includes a verification unit configured to execute acquisition of a verification file corresponding to the target page; the verification file is used to verify whether there is an error between the target page and the original graphic file; the target page is verified according to the verification file; if the verification of the target page fails, the target page corresponding to the page to be generated is regenerated.
[0039] In an exemplary embodiment, the verification unit is further configured to execute, based on the verification file, a determination as to whether there is an error between the target page and the original graphic file; if there is an error between the target page and the original graphic file, it is determined that the verification of the target page has failed.
[0040] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement a page generation method as described in any one of the embodiments of the first aspect.
[0041] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, comprising: when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the page generation method described in any one of the embodiments of the first aspect.
[0042] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, the program product comprising a computer program, the computer program being stored in a readable storage medium, at least one processor of a device reading and executing the computer program from the readable storage medium, so that the device executes the page generation method described in any one of the embodiments of the first aspect.
[0043] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:
[0044] By obtaining the box model corresponding to each element in the original graphic file of the page to be generated, and the outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent elements; then each element is generated on the preset layout page to obtain the initial page corresponding to the page to be generated; finally, according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain the target page corresponding to the page to be generated. In this way, the purpose of page development according to the box model is achieved, and it is ensured that the elements in the generated target page correspond to the elements in the original graphic file and the element parameters are consistent, which improves the restoration rate of the target page to the original graphic file, thereby reducing the error between the generated page and the original graphic file, and thus improving the page generation effect.
[0045] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.
[0047] Figure 1 The diagram is an application environment diagram of a page generation method according to an exemplary embodiment.
[0048] Figure 2 The figure is a flow chart of a page generation method according to an exemplary embodiment.
[0049] Figure 3 The present invention is a flowchart showing the steps of obtaining a box model corresponding to each element in an original graphic file of a page to be generated and an outer margin of the box model corresponding to each element according to an exemplary embodiment.
[0050] Figure 4 The figure is a flow chart of a page generation method according to an exemplary embodiment.
[0051] Figure 5 The figure is a flowchart of another page generation method according to an exemplary embodiment.
[0052] Figure 6 The invention is a block diagram of a device for generating a page according to an exemplary embodiment.
[0053] Figure 7It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0054] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.
[0055] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0056] The page generation method provided by the present disclosure can be applied to Figure 1 In the application environment shown. The application environment includes a terminal 110, which can be, but is not limited to, various smart phones, tablet computers, or laptop computers. Specifically, refer to Figure 1 , the terminal 110 obtains the box model corresponding to each element in the original graphic file of the page to be generated, and the outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent elements; each element is generated on the preset layout page to obtain the initial page corresponding to the page to be generated; according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain the target page corresponding to the page to be generated.
[0057] Figure 2 is a flow chart of a page generation method according to an exemplary embodiment. Figure 2 As shown, the page generation method is used as follows Figure 1 The terminal 110 shown includes the following steps:
[0058] In step S210, the box model corresponding to each element in the original graphic file of the page to be generated and the outer margin of the box model corresponding to each element are obtained; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent elements.
[0059] Among them, the page to be generated refers to the page that needs to be generated, and the original graphic file refers to the more beautiful PSD file designed by the designer based on the demand document. PSD is a unique image file format in Photoshop; in actual scenarios, the original graphic file specifically refers to the design draft.
[0060] The original graphic file includes multiple elements, such as text, pictures, etc. Each element has corresponding element parameters and has a certain distance from adjacent elements. Element parameters refer to the style attributes of the element, such as line height, font size, font color, font weight, etc. It should be noted that line height refers to the height of a line of text.
[0061] Among them, the box model is a rectangular frame used to characterize the style attributes of elements in a page, including content, padding, and border, which constitute the height of the box model. The content is the actual content of the element, such as actual text, with a corresponding line height; the padding is between the content and the border, and the border is the border surrounding the padding and content. In addition, the box model also has a corresponding margin, which refers to the distance between the box model and the adjacent box model, and is used to characterize the distance between elements and adjacent elements in the page. In actual scenarios, the box model specifically refers to the IE box model. It should be noted that each element in the original graphic file corresponds to a box model.
[0062] Specifically, the terminal obtains the element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and the adjacent elements through a preset information acquisition instruction; based on the element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and the adjacent elements, the box model corresponding to each element in the original graphic file of the page to be generated and the outer margin of the box model corresponding to each element are determined.
[0063] In step S220, each element is generated on the preset layout page to obtain an initial page corresponding to the page to be generated.
[0064] Among them, the preset layout page is a basic page without elements.
[0065] Specifically, the terminal obtains a preset layout page and a position label of each element in the original graphic file; generates corresponding elements at corresponding positions on the preset layout page according to the position label of each element in the original graphic file, and obtains an initial page corresponding to the page to be generated.
[0066] In step S230, according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain the target page corresponding to the page to be generated.
[0067] The target page corresponding to the page to be generated refers to the real page corresponding to the original graphic file.
[0068] Specifically, the terminal adjusts the element parameters of each element on the initial page according to the box model corresponding to each element, so that the element parameters of each element on the initial page are respectively the same as the element parameters represented by the box model corresponding to each element, that is, respectively the same as the element parameters of each element in the original graphic file of the page to be generated; for example, the height of the corresponding element is adjusted according to the height of the box model; the content and line height of the corresponding element are adjusted according to the content and line height included in the box model; the inner padding of the corresponding element is adjusted according to the inner padding included in the box model; the border of the corresponding element is adjusted according to the border included in the box model. Then, the terminal adjusts the distance between each element and the adjacent element on the initial page according to the outer margin of the box model corresponding to each element, so that the distance between each element on the initial page and the adjacent element is respectively the same as the distance between the corresponding element and the adjacent element represented by the outer margin of the box model corresponding to each element, that is, respectively the same as the distance between each element and the adjacent element in the original graphic file of the page to be generated. In this way, the element parameters of each element on the initial page are adjusted according to the box model corresponding to each element, ensuring that the error between the elements in the target page finally generated and the elements in the original graphic file is small; the distance between each element on the initial page and the adjacent elements is adjusted according to the outer margins of the box model corresponding to each element, ensuring that the error between the target page finally generated and the page corresponding to the original graphic file is small, thereby ensuring high-precision development of the page.
[0069] In the above page generation method, by obtaining the box model corresponding to each element in the original graphic file of the page to be generated and the outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent elements; then each element is generated on the preset layout page to obtain the initial page corresponding to the page to be generated; finally, according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain the target page corresponding to the page to be generated. In this way, the purpose of page development according to the box model is achieved, and it is ensured that the elements in the generated target page correspond to the elements in the original graphic file and the element parameters are consistent, which improves the restoration rate of the target page to the original graphic file, thereby reducing the error between the generated page and the original graphic file, and thus improving the page generation effect.
[0070] In an exemplary embodiment, if Figure 3 As shown, in step S210, obtaining the box model corresponding to each element in the original graphic file of the page to be generated and the outer margin of the box model corresponding to each element can be specifically achieved by the following steps:
[0071] In step S310, element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and adjacent elements are obtained.
[0072] Specifically, the terminal responds to the received information acquisition instruction and acquires the element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and the adjacent elements.
[0073] For example, developers use Photoshop to open the design draft provided by the designer; then use Photoshop's move tool to select any element in the design draft, and then click the element's property button. If the element is text, you can view the line height, font size, font color value, font thickness, etc. of the text; if the element is a picture, you can view the width (width) and height (height) of the picture.
[0074] In step S320, the correspondence between the element parameters and the box model is queried according to the element parameters corresponding to each element, so as to obtain the box model corresponding to each element.
[0075] Among them, since the box model is used to characterize the element parameters of the element, different element parameters correspond to different box models; the correspondence between element parameters and box models refers to a one-to-one correspondence between element parameters and the box model that characterizes the element parameters.
[0076] Specifically, the terminal obtains the correspondence between element parameters and box models, and then queries the correspondence between element parameters and box models according to the element parameters corresponding to each element, obtains the box model corresponding to the element parameters of each element, and uses it as the box model corresponding to each element.
[0077] In step S330, the outer margin of the box model corresponding to each element is determined according to the distance between each element and the adjacent element.
[0078] Specifically, the terminal obtains the distance between the box model corresponding to each element and the box model corresponding to the adjacent element according to the distance between each element and the adjacent element and the box model corresponding to each element, which corresponds to the outer margin of the box model corresponding to each element.
[0079] The technical solution provided by the disclosed embodiment, by acquiring the box model corresponding to each element in the original graphic file of the page to be generated and the outer margin of the box model corresponding to each element, is conducive to the subsequent adjustment of the element parameters of each element on the initial page and the distance between each element and the adjacent elements according to the box model corresponding to each element in the original graphic file of the page to be generated and the outer margin of the box model corresponding to each element, so as to obtain the target page corresponding to the page to be generated, thereby ensuring that the elements in the generated target page correspond to the elements in the original graphic file and the element parameters are consistent, thereby reducing the error between the generated page and the original graphic file, and further improving the page generation effect.
[0080] In an exemplary embodiment, in the above step S230, according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain the target page corresponding to the page to be generated, including: generating a page configuration file of the page to be generated according to the box model corresponding to each element and the outer margin of the box model corresponding to each element; according to the page configuration file, adjusting the element parameters of each element on the initial page and the distance between each element and the adjacent elements to obtain the target page corresponding to the page to be generated.
[0081] The page configuration file is a configuration file for automatically adjusting element parameters of each element on the initial page and the distance between each element and adjacent elements.
[0082] Specifically, the terminal obtains the box model corresponding to each element and the outer margin of the box model corresponding to each element, and the position tags in the configuration file template respectively; according to the position tags, the box model corresponding to each element and the outer margin of the box model corresponding to each element are respectively imported into the corresponding positions in the configuration file template to obtain the page configuration file of the page to be generated; according to the page configuration file, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted, so that the element parameters of each element on the initial page are respectively the same as the element parameters represented by the box model corresponding to each element, and the distance between each element on the initial page and the adjacent elements are respectively the same as the distance between the corresponding element and the adjacent elements represented by the outer margin of the box model corresponding to each element, thereby obtaining the adjusted initial page as the target page corresponding to the page to be generated.
[0083] The technical solution provided by the embodiment of the present disclosure automatically adjusts the element parameters of each element on the initial page and the distance between each element and the adjacent elements according to the page configuration file generated based on the box model corresponding to each element and the outer margin of the box model corresponding to each element, thereby achieving the purpose of generating a target page corresponding to the page to be generated with one click, which is beneficial to improving the page generation efficiency; at the same time, it reduces the error between the generated page and the original graphic file, ensuring that the generated target page can highly restore the style attributes of the elements in the original graphic file, thereby improving the restoration rate of the target page to the original graphic file.
[0084] In an exemplary embodiment, in the above step S230, after adjusting the element parameters of each element on the initial page and the distance between each element and the adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, and obtaining the target page corresponding to the page to be generated, it also includes: obtaining element modification data of the original graphic file; updating the box model of the element to be modified in the original graphic file according to the element modification data, and obtaining a new box model of the element to be modified; adjusting the element parameters of the element to be modified in the target page according to the new box model of the element to be modified, and obtaining a first updated page corresponding to the target page.
[0085] The element modification data refers to the replacement data of the element parameters of the element to be modified, such as adjusting the element parameters of an element in the original graphic file to obtain the replacement data of the element parameters of the element. It should be noted that the element parameters of the element to be modified can refer to one element parameter of the element to be modified, or can refer to multiple element parameters of the element to be modified.
[0086] Specifically, the terminal obtains the element modification data of the original graphic file, determines the replacement data of the element parameters of the element to be modified in the original graphic file according to the element modification data of the original graphic file; updates the box model of the element to be modified in the original graphic file according to the replacement data, and obtains a new box model of the element to be modified; adjusts the element parameters of the element to be modified in the target page according to the new box model of the element to be modified, and obtains the adjusted target page as the first update page corresponding to the target page. For example, if the design draft only modifies the size of a picture, the developer only needs to pay attention to the picture to be modified in the target page and modify the size of the picture.
[0087] Further, assuming that the element modification data refers to the replacement data of the distance between the element to be modified and the adjacent elements, the terminal updates the outer margins of the box model of the element to be modified in the original graphic file according to the replacement data of the distance between the element to be modified and the adjacent elements, and obtains the new outer margins of the box model of the element to be modified; according to the new outer margins of the box model of the element to be modified, the distance between the element to be modified and the adjacent elements in the target page is adjusted to obtain the adjusted target page as the first updated page corresponding to the target page. For example, if the design draft only modifies the distance between two pictures, the developer only needs to modify the distance between the two pictures in the target page.
[0088] The technical solution provided by the embodiment of the present disclosure, when the element parameters of the elements in the original graphic file are modified, only needs to adjust the element parameters of the elements to be modified in the target page according to the new box model of the elements to be modified, without having to re-acquire the box model corresponding to each element in the original graphic file and the outer margins of the box model corresponding to each element, and generate the corresponding target page, thereby simplifying the update process of the target page and further improving the update efficiency of the target page.
[0089] In an exemplary embodiment, in the above step S230, after adjusting the element parameters of each element on the initial page and the distance between each element and the adjacent elements according to the box model corresponding to each element and the margins of the box model corresponding to each element, and obtaining the target page corresponding to the page to be generated, it also includes: obtaining the element new data of the original graphic file; determining the box model corresponding to the to-be-added element and the margins of the box model corresponding to the to-be-added element in the original graphic file according to the element new data; generating the to-be-added element on the target page, and adjusting the element parameters of the to-be-added element and the distance between the to-be-added element and the adjacent elements in the target page according to the box model corresponding to the to-be-added element and the margins of the box model corresponding to the to-be-added element, to obtain a second updated page corresponding to the target page.
[0090] The newly added element data refers to the element parameters of the element to be added in the original graphic file, and the distance between the element to be added and the adjacent elements. For example, when an element is added to the original graphic file, the element parameters of the element and the distance between the element and the adjacent elements are obtained as the newly added element data.
[0091] Specifically, the terminal obtains the element new data of the original graphic file, and determines the element parameters of the element to be added and the distance between the element to be added and the adjacent elements in the original graphic file according to the element new data of the original graphic file; determines the box model corresponding to the element to be added in the original graphic file and the outer margin corresponding to the box model according to the element parameters of the element to be added and the distance between the element to be added and the adjacent elements in the original graphic file; determines the position label of the element to be added on the target page, and generates the element to be added at the corresponding position on the target page according to the position label; adjusts the element parameters of the element to be added and the distance between the element to be added and the adjacent elements in the target page according to the box model corresponding to the element to be added and the outer margin corresponding to the box model, respectively, to obtain the adjusted target page as the second updated page corresponding to the target page. For example, if only a new element is added in the design draft, the developer only needs to add the new element on the target page.
[0092] The technical solution provided by the embodiment of the present disclosure is that, when adding a new element to the original graphic file, it is only necessary to add the new element to the target page, and adjust the element parameters of the new element in the target page and the distance between the new element and the adjacent elements according to the box model corresponding to the new element and the margin corresponding to the box model. There is no need to re-acquire the box model corresponding to each element in the original graphic file and the margin of the box model corresponding to each element, and generate the corresponding target page, thereby simplifying the update process of the target page and further improving the update efficiency of the target page.
[0093] In an exemplary embodiment, in the above step S230, after adjusting the element parameters of each element on the initial page and the distance between each element and the adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, and obtaining the target page corresponding to the page to be generated, it also includes: obtaining a verification file corresponding to the target page; the verification file is used to verify whether there is an error between the target page and the original graphic file; verifying the target page according to the verification file; if the verification of the target page fails, regenerating the target page corresponding to the page to be generated.
[0094] Among them, there is no error between the target page and the original graphic file, which means that the elements in the target page correspond to the elements in the original graphic file and the element parameters are consistent; there is an error between the target page and the original graphic file, which means that the elements in the target page do not correspond to the elements in the original graphic file and / or the element parameters are inconsistent.
[0095] Specifically, the terminal verifies the target page according to the verification file corresponding to the target page to determine whether there is an error between the target page and the original graphic file; if there is an error between the target page and the original graphic file, it means that the verification of the target page has failed; if the verification of the target page has failed, steps S210 to S230 are re-executed to regenerate the target page corresponding to the page to be generated.
[0096] In addition, if there is no error between the target page and the original graphic file, it means that the target page verification is successful; if the target page verification is successful, it means that the target page meets the requirements and can be put into practical application.
[0097] The technical solution provided by the embodiment of the present disclosure verifies the target page according to the verification file corresponding to the target page after generating the target page corresponding to the page to be generated, so as to determine whether there is an error between the target page and the original graphic file, and regenerates the target page corresponding to the page to be generated when the verification of the target page fails, thereby ensuring that the target page finally generated meets the requirements and can highly restore the style attributes of the elements in the original graphic file.
[0098] In an exemplary embodiment, verifying the target page according to the verification file includes: judging whether there is an error between the target page and the original graphic file according to the verification file; if there is an error between the target page and the original graphic file, confirming that the verification of the target page fails.
[0099] For example, the terminal determines, based on the verification file, whether the elements in the target page correspond to the elements in the original graphic file and whether the element parameters are consistent; if the elements in the target page do not correspond to the elements in the original graphic file and / or the element parameters are inconsistent, it means that there is an error between the target page and the original graphic file, and then confirms that the target page verification has failed.
[0100] In addition, if the elements in the target page correspond to the elements in the original graphic file and the element parameters are consistent, it means that there is no error between the target page and the original graphic file, thereby confirming that the target page verification is successful.
[0101] The technical solution provided by the embodiment of the present disclosure realizes the purpose of verifying the target page according to the verification file corresponding to the target page, which is conducive to regenerating the target page corresponding to the page to be generated in the event that the verification of the target page fails, thereby ensuring that the target page finally generated can highly restore the style attributes of the elements in the original graphic file, thereby improving the page generation effect.
[0102] Figure 4 is a flow chart of another page generation method according to an exemplary embodiment. Figure 4 As shown, the page generation method is used as follows Figure 1 The terminal 110 shown includes the following steps:
[0103] In step S410, element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and adjacent elements are obtained.
[0104] In step S420, the correspondence between the element parameters and the box model is queried according to the element parameters corresponding to each element, so as to obtain the box model corresponding to each element.
[0105] In step S430, the outer margin of the box model corresponding to each element is determined according to the distance between each element and the adjacent element.
[0106] In step S440, each element is generated on the preset layout page to obtain an initial page corresponding to the page to be generated.
[0107] In step S450, a page configuration file of the to-be-generated page is generated according to the box model corresponding to each element and the outer margin of the box model corresponding to each element.
[0108] In step S460, according to the page configuration file, the element parameters of each element on the initial page and the distance between each element and adjacent elements are adjusted to obtain a target page corresponding to the page to be generated.
[0109] The technical solution provided by the embodiment of the present disclosure achieves the purpose of page development based on the box model, ensures that the elements in the generated target page correspond to the elements in the original graphic file and the element parameters are consistent, improves the restoration rate of the target page to the original graphic file, thereby reducing the error between the generated page and the original graphic file, and further improves the page generation effect.
[0110] In an exemplary embodiment, if Figure 5 As shown, in order to more clearly illustrate the technical solution provided by the embodiment of the present disclosure, an application example of the page generation method of the present disclosure will be described in detail below, and the specific content of the application example is as follows:
[0111] First, analyze the design draft and correctly find the line-height, padding and margin of each element in the design draft; then, add the corresponding elements to the h5 page, and finally use the line-height and padding to set the style attributes of a single element, and use the margin to set the distance between elements, and finally get the target page corresponding to the design draft.
[0112] It should be noted that in the prior art, for a single line of text in a design draft, the height of the entire element is set, and then the element is set to be centered, and the spacing between elements is achieved with padding; however, when designing a multi-line text display, the above solution is obviously no longer applicable, and it is impossible to ensure the layout of each line of text and each line of text, as well as the height of the first line of text and the last line of text and the border to restore the design draft; moreover, using padding to set the spacing between elements will make the page readability very poor, and later design changes will be prone to errors; if the page is very complex, it will cause errors between the developed H5 page and the design draft later.
[0113] The above page generation method can achieve the following technical effects: (1) Based on the IE box model, margin, and line-height, it is conducive to high-precision development of the page; (2) It ensures the beauty of the page and can improve the speed of page development; (3) Correctly understand the layout idea of the design draft, ensure consistency with the layout idea of the design draft, correctly use line-height, padding and margin, and achieve zero error between the h5 page and the design draft.
[0114] It should be understood that although Figure 2-4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-4 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0115] Figure 6 is a block diagram of a page generation device according to an exemplary embodiment. Figure 6The device includes an acquisition unit 610, a generation unit 620 and an adjustment unit 630.
[0116] The acquisition unit 610 is configured to execute acquisition of the box model corresponding to each element in the original graphic file of the page to be generated, and the outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent elements.
[0117] The generating unit 620 is configured to generate each element on the preset layout page to obtain an initial page corresponding to the page to be generated.
[0118] The adjustment unit 630 is configured to adjust the element parameters of each element on the initial page and the distance between each element and the adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, so as to obtain the target page corresponding to the page to be generated.
[0119] In an exemplary embodiment, the acquisition unit 610 is further configured to execute the acquisition of element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and adjacent elements; query the correspondence between the element parameters and the box model according to the element parameters corresponding to each element, and obtain the box model corresponding to each element; determine the outer margin of the box model corresponding to each element according to the distance between each element and adjacent elements.
[0120] In an exemplary embodiment, the adjustment unit 630 is further configured to generate a page configuration file of the page to be generated based on the box model corresponding to each element and the outer margin of the box model corresponding to each element; according to the page configuration file, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain a target page corresponding to the page to be generated.
[0121] In an exemplary embodiment, the page generation device provided by the present disclosure also includes a modification unit, which is configured to execute the acquisition of element modification data of the original graphic file; based on the element modification data, the box model of the element to be modified in the original graphic file is updated to obtain a new box model of the element to be modified; based on the new box model of the element to be modified, the element parameters of the element to be modified in the target page are adjusted to obtain a first updated page corresponding to the target page.
[0122] In an exemplary embodiment, the page generation device provided by the present disclosure also includes an updating unit, which is configured to execute the acquisition of new element data of the original graphic file; determine the box model corresponding to the to-be-added element in the original graphic file and the margins of the box model corresponding to the to-be-added element based on the new element data; generate the to-be-added element on the target page, and adjust the element parameters of the to-be-added element in the target page and the distance between the to-be-added element and the adjacent elements based on the box model corresponding to the to-be-added element and the margins of the box model corresponding to the to-be-added element, so as to obtain a second updated page corresponding to the target page.
[0123] In an exemplary embodiment, the page generation device provided by the present disclosure also includes a verification unit, which is configured to execute acquisition of a verification file corresponding to a target page; the verification file is used to verify whether there is an error between the target page and the original graphic file; the target page is verified according to the verification file; if the verification of the target page fails, the target page corresponding to the page to be generated is regenerated.
[0124] In an exemplary embodiment, the verification unit is further configured to determine whether there is an error between the target page and the original graphic file based on the verification file; if there is an error between the target page and the original graphic file, it is determined that the verification of the target page has failed.
[0125] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0126] Figure 7 700 is a block diagram of a device 700 for executing the above-mentioned page generation method according to an exemplary embodiment. For example, the device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0127] Reference Figure 7 , device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .
[0128] The processing component 702 generally controls the overall operation of the device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0129] The memory 704 is configured to store various types of data to support operations on the device 700. Examples of such data include instructions for any application or method operating on the device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.
[0130] The power supply component 706 provides power to the various components of the device 700. The power supply component 706 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device 700.
[0131] The multimedia component 708 includes a screen that provides an output interface between the device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0132] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the device 700 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.
[0133] I / O interface 712 provides an interface between processing component 702 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.
[0134] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the device 700. For example, the sensor assembly 714 can detect the open / closed state of the device 700, the relative positioning of components, such as the display and keypad of the device 700, and the sensor assembly 714 can also detect the position change of the device 700 or a component of the device 700, the presence or absence of user contact with the device 700, the orientation or acceleration / deceleration of the device 700, and the temperature change of the device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0135] The communication component 716 is configured to facilitate wired or wireless communication between the device 700 and other devices. The device 700 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 716 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 716 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0136] In an exemplary embodiment, the device 700 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned page generation method.
[0137] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by the processor 720 of the device 700 to complete the above-mentioned page generation method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0138] In an exemplary embodiment, a computer program product is also provided, which includes a computer program stored in a computer-readable storage medium, and at least one processor of a device reads and executes the computer program from the computer-readable storage medium, so that the device executes the page generation method described in any embodiment of the present disclosure.
[0139] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.
[0140] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A page generation method, characterized in that: include: Obtain the box model corresponding to each element in the original graphic file of the page to be generated, and the outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify the element parameters of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify the distance between the corresponding element and the adjacent element; Generate corresponding elements at corresponding positions on a preset layout page according to the position labels of each element in the original graphic file, and obtain an initial page corresponding to the page to be generated; According to the box model corresponding to each element and the outer margin of the box model corresponding to each element, the element parameters of each element on the initial page and the distance between each element and the adjacent elements are adjusted to obtain the target page corresponding to the page to be generated; the target page corresponding to the page to be generated is the real page corresponding to the original graphic file.
2. The page generation method according to claim 1, characterized in that: The step of obtaining the box model corresponding to each element in the original graphic file of the page to be generated, and the outer margin of the box model corresponding to each element, includes: Obtaining element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and an adjacent element; According to the element parameters corresponding to each element, query the corresponding relationship between the element parameters and the box model to obtain the box model corresponding to each element; According to the distance between each element and an adjacent element, the outer margin of the box model corresponding to each element is determined.
3. The page generation method according to claim 1, characterized in that: The step of adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, to obtain the target page corresponding to the page to be generated, includes: Generate a page configuration file of the page to be generated according to the box model corresponding to each element and the outer margin of the box model corresponding to each element; According to the page configuration file, the element parameters of each element on the initial page and the distance between each element and adjacent elements are adjusted to obtain a target page corresponding to the page to be generated.
4. The page generation method according to claim 1, characterized in that: After adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated, the method further includes: Obtaining element modification data of the original graphic file; According to the element modification data, the box model of the element to be modified in the original graphic file is updated to obtain a new box model of the element to be modified; According to the new box model of the element to be modified, the element parameters of the element to be modified in the target page are adjusted to obtain a first updated page corresponding to the target page.
5. The page generation method according to claim 1, characterized in that: After adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated, the method further includes: Obtaining newly added data of elements of the original graphic file; Determine, according to the element new data, a box model corresponding to the element to be added in the original graphic file and an outer margin of the box model corresponding to the element to be added; The element to be added is generated on the target page, and according to the box model corresponding to the element to be added and the outer margin of the box model corresponding to the element to be added, the element parameters of the element to be added in the target page and the distance between the element to be added and the adjacent elements are adjusted to obtain a second updated page corresponding to the target page.
6. The page generation method according to claim 1, characterized in that: After adjusting the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element to obtain the target page corresponding to the page to be generated, the method further includes: Acquire a verification file corresponding to the target page; the verification file is used to verify whether there is an error between the target page and the original graphic file; Verifying the target page according to the verification file; If the target page verification fails, the target page corresponding to the to-be-generated page is regenerated.
7. The page generation method according to claim 6, characterized in that: The verifying the target page according to the verification file includes: According to the verification file, determining whether there is an error between the target page and the original graphic file; If there is an error between the target page and the original graphic file, it is determined that the target page verification fails.
8. A page generating device, characterized in that: include: an acquisition unit, configured to acquire a box model corresponding to each element in an original graphic file of a page to be generated, and an outer margin of the box model corresponding to each element; the box model corresponding to each element is used to identify an element parameter of the corresponding element, and the outer margin of the box model corresponding to each element is used to identify a distance between the corresponding element and an adjacent element; A generating unit is configured to generate corresponding elements at corresponding positions on a preset layout page according to the position labels of each element in the original graphic file, so as to obtain an initial page corresponding to the page to be generated; The adjustment unit is configured to adjust the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the box model corresponding to each element and the outer margin of the box model corresponding to each element, so as to obtain a target page corresponding to the page to be generated; the target page corresponding to the page to be generated is a real page corresponding to the original graphic file.
9. The page generating device according to claim 8, characterized in that: The acquisition unit is further configured to execute acquisition of element parameters corresponding to each element in the original graphic file of the page to be generated and the distance between each element and adjacent elements; query the correspondence between the element parameters and the box model according to the element parameters corresponding to each element, and obtain the box model corresponding to each element; determine the outer margin of the box model corresponding to each element according to the distance between each element and adjacent elements.
10. The page generating device according to claim 8, characterized in that: The adjustment unit is further configured to generate a page configuration file of the page to be generated according to the box model corresponding to each element and the outer margin of the box model corresponding to each element; and adjust the element parameters of each element on the initial page and the distance between each element and adjacent elements according to the page configuration file to obtain a target page corresponding to the page to be generated.
11. The page generating device according to claim 8, characterized in that: The page generation device also includes a modification unit, which is configured to execute acquisition of element modification data of the original graphic file; update the box model of the element to be modified in the original graphic file according to the element modification data to obtain a new box model of the element to be modified; and adjust the element parameters of the element to be modified in the target page according to the new box model of the element to be modified to obtain a first updated page corresponding to the target page.
12. The page generating device according to claim 8, characterized in that: The page generation device also includes an updating unit, which is configured to execute the acquisition of new element data of the original graphic file; determine the box model corresponding to the to-be-added element in the original graphic file and the outer margin of the box model corresponding to the to-be-added element according to the new element data; generate the to-be-added element on the target page, and adjust the element parameters of the to-be-added element in the target page and the distance between the to-be-added element and the adjacent elements according to the box model corresponding to the to-be-added element and the outer margin of the box model corresponding to the to-be-added element, so as to obtain a second updated page corresponding to the target page.
13. The page generating device according to claim 8, characterized in that: The page generation device further includes a verification unit configured to obtain a verification file corresponding to the target page; the verification file is used to verify whether there is an error between the target page and the original graphic file; and verify the target page according to the verification file; If the target page verification fails, the target page corresponding to the to-be-generated page is regenerated.
14. The page generation method according to claim 13, characterized in that: The verification unit is further configured to determine whether there is an error between the target page and the original graphic file based on the verification file; if there is an error between the target page and the original graphic file, confirm that the verification of the target page fails.
15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the page generation method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the page generation method as claimed in any one of claims 1 to 7.
17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the page generation method according to any one of claims 1 to 7 is implemented.
