Code determination method and device, equipment, medium and product

By obtaining the design draft and annotation information, analyzing and generating structured files, and using component reference codes to determine the codes of design draft elements, the problem of low efficiency and code mismatch in the D2C process is solved, and automated conversion and efficiency improvement are achieved.

CN118567649APending Publication Date: 2024-08-30BEIJING YOUZHUJU NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410675697.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The conversion process of design draft to code (D2C) in the existing technology is inefficient. R&D personnel need to manually parse and convert design elements, resulting in low efficiency and code mismatch problems.

Method used

By obtaining the design draft and its annotation information, the structured file is analyzed, the element code is determined using the component reference code and structured data of the target component, and the code is generated under the development framework adapted to the component library to achieve automated conversion.

Benefits of technology

It improves the conversion efficiency from design draft to code, avoids the problem of mismatch between code and development framework, and simplifies the work process of R&D personnel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567649A
    Figure CN118567649A
Patent Text Reader

Abstract

The invention discloses a code determination method and device, equipment, a medium and a product, and the method comprises the steps that a design draft and marking information of the design draft are obtained, the design draft comprises a first element, and a target component matched with the first element exists in a component library; the annotation information comprises a mapping relation between the attribute of the first element and the attribute of the target component; analyzing the design draft and the annotation information to obtain a structured file; the structured file comprises structured data corresponding to the first element; then, according to the component reference code of the target component and the structured data corresponding to the first element, determining a code corresponding to the first element; and finally, according to the code corresponding to the first element, determining the code of the design draft under the development framework adapted to the component library, so that the purpose of automatically converting the design draft into the code can be achieved.
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 determination method, device, equipment, medium, and product. Background Art

[0002] With the continuous development of software development and design fields, the demand for design to code (D2C) is becoming more and more important. For example, in some scenarios, such as software development scenarios, designers can first manually create a design draft so that the design draft is used to display the appearance and / or interaction of an application or website; then the R&D personnel manually convert the design draft into code. Among them, because the R&D personnel need to manually parse the elements in the design draft and manually convert the elements obtained from the parse into corresponding codes, the task of converting a design draft into code becomes a tedious and time-consuming task, which leads to relatively low efficiency. Summary of the invention

[0003] The present application provides a code determination method, apparatus, device, medium, and product, which are conducive to improving the efficiency of D2C.

[0004] In order to achieve the above objectives, the technical solutions provided by this application are as follows:

[0005] The present application provides a code determination method, the method comprising:

[0006] Acquire a design draft and annotation information of the design draft, wherein the design draft includes a first element, a target component matching the first element exists in a component library, and the annotation information includes a mapping relationship between an attribute of the first element and an attribute of the target component;

[0007] Analyze the design draft and the annotation information to obtain a structured file; the structured file includes structured data corresponding to the first element;

[0008] Determining a code corresponding to the first element according to a component reference code of the target component and structured data corresponding to the first element;

[0009] According to the code corresponding to the first element, the code of the design draft under the development framework adapted by the component library is determined.

[0010] In a possible implementation manner, the process of determining the code corresponding to the first element includes:

[0011] Acquire at least one piece of attribute information from the structured data corresponding to the first element, the at least one piece of attribute information including a first attribute, and the first attribute does not belong to a preset type;

[0012] Determining a processing method corresponding to the first attribute according to a data type of the first attribute;

[0013] Processing the first attribute according to the processing method corresponding to the first attribute to obtain a processing result corresponding to the first attribute, wherein the processing result belongs to the preset type;

[0014] Determining an attribute code corresponding to the first element according to a processing result corresponding to the first attribute;

[0015] The code corresponding to the first element is determined according to the component reference code of the target component and the attribute code corresponding to the first element.

[0016] In a possible implementation manner, the at least one attribute information further includes a second attribute, and the second attribute belongs to a preset type;

[0017] The determining, according to the processing result corresponding to the first attribute, the attribute code corresponding to the first element includes:

[0018] The attribute code corresponding to the first element is determined according to a concatenation result between the processing result corresponding to the second attribute and the first attribute.

[0019] In a possible implementation manner, determining the code corresponding to the first element according to the component reference code of the target component and the structured data corresponding to the first element includes:

[0020] Determining a component code corresponding to the first element according to a component reference code of the target component and attribute information in structured data corresponding to the first element;

[0021] The code corresponding to the first element is determined according to the component code corresponding to the first element and the style information in the structured data corresponding to the first element.

[0022] In a possible implementation manner, the design draft further includes a sub-element of the first element;

[0023] The structured document also includes structured data corresponding to the sub-element;

[0024] Before determining the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element, the method further includes:

[0025] The code corresponding to the first element is updated using the code corresponding to the sub-element, where the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element.

[0026] In a possible implementation manner, the design draft further includes a second element, and there is no component matching the second element in the component library;

[0027] The structured file further includes structured data corresponding to the second element;

[0028] The step of determining the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element includes:

[0029] The code of the design draft under the development framework adapted by the component library is determined based on the code corresponding to the first element and the code corresponding to the second element; the code corresponding to the second element is determined based on the structured data corresponding to the second element.

[0030] The present application provides a code determination device, comprising:

[0031] A data acquisition unit, configured to acquire a design draft and annotation information of the design draft, wherein the design draft includes a first element, a target component matching the first element exists in a component library, and the annotation information includes a mapping relationship between an attribute of the first element and an attribute of the target component;

[0032] A data analysis unit, configured to analyze the design draft and the annotation information to obtain a structured file; the structured file includes structured data corresponding to the first element;

[0033] a first determining unit, configured to determine a code corresponding to the first element according to a component reference code of the target component and structured data corresponding to the first element;

[0034] The second determining unit is used to determine the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element.

[0035] The present application provides an electronic device, the device comprising: a processor and a memory;

[0036] The memory is used to store instructions or computer programs;

[0037] The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the code determination method provided in the present application.

[0038] The present application provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes the code determination method provided by the present application.

[0039] The present application provides a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the code determination method provided by the present application.

[0040] Compared with the related art, this application has at least the following advantages:

[0041] In the technical solution provided by the present application, a design draft and annotation information of the design draft are first obtained, the design draft includes a first element, there is a target component matching the first element in the component library, and the annotation information includes a mapping relationship between the attributes of the first element and the attributes of the target component; then the design draft and the annotation information are analyzed to obtain a structured file; the structured file includes structured data corresponding to the first element; then, based on the component reference code of the target component and the structured data corresponding to the first element, the code corresponding to the first element is determined; finally, based on the code corresponding to the first element, the code of the design draft under the development framework adapted by the component library is determined, so that the purpose of automatically converting the design draft into code can be achieved.

[0042] In addition, because the first element in the design draft matches the target component in the component library, the first element and its attributes can be implemented with the help of the target component and its attributes, so that the code corresponding to the first element can be determined with the help of the component reference code of the target component. In this way, the first element can be converted into the corresponding component in the component library during the D2C process, thereby effectively overcoming the defects caused by converting the first element into a Hypertext Markup Language (HTML) element during the D2C process, such as the incompatibility of the converted code with the actual development framework, and thus effectively improving the D2C effect. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0044] Figure 1 A flowchart of a code determination method provided in an embodiment of the present application;

[0045] Figure 2 A schematic diagram of a D2C process provided in an embodiment of the present application;

[0046] Figure 3A schematic diagram of a process of converting JSON data into code provided in an embodiment of the present application;

[0047] Figure 4 A schematic diagram of the structure of a code determination device provided in an embodiment of the present application;

[0048] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0049] Research has found that for the solution of manually converting design drafts into codes, this solution requires a large number of manual operations by R&D personnel, such as analyzing design elements, writing HTML, Cascading Style Sheets (CSS), JavaScript codes, etc., which makes the solution have defects such as low efficiency, prone to errors, and time-consuming.

[0050] The research also found that for some automatic implementation solutions of D2C, these solutions can automatically convert the elements in the design draft into simple HTML elements instead of the components in the component library involved in the actual development. This difference may cause the converted code to not match the components involved in the actual development, which will cause R&D personnel to manually adjust the converted code to resolve the mismatch, resulting in low efficiency.

[0051] Based on the above research, in order to better improve the D2C effect, such as efficiency, the present application provides a code determination method, which includes: first obtaining a design draft and annotation information of the design draft, the design draft includes a first element, there is a target component matching the first element in the component library, and the annotation information includes a mapping relationship between the attribute of the first element and the attribute of the target component; then analyzing the design draft and the annotation information to obtain a structured file; the structured file includes structured data corresponding to the first element; then, according to the component reference code of the target component and the structured data corresponding to the first element, determining the code corresponding to the first element; finally, according to the code corresponding to the first element, determining the code of the design draft under the development framework adapted by the component library, so that the purpose of automatically and quickly converting the design draft into code can be achieved.

[0052] In addition, because the first element in the design draft matches the target component in the component library, the first element and its attributes can be implemented with the help of the target component and its attributes, so that the code corresponding to the first element can be determined with the help of the component reference code of the target component. In this way, the first element can be converted into the corresponding component in the component library during the D2C process, thereby effectively overcoming the defects caused by converting the first element into an HTML element during the D2C process, such as the incompatibility of the converted code with the actual development framework, and thus effectively improving the D2C effect.

[0053] In addition, the present application does not limit the execution subject of the code determination method provided in the embodiment of the present application. For example, the code determination method provided in the embodiment of the present application can be applied to a terminal device or a server. For another example, the code determination method provided in the embodiment of the present application can also be implemented with the help of the data interaction process between the terminal device and the server. Among them, the terminal device can be a smart phone, a computer, a personal digital assistant (PDA), a tablet computer, etc. The server can be a stand-alone server, a cluster server, or a cloud server.

[0054] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0055] In order to better understand the technical solution provided by the present application, the code determination method provided by the present application is described below with reference to some drawings. Figure 1 As shown, the code determination method provided in the embodiment of the present application includes the following S1-S4. Figure 1 A flowchart of a code determination method provided in an embodiment of the present application.

[0056] S1: Obtain a design draft and annotation information of the design draft, the design draft includes a first element, a target component matching the first element exists in the component library, and the annotation information includes a mapping relationship between attributes of the first element and attributes of the target component.

[0057] Among them, the design draft is used to show the visual effects of some elements, such as responsive design, animation effects, interaction and other effects; and this application does not limit the design draft. For example, in some scenarios, such as software development scenarios, the design draft can be used to show the appearance and / or interaction of an application or website. It should be noted that this application does not limit the implementation method of the element. For example, it can refer to any user interface unit existing in the design draft, such as buttons, input boxes and other UI units.

[0058] In addition, for the design draft, such as Figure 2 For the design draft shown, the design draft may include at least one element so that the design draft is used to display the visual effect of the at least one element. The at least one element refers to some or all elements in the design draft.

[0059] In addition, the present application does not limit the implementation method of at least one element in the above paragraph. For example, the at least one element may include one or more first elements. Among them, the first element refers to an element that can match a component in the component library, so that the first element satisfies the following constraints: there is a target component matching the first element in the component library, so that the first element can be implemented with the help of the relevant code of the target component. The target component refers to a component that exists in the component library and matches the first element. It should be noted that the component library refers to the component library involved in the actual development, such as a standard component library adapted to vue3.

[0060] For example, in some scenarios, the at least one element may include not only one or more first elements, but also one or more second elements, wherein the second element refers to an element that cannot be matched with a component in the component library, such as an element customized by a designer.

[0061] In addition, the design draft is manually designed by the designer; and this application does not limit the method of obtaining the design draft. For example, the design draft can be created with the help of any application with a design draft building function.

[0062] For example, in some scenarios, the design draft acquisition process can be: after creating a blank design draft, select one or more variants from a pre-built component variant set and deploy them to the design draft, so that the design draft includes these variants, which is conducive to improving efficiency. The component variant set refers to a collection of component variants pre-built based on components in the component library, and a component variant is used to represent a component in a certain form.

[0063] It should be noted that the present application does not limit the construction method of the above component variant set. For example, it can specifically include the following steps: first, based on a component in the component library, create a main component in figma so that the structure and style of the main component are similar to the "certain component"; second, based on the "certain component", deploy some properties of the main component, such as font, color, alignment and other properties, so that different variants of the main component can be created with the help of these properties later; then, use the component variant (Figma variants) function to create different variants based on the main component, for example, select the main component → add a variant by clicking the "+" button in the property panel on the right, and set the corresponding property value for each variant so that different variants can represent different forms of the main component, such as different colors, different shapes and other forms. Finally, establish an association relationship between each variant and its properties, for example, select a variant on the main component → select the corresponding property in the property panel so that the property can represent the form of the variant. It can be seen that the present application can make different variants of some components through Figmavariants, so that these variants can express different forms, so that subsequent designers can switch different properties and then match the variants corresponding to the properties to meet their different deformation needs.

[0064] The annotation information of the design draft is used to map the attributes of some or all elements in the design draft to the corresponding attributes of the component that matches the element in the component library, so as to ensure that the attributes of the element can correspond one-to-one to the attributes of the component, thereby ensuring that the element can be implemented with the help of the relevant code of the component in the future. It can be seen that when the design draft includes a first element, and there is a target component matching the first element in the component library, the annotation information may include a mapping relationship between the attributes of the first element and the attributes of the target component. Among them, the mapping relationship is used to indicate which attribute of the target component each attribute of the first element corresponds to, and the present application does not limit the implementation method of the mapping relationship. For example, the mapping relationship may include the corresponding relationship between the color attribute of the first element and the color attribute of the target component, the corresponding relationship between the shape attribute of the first element and the shape attribute of the target component, and so on.

[0065] In addition, this application does not limit the method of obtaining the annotation information of the design draft. For example, the annotation information can be manually annotated by relevant personnel, such as R&D personnel, or the code conversion of the attributes. It can be seen that in a possible implementation mode, after the designer completes the design draft, the R&D personnel can manually add annotation information to the design draft, so that the annotation information can describe which component in the component library some or all elements in the design draft correspond to, and which attributes of the corresponding components in the component library each attribute of the element corresponds to.

[0066] For another example, in some scenarios, when the designer completes the design work by copying some existing elements to the current design draft, since these existing elements have been respectively annotated and bound with component mapping information in advance, in order to improve efficiency, when these existing elements are deployed to the design draft, the component mapping information bound to these existing elements can also be stored in the annotation information of the design draft, so that the annotation information of the design draft can include the component mapping information bound to these existing elements. Among them, for any element, if there is a component matching the element in the component library, the component mapping information bound to the element includes the mapping relationship between the attributes of the element and the attributes of the matching component. It should be noted that the present application does not limit the implementation method of the existing element. For example, the existing element can be implemented using a variant in a component variant set or an element in a previously completed design draft.

[0067] Based on the above paragraph, for the variants in the above component variant set, after the variant is created, the developer can annotate and bind component mapping information for these variants, so that the component mapping information can represent the mapping relationship between the properties of the variant and the properties of the corresponding component in the component library, so that the properties of the variant can correspond one-to-one to the properties of the component in the component library that matches the variant. In addition, because Figma supports custom plug-ins, developers can use custom plug-ins to add custom information (metaData) to the image structure of Figma, such as the metaData shown in the second row and second column of Table 1 below, so that the custom information includes the component mapping information. It should be noted that the present application does not limit the implementation method of the component mapping information. For example, the component mapping information may at least include the component name of the component in the component library that matches the variant, the mapping relationship between the properties of the variant and the properties of the matching component, and the conversion logic of the variant properties to the properties of the component.

[0068]

[0069] Table 1 MetaData annotated for some existing elements

[0070] It should be noted that in some scenarios, designers may customize some content, such as text, icons or other custom structures. Among them, because these customized contents may not be implemented with the help of figma variants, the annotation method of these customized contents is different from the annotation method of the above variants. In addition, the present application does not limit the implementation method of the annotation method of these customized contents, which can be set according to the actual application scenario. For example, in some scenarios, if the designer customizes a prefix layer structure in the input box, such as adding icons, drop-down structures, etc., the R&D personnel can map the prefix layer structure to the slot structure in the component library, and the metaData annotated for the prefix layer structure can be the metaData shown in the third row and second column of Table 1 above. In addition, for each customized content, the R&D personnel can determine which component in the component library the customized content can be mapped to based on some preset rules, or the R&D personnel can determine which component in the component library the customized content can be mapped to based on the component constraint information specified by the designer in advance for the customized content, such as component name, component type and other information.

[0071] In addition, in some scenarios, such as the scenario of development with the help of multiple component libraries, the present application also provides a possible implementation of the annotation information of the above design draft. In this implementation, when the design draft includes a first element, and there is a target component matching the first element in the multiple component libraries, the annotation information of the design draft may include the component mapping information corresponding to the first element. Among them, the component mapping information corresponding to the first element is used to describe which component in which component library the first element corresponds to, and which attributes of the corresponding component in the corresponding component library the attributes of the first element correspond to. It can be seen that in a possible implementation, the annotation information of the design draft may include the component library information of the first element, the description information of the target component matching the first element, and the mapping relationship between the attributes of the first element and the attributes of the target component. Among them, the component library information of the first element is used to describe which component library the target component matching the first element belongs to; and the present application does not limit the implementation of the component library information, for example, it may include the component library name. The description information of the target component is used to describe the target component; and the present application does not limit the implementation of the description information of the target component, for example, it may include the component name of the target component.

[0072] Based on the relevant content of S1 above, it can be known that in some scenarios, such as software development scenarios with the help of at least one component library, after obtaining the design draft, the annotation information of the design draft can be obtained, so that the annotation information includes the component mapping information corresponding to some or all elements in the design draft, so that the annotation information can indicate which component of these component libraries these elements correspond to, and which attributes of these elements correspond to which attributes in these component libraries. Among them, for an element, the component mapping information corresponding to the element is used to indicate which component of which component library the element corresponds to, and which attributes of the element correspond to which attributes of the corresponding component in the corresponding component library, so that the component mapping information can be converted into the code corresponding to the element during subsequent code conversion.

[0073] S2: Analyze the design draft and the annotation information of the design draft to obtain a structured file; the structured file includes structured data corresponding to the first element.

[0074] Among them, the structured file is used to express the information described by the design draft and the annotation information of the design draft in a structured manner, such as the characteristics of each element in the design draft; and this application does not limit the structured manner, such as it can be implemented by key-value pairs. It can be seen that in a possible implementation method, the structured file can be used to express the information described by the design draft and the annotation information of the design draft in a key-value pair manner.

[0075] In addition, the present application does not limit the implementation method of the structured file. For example, the structured file can use JSON data, such as Figure 3 The JSON data shown is implemented.

[0076] In addition, in some scenarios, when multiple elements are deployed in the design draft, the above structured file may include structured data corresponding to these elements. Among them, for any element, the structured data corresponding to the element is used to express the information described by the design draft and the annotation information of the design draft for the element in a structured manner; and the present application does not limit the implementation method of the structured data corresponding to the element, for example, the structured data corresponding to the element may include attribute information and / or style information. Among them, the attribute information is used to describe the attributes of the element, such as color, shape and other attributes. The style information is used to describe the style of the element. For ease of understanding, the following two examples are used for explanation.

[0077] Example 1, in some scenarios, when the design draft includes a first element, and there is a target component matching the first element in the component library, the above structured file may include structured data corresponding to the first element. Among them, the structured data corresponding to the first element is used to express in a structured manner the information described by the design draft and the annotation information of the design draft for the first element, such as the style of the first element, the attributes of the first element, the component name of the target component matching the first element, the mapping relationship between the attributes of the first element and the attributes of the target component, and other information. It should be noted that if there are child elements (Children) of the first element in the design draft, the structured data corresponding to the first element can also be used to describe which elements the child elements of the first element include. Among them, the child element refers to an element that exists in the design draft and has the first element as its parent node.

[0078] Example 2, in some scenarios, when the design draft includes a first element and a second element, and there is no component matching the second element in the component library, the above structured file may include structured data corresponding to the first element and structured data corresponding to the second element. The structured data corresponding to the second element is used to express the information described by the design draft for the second element in a structured manner, such as the style of the second element, the attributes of the second element, and other information. It should be noted that if there are child elements of the second element in the design draft, the structured data corresponding to the second element can also be used to describe which elements the child elements of the second element include. The child element refers to an element that exists in the design draft and has the second element as its parent node.

[0079] Based on the above two paragraphs, it can be known that in some scenarios, when the design draft includes a first element and a second element, there is a target component matching the first element in the component library, and there is no component matching the second element in the component library, if the above structured file is implemented using JSON data, then the structured file may include JSON data corresponding to the first element and JSON data corresponding to the second element. Among them, the JSON data corresponding to the first element includes at least one key-value pair, so that the JSON data corresponding to the first element is used to express the information described by the design draft and the annotation information of the design draft for the first element in a key-value pair manner, such as the style of the first element, the sub-elements of the first element, the attributes of the first element, the component name of the target component matching the first element, the mapping relationship between the attributes of the first element and the attributes of the target component, etc. The JSON data corresponding to the second element includes at least one key-value pair, so that the JSON data corresponding to the second element is used to express the information described by the design draft for the second element in a key-value pair manner, such as the style of the second element, the attributes of the second element, the sub-elements of the second element, etc.

[0080] In addition, the present application does not limit the implementation method of S2 above. For example, it can be specifically as follows: after obtaining the design draft and the annotation information of the design draft, the relevant information of each element can be analyzed from the design draft and its annotation information, and the structured data corresponding to each element can be determined based on the relevant information of each element, so that the structured file can be determined based on the structured data corresponding to these elements in the future, so that the structured file includes the structured data corresponding to these elements. Among them, for any element, the relevant information of the element refers to the information related to the element recorded in the design draft and its annotation information, such as style, attributes, sub-elements and other information. It should be noted that the present application does not limit the method for determining the structured data corresponding to each element. For example, it can adopt any existing or future method that can perform structured processing on some data, such as Figure 2 The domain specific language (DSL) shown is used for implementation.

[0081] Based on the relevant content of S2 above, it can be known that after obtaining the design draft and its annotation information, the design draft and its annotation information can be structured with the help of a certain method, such as DSL, to obtain a structured file, so that the structured file includes the structured data corresponding to all elements in the design draft, so that the structured file can represent the relevant information of these elements in a structured manner, such as style, attributes, sub-elements and other information.

[0082] S3: Determine the code corresponding to the first element according to the component reference code of the target component and the structured data corresponding to the first element.

[0083] Among them, the component reference code of the target component refers to the code pre-configured for the target component and required to be used when referencing the target component, so that the target component can be called later with the help of the component reference code; and the present application does not limit the implementation method of the component reference code of the target component. For example, in some scenarios, the component reference code of the target component may at least include the component name of the target component, such as oc-input, oc-checkbox-group, oc-button and other component names. For another example, in some scenarios, the component reference code of the target component may at least include the component name of the target component and some attribute names of the target component, such as size, row-title and other attribute names. It can be seen that in one possible implementation method, if the target component is an input box, the component reference code of the target component can be used.<oc-input row-title=;is-required=;……> This code is implemented so that the component reference code can indicate the component name of the target component and some property names of the target component, such as the parameter names of some parameters required to be provided when calling the target component. If the target component is a button, the component reference code of the target component can be<oc-button size=;:disabled=;……> It should be noted that the spaces in the two component reference codes are used to fill in the actual attribute values, such as the attribute value of the first element, etc., and the ellipsis marks in the two component reference codes represent the relevant content of other attributes, such as the attribute name and the filling position of the attribute value.

[0084] The code corresponding to the first element refers to the code required to render the first element, such as<oc-buttonsize=“md”;:disabled=“false”;……> This code is used to render the first element later.

[0085] In addition, the present application does not limit the implementation method of S3 above. For example, it can adopt any existing or future method that can integrate and process the component reference code of the target component with the structured data corresponding to the first element, such as pre-set integration rules or pre-built machine learning models with code generation functions.

[0086] In addition, in order to better improve the code generation effect, the present application also provides a possible implementation method of the above S3. In this method, the S3 may specifically include the following steps 11 to 15.

[0087] Step 11: Acquire at least one piece of attribute information from the structured data corresponding to the first element, where the at least one piece of attribute information includes a first attribute, and the first attribute does not belong to a preset type.

[0088] The at least one attribute information refers to the attribute content existing in the structured data corresponding to the first element, such as all attribute values.

[0089] In addition, the present application does not limit the implementation method of the at least one attribute information above. For example, the at least one attribute information may include at least one first attribute and / or at least one second attribute, the first attribute does not belong to the preset type, and the second attribute belongs to the preset type. Among them, the preset type refers to a preset attribute type that does not require additional processing, such as Boolean and string; and the present application does not limit the preset type. For example, the preset type may include Boolean and string. The first attribute refers to an attribute that exists in the at least one attribute information and does not belong to the preset type, such as an attribute belonging to the object type, an attribute belonging to the array type, etc. The second attribute refers to an attribute that exists in the at least one attribute information and belongs to the preset type, such as an attribute belonging to the Boolean type and an attribute belonging to the string type, etc.

[0090] In addition, for at least one attribute information above, the at least one attribute information may include at least one attribute. Among them, for any attribute, the attribute may at least include an attribute value, such as the attribute value of "red". It can be seen that in some scenarios, the at least one attribute information may include some attribute names and attribute values ​​corresponding to these attribute names, such as {size="md";:disabled="false";...}. In other scenarios, the at least one attribute information may include some attribute values ​​arranged in order, such as {"md"; "false";...}. The arrangement position of each attribute value is determined according to the arrangement position of the attribute corresponding to the attribute value in the component reference code of the target component, so that the attribute value can be spliced ​​to the corresponding position in the component reference code based on the arrangement position.

[0091] In addition, the present application does not limit the implementation method of step 11 above. For example, it can adopt any existing or future method that can obtain attribute information from the structured data corresponding to the first element, such as by means of pre-set attribute extraction rules or a pre-built machine learning model with attribute extraction function.

[0092] Step 12: Determine a processing method corresponding to the first attribute according to the data type of the first attribute.

[0093] The data type of the first attribute is used to indicate the type of the first attribute, such as Object or Array.

[0094] In addition, the processing method corresponding to the first attribute is used to convert the first attribute into data of a preset type; and the present application does not limit the processing method corresponding to the first attribute. For example, when the first attribute belongs to the Object type, the processing method corresponding to the first attribute can adopt the processing method corresponding to the object type, such as Figure 3 The escape shown is implemented, wherein the processing method corresponding to the object type is used to convert the object type data into string type data. For another example, when the first attribute belongs to the Array type, the processing method corresponding to the first attribute can adopt the processing method corresponding to the array type, such as Figure 3 The data shown is flattened + escaped for implementation, wherein the processing method corresponding to the array type is used to convert the array type data into string type data. It should be noted that the processing method corresponding to the object type and the processing method corresponding to the array type can be set in advance according to the actual application scenario.

[0095] In addition, the present application does not limit the implementation of the above step 12. For example, it can be specifically: after obtaining the data type of the first attribute, a processing method matching the data type of the first attribute can be queried from the database as the processing method corresponding to the first attribute. The database records processing methods corresponding to different types, such as processing methods corresponding to object types, processing methods corresponding to array types, etc.

[0096] Step 13: Process the first attribute according to the processing method corresponding to the first attribute to obtain a processing result corresponding to the first attribute, which belongs to a preset type.

[0097] The processing result corresponding to the first attribute refers to a result obtained by processing the first attribute using the processing method corresponding to the first attribute, so that the processing result corresponding to the first attribute belongs to a preset type.

[0098] Based on the relevant content of step 13 above, it can be known that after determining the processing method corresponding to the first attribute based on the data type of the first attribute, the first attribute can be processed according to the processing method to obtain the processing result corresponding to the first attribute, so that the processing result belongs to the preset type. In this way, data that does not belong to the preset type can be converted into data that belongs to the preset type, thereby effectively solving the defects caused by the inability to splice multiple types of data, such as the need to further record the correspondence between each type of data and the first attribute, which leads to more storage resource consumption and other defects.

[0099] Step 14: Determine the attribute code corresponding to the first element according to the processing result corresponding to the first attribute, such as<size=“md”;:disabled=“false”;……> This code or <"md";"false";...> this code.

[0100] It should be noted that the present application does not limit the implementation method of the above step 14. For example, when the above at least one attribute information includes multiple first attributes, the step 14 may specifically be: determining the attribute code corresponding to the first element based on the splicing result between the multiple first attributes. For another example, when the above at least one attribute information includes at least one first attribute and at least one second attribute, the step 14 may specifically be: determining the attribute code corresponding to the first element based on the splicing result between the processing result corresponding to the at least one first attribute and the processing result of the at least one second attribute.

[0101] It should be noted that the present application does not limit the implementation method of "determining the attribute code corresponding to the first element based on the splicing result" in the previous paragraph. For example, it can be specifically: if the splicing result meets the code requirements under the actual development framework, then the splicing result is directly determined as the attribute code corresponding to the first element; if the splicing result does not meet the code requirements under the actual development framework, then the splicing result is first adjusted according to the code requirements to obtain an adjusted result, so that the adjusted result can not only represent the information carried by the splicing result, but also meet the code requirements; and then the adjusted result is determined as the attribute code corresponding to the first element.

[0102] Step 15: Determine the code corresponding to the first element based on the component reference code of the target component and the attribute code corresponding to the first element.

[0103] It should be noted that the present application does not limit the implementation method of the above step 15. For example, it can adopt a splicing method, such as Figure 3 It can be seen that in a possible implementation, step 15 can be specifically: integrating the component reference code of the target component with the attribute code corresponding to the first element, such as splicing, to obtain the code corresponding to the first element, such as<oc-button size=“md”;:disabled=“false”;……> It should be noted that the present application does not limit the integration process, for example, the integration process can be used to splice the attribute value in the attribute code to the back of the corresponding attribute name in the component reference code.

[0104] Based on the relevant contents of steps 11 to 15 above, it can be known that in some scenarios, for any first element in the design draft, since there is a target component matching the first element in the component library, the code corresponding to the first element can be constructed with the help of the component reference code of the target component, so that the code corresponding to the first element can indicate that the target component is referenced to implement the first element, so that the consistency of the first element and the target component in some aspects, such as attributes, can be effectively ensured. Among them, since the component reference code is pre-configured for the target component, the component reference code can be directly used in the process of determining the code corresponding to the first element, without regenerating the code corresponding to some characteristics of the first element matching the target component, which is beneficial to efficiency. In addition, since the component reference code is only used to call the target component, rather than to implement the target component, the character amount of the component reference code is very small, such as only one line of characters, etc., which is conducive to reducing the amount of code without affecting the rendering effect, thereby effectively overcoming the defects caused by too much code, such as a large number of code errors and a long time for code generation.

[0105] In fact, in some scenarios, the designer not only designs the attribute information for the first element, but also designs the style information. Therefore, in order to better render the first element that meets the design requirements, the present application also provides a possible implementation method of S3 above. In this method, S3 may include the following steps 21-22.

[0106] Step 21: Determine the component code corresponding to the first element based on the component reference code of the target component and the attribute information in the structured data corresponding to the first element.

[0107] The component code corresponding to the first element refers to the code required to implement some characteristics of the first element, such as attributes, by referencing the target component matching the first element.<oc-button size=“md”;:disabled=“false”;……> This code.

[0108] In addition, the present application does not limit the implementation of step 21 above. For example, the implementation of step 21 is similar to the code determination process shown in steps 11 to 15 above. It can be seen that in one possible implementation, the component code corresponding to the first element is determined based on the component reference code of the target component and the attribute code corresponding to the first element. For the relevant content of the attribute code, please refer to the above.

[0109] Step 22: Determine the code corresponding to the first element according to the component code corresponding to the first element and the style information in the structured data corresponding to the first element.

[0110] Among them, the style information in the structured data corresponding to the first element is used to describe the style in which the first element is located; moreover, the present application does not limit the implementation manner of the style information. For example, the style information can be implemented by <style="style value 1"> or <"style value 1">. In addition, the present application does not limit the acquisition manner of the style information. For example, it can adopt any existing or future style information extraction method, such as implementing it by means of a pre-set style information extraction rule or a pre-constructed machine learning model with a style information extraction function.

[0111] In addition, the present application does not limit the implementation manner of step 22 above. For example, step 22 can specifically be: integrating and processing the component code corresponding to the first element and the style information in the structured data corresponding to the first element, such as splicing and other processing, to obtain the code corresponding to the first element. It should be noted that the present application does not limit the implementation manner of the integration processing. For example, it can specifically be: if there is a style name in the component reference code of the target component, then there is also a style name in the component code corresponding to the first element determined based on the component reference code. Therefore, the style value appearing in the style information in the structured data corresponding to the first element can be directly spliced after the style name in the component code corresponding to the first element.

[0112] Another example is that when there is no style name in the component reference code of the target component, step 22 above can specifically be: first extracting the style information from the structured data corresponding to the first element; then obtaining the code corresponding to the style information so that the code can represent the style described by the style information according to the code requirements under the actual development framework; then, splicing the code corresponding to the style information with the component code corresponding to the first element to obtain the code corresponding to the first element. It should be noted that the present application does not limit the acquisition manner of the code corresponding to the style information. For example, it can specifically be: querying the code matching the style information from a pre-constructed code library to obtain the code corresponding to the style information. Among them, the code library refers to a pre-constructed database that is at least used to record the codes corresponding to some style information.

[0113] Based on the relevant contents of steps 21 to 22 above, it can be known that in some scenarios, for any first element in the design draft, since there is a target component matching the first element in the component library, the component code corresponding to the first element can be determined based on the component reference code of the target component and the attribute information in the structured data corresponding to the first element, so that the component code can represent the reference information of the target component and the attribute information of the first element; and then the code corresponding to the first element is determined based on the component code corresponding to the first element and the style information in the structured data, so that the code can represent the reference information of the target component, the attribute information of the first element and the style information of the first element, so that the code can more comprehensively represent the characteristics of the first element, thereby helping to improve the rendering effect of the first element.

[0114] In fact, for the design draft, the design draft not only includes the first element, but may also include sub-elements of the first element. Therefore, in order to better render the first element that meets the design requirements, the present application also provides a method for determining the code corresponding to the first element above. Under this method, the process of determining the code corresponding to the first element can include the following steps 31-32.

[0115] Step 31: Determine the code corresponding to the first element based on the component reference code of the target component and the structured data corresponding to the first element.

[0116] It should be noted that the present application does not limit the implementation method of the above step 31. For example, it can be implemented by any implementation method of the above S3.

[0117] Step 32: If it is determined that the design draft also includes a sub-element of the first element, the code corresponding to the sub-element is used to update the code corresponding to the first element so that the updated code includes the code corresponding to the sub-element, wherein the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element.

[0118] Among them, the child element refers to the element existing in the design draft with the first element as the parent node.

[0119] In addition, for the above sub-element, the structured data corresponding to the sub-element refers to the data existing in the above structured file and used to describe the characteristics of the sub-element. It should be noted that the present application does not limit the implementation method of the structured data corresponding to the sub-element. For example, if there is a component matching the sub-element in the component library, the structured data corresponding to the sub-element is used to represent the information described by the design draft and the annotation information of the design draft for the element in a structured manner; and the implementation method of the structured data corresponding to the sub-element is similar to the implementation method of the structured data corresponding to the first element above. For another example, if there is no component matching the sub-element in the component library, the structured data corresponding to the sub-element is used to represent the information described by the design draft for the element in a structured manner; and the implementation method of the structured data corresponding to the sub-element is similar to the implementation method of the structured data corresponding to the second element above.

[0120] In addition, for the above sub-element, the code corresponding to the sub-element refers to the code required to be used when rendering the sub-element; and the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element. It should be noted that the present application does not limit the method for determining the code corresponding to the sub-element. For example, if there is a component matching the sub-element in the component library, the code corresponding to the sub-element is determined based on the component reference code of the matching component and the structured data corresponding to the sub-element; and the implementation method of the process for determining the code corresponding to the sub-element is similar to the implementation method of the process for determining the code corresponding to the first element above. For another example, if there is no component matching the sub-element in the component library, the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element; and the implementation method of the process for determining the code corresponding to the sub-element is similar to the implementation method of the process for determining the code corresponding to the second element below.

[0121] In addition, the present application does not limit the implementation method of the above step 32. For example, it can be specifically: if it is determined that the design draft also includes a sub-element of the first element, the pre-update code corresponding to the first element and the code corresponding to the sub-element are integrated, such as splicing, to obtain the updated code corresponding to the first element, so that the updated code includes the pre-update code and the code corresponding to the sub-element, so that the updated code can better express the characteristics of the first element.

[0122] Based on the relevant contents of steps 31 to 32 above, it can be known that in some scenarios, for any first element in a design draft, if the design draft also includes sub-elements of the first element, the code corresponding to the first element can be determined based on the structured data corresponding to the first element and the structured data corresponding to the sub-element, so that the code can better express the characteristics of the first element.

[0123] Based on the relevant content of S3 above, it can be known that for any first element in the design draft, if the design draft also includes a sub-element of the first element, and there is a target component matching the first element in the component library, then the code corresponding to the first element can be determined based on the component reference code of the target component, the structured data corresponding to the first element, and the structured data corresponding to the sub-element, so that the code can better express the characteristics of the first element.

[0124] S4: Based on the code corresponding to the first element, determine the code of the design draft under the development framework adapted by the component library.

[0125] The development framework adapted by the component library refers to a development framework that can perform development tasks with the help of the component library. As an example, if the component library is a standard component library, the development framework adapted by the component library is the vue3 development framework.

[0126] In addition, the present application does not limit the implementation method of S4 above. For example, if the design draft includes at least one first element, then S4 can specifically be: integrating the codes corresponding to all the first elements in the design draft, such as splicing, to obtain the code of the design draft under the development framework adapted by the component library, so that the "code of the design draft under the development framework adapted by the component library" includes the codes corresponding to these first elements, so that these first elements can be rendered when rendering based on the "code of the design draft under the development framework adapted by the component library" later.

[0127] For another example, in some scenarios, if the design draft includes a first element and a second element, S4 above may specifically be: based on the code corresponding to the first element and the code corresponding to the second element, determine the code of the design draft under the development framework adapted by the component library, so that the "code of the design draft under the development framework adapted by the component library" includes the code corresponding to the first element and the code corresponding to the second element. Among them, there is no component matching the second element in the component library. The code corresponding to the second element refers to the code required to render the second element; and the code corresponding to the second element is determined based on the structured data corresponding to the second element. It should be noted that the relevant content of the second element and the structured data corresponding to the second element can be found above.

[0128] In addition, the present application does not limit the implementation method of the code corresponding to the second element above. For example, it can adopt any existing or future method that can obtain the code corresponding to an element, such as converting the element into an HTML element or implementing it with the help of a pre-built machine learning model with element code generation function. For another example, the process of determining the code corresponding to the second element can be: first obtain at least one attribute information from the structured data corresponding to the second element; then query the code matching these attribute information from the pre-built code library to obtain the code corresponding to the second element. Among them, the code library refers to a pre-built database that is used to record at least some codes corresponding to attributes.

[0129] In addition, in order to improve the code determination effect, the present application also provides a method for determining the code corresponding to the second element above, under which the process of determining the code corresponding to the second element may include the following steps 41 to 44.

[0130] Step 41: Acquire at least one attribute information from the structured data corresponding to the second element, the at least one attribute information comprising a third attribute and a fourth attribute, the third attribute does not belong to a preset type, and the fourth attribute belongs to a preset type.

[0131] The third attribute refers to an attribute obtained from the structured data corresponding to the second element and not belonging to a preset type, such as an attribute belonging to an object type, an attribute belonging to an array type, etc. It should be noted that the implementation method of the third attribute is similar to the implementation method of the first attribute above.

[0132] The fourth attribute refers to an attribute of a preset type obtained from the structured data corresponding to the second element, such as a Boolean attribute and a string attribute, etc. It should be noted that the implementation of the fourth attribute is similar to the implementation of the second attribute above.

[0133] Step 42: Determine a processing method corresponding to the third attribute according to the data type of the third attribute.

[0134] The data type of the third attribute is used to indicate the type of the third attribute, such as Object or Array.

[0135] In addition, the processing method corresponding to the third attribute is used to convert the third attribute into data of a preset type. It should be noted that the implementation method of the processing method corresponding to the third attribute is similar to the implementation method of the processing method corresponding to the first attribute above; and the determination method of the processing method corresponding to the third attribute is similar to the determination method of the processing method corresponding to the first attribute above.

[0136] Step 43: Process the third attribute according to the processing method corresponding to the third attribute to obtain a processing result corresponding to the third attribute, which belongs to a preset type.

[0137] The processing result corresponding to the third attribute refers to a result obtained by processing the third attribute using the processing method corresponding to the third attribute, so that the processing result corresponding to the third attribute belongs to a preset type.

[0138] Step 44: Determine the code corresponding to the second element according to the processing results corresponding to the fourth attribute and the third attribute.

[0139] It should be noted that the present application does not limit the implementation of step 44. For example, it may specifically be: integrating the processing results corresponding to the fourth attribute and the third attribute, such as splicing, to obtain the code corresponding to the second element, such as<size=“md”;:disabled=“false”;……> This code.

[0140] For example, in some scenarios, the above step 44 can be specifically as follows: first integrate the processing results corresponding to the fourth attribute and the third attribute, such as splicing, to obtain the attribute code corresponding to the second element, so that the attribute code can represent the attribute characteristics of the second element; then determine the code corresponding to the second element based on the attribute code corresponding to the second element and the style information in the structured data corresponding to the second element, so that the code can represent the attribute characteristics and style characteristics of the second element.

[0141] It should be noted that the present application does not limit the implementation method of the step of "determining the code corresponding to the second element based on the attribute code corresponding to the second element and the style information in the structured data corresponding to the second element" in the previous paragraph. For example, the step may specifically be: integrating the attribute code corresponding to the second element with the style information in the structured data corresponding to the second element, such as splicing, to obtain the code corresponding to the second element.

[0142] Based on the relevant contents of steps 41 to 44 above, it can be known that in some scenarios, for any second element in the design draft, since there is no component matching the second element in the component library, the code corresponding to the second element can be directly determined based on the attribute information and style information in the structured data corresponding to the second element, so that the code includes the codes corresponding to each attribute in the attribute information and the codes corresponding to each style in the style information, so that the code can represent the attribute characteristics and style characteristics of the second element, so that the second element can be rendered later with the help of the code. It should be noted that the attribute information can include at least one third attribute and / or at least one fourth attribute.

[0143] In fact, for the design draft, the design draft not only includes the second element, but may also include sub-elements of the second element. Therefore, in order to better render the second element that meets the design requirements, the present application also provides a method for determining the code corresponding to the second element above. Under this method, the process of determining the code corresponding to the second element can include the following steps 51-52.

[0144] Step 51: Determine the code corresponding to the second element according to the structured data corresponding to the second element.

[0145] It should be noted that the present application does not limit the implementation method of step 51 above. For example, it can be implemented by using any implementation method of the process of determining the code corresponding to the second element above.

[0146] Step 52: If it is determined that the design draft also includes a sub-element of the second element, the code corresponding to the sub-element is used to update the code corresponding to the second element, so that the updated code includes the code corresponding to the sub-element. The sub-element refers to an element existing in the design draft with the second element as the parent node; the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element.

[0147] It should be noted that the relevant content of the sub-element in step 52 is similar to the relevant content of the sub-element in the above step 32, and for the sake of brevity, it will not be repeated here.

[0148] It should also be noted that the present application does not limit the implementation method of step 52. For example, it can specifically be: integrating the pre-update code corresponding to the second element with the code corresponding to the sub-element, such as splicing, to obtain the updated code corresponding to the second element, so that the updated code includes the pre-update code and the code corresponding to the sub-element, so that the updated code can better express the characteristics of the second element.

[0149] Based on the relevant contents of steps 51 to 52 above, it can be known that in some scenarios, for any second element in the design draft, if the design draft also includes sub-elements of the second element, the code corresponding to the second element can be determined based on the structured data corresponding to the second element and the structured data corresponding to the sub-element, so that the code can better express the characteristics of the second element.

[0150] Based on the relevant content of S4 above, it can be known that in some scenarios, when the design draft includes at least one first element and at least one second element, S4 above can be specifically: the code corresponding to the at least one first element and the code corresponding to the at least one second element are integrated, such as splicing, to obtain the code of the design draft under the development framework adapted by the component library, so that the "code of the design draft under the development framework adapted by the component library" includes the code corresponding to these first elements and the code corresponding to these second elements, so that the first elements and the second elements can be rendered when rendering based on the "code of the design draft under the development framework adapted by the component library". Among them, because the "code of the design draft under the development framework adapted by the component library" has the function of copying and previewing, it can quickly debug and reuse the code later, which is conducive to improving the D2C effect.

[0151] Based on the relevant contents of S1 to S4 above, it can be known that for the code determination method provided in the embodiment of the present application, a design draft and annotation information of the design draft are first obtained, the design draft includes a first element, and there is a target component matching the first element in the component library, and the annotation information includes a mapping relationship between the attributes of the first element and the attributes of the target component; then the design draft and the annotation information are analyzed to obtain a structured file; the structured file includes structured data corresponding to the first element; then, based on the component reference code of the target component and the structured data corresponding to the first element, the code corresponding to the first element is determined; finally, based on the code corresponding to the first element, the code of the design draft under the development framework adapted by the component library is determined, so that the purpose of automatically converting the design draft into code can be achieved. Among them, because the first element in the design draft matches the target component in the component library, the first element and its attributes can be implemented with the help of the target component and its attributes, so that the code corresponding to the first element can be determined with the help of the component reference code of the target component. In this way, the first element can be converted into the corresponding component in the component library during the D2C process, thereby effectively overcoming the defects caused by converting the first element into an HTML element during the D2C process, such as the defect that the converted code is not compatible with the actual development framework, and thus effectively improving the D2C effect.

[0152] Based on the code determination method provided in the embodiment of the present application, the embodiment of the present application also provides a code determination device. Figure 4 Explain and illustrate. Figure 4 This is a schematic diagram of the structure of a code determination device provided in an embodiment of the present application. It should be noted that for the technical details of the code determination device provided in an embodiment of the present application, please refer to the relevant content of the code determination method above.

[0153] like Figure 4As shown, the code determination device 400 provided in the embodiment of the present application includes:

[0154] The data acquisition unit 401 is used to acquire a design draft and annotation information of the design draft, wherein the design draft includes a first element, a target component matching the first element exists in the component library, and the annotation information includes a mapping relationship between an attribute of the first element and an attribute of the target component;

[0155] A data analysis unit 402 is used to analyze the design draft and the annotation information to obtain a structured file; the structured file includes structured data corresponding to the first element;

[0156] A first determining unit 403 is configured to determine a code corresponding to the first element according to a component reference code of the target component and structured data corresponding to the first element;

[0157] The second determining unit 404 is used to determine the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element.

[0158] In one possible implementation, the first determination unit 403 is specifically used to: obtain at least one attribute information from the structured data corresponding to the first element, the at least one attribute information including a first attribute, and the first attribute does not belong to a preset type; determine a processing method corresponding to the first attribute based on a data type of the first attribute; process the first attribute according to the processing method corresponding to the first attribute to obtain a processing result corresponding to the first attribute, and the processing result belongs to the preset type; determine an attribute code corresponding to the first element based on the processing result corresponding to the first attribute; determine a code corresponding to the first element based on a component reference code of the target component and an attribute code corresponding to the first element.

[0159] In a possible implementation manner, the at least one attribute information further includes a second attribute, and the second attribute belongs to a preset type;

[0160] The first determining unit 403 is specifically configured to determine the attribute code corresponding to the first element according to a concatenation result between the second attribute and a processing result corresponding to the first attribute.

[0161] In one possible implementation, the first determination unit 403 is specifically used to: determine the component code corresponding to the first element based on the component reference code of the target component and the attribute information in the structured data corresponding to the first element; determine the code corresponding to the first element based on the component code corresponding to the first element and the style information in the structured data corresponding to the first element.

[0162] In a possible implementation manner, the design draft further includes a sub-element of the first element;

[0163] The structured document also includes structured data corresponding to the sub-element;

[0164] The code determination device 400 further includes:

[0165] The code updating unit is used to update the code corresponding to the first element by using the code corresponding to the sub-element, wherein the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element.

[0166] In a possible implementation manner, the design draft further includes a second element, and there is no component matching the second element in the component library;

[0167] The structured file further includes structured data corresponding to the second element;

[0168] The second determination unit 404 is specifically used to: determine the code of the design draft under the development framework adapted by the component library based on the code corresponding to the first element and the code corresponding to the second element; the code corresponding to the second element is determined based on the structured data corresponding to the second element.

[0169] Based on the relevant content of the above-mentioned code determination device 400, it can be known that the working principle of the code determination device 400 provided in the embodiment of the present application includes: first obtaining a design draft and annotation information of the design draft, the design draft includes a first element, and there is a target component matching the first element in the component library, and the annotation information includes a mapping relationship between the attributes of the first element and the attributes of the target component; then analyzing the design draft and the annotation information to obtain a structured file; the structured file includes structured data corresponding to the first element; then, according to the component reference code of the target component and the structured data corresponding to the first element, determine the code corresponding to the first element; finally, according to the code corresponding to the first element, determine the code of the design draft under the development framework adapted by the component library, so that the purpose of automatically converting the design draft into code can be achieved. In addition, because the first element in the design draft matches the target component in the component library, the first element and its attributes can be implemented with the help of the target component and its attributes, so that the code corresponding to the first element can be determined with the help of the component reference code of the target component. In this way, the first element can be converted into the corresponding component in the component library during the D2C process, thereby effectively overcoming the defects caused by converting the first element into a Hypertext Markup Language (HTML) element during the D2C process, such as the incompatibility of the converted code with the actual development framework, and thus effectively improving the D2C effect.

[0170] In addition, an embodiment of the present application also provides an electronic device, which includes a processor and a memory: the memory is used to store instructions or computer programs; the processor is used to execute the instructions or computer programs in the memory, so that the electronic device executes any implementation of the code determination method provided in the embodiment of the present application.

[0171] See also Figure 5 , which shows a schematic diagram of the structure of an electronic device 500 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0172] like Figure 5As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0173] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0174] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0175] The electronic device provided by the embodiment of the present disclosure and the method provided by the above embodiment belong to the same inventive concept, and the technical details not fully described in this embodiment can be referred to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.

[0176] The embodiment of the present application also provides a computer-readable medium, in which instructions or computer programs are stored. When the instructions or computer programs are executed on a device, the device executes any implementation of the code determination method provided in the embodiment of the present application.

[0177] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0178] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0179] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0180] The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device can execute the method.

[0181] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0182] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0183] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit / module does not, in some cases, constitute a limitation on the unit itself.

[0184] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0185] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0186] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0187] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0188] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0189] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0190] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A code determination method, characterized in that: The method comprises: Acquire a design draft and annotation information of the design draft, wherein the design draft includes a first element, a target component matching the first element exists in a component library, and the annotation information includes a mapping relationship between an attribute of the first element and an attribute of the target component; Analyze the design draft and the annotation information to obtain a structured file; the structured file includes structured data corresponding to the first element; Determining a code corresponding to the first element according to a component reference code of the target component and structured data corresponding to the first element; According to the code corresponding to the first element, the code of the design draft under the development framework adapted by the component library is determined.

2. The method according to claim 1, characterized in that The process of determining the code corresponding to the first element includes: Acquire at least one piece of attribute information from the structured data corresponding to the first element, the at least one piece of attribute information including a first attribute, and the first attribute does not belong to a preset type; Determining a processing method corresponding to the first attribute according to a data type of the first attribute; Processing the first attribute according to the processing method corresponding to the first attribute to obtain a processing result corresponding to the first attribute, wherein the processing result belongs to the preset type; Determining an attribute code corresponding to the first element according to a processing result corresponding to the first attribute; The code corresponding to the first element is determined according to the component reference code of the target component and the attribute code corresponding to the first element.

3. The method according to claim 2, characterized in that The at least one attribute information further includes a second attribute, and the second attribute belongs to a preset type; The determining, according to the processing result corresponding to the first attribute, the attribute code corresponding to the first element includes: The attribute code corresponding to the first element is determined according to a concatenation result between the processing result corresponding to the second attribute and the first attribute.

4. The method according to claim 1, characterized in that: The determining, based on the component reference code of the target component and the structured data corresponding to the first element, a code corresponding to the first element includes: Determining a component code corresponding to the first element according to a component reference code of the target component and attribute information in structured data corresponding to the first element; The code corresponding to the first element is determined according to the component code corresponding to the first element and the style information in the structured data corresponding to the first element.

5. The method according to claim 1, characterized in that The design draft also includes sub-elements of the first element; The structured document also includes structured data corresponding to the sub-element; Before determining the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element, the method further includes: The code corresponding to the first element is updated using the code corresponding to the sub-element, where the code corresponding to the sub-element is determined based on the structured data corresponding to the sub-element.

6. The method according to claim 1, characterized in that The design draft also includes a second element, and there is no component matching the second element in the component library; The structured file further includes structured data corresponding to the second element; The step of determining the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element includes: Determine the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element and the code corresponding to the second element; The code corresponding to the second element is determined according to the structured data corresponding to the second element.

7. A code determination device, characterized in that: include: A data acquisition unit, configured to acquire a design draft and annotation information of the design draft, wherein the design draft includes a first element, a target component matching the first element exists in a component library, and the annotation information includes a mapping relationship between an attribute of the first element and an attribute of the target component; A data analysis unit, used to analyze the design draft and the annotation information to obtain a structured file; The structured file includes structured data corresponding to the first element; a first determining unit, configured to determine a code corresponding to the first element according to a component reference code of the target component and structured data corresponding to the first element; The second determining unit is used to determine the code of the design draft under the development framework adapted by the component library according to the code corresponding to the first element.

8. An electronic device, characterized in that: The device comprises: a processor and a memory; The memory is used to store instructions or computer programs; The processor is used to execute the instructions or computer programs in the memory so that the electronic device executes the method according to any one of claims 1 to 6.

9. A computer-readable medium, characterized in that The computer-readable medium stores instructions or computer programs, and when the instructions or computer programs are executed on a device, the device executes the method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises a computer program carried on a non-transitory computer-readable medium, wherein the computer program comprises a program code for executing the method according to any one of claims 1 to 6.