By HAOMO Technology - Zhuang Xiaoduo, Hu Xiaogen, Alibaba F(x) Team - Suchuan
HAOMO Technology is an industry software customization development enterprise that involves industries, including office collaboration, blockchain, data visualization, retail e-commerce, smart environmental protection, smart water, smart environment sanitation, smart inspection, smart government affairs, smart logistics, smart education, smart manufacturing, Internet of Things, data analysis, network and security, O2O, P2P, B2B, and B2C.
Both mobile and web pages are developed. The frontend main technology stacks include Vue, React, Flutter, UniApp, Taro, and HTML. HAOMO Technology uses imgcook sketch plug-in to export, customize DSL, CLI command line, and to improve the front-end code development speed.
From 2020-02-03 to 2021-05-25, the number of modules created in imgcook reached 2000+, covering 60+ frontend projects and helping R&D improve efficiency by more than 40%.
By default, the codes generated by UniApp and Taro are all used for mobile phones. When generating code on a mobile phone, you need to follow the following rules:
Sometimes it is necessary to generate pad-side or desktop-side applications, and there are situations where local visual codes need to be generated. (The width of all elements to be generated cannot be forced to be consistent like mobile phone-side applications.) If no configuration items are added, the generated code is not adaptive (chaotic layout).
Two attributes solve this problem by adding to the Page element to implement local code screen adaptation for pad or desktop applications in the web management side of imgcook.
export default {
designWidth: 1920, // the width of the design draft
responsive: "vw" // When you configure responsive, css adaptive uses the vw unit. If responsive is not configured (only designWidth is configured), uniapp uses rpx to control adaptation by default (experience is better under pad side), and Taro uses Taro.pxTransform() function to control adaptation by default.
}
The configuration screenshot is listed below:
Since all elements generated by imgcook are Div/Text/Image, there is no good support for form elements and complex components.
The component replacement of imgcook is realized by combining the components configured by xmind2code. The component of the imgcook is replaced by the component in the xmind2code->ui config file. Currently, non-container components (input/button) are supported. The replacement of container-type components (such as Tab) is not supported for the time being.
When exporting code, the plug-in @imgcook/hm-replace-component is used to replace the component.
imgcook install @imgcook/hm-replace-component@0.0.9
In the schema of imgcook, there are three main types of UI elements:
In principle, the preceding three types of elements in imgcook can be replaced with any component configured by HAOMO. The proposed replacement is listed below:
Replacement Steps:
1. On the web interface of imgcook, configure additional attributes of Div: hm-component=\
export default {
'hm-component': 'van-button'
}
The configuration screenshot is listed below:
2. Configure the xmind2code component in the project.
Official Introduction:
The imgcook-cli can combine the ability of the plugin to place the code products generated by the imgcook platform into your local project with one click and seamlessly integrate them into your research and development process. If you have processing requirements for the code products generated by imgcook (such as using the plugin to develop automated uploads of pictures to your map bed or file directory conversion), imgcook-cli will be the only choice for you to apply the plugin.
npm install -g @imgcook/cli
imgcook config edit # configure imgcook.
Configure the plugin for CLI. Here, the official configuration of the plugin is configured by default.
Image Conversion Plug-In: @imgcook/plugin-images
Module Export Generation: @imgcook/plugin-generate
Then, add the custom plugin:
The final configuration is listed below:
{
"accessId": "RolT******V3d1",
"dslId": "259",
"generator": [],
"plugin": [
"@imgcook/hm-replace-component",
"@imgcook/plugin-images",
"@imgcook/plugin-generate"
],
"uploadUrl": ""
}
Pull the module code and write it to a path in the file directory:
# Pull a module code to the local path
imgcook pull <moduleId> --path <path>
# Example
imgcook pull 17108 --path ./src/mods/mod17108
You can download the imgcook sketch plug-in from the imgcook homepage:
Use the imgcook plug-in to export layer data and paste it into imgcook:
imgcook provides custom DSL capabilities. You can generate the required code based on the data and capabilities provided by imgcook. Ten imgcook DSLs have been developed by HAOMO Technology to meet the code generation requirements of different applications. (The links below are in Chinese):
imgcook-cli can combine with the capabilities of the plugin to place the code products generated by the imgcook platform into the local project with one click. We download the code to the local project file by using the CLI command line.
When using imgcook-cli to download code, you can configure the custom plugin to process the code products generated by the imgcook platform. We have customized the @imgcook/hm-replace-component plugin to replace the component attributes we set in the editor with their components.
We can organize a team meeting, gather the team members together, and introduce the research and development of imgcook.
Introduction:
imgcook is an intelligent code generation platform for design drafts opened by Alibaba. It can generate maintainable frontend code, such as React, Vue, and applets, from Sketch, PSD, Figma, and pictures. It can also customize the generated code.
We can install Sketch, Photoshop, and Figma plug-ins to export layer data to imgcook by using plug-ins or uploading design files directly to imgcook editor for parsing and viewing the generated code in imgcook editor.
Introduction:
This document contains some user cases, including the open capabilities of imgcook. Further user cases will be revealed on the imgcook website.
imgcook can generate code with high maintainability automatically, but the design layer is ever-changing, and some scenarios have not been covered. Examples:
imgcook provides a design protocol for these problems that helps users manually intervene in layers to solve them. It can also be visually adjusted in the imgcook editor after generation.
If your team is connected to the D2C service provided by imgcook or you have experience using imgcook, please leave a message in the comment area of this article.
AI Application Scenarios and Implementation Practices in Draft Design Generation Code
66 posts | 3 followers
FollowAlibaba Clouder - December 31, 2020
Alibaba F(x) Team - June 20, 2022
Alibaba F(x) Team - June 20, 2022
Alibaba F(x) Team - December 7, 2020
Alibaba F(x) Team - August 29, 2022
Alibaba F(x) Team - March 3, 2021
66 posts | 3 followers
FollowExplore Web Hosting solutions that can power your personal website or empower your online business.
Learn MoreA low-code development platform to make work easier
Learn MoreExplore how our Web Hosting solutions help small and medium sized companies power their websites and online businesses.
Learn MoreHelp enterprises build high-quality, stable mobile apps
Learn MoreMore Posts by Alibaba F(x) Team