Search

CN-121996246-A - Code mapping conversion method and device and electronic equipment

CN121996246ACN 121996246 ACN121996246 ACN 121996246ACN-121996246-A

Abstract

The disclosure provides a code mapping conversion method, a code mapping conversion device and electronic equipment, wherein a design plug-in responds to a code conversion request aiming at a target design draft to obtain a design component contained in the target design draft, a mapping function corresponding to the design component is searched, the design component is converted into target codes based on the mapping function, the mapping function is a function which is debugged in advance and is used for defining conversion logic from the design component to the code component, and the design code corresponding to the target design draft is generated based on the target codes corresponding to the design component. In the mode, the design plug-in not only can accurately position the mapping function corresponding to the design component, but also integrates the mapping function analysis and execution logic, and can realize the real-time conversion from the design component to the code component based on the mapping function, thereby improving the efficiency and the accuracy of the code conversion.

Inventors

  • LIU YIQI

Assignees

  • 杭州网易智企科技有限公司

Dates

Publication Date
20260508
Application Date
20251225

Claims (10)

  1. 1. A method of code mapping conversion, the method being applied to a design plug-in installed in an electronic device, the method comprising: Responding to a code conversion request aiming at a target design draft, and acquiring a design component contained in the target design draft; Searching a mapping function corresponding to the design component, and converting the design component into target codes based on the mapping function, wherein the mapping function is a function which is debugged in advance and is used for defining conversion logic from the design component to the code component; and generating the design code corresponding to the target design draft based on the target code corresponding to the design component.
  2. 2. The method of claim 1, wherein design components in the target design script are labeled with function identifications for indicating mapping functions corresponding to the design components; The step of searching the mapping function corresponding to the design component comprises the following steps: and obtaining a mapping function corresponding to the design component according to the function identifier marked by the design component.
  3. 3. The method of claim 2, wherein the function identification of the design component callout is determined by: storing the function identification of the mapping function after debugging into configuration data of a corresponding marked design component in a lasting mode so as to mark the function identification for the design component; and generating a component mapping configuration table according to the mapping function corresponding to the function identification marked by the design component, wherein the component mapping configuration table comprises a plurality of design components and mapping functions respectively corresponding to the plurality of design components.
  4. 4. The method of claim 3, wherein the design plugin is communicatively coupled to a design system, the design system including a plurality of design components therein for generating different design releases, the method further comprising: Acquiring the component mapping configuration table; Traversing each design component in a design system, determining mapping functions corresponding to each design component according to the component mapping configuration table, and labeling function identifiers of the mapping functions corresponding to the design components for the design components, wherein different mapping functions correspond to different function identifiers.
  5. 5. The method of claim 1, wherein the step of converting the design component into object code based on the mapping function comprises: dynamically analyzing a mapping function corresponding to the design component to construct an objective function object; executing the mapping function according to the objective function object and the preset function parameter to obtain a code structure corresponding to the design component, wherein the code structure comprises a code character string and slot information; and obtaining the target code corresponding to the design component based on the code structure and the component attribute corresponding to the design component.
  6. 6. The method of claim 1, wherein the step of obtaining the design components contained in the target design script comprises: traversing all component instances in the target design manuscript, and acquiring a target component instance with a target type; and acquiring the design components contained in the target component examples, and determining the acquired design components as the design components contained in the target design manuscript.
  7. 7. The method of claim 1, wherein the mapping function completes debugging by: Generating a function template through a scaffold tool, and generating a standard function structure corresponding to the function template, wherein the standard function structure supports various front end frameworks; Receiving a logic writing instruction acting on the function template through a standardized interface, and generating a mapping function based on the conversion logic from a design component defined by the logic writing instruction to a code component and the standard function structure; debugging the mapping function to obtain a debugging result; and if the debugging result indicates that the debugging is passed, obtaining the mapping function after the debugging is completed.
  8. 8. A code mapping conversion apparatus, the apparatus being provided in a design plug-in installed in an electronic device, the apparatus comprising: The component acquisition module is used for responding to a code conversion request aiming at a target design draft and acquiring a design component contained in the target design draft; the code conversion module is used for searching a mapping function corresponding to the design component and converting the design component into target codes based on the mapping function, wherein the mapping function is a function which is debugged in advance and is used for defining conversion logic from the design component to the code component; and the code sending module is used for generating the design code corresponding to the target design draft based on the target code corresponding to the design component.
  9. 9. An electronic device comprising a processor and a memory, the memory storing computer-executable instructions executable by the processor, the processor executing the computer-executable instructions to implement the code mapping conversion method of any of claims 1-7.
  10. 10. A computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the code mapping conversion method of any one of claims 1-7.

Description

Code mapping conversion method and device and electronic equipment Technical Field The disclosure relates to the field of design transcoding, and in particular relates to a code mapping conversion method, a code mapping conversion device and electronic equipment. Background In the related art, in order to convert a design draft into executable codes, a machine learning model may be used to identify UI components in the design draft and automatically generate codes, but the identification accuracy of this method is unstable and complex custom components cannot be processed. Disclosure of Invention In view of the above, an object of the present disclosure is to provide a code mapping conversion method, apparatus and electronic device, so as to accurately and quickly convert a design draft into a code. In a first aspect, an embodiment of the present disclosure provides a code mapping conversion method, which is applied to a design plug-in installed in an electronic device, and the method includes obtaining a design component included in a target design draft in response to a code conversion request for the target design draft, searching a mapping function corresponding to the design component, and converting the design component into target code based on the mapping function, where the mapping function is a function which is debugged in advance and is used for defining conversion logic from the design component to the code component, and generating a design code corresponding to the target design draft based on the target code corresponding to the design component. In a second aspect, an embodiment of the present disclosure further provides a code mapping conversion device, which is provided in a design plug-in installed in an electronic device, where the device includes a component obtaining module configured to obtain a design component included in a target design draft in response to a code conversion request for the target design draft, a code conversion module configured to find a mapping function corresponding to the design component and convert the design component into a target code based on the mapping function, where the mapping function is a function that is completed in advance and is used to define conversion logic from the design component to the code component, and a code sending module configured to generate a design code corresponding to the target design draft based on the target code corresponding to the design component. In a third aspect, the present disclosure provides an electronic device comprising a processor and a memory storing machine executable instructions executable by the processor to implement the above-described code mapping conversion method. In a fourth aspect, the present disclosure provides a computer-readable storage medium storing computer-executable instructions that, when invoked and executed by a processor, cause the processor to implement the code mapping conversion method described above. The embodiment of the disclosure brings the following beneficial effects: The code mapping conversion method, the code mapping conversion device and the electronic equipment are characterized in that firstly, a design plug-in acquires a design component contained in a target design draft aiming at a code conversion request of the target design draft, then searches a mapping function corresponding to the design component, and converts the design component into target codes based on the mapping function, wherein the mapping function is a function which is debugged in advance and is used for defining conversion logic from the design component to the code component, and then generates the design codes corresponding to the target design draft based on the target codes corresponding to the design component. In the mode, the design plug-in not only can accurately position the mapping function corresponding to the design component, but also integrates the mapping function analysis and execution logic, and can realize the real-time conversion from the design component to the code component based on the mapping function, thereby improving the efficiency and the accuracy of the code conversion. Additional features and advantages of the disclosure will be set forth in the description which follows, and in part will be apparent from the description, or may be learned by practice of the disclosure. The objectives and other advantages of the disclosure will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings. The foregoing objects, features and advantages of the disclosure will be more readily apparent from the following detailed description of the preferred embodiments taken in conjunction with the accompanying drawings. Drawings In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings that are needed in the description of the