Code compiling method and device, electronic equipment and storage medium

By constructing a node tree of page elements and generating metadata, the problem of low page development efficiency in the existing technology is solved, component interaction and flexible modification of UI styles are realized, and the development threshold is lowered.

CN118519635APending Publication Date: 2024-08-20TENCENT TECH (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310153241.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-02-17
Publication Date
2024-08-20

AI Technical Summary

Technical Problem

In the existing technology, the page development efficiency is low, it is difficult to interact between components, it is difficult to modify the UI style, and the component library is very targeted, resulting in reuse problems and high development threshold.

Method used

By obtaining the initial border and preset border in the drawn page, building a node tree, generating metadata and compiling it into preset frame code, the node tree of page elements and page development can be quickly constructed.

Benefits of technology

It improves code compilation efficiency and page development efficiency, enables interaction between components and flexible modification of UI styles, and lowers the development threshold.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519635A_ABST
    Figure CN118519635A_ABST
Patent Text Reader

Abstract

The invention discloses a code compiling method and device, electronic equipment and a storage medium, which can be applied to various scenes such as cloud technology, artificial intelligence, smart traffic, Internet of Vehicles and the like, and the method comprises the following steps: obtaining a drawn page; the drawn page comprises initial frames corresponding to the multiple page elements and preset frames corresponding to the multiple initial frames; each preset frame surrounds at least two initial frames; constructing a node tree based on the initial frame and a preset frame; the node tree comprises initial nodes and preset nodes; the initial node represents an initial frame, and the preset node represents a preset frame; the preset node is a father node of the initial node; generating metadata corresponding to the page elements according to the node tree; compiling the metadata corresponding to the plurality of page elements into codes of a preset framework; the code is used for displaying a preset page in a terminal corresponding to the preset frame; the code compiling efficiency can be improved, and the page development efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a code compilation method, device, electronic device and storage medium. Background Art

[0002] In related technologies, pages can be built visually using ready-made components; however, the components are less customizable (the style and logic of the components are difficult to modify), and you can only select and directly use the provided components; it is generally difficult to achieve more complex layout modes. The components are independent of each other and basically cannot interact; once secondary development is carried out, it is difficult to continue to use the visual editing product. Using the front-end component library to develop pages requires code development, which has a high threshold; component libraries are generally very targeted, such as antd, element-ui, etc., and it is difficult to modify the UI style. For some other tool libraries or hooks libraries, there is no efficiency improvement in developing the UI level. The same problem will arise when reusing components.

[0003] Therefore, the page development efficiency in the prior art is low. Summary of the invention

[0004] The present application provides a code compilation method, device, electronic device and storage medium, which can quickly construct a node tree corresponding to page elements in a page, thereby improving code compilation efficiency and improving page development efficiency.

[0005] In one aspect, the present application provides a code compilation method, the method comprising:

[0006] Acquire a drawing page; the drawing page includes initial frames corresponding to a plurality of page elements and preset frames corresponding to a plurality of the initial frames; each initial frame represents a page element; each preset frame surrounds at least two initial frames;

[0007] Based on the initial border and the preset border, a node tree is constructed; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node;

[0008] Generating metadata corresponding to each of the plurality of page elements according to the node tree;

[0009] The metadata corresponding to each of the plurality of page elements are compiled into a code of a preset framework; the code is used to display a preset page in a terminal corresponding to the preset framework.

[0010] Another aspect provides a code compilation device, the device comprising:

[0011] A page acquisition module, used to acquire a drawing page; the drawing page includes initial frames corresponding to a plurality of page elements and preset frames corresponding to a plurality of the initial frames; each initial frame represents a page element; each preset frame surrounds at least two initial frames;

[0012] A node tree construction module, used to construct a node tree based on the initial border and the preset border; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node;

[0013] A metadata generation module, used to generate metadata corresponding to each of the plurality of page elements according to the node tree;

[0014] The compiling module is used to compile the metadata corresponding to each of the plurality of page elements into a code of a preset framework; the code is used to display a preset page in a terminal corresponding to the preset framework.

[0015] In an exemplary embodiment, the node tree construction module includes:

[0016] A sorting submodule, used to sort the multiple candidate borders according to their respective corresponding areas to obtain a border sorting result; the candidate borders include the initial border and the preset border;

[0017] A coordinate determination submodule, used to determine the coordinate information corresponding to each of the plurality of candidate frames in the drawing page;

[0018] The construction submodule is used to construct the node tree according to the frame sorting result and the coordinate information corresponding to each of the plurality of candidate frames.

[0019] In an exemplary embodiment, the building block comprises:

[0020] A current frame determining unit, configured to determine a current frame according to the frame sorting result; the area of ​​the current frame is smaller than a preset area threshold;

[0021] A current outer frame determining unit, configured to determine a current outer frame corresponding to the current frame according to the coordinate information of each candidate frame; the current outer frame surrounds the current frame;

[0022] A parent-child node determination unit, used to determine the current border as a child node and the current outer border as a parent node;

[0023] a repeating unit, configured to redefine the current outer border as the current border, and repeat the steps of determining the current outer border corresponding to the current border according to the coordinate information of each candidate border, to determining the current border as a child node, and determining the current outer border as a parent node; until the current outer border is the target border;

[0024] A node tree construction unit is used to construct the node tree based on the parent node and the child node.

[0025] In an exemplary embodiment, the apparatus further comprises:

[0026] A traversal module, used for traversing the nodes in the node tree in sequence;

[0027] A current child node determination module, used to determine, for each current node traversed in the node tree, a current child node corresponding to the current node;

[0028] A sub-frame determination module, used for determining sub-frames corresponding to at least two current sub-nodes respectively if there are at least two current sub-nodes;

[0029] The arrangement mode determination module is used to determine the arrangement mode of at least two current sub-nodes according to the coordinate information corresponding to the at least two sub-frames.

[0030] In an exemplary embodiment, the arrangement determination module includes:

[0031] A coordinate acquisition submodule, used for acquiring coordinate information corresponding to any two target sub-frames in at least two of the sub-frames in the drawing page;

[0032] A center point coordinate determination submodule, used to determine the center point coordinates corresponding to the two target sub-frames respectively according to the coordinate information corresponding to the two target sub-frames respectively in the drawing page;

[0033] A connection line determination submodule, used to determine a connection line of the center points of the two target sub-frames according to the coordinates of the center points corresponding to the two target sub-frames;

[0034] An angle determination submodule, used to determine the angle between the center point line of the two target sub-frames and the horizontal line;

[0035] The first mode determination submodule is used to determine that the current sub-nodes corresponding to the two target sub-frames are arranged horizontally if the angle is less than a preset angle threshold.

[0036] In an exemplary embodiment, the apparatus further comprises:

[0037] The second mode determination module is used to determine that the current sub-nodes corresponding to the two target sub-borders are arranged vertically if the angle is greater than or equal to the preset angle threshold.

[0038] In an exemplary embodiment, the apparatus further comprises:

[0039] A reference page acquisition module, used to acquire a reference page, wherein the reference page includes the plurality of page elements;

[0040] An initial frame construction module, used to construct initial frames corresponding to the plurality of page elements respectively according to the coordinate information corresponding to the plurality of page elements respectively in the reference page;

[0041] A horizontal border determination module is used to determine a plurality of initial borders located in the same horizontal direction to obtain a plurality of horizontal borders;

[0042] A peripheral border construction module, used to construct a peripheral border based on the multiple horizontal borders; the peripheral border surrounds the multiple horizontal borders;

[0043] A preset frame determining module, configured to determine the outer frame as the preset frame if there is only one outer frame;

[0044] The page construction module is used to construct the drawing page according to the initial frame and the preset frame.

[0045] In an exemplary embodiment, if there are multiple peripheral borders, the device further includes:

[0046] An update frame determination module, configured to construct an update peripheral frame based on the plurality of peripheral frames; the update peripheral frame surrounds the plurality of peripheral frames;

[0047] The preset frame updating module is used to determine the outer frame and the updated outer frame as the preset frame.

[0048] In an exemplary embodiment, the metadata generation module includes:

[0049] A label determination submodule, used to determine the label type corresponding to each node in the node tree;

[0050] The metadata generation submodule is used to generate metadata corresponding to each of the plurality of page elements in the preset page according to the tag type corresponding to each node in the node tree.

[0051] On the other hand, a code compiling device is provided, the device comprising a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by the processor to implement the code compiling method as described above.

[0052] On the other hand, a computer storage medium is provided, wherein the computer storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the code compilation method as described above.

[0053] On the other hand, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the code compilation method as described above.

[0054] The code compilation method, device, electronic device and storage medium provided by this application have the following technical effects:

[0055] The present application obtains a drawing page; the drawing page includes initial borders corresponding to multiple page elements and preset borders corresponding to multiple initial borders; each initial border represents a page element; each preset border surrounds at least two initial borders; based on the initial borders and the preset borders, a node tree is constructed; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node; the present application can quickly construct a node tree corresponding to page elements in a page in the form of drawing borders; then, based on the node tree, metadata corresponding to multiple page elements in a preset page are generated; the metadata corresponding to multiple page elements are compiled into a code for a preset frame; the code is used to display the preset page in a terminal corresponding to the preset frame; thereby improving code compilation efficiency and page development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the technical solutions and advantages of the embodiments of this specification or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0057] Figure 1 is a schematic diagram of a code compilation system provided in an embodiment of this specification;

[0058] Figure 2 It is a flowchart of a code compilation method provided in an embodiment of this specification;

[0059] Figure 3 is a schematic diagram of a drawing page provided in an embodiment of this specification;

[0060] Figure 4 It is a flowchart of a method for constructing a drawing page provided in an embodiment of this specification;

[0061] Figure 5 is a schematic diagram of a reference page provided in an embodiment of this specification;

[0062] Figure 6 is a schematic diagram of an initial frame drawn based on a reference page provided in an embodiment of this specification;

[0063] Figure 7 It is a frame structure diagram provided by the embodiment of this specification;

[0064] Figure 8 is a schematic diagram of a node tree provided in an embodiment of this specification;

[0065] Fig. 9 It is a flowchart of a method for constructing a node tree based on an initial border and a preset border provided in an embodiment of this specification;

[0066] Fig.10 is a flowchart of a method for constructing the node tree according to the border sorting result and the coordinate information corresponding to each of the plurality of candidate borders provided in an embodiment of the present specification;

[0067] Fig.11 is a flowchart of a method for determining an arrangement of at least two current child nodes according to a node tree provided in an embodiment of this specification;

[0068] Fig.12 It is a flowchart of a method for determining an arrangement of at least two current sub-nodes according to coordinate information corresponding to at least two sub-frames provided by an embodiment of the present specification;

[0069] Fig.13 It is a structural diagram of a code compiling device provided in an embodiment of this specification;

[0070] Fig.14 It is a structural diagram of a server provided in an embodiment of this specification. DETAILED DESCRIPTION

[0071] The following will be combined with the drawings in the embodiments of this specification to clearly and completely describe the technical solutions in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0072] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application 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 interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0073] See also Figure 1 , Figure 1 is a schematic diagram of a code compilation system provided in an embodiment of this specification, such as Figure 1 As shown, the code compilation system may include at least a server 01 and a client 02 .

[0074] Specifically, in the embodiments of this specification, the server 01 may include an independently operated server, or a distributed server, or a server cluster composed of multiple servers, and may also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. Server 01 may include a network communication unit, a processor, a memory, and the like. Specifically, the server 01 can be used to construct a node tree and compile it into a code of a preset framework according to the node tree.

[0075] Specifically, in the embodiments of this specification, the client 02 may include physical devices such as smart phones, desktop computers, tablet computers, laptops, digital assistants, smart wearable devices, smart speakers, vehicle terminals, smart TVs, etc., and may also include software running in physical devices, such as web pages provided by some service providers to users, or applications provided by these service providers to users. Specifically, the client 02 may be used to display drawing pages, node trees, and code files of preset frameworks.

[0076] The following introduces a code compilation method of this application. Figure 2 It is a flowchart of a code compilation method provided by an embodiment of this specification. This specification provides method operation steps as described in the embodiment or flowchart, but may include more or fewer operation steps based on conventional or non-creative labor. The order of steps listed in the embodiment is only one way of executing the order of many steps and does not represent the only execution order. When the actual system or server product is executed, it can be executed in sequence or in parallel according to the method shown in the embodiment or the accompanying drawings (for example, in a parallel processor or multi-threaded processing environment).

[0077] Specific as Figure 2 As shown, the above method may include:

[0078] S201: Acquire a drawing page; the drawing page includes initial frames corresponding to a plurality of page elements and preset frames corresponding to the initial frames; each initial frame represents a page element; each preset frame surrounds at least two initial frames.

[0079] In the embodiment of the present specification, the plurality of page elements may be elements in a preset page to be displayed, and the page elements may include but are not limited to text, images, text boxes, and the like.

[0080] In the embodiments of this specification, the developer can use a mouse or a touchpad to draw a page on a terminal device. Accordingly, the terminal device will obtain the drawing page and then execute the following steps to generate code. Running the code can display the preset page.

[0081] Since developers only need to draw pages that reflect the clear relative position relationship between initial borders, the clear relative position relationship between preset borders, and the nested relationship between initial borders and preset borders, where the relative position relationship mainly includes "horizontal relationship" and "vertical relationship", and there is no need to draw the page very accurately, for example, there is no need to consider the specific size of each initial border and each preset border; so this method can improve code compilation efficiency and page development efficiency. Therefore, when drawing, you only need to pay attention to clearly expressing these two relationships.

[0082] In an exemplary embodiment, if Figure 3 As shown, Figure 3 is a schematic diagram of drawing a page, wherein the initial border can be a rectangular frame of different sizes, such as Figure 3 The initial borders 03, 04, 05, 06 in ; the preset borders containing the same number of initial borders can also be rectangular frames of different sizes, such as Figure 3 Preset borders 07 and 08 in .

[0083] In the embodiment of the present specification, multiple page elements in the reference page can be identified by artificial intelligence technology, and the initial frame and the preset frame can be drawn according to the position information of each page element in the page. The initial frame can include but is not limited to a rectangular frame, a polygonal frame, etc.

[0084] In some embodiments, a reference page may be displayed in a display interface to facilitate developers to draw borders through the displayed page.

[0085] In some embodiments, Figure 4 As shown, the construction method of the above drawing page includes:

[0086] S401: Acquire a reference page, where the reference page includes the multiple page elements;

[0087] In the embodiment of the present specification, the reference page is a sample page corresponding to the preset page, and the page elements in the preset page are the same as the page elements in the reference page.

[0088] S403: constructing initial frames corresponding to the plurality of page elements according to the coordinate information corresponding to the plurality of page elements in the reference page;

[0089] In the embodiment of the present specification, in a drawing page, an initial border may surround an area corresponding to a page element.

[0090] S405: Determine a plurality of initial frames located in the same horizontal direction to obtain a plurality of horizontal frames;

[0091] In the embodiment of the present specification, a plurality of initial borders located in the same horizontal direction may be determined as horizontal borders, so as to further draw a preset border.

[0092] S407: constructing a peripheral border based on the multiple horizontal borders; the peripheral border surrounds the multiple horizontal borders;

[0093] In the embodiment of the present specification, a peripheral frame may be drawn outside a plurality of horizontal frames in the same horizontal direction, so that the peripheral frame surrounds the plurality of horizontal frames.

[0094] S409: If there is only one outer border, determine the outer border as the preset border;

[0095] In the embodiment of the present specification, if only one outer border can be constructed according to the initial border, the outer border is determined as the preset border.

[0096] In the embodiment of the present specification, if there are multiple outer borders, the method further includes:

[0097] Based on the plurality of the outer borders, an updated outer border is constructed; the updated outer border surrounds the plurality of the outer borders;

[0098] The outer border and the updated outer border are determined as the preset border.

[0099] In the embodiment of the present specification, if multiple peripheral borders can be constructed according to the initial border, then the updated peripheral border can be constructed according to multiple peripheral borders in the same horizontal direction or vertical direction, so that the updated peripheral border surrounds multiple peripheral borders; at this time, if the constructed updated peripheral border is one, the peripheral border and the above-mentioned updated peripheral border are determined as the above-mentioned preset border; if the constructed updated peripheral border is multiple, then the newly added border can be constructed on the basis of the updated peripheral border, and so on, until the final constructed border is one, and all the constructed borders are used as preset borders. And the border structure diagram can be displayed in the display interface; the border structure diagram includes all the constructed borders.

[0100] In some embodiments, a preset border can be first constructed according to the range of the above-mentioned multiple page elements in the drawing page, and then an initial border can be constructed according to the position information of the above-mentioned multiple page elements in the drawing page; each initial border represents a page element, and the preset border surrounds at least two initial borders.

[0101] In some embodiments, there are only two relative positions between borders: "horizontal relationship" and "vertical relationship", so when drawing, you only need to pay attention to clearly expressing these two relationships. At the same time, since you only need to pay attention to the relative position, the size of the rectangular area of ​​the border does not matter, so some nested rectangular structure diagrams can be drawn very quickly. In some embodiments, you can also first determine multiple vertical borders in the same vertical direction, and then draw a peripheral border around the multiple vertical borders.

[0102] In some embodiments, the initial borders corresponding to the above-mentioned multiple page elements can be constructed according to the position information of the above-mentioned multiple page elements in the above-mentioned drawing page; each initial border represents a page element. Then, based on the positional relationship between the initial borders, a preset border is constructed; the above-mentioned preset border surrounds at least two initial borders. In the embodiments of this specification, after the initial border is constructed, the preset border can be further constructed by artificial intelligence technology, and the developer can also draw the preset border manually; each preset border can surround at least two initial borders.

[0103] In an exemplary embodiment, if Figure 5 As shown, Figure 5is a schematic diagram of a reference page, in which the texts such as "email", "password", "login", "register" and the text boxes are all page elements; Figure 6 As shown, Figure 6 A schematic diagram of the initial border drawn based on the reference page; Figure 5 Each page element in Figure 6 There is a corresponding rectangular frame in each.

[0104] In an exemplary embodiment, if Figure 7 As shown, Figure 7 is a frame structure diagram, in which rectangular frames 09 and 10 are both in Figure 6 A preset border that builds on the initial border shown.

[0105] S4011: Construct the drawing page according to the initial frame and the preset frame.

[0106] In the embodiment of the present specification, the display page corresponding to the initial frame and the preset frame may be determined as the drawing page.

[0107] In the embodiments of the present specification, the drawing page can be constructed by artificial intelligence technology, or the drawing page can be obtained by manually drawing a border.

[0108] S203: constructing a node tree based on the initial border and the preset border; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node.

[0109] In the embodiments of the present specification, a border structure diagram can be constructed based on the initial border and the above-mentioned preset border, and then a node tree can be constructed based on the border structure diagram. The nodes in the node tree represent the above-mentioned initial border and the above-mentioned preset border; wherein the root node represents the border with the largest area. A border structure diagram can correspond to one or more node trees, and a node tree can be constructed based on a border structure diagram, or multiple node trees can be constructed based on a border structure diagram.

[0110] In an exemplary embodiment, if Figure 8 As shown, Figure 8 is a schematic diagram of a node tree, where node 11 corresponds to Figure 6 The border 09 in the root node corresponds to Figure 6 Middle frame 10.

[0111] In some embodiments, Fig. 9 As shown, based on the above initial border and the above preset border, a node tree is constructed, including:

[0112] S2031: sorting the plurality of candidate borders according to their respective corresponding areas to obtain a border sorting result; the candidate borders include the initial border and the preset border;

[0113] In the embodiments of the present specification, both the initial border and the preset border can be used as candidate borders; and all candidate borders are sorted from small to large according to the area corresponding to each border to obtain a border sorting result; and a node tree is further constructed according to the border sorting result.

[0114] S2033: Determine the coordinate information corresponding to each of the plurality of candidate frames in the drawing page;

[0115] In an embodiment of the present specification, after the candidate borders are constructed, the border identifiers of the candidate borders and the coordinate information in the above-mentioned drawing page can be determined; for any candidate border, the position of the rectangle can be determined by the coordinate information of the two vertices on a diagonal line of the rectangular frame; for example, the coordinate information of the upper left corner and the lower right corner of the candidate border can be determined, and a candidate border can be uniquely represented by these two coordinates.

[0116] S2035: Constructing the node tree according to the border sorting result and the coordinate information corresponding to each of the plurality of candidate borders.

[0117] In the embodiment of the present specification, the nodes in the node tree can be constructed from bottom to top according to the border sorting result, and the parent node corresponding to each child node can be determined according to the coordinate information of each candidate border.

[0118] In the embodiments of this specification, Fig.10 As shown, according to the above border sorting results and the coordinate information corresponding to each of the above multiple candidate borders, the above node tree is constructed, including:

[0119] S20351: Determine a current border according to the border sorting result; the area of ​​the current border is smaller than a preset area threshold;

[0120] In the embodiment of the present specification, the parent node of each frame can be determined in order from small to large areas according to the frame sorting result; first, the frame with the smallest area is used as the current frame, so as to determine the parent node corresponding to the current frame.

[0121] S20353: Determine a current outer border corresponding to the current border according to the coordinate information of each candidate border in the drawing page; the current outer border surrounds the current border;

[0122] In an embodiment of the present specification, a filtering border having an area larger than the current border can be filtered out from multiple candidate borders, and then the current outer border corresponding to the current border can be determined based on the coordinate information of each filtering border; the current outer border is a border that contains the current border, and whether there is an inclusion relationship between the borders can be determined through the coordinate information of each border.

[0123] S20355: Determine the current border as a child node, and determine the current outer border as a parent node;

[0124] In the embodiment of the present specification, after the current border and the current peripheral border are determined, the node corresponding to the current peripheral border can be used as a parent node, and the node corresponding to the current border can be used as a child node.

[0125] S20357: re-determine the current outer border as the current border, repeat the above steps of determining the current outer border corresponding to the current border according to the coordinate information of each candidate border, until the above steps of determining the current border as a child node and the current outer border as a parent node; until the current outer border is the target border;

[0126] In the embodiment of the present specification, the target border is the border with the largest area among the candidate borders. If the current outer border is the target border, it means that all candidate borders have been traversed. If the current outer border is not the target border, the current outer border can be used as the current border again, and the current outer border corresponding to the current border is determined repeatedly according to the coordinate information of each candidate border, until the step of determining the current border as a child node and the current outer border as a parent node is performed, and the parent node corresponding to the current outer border is continued to be determined, thereby constructing more parent-child node pairs, so as to facilitate the construction of a complete node tree.

[0127] S20359: Based on the parent node and the child node, construct the node tree.

[0128] In the embodiments of the present specification, the target border may be used as a root node to construct a complete node tree; configuration information corresponding to each node may be stored in the node tree, and if the node corresponds to a page element, the configuration information of the page element is stored.

[0129] In some embodiments, Fig.11 As shown, after constructing the node tree based on the initial border and the preset border, the method further includes:

[0130] S2041: traverse the nodes in the node tree in sequence;

[0131] In the embodiments of this specification, after constructing the node tree, the same parent node may correspond to multiple child nodes, and the arrangement between the child nodes generally includes two ways: horizontal arrangement and vertical arrangement; the arrangement between the child nodes needs to be determined according to the center line of the border corresponding to the child node. Starting from the root node, each node in the node tree can be traversed in turn, and a node including multiple child nodes can be determined.

[0132] S2043: for each current node traversed in the node tree, determine a current child node corresponding to the current node;

[0133] In the embodiment of the present specification, for each traversed current node, the number of its corresponding current child nodes can be determined.

[0134] S2045: If there are at least two current child nodes, determine sub-frames corresponding to at least two of the current child nodes;

[0135] In the embodiment of the present specification, if there are multiple current sub-nodes, the arrangement of the sub-nodes can be determined according to the sub-borders corresponding to the current sub-nodes.

[0136] S2047: Determine an arrangement of at least two of the current sub-nodes according to the coordinate information corresponding to the at least two sub-borders in the drawing page.

[0137] In the embodiment of the present specification, the arrangement of at least two current sub-nodes may be determined according to the coordinate information corresponding to the at least two sub-borders; the arrangement includes horizontal arrangement and vertical arrangement.

[0138] In some embodiments, Fig.12 As shown, the method of determining the arrangement of at least two current sub-nodes according to the coordinate information corresponding to the at least two sub-frames in the drawing page includes:

[0139] S20471: For any two target sub-frames of the at least two sub-frames, obtaining coordinate information corresponding to the two target sub-frames in the drawing page;

[0140] In the embodiment of the present specification, the coordinate information corresponding to any two target sub-borders in the above drawing page can be obtained, and the arrangement of the current sub-nodes corresponding to the two can be determined according to the coordinate information.

[0141] S20473: Determine the coordinates of the center points of the two target sub-frames, according to the coordinate information of the two target sub-frames.

[0142] In the embodiment of the present specification, the coordinates of the center point of the target sub-frame may be determined according to the coordinate information corresponding to the target sub-frame.

[0143] S20475: Determine a line connecting the center points of the two target sub-frames according to the coordinates of the center points corresponding to the two target sub-frames;

[0144] In the embodiment of the present specification, the center point connection line of the two target sub-frames may be determined according to the center point coordinates corresponding to the two target sub-frames.

[0145] S20477: Determine the angle between the line connecting the center points of the two target sub-frames and the horizontal line;

[0146] In the embodiment of the present specification, the angle between the center point line and the horizontal line may be calculated, and the arrangement of the current sub-nodes may be determined according to the angle.

[0147] S20479: If the angle is less than a preset angle threshold, determine that the current sub-nodes corresponding to the two target sub-borders are arranged horizontally.

[0148] In the embodiments of the present specification, the preset angle threshold can be determined according to the actual situation, for example, the preset angle threshold can be set to 45 degrees, or it can be set to other values ​​according to the actual situation. When the angle is less than the preset angle threshold, it can be determined that the current sub-nodes corresponding to the two target sub-borders are arranged horizontally.

[0149] In some embodiments, the above method further comprises:

[0150] S204711: If the angle is greater than or equal to the preset angle threshold, determine that the current sub-nodes corresponding to the two target sub-borders are arranged vertically.

[0151] In the embodiment of the present specification, when the included angle is greater than or equal to a preset angle threshold, it can be determined that the current sub-nodes corresponding to the two target sub-borders are arranged vertically.

[0152] S205: Generate metadata corresponding to each of the plurality of page elements according to the node tree.

[0153] In the embodiments of this specification, metadata, also known as intermediary data or relay data, is data about data, mainly information describing data properties, used to support functions such as indicating storage location, historical data, resource search, and file records. The metadata repository is a warehouse that organizes, stores, and manages data according to data structures. Since the structure of the node tree itself already indicates a nested relationship, location-related data may no longer be recorded in the metadata of this embodiment. By continuously expanding this structure and using this structure, it can function in more scenarios.

[0154] In the embodiment of the present specification, metadata corresponding to each of the plurality of page elements in the preset page is generated according to the node tree, including:

[0155] Determine the label type corresponding to each node in the above node tree;

[0156] In the embodiments of the present specification, since the Document Object Model (DOM) structure code has multiple tags, a tag field can be extended based on the metadata, and the metadata can be constructed according to the tag type corresponding to each node in the node tree; DOM is a standard programming interface for processing extensible markup language recommended by the W3C organization; DOM provides an access model for the entire document, treating the document as a tree structure, and each node of the tree represents an HTML tag or a text item in the tag. The DOM tree structure accurately describes the interrelationships between tags in the HTML document. The process of converting an HTML or XML document into a DOM tree is called parsing.

[0157] According to the tag type corresponding to each node in the node tree, metadata corresponding to each of the plurality of page elements in the preset page is generated.

[0158] In the embodiment of the present specification, metadata corresponding to each of the plurality of page elements in the above-mentioned preset page may be generated according to the tag type corresponding to each node in the node tree, so that the metadata includes the tag type of each node.

[0159] S207: Compile the metadata corresponding to each of the above-mentioned multiple page elements into a code of a preset framework; the above-mentioned code is used to display the preset page in the terminal corresponding to the preset framework.

[0160] In the embodiments of the present specification, the preset page is a page composed of multiple elements; different terminals may correspond to different preset frames, and the metadata corresponding to the multiple page elements may be compiled into the code of the preset frame through a compiler, and the code may be a DOM structure code; the above code is used to display the above preset page in the terminal corresponding to the above preset frame; thereby, multiple versions of DOM structure code are obtained based on one piece of metadata, thereby improving the reuse rate of metadata and the efficiency of code compilation.

[0161] In the embodiments of this specification, visual editing of DOM structure code is realized, and this visual editing method is continuously iterable, and will not be unable to be edited again because of one generation. The secondary editing here means that it can still be edited visually later; the metadata structure generated by visual editing has many usage scenarios, such as compiling multi-terminal codes, persisting the editing status, and being able to be expanded more according to actual needs. This embodiment is a general solution for visual structured editing. As long as it is such a nested structured editing scenario, this solution can be used, rather than being limited to DOM structure scenarios.

[0162] It can be seen from the technical solution provided in the above embodiments of this specification that the embodiments of this specification obtain a drawing page; the above-mentioned drawing page includes initial borders corresponding to multiple page elements and preset borders corresponding to multiple initial borders; each initial border represents a page element; each preset border surrounds at least two initial borders; based on the above-mentioned initial borders and the above-mentioned preset borders, a node tree is constructed; the above-mentioned node tree includes an initial node and a preset node; the above-mentioned initial node represents the above-mentioned initial border, and the above-mentioned preset node represents the above-mentioned preset border; the above-mentioned preset node is the parent node of the above-mentioned initial node; the present application can quickly construct a node tree corresponding to the page elements in the page in the form of drawing borders; then generate metadata corresponding to multiple page elements in the preset page according to the node tree; compile the metadata corresponding to multiple page elements into the code of the preset frame; the code is used to display the preset page in the terminal corresponding to the preset frame; thereby improving the code compilation efficiency and the page development efficiency.

[0163] The embodiment of this specification also provides a code compilation device, such as Fig.13 As shown, the above device comprises:

[0164] The page acquisition module 1310 is used to acquire a drawing page; the drawing page includes initial frames corresponding to multiple page elements and preset frames corresponding to multiple initial frames; each initial frame represents a page element; each preset frame surrounds at least two initial frames;

[0165] The node tree construction module 1320 is used to construct a node tree based on the initial border and the preset border; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node;

[0166] The metadata generation module 1330 is used to generate metadata corresponding to each of the plurality of page elements according to the node tree;

[0167] The compiling module 1340 is used to compile the metadata corresponding to each of the above-mentioned multiple page elements into a code of a preset framework; the above-mentioned code is used to display a preset page in a terminal corresponding to the above-mentioned preset framework.

[0168] In an exemplary embodiment, the node tree construction module includes:

[0169] A sorting submodule, used to sort the plurality of candidate borders according to their respective corresponding areas to obtain a border sorting result; the candidate borders include the initial border and the preset border;

[0170] A coordinate determination submodule, used to determine the coordinate information corresponding to each of the above-mentioned multiple candidate bounding boxes;

[0171] The construction submodule is used to construct the node tree according to the border sorting result and the coordinate information corresponding to each of the plurality of candidate borders in the drawing page.

[0172] In an exemplary embodiment, the above-mentioned building block comprises:

[0173] A current border determining unit, used to determine a current border according to the border sorting result; the area of ​​the current border is smaller than a preset area threshold;

[0174] A current outer frame determining unit, used to determine a current outer frame corresponding to the current frame according to the coordinate information of each candidate frame; the current outer frame surrounds the current frame;

[0175] A parent-child node determination unit, used to determine the current border as a child node and the current outer border as a parent node;

[0176] a repeating unit, configured to redefine the current outer border as the current border, repeat the steps of determining the current outer border corresponding to the current border according to the coordinate information of each candidate border, to determining the current border as a child node, and determining the current outer border as a parent node; until the current outer border is the target border;

[0177] The node tree construction unit is used to construct the node tree based on the parent node and the child node if the current outer border is a target border.

[0178] In an exemplary embodiment, the apparatus further comprises:

[0179] A traversal module, used to traverse the nodes in the above node tree in sequence;

[0180] A current child node determination module, used to determine the current child node corresponding to each current node traversed in the node tree;

[0181] A sub-border determining module, used for determining sub-borders corresponding to at least two of the current sub-nodes respectively if there are at least two current sub-nodes;

[0182] The arrangement mode determination module is used to determine the arrangement mode of at least two of the above-mentioned current sub-nodes according to the coordinate information corresponding to each of the at least two above-mentioned sub-frames.

[0183] In an exemplary embodiment, the arrangement determination module includes:

[0184] A coordinate acquisition submodule, for acquiring coordinate information corresponding to any two target sub-frames of at least two of the sub-frames in the drawing page;

[0185] A center point coordinate determination submodule, used to determine the center point coordinates corresponding to the two target sub-frames respectively according to the coordinate information corresponding to the two target sub-frames respectively in the drawing page;

[0186] A connection line determination submodule, used for determining a connection line of the center points of the two target sub-frames according to the coordinates of the center points corresponding to the two target sub-frames;

[0187] An angle determination submodule, used to determine the angle between the center point line of the two target sub-frames and the horizontal line;

[0188] The first mode determination submodule is used to determine that the current sub-nodes corresponding to the two target sub-borders are arranged horizontally if the angle is less than a preset angle threshold.

[0189] In an exemplary embodiment, the apparatus further comprises:

[0190] The second mode determination module is used to determine that the current sub-nodes corresponding to the two target sub-borders are arranged vertically if the angle is greater than or equal to the preset angle threshold.

[0191] In an exemplary embodiment, the apparatus further comprises:

[0192] A reference page acquisition module, used to acquire a reference page, wherein the reference page includes the above-mentioned multiple page elements;

[0193] An initial frame construction module, used to construct initial frames corresponding to the plurality of page elements respectively according to the coordinate information corresponding to the plurality of page elements respectively in the reference page;

[0194] A horizontal border determination module is used to determine a plurality of initial borders located in the same horizontal direction to obtain a plurality of horizontal borders;

[0195] A peripheral border construction module is used to construct a peripheral border based on the multiple horizontal borders; the peripheral border surrounds the multiple horizontal borders;

[0196] A preset frame determining module, configured to determine the outer frame as the preset frame if there is only one outer frame;

[0197] The page construction module is used to construct the drawing page according to the initial frame and the preset frame.

[0198] In an exemplary embodiment, if there are multiple peripheral frames, the device further includes:

[0199] An update border determination module, configured to construct an update peripheral border based on the plurality of peripheral borders; the update peripheral border surrounds the plurality of peripheral borders;

[0200] The preset frame updating module is used to determine the above outer frame and the above updated outer frame as the above preset frame.

[0201] In an exemplary embodiment, the metadata generation module includes:

[0202] The label determination submodule is used to determine the label type corresponding to each node in the above node tree;

[0203] The metadata generation submodule is used to generate metadata corresponding to each of the multiple page elements in the above-mentioned preset page according to the tag type corresponding to each node in the above-mentioned node tree.

[0204] The device and method embodiments in the above-mentioned device embodiments are based on the same inventive concept.

[0205] An embodiment of the present specification provides a code compilation device, which includes a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the code compilation method provided in the above method embodiment.

[0206] An embodiment of the present application also provides a computer storage medium, which can be set in a terminal to store at least one instruction or at least one program related to a code compilation method in the method embodiment. The at least one instruction or at least one program is loaded and executed by the processor to implement the code compilation method provided by the above method embodiment.

[0207] The embodiment of the present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes to implement the code compilation method provided in the above method embodiment.

[0208] Optionally, in the embodiments of this specification, the storage medium may be located in at least one of the multiple network servers of the computer network. Optionally, in this embodiment, the storage medium may include, but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.

[0209] The above-mentioned memory in the embodiment of this specification can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, application programs required for functions, etc.; the data storage area may store data created according to the use of the above-mentioned devices, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor with access to the memory.

[0210] The code compilation method embodiment provided in the embodiments of this specification can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Taking running on a server as an example, Fig.14 1 is a hardware structure diagram of a server of a code compilation method provided in an embodiment of this specification. Fig.14As shown, the server 1400 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1410 (the central processing unit 1410 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 1430 for storing data, and one or more storage media 1420 (such as one or more mass storage devices) for storing application programs 1423 or data 1422. Among them, the memory 1430 and the storage medium 1420 can be short-term storage or permanent storage. The program stored in the storage medium 1420 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit 1410 can be configured to communicate with the storage medium 1420 and execute a series of instruction operations in the storage medium 1420 on the server 1400. The server 1400 may also include one or more power supplies 1460, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1440, and / or one or more operating systems 1421, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, FreeBSD TM, etc.

[0211] The input / output interface 1440 may be used to receive or send data via a network. The specific example of the network may include a wireless network provided by a communication provider of the server 1400. In one example, the input / output interface 1440 includes a network adapter (Network Interface Controller, NIC), which may be connected to other network devices via a base station so as to communicate with the Internet. In one example, the input / output interface 1440 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0212] It can be understood by those skilled in the art that Fig.14 The structure shown is only for illustration and does not limit the structure of the above electronic device. Fig.14 More or fewer components as shown, or with Fig.14 Different configurations shown.

[0213] It can be seen from the embodiments of the code compilation method, device, equipment or storage medium provided by the above-mentioned application that the present application obtains a drawing page; the above-mentioned drawing page includes initial borders corresponding to multiple page elements and preset borders corresponding to multiple initial borders; each initial border represents a page element; each preset border surrounds at least two initial borders; based on the above-mentioned initial borders and the above-mentioned preset borders, a node tree is constructed; the above-mentioned node tree includes an initial node and a preset node; the above-mentioned initial node represents the above-mentioned initial border, and the above-mentioned preset node represents the above-mentioned preset border; the above-mentioned preset node is the parent node of the above-mentioned initial node; the present application can quickly construct a node tree corresponding to the page elements in the page in the form of drawing borders; then generate metadata corresponding to multiple page elements in the preset page according to the node tree; compile the metadata corresponding to multiple page elements into the code of the preset frame; the code is used to display the preset page in the terminal corresponding to the preset frame; thereby improving the code compilation efficiency and the page development efficiency.

[0214] It should be noted that the above sequence of the embodiments of this specification is for description only and does not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0215] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0216] A person skilled in the art will appreciate that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program. The above program may be stored in a computer storage medium, and the above storage medium may be a read-only memory, a disk, or an optical disk, etc.

[0217] The above is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the protection scope of the present application.

Claims

1. A code compilation method, It is characterized in that The method comprises: Acquire a drawing page; the drawing page includes initial frames corresponding to a plurality of page elements and preset frames corresponding to a plurality of the initial frames; each initial frame represents a page element; each preset frame surrounds at least two initial frames; Based on the initial border and the preset border, a node tree is constructed; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node; Generating metadata corresponding to each of the plurality of page elements according to the node tree; The metadata corresponding to each of the plurality of page elements are compiled into a code of a preset framework; the code is used to display a preset page in a terminal corresponding to the preset framework.

2. The method according to claim 1, It is characterized in that The step of constructing a node tree based on the initial border and the preset border includes: Sorting the plurality of candidate frames according to their respective corresponding areas to obtain a frame sorting result; the candidate frames include the initial frame and the preset frame; Determine coordinate information corresponding to each of the plurality of candidate frames in the drawing page; The node tree is constructed according to the frame sorting result and the coordinate information corresponding to each of the plurality of candidate frames.

3. The method according to claim 2, It is characterized in that The step of constructing the node tree according to the border sorting result and the coordinate information corresponding to each of the plurality of candidate borders includes: Determine a current frame according to the frame sorting result; the area of ​​the current frame is smaller than a preset area threshold; Determine a current outer border corresponding to the current border according to the coordinate information of each candidate border; the current outer border surrounds the current border; Determine the current border as a child node, and determine the current outer border as a parent node; The current outer border is re-determined as the current border, and the steps of determining the current outer border corresponding to the current border according to the coordinate information of each candidate border are repeated until the steps of determining the current border as a child node and the current outer border as a parent node are repeated until the current outer border is the target border; The node tree is constructed based on the parent node and the child node.

4. The method according to claim 1, It is characterized in that After constructing the node tree based on the initial border and the preset border, the method further includes: Traversing the nodes in the node tree in sequence; For each current node traversed in the node tree, determine a current child node corresponding to the current node; If there are at least two current subnodes, determine sub-frames corresponding to at least two of the current subnodes respectively; Determining an arrangement mode of at least two current sub-nodes according to coordinate information corresponding to at least two sub-frames in the drawing page; The arrangement of the at least two current sub-nodes is stored in the configuration information corresponding to the current node.

5. The method according to claim 4, It is characterized in that The determining, according to the coordinate information corresponding to the at least two sub-frames in the drawing page, the arrangement of at least two current sub-nodes includes: For any two target sub-frames of at least two of the sub-frames, obtaining coordinate information corresponding to the two target sub-frames in the drawing page; Determine the center point coordinates of the two target sub-frames respectively according to the coordinate information of the two target sub-frames respectively in the drawing page; Determine a line connecting the center points of the two target sub-frames according to the coordinates of the center points corresponding to the two target sub-frames; Determine the angle between the center point line of the two target sub-frames and the horizontal line; If the included angle is less than a preset angle threshold, it is determined that the current sub-nodes corresponding to the two target sub-borders are arranged horizontally.

6. The method according to claim 5, It is characterized in that The method further comprises: If the included angle is greater than or equal to the preset angle threshold, it is determined that the current sub-nodes corresponding to the two target sub-borders are arranged vertically.

7. The method according to any one of claims 1 to 6, It is characterized in that The method for constructing the drawing page includes: Acquire a reference page, wherein the reference page includes the plurality of page elements; Constructing initial frames corresponding to the plurality of page elements respectively according to the coordinate information corresponding to the plurality of page elements in the reference page; Determine a plurality of initial borders located in the same horizontal direction to obtain a plurality of horizontal borders; Based on the multiple horizontal borders, construct a peripheral border; the peripheral border surrounds the multiple horizontal borders; If there is one outer border, determining the outer border as the preset border; The drawing page is constructed according to the initial frame and the preset frame.

8. The method according to claim 7, It is characterized in that If there are multiple outer borders, the method further includes: Based on the plurality of the outer borders, construct an updated outer border; the updated outer border surrounds the plurality of the outer borders; The outer border and the updated outer border are determined as the preset border.

9. The method according to claim 1, It is characterized in that Generating metadata corresponding to each of the plurality of page elements according to the node tree includes: Determine the label type corresponding to each node in the node tree; According to the tag type corresponding to each node in the node tree, metadata corresponding to each of the multiple page elements is generated.

10. A code compiling device, It is characterized in that The device comprises: A page acquisition module, used to acquire a drawing page; the drawing page includes initial frames corresponding to a plurality of page elements and preset frames corresponding to a plurality of the initial frames; each initial frame represents a page element; each preset frame surrounds at least two initial frames; A node tree construction module, used to construct a node tree based on the initial border and the preset border; the node tree includes an initial node and a preset node; the initial node represents the initial border, and the preset node represents the preset border; the preset node is the parent node of the initial node; A metadata generation module, used to generate metadata corresponding to each of the plurality of page elements according to the node tree; The compiling module is used to compile the metadata corresponding to each of the plurality of page elements into a code of a preset framework; the code is used to display a preset page in a terminal corresponding to the preset framework.

11. An electronic device, It is characterized in that The device comprises: a processor and a memory, wherein the memory stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by the processor to implement the code compilation method according to any one of claims 1-9.

12. A computer storage medium, It is characterized in that The computer storage medium stores at least one instruction or at least one program, and the at least one instruction or at least one program is loaded and executed by a processor to implement the code compilation method according to any one of claims 1 to 9.

13. A computer program product, comprising at least one instruction or at least one program, wherein the at least one instruction or at least one program is loaded and executed by a processor to implement the code compiling method according to any one of claims 1 to 9.