1分钟,图文并茂手把手教你用Trae AI将你的设计稿自动生成前端代码 One-Minute Guide with Visuals: Turn Design Mockups into Code wit

1分钟,图文并茂手把手教你用Trae AI将你的设计稿自动生成前端代码 One-Minute Guide with Visuals: Turn Design Mockups into Code wit

1分钟,图文并茂手把手教你用Trae AI将你的设计稿自动生成前端代码 One-Minute Guide with Visuals: Turn Design Mockups into Code with Trae AI

无需手动编码,设计图直接变代码,AI正在重塑前端开发的工作流。| No manual coding needed. Design mockups directly transform into code. AI is reshaping frontend development workflows.

本文为中英文双语,需要英文博客可以滑动到下面查看哦 | This is a bilingual article. Scroll down for the English version.

准备工作:

在开始之前,我们需要完成一些简单的环境配置:

  1. 安装Trae:访问Trae官网(trae.ai或trae.cn)下载对应操作系统的版本,支持Windows、Mac和Linux全平台。
  2. 准备一个需要写代码的项目:我搞了一个demo空白项目来进行举例~
  3. 选择工作模式:启动Trae后,切换到Builder模式,这个模式可以自动帮你写代码哦~

实操

第1步:上传设计图

在Trae的Builder模式下,直接拖拽或上传你的设计图文件。Trae支持多种格式设计稿。

我们在百度里随便找一个图作为案例,纠结中~ 啊哦,不纠结了,就用百度为案例吧~

image

第2步:下达指令

你可以按照以下结构向AI工具下达指令,这样它能最准确地理解你的需求:
image
指令模板
请根据我上传的图片,帮我: 1. **生成React组件代码** - 创建一个新的页面组件 - 组件文件路径:src/pages/[根据图片内容命名的文件夹]/index.tsx - 使用TypeScript - 包含必要的样式文件 2. **自动注册路由** - 在现有的路由配置中(通常是 src/router/index.tsx 或类似文件) - 添加新页面的路由配置 - 路由路径:/【根据图片内容建议的路由路径】 3. **文件夹结构** - 创建完整的文件夹结构 - 包含组件文件、样式文件(如需要) - 导出配置 图片内容描述:【这里简单描述图片显示的页面功能,比如:用户管理界面、仪表盘、登录页面等】 
具体示例
请根据我上传的图片,帮我: 1. 在 app 文件夹下创建demo1016文件夹,生成React组件 2. 创建图片中所需要的元素的所有组件,请自动拆分,可以创建多个子组件 3. 自动注册路由,路径为 "/demo1016" 4. 组件要包含页面中所有元素 
补充信息(让AI更准确)

如果可能,还可以提供:

  • 项目技术栈:使用的是 React Router v6 还是其他路由库?
  • UI组件库:Ant Design、Material-UI 还是自定义组件?
  • 状态管理:Redux、Zustand 还是 Context?
  • 样式方案:CSS Modules、Styled-components 还是 Tailwind?

这样AI工具就能生成完全符合你项目结构的代码,并正确集成到现有项目中。

第3步:AI自动解析

上传后,Trae会启动其AI引擎自动分析设计稿。

image


image
授权AI自动执行命令,创建编写代码

如果你不放心,我们一般都可以用git记录代码改动,AI工具生成的代码可以点击撤回,如果多次对话最终结果仍旧不满意,可以使用分支记录随时撤回哦~

image

第4步:AI自动生成高质量代码

解析完成后,Trae会自动生成对应的前端代码。你可以根据项目需求选择输出的技术栈:

  • React组件(支持TypeScript)
  • Vue组件(支持Vue 2和Vue 3)
  • 原生HTML/CSS/JavaScript
  • iOS原生UI代码(Swift)
image

第5步:实时预览与调整

生成代码后,如果发现与设计稿有差异,可以通过自然语言指示AI进行调整:

  • “将按钮颜色改为蓝色”
  • “增加元素之间的间距”

“添加悬停动效”

image


image


image


image

总结

虽然和原图有一些差异,但是界面元素已经全部捕获到了,而且我用的是随手截图的图片&免费模型,并不是真正的设计原稿,想要获得更好的效果,有下面几种方案:

  1. 可以安装插件市场提供的Figma插件哦~

使用更好的具有图片识别能力与代码生成能力的大模型

image

Preparation:

Before we begin, we need to complete some simple environment configurations:

  1. Install Trae: Visit the Trae official website (trae.ai or trae.cn) to download the version for your operating system. It supports Windows, Mac, and Linux platforms.
  2. Prepare a project that needs coding: I’ve set up a demo blank project for this example.
  3. Select working mode: After launching Trae, switch to Builder mode, which can automatically write code for you!

Practical Steps

Step 1: Upload Design Mockup

In Trae’s Builder mode, directly drag and drop or upload your design mockup file. Trae supports multiple formats of design drafts.

We’ll randomly find an image from Baidu as a case study. Let’s stop hesitating and use Baidu as our example!

image

Step 2: Give Instructions

You can issue instructions to the AI tool following this structure for the most accurate understanding of your needs:
image
Instruction Template
Please help me with the image I uploaded: 1. **Generate React component code** - Create a new page component - Component file path: src/pages/[folder named based on image content]/index.tsx - Use TypeScript - Include necessary style files 2. **Automatically register routes** - In the existing routing configuration (usually src/router/index.tsx or similar files) - Add routing configuration for the new page - Route path: /[suggested route path based on image content] 3. **Folder structure** - Create a complete folder structure - Include component files, style files (if needed) - Export configuration Image content description: [Briefly describe the page function shown in the image, such as: user management interface, dashboard, login page, etc.] 
Specific Example
Please help me with the image I uploaded: 1. Create a demo1016 folder under the app folder and generate React components 2. Create all components needed for the elements in the image, automatically split them, and create multiple sub-components 3. Automatically register the route with path "/demo1016" 4. Components should include all elements in the page 
Additional Information (For More Accurate AI)

If possible, you can also provide:

  • Project tech stack: Are you using React Router v6 or another routing library?
  • UI component library: Ant Design, Material-UI, or custom components?
  • State management: Redux, Zustand, or Context?
  • Styling solution: CSS Modules, Styled-components, or Tailwind?

This way, the AI tool can generate code that perfectly matches your project structure and integrates correctly into your existing project.

Step 3: AI Automatic Analysis

After uploading, Trae will start its AI engine to automatically analyze the design draft.

image


image
Authorize AI to Automatically Execute Commands and Write Code

If you’re unsure, we can generally use git to track code changes. The code generated by AI tools can be rolled back with a click. If you’re still not satisfied with the final result after multiple conversations, you can always roll back using branch records!

image

Step 4: AI Automatically Generates High-Quality Code

After analysis, Trae will automatically generate the corresponding frontend code. You can choose the output tech stack according to your project needs:

  • React components (supporting TypeScript)
  • Vue components (supporting Vue 2 and Vue 3)
  • Native HTML/CSS/JavaScript
  • iOS native UI code (Swift)
image

Step 5: Real-time Preview and Adjustment

After generating the code, if you find any differences from the design draft, you can instruct the AI to make adjustments using natural language:

  • “Change the button color to blue”
  • “Increase the spacing between elements”
  • “Add hover animations”
image


image


image


image

Summary

Although there are some differences from the original image, all interface elements have been captured. Moreover, I used a casually-screenshot image & free model, not a real design draft. To achieve better results, here are some solutions:

  1. You can install the Figma plugin provided in the plugin marketplace!
  2. Use better large models with image recognition and code generation capabilities
image
Conclusion | 结语
  • That’s all for today~ - | 今天就写到这里啦~
  • Guys, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ See you tomorrow~ | 小伙伴们,( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ我们明天再见啦~~
  • Everyone, be happy every day! 大家要天天开心哦
  • Welcome everyone to point out any mistakes in the article~ | 欢迎大家指出文章需要改正之处~
  • Learning has no end; win-win cooperation | 学无止境,合作共赢
  • Welcome all the passers-by, boys and girls, to offer better suggestions! ~ | 欢迎路过的小哥哥小姐姐们提出更好的意见哇~~

Read more

盘点降AIGC率网站排行榜前十名,免费功能实测结果全面解析

盘点降AIGC率网站排行榜前十名,免费功能实测结果全面解析

核心工具对比速览 排名 工具名称 降重效率 特色功能 适用场景 1 aicheck ⚡⚡⚡⚡⚡ 专业术语保留 高重复率论文急救 2 秒篇 ⚡⚡⚡⚡ 逻辑结构优化 社科类论文 3 askpaper ⚡⚡⚡⚡ 多轮迭代降重 理工科文献 4 PaperYY ⚡⚡⚡ 每日免费额度 日常小修 5 论文狗 ⚡⚡⚡ 三次免费机会 初稿优化 Q&A:AI降重工具到底能做什么? Q:这些工具真能解决我的论文重复率问题吗? A:现代AI降重工具早已不是简单的同义词替换。以aicheck为例,它能将42%重复率的市场调研论文降至7%,同时保留专业术语和核心观点,就像给论文做了场"精准瘦身手术"。 Q:不同学科论文降重效果有差异吗? A:确实存在学科适配性。秒篇在法律论文案例中表现出色,能将38%重复率降至6%且不破坏法条引用;

By Ne0inhk

智能写作辅助:bert-base-chinese应用案例

智能写作辅助:bert-base-chinese应用案例 1. 技术背景与应用场景 在自然语言处理(NLP)领域,预训练语言模型的出现极大推动了文本理解与生成任务的发展。其中,BERT(Bidirectional Encoder Representations from Transformers)作为 Google 提出的经典架构,通过双向上下文建模显著提升了多项 NLP 任务的性能。而针对中文场景优化的 bert-base-chinese 模型,因其对汉字级语义的精准捕捉能力,已成为中文文本处理的核心基座之一。 该模型基于全量中文维基百科语料进行预训练,包含 12 层 Transformer 编码器、768 维隐藏层和约 1.1 亿参数,在完型填空、句子分类、语义匹配等任务中表现出色。尤其在智能写作辅助系统中,bert-base-chinese 可以支撑如下关键功能: - 自动补全用户输入的不完整句子; - 判断两段文字是否表达相同意图,用于查重或推荐; - 提取文本深层语义特征,

By Ne0inhk

Stable Diffusion绘画实战:云端GPU 10分钟出图,2块钱玩一下午

Stable Diffusion绘画实战:云端GPU 10分钟出图,2块钱玩一下午 你是不是也和我一样,在小红书刷到那些惊艳的AI绘画作品时,心里直呼“这也太强了”?精致的插画、梦幻的场景、甚至能生成商业级的设计稿——关键是,人家一张图可能就几十秒搞定。作为设计师,看到这种效率,谁能不心动? 但一搜教程,满屏都是“需要NVIDIA显卡”“推荐RTX 4060以上”“显存至少8GB”,再一看价格,四五千起步……而你手里的MacBook连CUDA都不支持,本地根本跑不动。这时候你会不会想:能不能先试试水,看看效果到底值不值得我砸钱配一台高配电脑? 好消息是——现在不用买显卡,也能玩转AI绘画! 借助ZEEKLOG星图提供的预置Stable Diffusion镜像,配合云端GPU资源,你可以: * 10分钟内完成部署,直接在线生成高质量图像 * 成本低至每小时几毛钱,2块钱就能玩一下午 * 无需安装任何复杂环境,小白也能轻松上手 * 生成结果可直接用于客户提案、创意草图、风格探索 这篇文章就是为你量身定制的实战指南。我会带你从零开始,一步步在云端部署Stable Diffu

By Ne0inhk

文心一言API接入指南:手把手教你快速集成AI能力

文心一言API接入指南:手把手教你快速集成AI能力 关键词:文心一言API、大模型集成、开发者指南、AI能力调用、API接入实战 摘要:本文是面向开发者的文心一言API接入全流程指南,从注册账号到代码调用,用“手把手”式讲解+实战案例,带你快速掌握大模型能力集成方法。无论你是想给产品增加智能对话功能的中小团队,还是想尝试AI开发的个人开发者,读完本文都能轻松上手文心一言API! 背景介绍 目的和范围 近年来,以文心一言(ERNIE Bot)为代表的大语言模型(LLM)彻底改变了AI应用开发模式——开发者无需从头训练模型,通过API调用就能快速为产品注入智能对话、内容生成、文本理解等能力。本文聚焦文心一言API的实际接入流程,覆盖从账号注册到代码调试的全链路操作,帮助开发者快速将大模型能力集成到自己的应用中。 预期读者 * 中小团队开发者(需要为产品添加智能交互功能) * 个人开发者(想尝试AI应用开发) * 学生/技术爱好者(对大模型实际应用感兴趣) 文档结构概述 本文采用“知识铺垫→操作指南→实战验证→场景拓展”的逻辑,

By Ne0inhk