惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
LINUX DO - 最新话题
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Visual Studio Blog
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
月光博客
月光博客
博客园 - 叶小钗
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tailwind CSS Blog
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog RSS Feed
量子位
美团技术团队
Vercel News
Vercel News
Y
Y Combinator Blog
IT之家
IT之家
Martin Fowler
Martin Fowler
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
腾讯CDC
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
罗磊的独立博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
博客园 - 司徒正美
N
Netflix TechBlog - Medium
S
Schneier on Security
博客园 - 聂微东
U
Unit 42
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
Latest news
Latest news

少数派

派早报:Google 发布 Fitbit Air 等 - 少数派 「新人报到」確認需求,再開始 - 少数派 从 SOLO 独立开发者社区,我看到了越来越多开发者开始做自己的产品 - 少数派 我怎么管理那些"不常做,但总会忘"的生活事项 - 少数派 人形机器人量产元年,数据才是具身智能的“生死线” - 少数派 BuhoLaunchpad 高度还原 Mac 启动台:开发历程与思考 - 少数派 五年陪伴依然不舍,DIY 换壳后让罗技 MX Master 3 继续服役 - 少数派 新玩意 240|少数派的编辑们最近买了啥? - 少数派 一日一技|为什么你应该关闭 iOS 的键盘声音 - 少数派 我做了个插件和 Skills,一键提取任何网站的设计规范 Design.md - 少数派 住在三四线城市的你,该开始录播客了 - 少数派 甘南秘境,大白高国 - 少数派 AI的审美:谁让把我变成川内倫子 - 少数派 返工怎能不烦恼,打工人片单总有一部是你的「嘴替」 - 少数派 为了让「上厕所」更健康,我做了一个小工具 - 少数派 AI + Skill,能够让生成的文章去除 AI 味吗? - 少数派 新玩意|韶音OpenDots ONE 耳夹式耳机 - 少数派 《美满》| 在每一个春天的晚上相爱(362) - 少数派 新玩意|优篮子 PS01 MagSnap 磁吸支架 - 少数派 自我整合手记 | 我开始早睡了:用稳定规则,为自由托底 - 少数派 用龙虾(OpenClaw)两个多月,我最深的12个体会 - 少数派 听歌时间到,12 张你可能错过的 2025 华语乐坛好专辑 - 少数派 承诺能追吗 - 少数派 macOS 26启动台没了? 我做了个不一样的App启动器 - Keboard - 少数派 《四海为家的人》| INTJ对话INTJ(361) - 少数派 你发过的那些黑历史,是时候一次清干净了 - 少数派 新玩意:安安静静玩,越玩越专注:计客密码机 - 少数派 iPad 用户首次体验 Android 平板:vivo Pad6 Pro - 少数派 数据逻辑强 - 少数派 极北行+ | 一路向北,探访日本至北之地 | 001 - 少数派 万字剖析:千问App深度体验报告(2026) - 少数派 在2026年,如何真正防止别人抄袭你的作品 - 少数派 怎么用 50 块搭个 AI 语音助手?我踩了 3 天坑 - 少数派 YeeroAI:让 AI 对话真正成为知识管理的一部分 - 少数派 爬泰山 - 少数派 「旅图显影」 App 更新:这次,我们补上了一点「手感」 - 少数派 假期出门太折磨?我的 23 条经验帮你规划惬意旅行 - 少数派 工作流会变吗 - 少数派 Claude Opus 4.6 怎么用最省钱?我测了 5 种方案 - 少数派 GPT Image 2 让图文并茂不再稀罕 - 少数派 用户侧出发——什么是AI,我要不要学习? - 少数派 找片、转存、整理、播放一条龙!让你的付费网盘值回票价 - 少数派 欢迎试用!日课一问2.0插件 - 少数派 自己做的MDeditor,原本想购买 Typora 试了两次支付不成功,干脆自己做一个 - 少数派 vibe coding了一个 3MB 的小工具,让 ~/Downloads 彻底告别混乱 - 少数派 因为受不了 Mac 的风扇策略,我做了一个风扇控制工具 - 少数派 别只怪模型 - 少数派 Warp 终端的 AI 功能怎么用?我测了一周的体验 - 少数派 AI 写代码老是出 bug?这 5 个配置我后悔没早知道 - 少数派 「新玩意」苹果出相机可能就这样:Sigma BF + 45mm F2.8 DG Contemporary - 少数派 一个面向2030年的AI操作系统是什么样子的:浅谈cola这款有灵魂的Agent - 少数派 别只看写代码 - 少数派 每天解决10个问题,还是一口气攻坚解决400个? - 少数派 AI 交易机器人怎么搭?我用 Claude 跑了一周实盘 - 少数派 Maptoposter Online:把你爱的城市画成艺术海报 - 少数派 Function Calling 怎么用?我测了 3 个模型发现差距真大 - 少数派 Legend Talk:我做了个 AI 圆桌,让 160 位思想家围着你的问题转 - 少数派 如何找到自己的蓝方?在小县城寻找压力测试 - 少数派 语音输入与软件接口|2026年聊AI时,我们都聊些什么(上) - 少数派 混动已经卖爆,纯电又来补刀——钛7闪充版简直“不讲武德” - 少数派 本月玩什么|朋友收藏、识质存在、沙罗周期 - 少数派 为什么要每天坚持输出? - 少数派 Claude API 挂了好几个小时,你的项目有备用方案吗? - 少数派 Function Calling 没你想的复杂——我用它做了个有点用的工具 - 少数派 登录系统立即播放视频或者图片音乐的软件 - 少数派 我为什么创建 FlipHTML5 下载工具 - 少数派 残局没电?多品牌外设电量统一管理软件EasyBluetooth已支持RTSS游戏内显示以及AIDA64 - 少数派 前往通义路的路 - 少数派 太好看了,媲美Sun的个人导航页,NAS部署星云门户 - 少数派 乌黑嘴唇“一键检测”上线了 - 少数派 派早报:Claude AI 接入多个创意软件生态、FILCO 生产方接手品牌等 - 少数派 【更新】BearCLI、Claude 连接器与 MCP 服务器 - 少数派 记了上千条流水,还是看不懂财务?我做了一个让 AI 读懂账本的工作台 - 少数派 MINI R56 升级原厂 Sport 模式 - 少数派 新玩意 | 一棵柠檬树(仿真版) - 少数派 Momenta的“物理AI”野望,需迈过“含摩量”这道关 - 少数派 网页直接投屏控制手机!NAS一键部署PandaScrcpy,流畅丝滑可远程。 - 少数派 众测|邀你一同探索随身 AI 硬件入口 YoooClaw C·ONE - 少数派 2050大会:分享时间是真诚 参会记 - 少数派 iPad 赋能电影创作:国内首部宣纸手绘长片《燃比娃》的幕后故事 - 少数派 AI的审美:我用 8 个大模型给 100 张旅行照片打分 - 少数派 普通人如何破圈?去参加一个本地协会 - 少数派 把极空间的图标全换了,主题DIY全攻略打造你的专属NAS桌面 - 少数派 电子便签墙,帮你实现便签自由 - 少数派 我如何用三个 CLI 工具取代文档创建需求 - 少数派 原来真的有人可以玩一辈子 - 少数派 社区速递 139 | 派友热议三月买了啥、复古单反尼康 Df 体验 - 少数派 06 作品的赏析与评价 - 少数派 TDS REVIEW|索尼 WF-1000XM6 降噪真无线耳机体验 - 少数派 35.98万起售的第二代腾势D9,我看重的不是堆料,而是不凑合 - 少数派 鼠须管 Squirrel 皮肤配置指北 - 少数派 从watch ultra2换到redmi watch6 - 少数派 派早报:阿里巴巴发布视频生成模型 HappyHorse 1.0 等 - 少数派 别迷信1M - 少数派 家人们天塌了!网盘“大封杀”,多个渠道多条路,NAS部署PanHub - 少数派 AI与人勾心斗角!NAS一键部署AI狼人杀,假日休闲必备。 - 少数派 电商必备!Comfyui工作流批量生图插件,一次生成12张!支持Nano banana pro模型 - 少数派 Comfyui工作流配置Gpt-image-2模型教程,0.03/张 - 少数派 OpenClaw第三方APi怎么配置?可使用Gpt-image-2模型 - 少数派 会员社区话题精选 Ep. 103 - 少数派
【Cursor+PromptCoder】利用AI智能编辑器快速实现设计稿(自动提示词版) - 少数派
2025-03-17 · via 少数派

在现代前端开发中,将设计稿转化为可运行的代码是一项耗时的工作。然而,借助人工智能工具,这一过程可以变得更加高效和简单。本文将介绍如何结合 PromptCoderCursor,从设计截图生成页面和对应的路由,极大提升开发效率。

Cursor 是一款基于 VS Code 构建的 AI 智能代码编辑器,集成了强大的AI功能,旨在优化开发者的编码体验。它不仅提供传统的代码补全,还能通过自然语言交互生成代码、理解项目上下文,并助力开发者快速实现复杂的开发任务。

Cursor 的核心特点

  • 智能补全:通过 Tab 功能,Cursor 能根据上下文预测并提供多行代码建议。
  • 聊天交互:内置聊天窗口,开发者可以直接与 AI 对话,请求生成特定代码或解决问题。
  • 项目理解:Cursor 能够分析整个项目结构,确保生成的代码与现有代码无缝衔接。
  • 多框架支持:支持多种语言和框架,如 React、Next.js、Vue 等,适应不同开发需求。
  • 与传统编辑器相比,Cursor 的 AI 能力让开发者能够以更自然的方式与代码交互,显著减少手动编写的时间。

【PromptCoder】智能代码提示词生成

PromptCoder 是一款利用人工智能的代码生成工具,能够识别设计图或截图,并生成匹配的前端代码提示词。无论是复杂的交互组件还是简洁的页面布局,PromptCoder 都能帮助开发者快速复刻设计稿,提升效率并减少错误。

PromptCoder 的核心特点

  • 交互简单易用:通过先进的图像识别技术,只需上传设计图即可生成精确的代码提示词。
  • 从免费开始:提供免费注册体验,低门槛尝试其强大功能。
  • 多框架支持:兼容 React、Vue、Flutter 等多种前端框架,轻松集成到现有项目。
  • 多种模式选择:普通模式生成单页提示词,而 cascade 模式 能分析潜在路由并生成多页面提示词。

实战案例:从 Dribbble 中复制一个 Dashboard 页面

下面,我们将通过一个实战案例,展示如何使用 PromptCoder 和 Cursor,从 Dribbble 的设计稿生成一个功能完整的 Dashboard 页面,并设置相关路由。

步骤 1:选择设计稿

首先,前往 Dribbble 寻找一个心仪的设计稿。例如,我们选择了一个简洁清新的 Dashboard 设计,只需截图即可。

步骤 2:使用 PromptCoder 生成提示词

将设计截图上传至 PromptCoder,选择 cascade 模式。工具会自动识别设计中的元素(如导航栏、主内容区等),分析潜在路由(如 ‘manage’、‘history’),并生成详细的代码提示词。

步骤 3:使用 Cursor 生成代码

  • 启动 Cursor:打开 Cursor 编辑器,新建一个 Next.js 项目(本例使用 Next.js)。
  • 输入提示词:在 Cursor 的聊天窗口中,粘贴 PromptCoder 生成的提示词部分。例如,输入:
Create a Next.js component for a dashboard layout with a fixed sidebar and main content area. The sidebar includes a logo and navigation menu. Use Tailwind CSS for styling.
  • 生成代码:AI 会生成对应的代码片段,点击接受后插入到项目中。
  • 逐一构建组件:继续通过聊天功能生成其他组件,如 WalletSummary、TransactionsSection 等。
  • 智能补全:在手动调整代码时,使用 Tab 功能获取 AI 的上下文建议,加速编码。
  • 配置路由:在聊天窗口询问:
How do I set up routes for '/manage' and '/history' in Next.js?

根据 AI 的建议,在 app 目录下创建对应页面。

  • 完成项目:最终,我们不仅复刻了设计稿,还实现了路由跳转,如 ‘/manage’ 和 ‘/history’。

通过这种方式,我们利用 Cursor 的 AI 能力,将 PromptCoder 的提示词转化为功能完整的代码。


提示词示例

以下是 PromptCoder 生成的详细提示词示例,您可以在 Cursor 的聊天窗口中使用它来指导代码生成:


Create detailed Next.js components with these requirements:
1. Use 'use client' directive for client-side components
2. Style with Tailwind CSS utility classes for responsive design
3. Use Lucide React for icons (from lucide-react package). Do NOT use other UI libraries unless requested
4. Use stock photos from picsum.photos where appropriate, only valid URLs you know exist
5. Configure next.config.js image remotePatterns to enable stock photos from picsum.photos
6. Avoid duplicate components
7. Automatically source and display logos from a CDN in design placeholders
8. Follow proper import practices:
   - Use @/ path aliases
   - Keep component imports organized
   - Update current src/app/page.tsx with new comprehensive code
   - Don't forget root route (page.tsx) handling
   - You MUST complete the entire prompt before stopping

   Okay, here's a detailed description optimized for Next.js code generation, based on your UI analysis, and tailored for IDE tools like Cursor and Windsurf:

```
1. Layout Overview

- **Page Structure:**
    - The page utilizes a classic dashboard layout with a fixed-width sidebar on the left and a main content area that takes up the remaining space.  The main content area appears to use a grid or flexbox layout to arrange cards (dashboard widgets).  A top bar spans the entire width, above both the sidebar and main content.
    - The structure can be represented in Next.js using a combination of `<div>` elements for containers and semantic HTML5 elements where appropriate (e.g., `<nav>` for the sidebar, `<header>` for the top bar, `<main>` for the content area, `<aside>` could also be used).  A layout component (`Layout.tsx` or similar) is highly recommended to encapsulate the sidebar and top bar, providing a consistent structure across multiple pages.
    - Key structural components:
        -   `Layout` (wraps entire page, handles sidebar and top bar)
        -   `Sidebar`
        -   `TopBar`
        -   `MainContent` (holds the grid of cards)
        -   `DashboardCard` (a reusable component for each card)

- **Component Hierarchy:**
    - `App` (root component)
        - `Layout`
            - `Sidebar`
                - `Logo`
                - `SearchBar`
                - `NavItem` (repeated for each navigation item)
                - `DownloadSection`
            - `TopBar`
                - `Logo`
                - `DateDisplay`
                - `NotificationIcon`
                - `UserProfile`
            - `MainContent`
                - `DashboardCard` (repeated, with different content)
                    - `CardHeader`
                    - `CardContent` (content varies greatly - see below)
                        - *Water Card:* `WaterDisplay`
                        - *Calories Card:* `CalorieDisplay`
                        - *Step Goals Card:* `CircularProgress`
                        - *New Route Card:* `MapDisplay`
                        - *Meditation Class Card:* `ImageWithQRCode`
                        - *Today Plans Card:* `MealList`
                        - *Weight Card:* `WeightChart`
                        - *Workout Card:* `WorkoutTimer`
                - `WorkoutProgressSection`
                    -`ProgressBar`
                    -`IncreaseDurationButton`

- **Responsive Design Considerations:**
    - The layout should be responsive, adapting to different screen sizes.  This can be achieved using CSS media queries and a mobile-first approach.
    - **Sidebar:** On smaller screens, the sidebar could collapse into a hamburger menu or a bottom navigation bar.  This can be handled with a state variable (e.g., `isSidebarOpen`) and conditional rendering.
    - **Main Content:** The grid of cards should reflow.  On smaller screens, the cards should stack vertically (one card per row).  CSS Grid's `grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));` (or similar) is ideal for this.  The `minmax()` value should be adjusted based on the desired minimum card width.
    - **Top Bar:**  Elements in the top bar might need to be rearranged or hidden on smaller screens.
    - Use of a CSS framework like Tailwind CSS (favored by Windsurf) or a component library like Material UI, Chakra UI, or Ant Design can significantly simplify responsive design implementation.  These frameworks provide pre-built responsive components and utilities.

2. Styling Specifications

- **Color Schemes:**
    - **Primary:** Teal/Turquoise (`#4FC8B9` - suggested).  Use CSS variables (e.g., `--primary-color: #4FC8B9;`) for easy modification and theming.  Apply this to active navigation items, progress bars, and potentially button hover states.
    - **Secondary:** Light Gray (`#F5F9FA`). Use as the background color for the main content area and some secondary text.  `--secondary-color: #F5F9FA;`
    - **Neutral:** White (`#FFFFFF`) for the main background.  Dark gray/black for text.  `--background-color: #FFFFFF;`, `--text-color: #333;` (or similar dark gray).
    - **Accent:** Green (`#69D196`) for completed progress bars. Red (`#C24242`) for the workout timer. `--accent-green: #69D196;`, `--accent-red: #C24242;`
    - **Icons:** Darker shade than surrounding backgrounds.  Consider using a consistent icon library (e.g., Font Awesome, Heroicons, React Icons) for easy management and styling.

- **Typography:**
    - Use a sans-serif font (e.g., Open Sans, Roboto, or a similar web-safe font).  Define font families in your CSS or Tailwind configuration.
    - **Headings:** Larger font sizes (e.g., `text-xl`, `text-2xl` in Tailwind) and semi-bold/bold weights (`font-semibold`, `font-bold`).
    - **Body Text:** Smaller font size (e.g., `text-base`, `text-sm`) and normal/medium weight (`font-normal`, `font-medium`).
    - **Emphasis:** Use `font-bold` and color (primary or accent colors) to highlight important information.
    - Define reusable text styles (e.g., using Tailwind's `@apply` directive or CSS classes) to maintain consistency.

- **Spacing and Alignment:**
    - Use a consistent spacing scale (e.g., 4px, 8px, 16px, 24px, 32px).  Tailwind's spacing scale (e.g., `p-4`, `mx-2`, `my-8`) is highly recommended.
    - Elements are generally left-aligned.  Use `text-left` (or the default left alignment) for most text.  Center some elements (e.g., progress indicators) using `text-center` or flexbox/grid centering techniques.
    - Use ample whitespace to create a clean and uncluttered layout.
    - Consistent margins and padding around elements and within cards.

- **Animations and Transitions:**
    - **Progress Bars:** Use CSS transitions or animations to smoothly update the progress bars.  Consider libraries like `framer-motion` or `react-spring` for more complex animations.
    - **Hover States:** Add subtle transitions (e.g., `transition-colors duration-200`) to button and navigation item hover states.  Change the background color or text color slightly on hover.
    - **Sidebar Collapse:** If implementing a collapsible sidebar, use a smooth transition (e.g., `transition-transform duration-300 ease-in-out`) to animate the opening and closing.

3. Interactive Elements

- **User Inputs:**
    - **Search Bar:**  Use an `<input type="text">` element.  Consider adding a clear button and handling the search input with a state variable and an `onChange` event handler.
    - **Workout Duration Increase:** Use a `<button>` element.  Increment a state variable (representing the workout duration) on click.
    - **Weight Kg Selector:** This could be a dropdown (`<select>`) or a custom component.

- **Navigation:**
    - **Sidebar:** Use a `<nav>` element containing a list (`<ul>`, `<li>`) of navigation items.  Each item should be a link (`<a>` or Next.js's `<Link>` component).  Use an `active` class (or a similar mechanism) to highlight the currently selected page.
    - **Top Bar:**  The date, notification icon, and user profile are likely links or buttons.

- **Loading States:**
    - While not shown, implement loading states for data-fetching operations.  Use spinners or skeleton loaders (e.g., from a component library) to indicate that data is being loaded.  Conditional rendering based on a loading state variable (e.g., `isLoading`) is key.

- **Micro-interactions:**
    - **Hover States:** As mentioned above, use subtle color changes or other visual cues on hover.
    - **Active States:** Clearly indicate the active navigation item.
    - **Button Clicks:** Provide visual feedback on button clicks (e.g., a slight change in background color or a ripple effect).

4. Routes

- `/` (Dashboard - Main page)
- `/workout`
- `/nutrition`
- `/health-stats`
- `/goals`
- `/analytics`
- `/settings`
- The search bar might trigger a search results page (e.g., `/search?q=...`) or update the current page dynamically.

These routes would correspond to files within the `pages` directory in a Next.js project (e.g., `pages/workout.tsx`, `pages/nutrition.tsx`, etc.). The `Layout` component would be used in each of these page components to maintain the consistent sidebar and top bar. The `_app.tsx` file would likely wrap the entire application to provide global styles and context.
```

您可以将上述提示词分段输入 Cursor 的聊天窗口,逐步生成代码。例如,先请求生成 DashboardLayout,再生成 Sidebar,以此类推。


总结

通过 PromptCoder 和 Cursor 的协作,开发者可以快速将设计稿转化为可运行的代码。PromptCoder 负责从截图生成详细提示词,而 Cursor 则通过其 AI 功能帮助实现代码编写和路由配置。相比传统开发,这种方式不仅高效,还赋予开发者更多控制权。

立即访问官网:PromptCoder,获取免费试用!您也可以前往 Cursor 官网 下载这款强大的 AI 编辑器,开启智能编码之旅。