Communitygithub.com

UI转Vue

当用户需要将UI截图或设计稿批量转换为Vue 3组件时使用,尤其适用于Vant、Element Plus或Ant Design Vue组件库。

UI转Vue 是什么?

该技能可以将一组UI设计截图批量转换为Vue 3 Composition API组件代码。它非常适合快速搭建页面组件、共享组件以及路由连接,特别适用于使用Vant(移动端)、Element Plus(桌面端)或Ant Design Vue(桌面端)组件库的项目。用户只需提供一个包含按模块分组的截图目录,工具会自动识别页面状态(如列表、详情、表单、加载、空状态),将相似的截图合并为单个页面组件,并将重复的UI区域提取为共享组件。转换过程基于DashScope API,因此需要设置DASHSCOPE_API_KEY环境变量。工具支持通过npx直接运行,也可以全局安装使用;同时提供丰富的命令行选项,如指定输入目录、输出目录、目标UI库以及配置文件路径。注意:设计截图会发送到外部模型API,因此请勿用于包含客户隐私数据的场景,且生成的代码在提交前应进行审查。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/ui-to-vue

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

UI转Vue 是做什么的?

将UI设计截图批量转换为Vue 3 Composition API组件代码。

使用场景

  • 用户提供了包含设计截图或设计导出图片的目录。
  • 目标应用是Vue 3。
  • 用户希望一次性生成页面组件、共享组件以及路由连接。
  • 用户指定了Vant、Element Plus或Ant Design Vue作为组件库。

不适用场景

  • 用户只有一张截图,需要定制化的单个组件。
  • 目标项目不是Vue。
  • 设计稿需要复杂的交互逻辑、数据流或可访问性审查。
  • 截图包含无法发送到外部模型API的客户隐私数据。

输入

使用按模块和页面状态分组的输入目录:

screenshots/
|-- HomePage/
|   |-- List/
|   |   |-- [email protected]
|   |   `-- cut-images/
|   |-- cut-images/
|   `-- [email protected]
`-- cut-images/

支持的切图目录名称包括 assets、icons、sprites、cut、images 和 cut-images。

转换模型

  • 页面分组:当截图表示列表、详情、表单、加载或空状态时,将相关截图合并为一个页面组件。
  • UI库映射:尽可能将原生视觉元素映射到Vant、Element Plus或Ant Design Vue组件。
  • 切图优先级:优先使用页面级资源,其次是模块级资源,最后是全局共享资源。
  • 组件提取:重复出现的UI区域会被提取为共享组件(出现超过一次时)。

CLI使用方法

使用 npx 运行转换器,确保文档中的命令不依赖全局安装的二进制文件:

export DASHSCOPE_API_KEY=your_key
npx [email protected] --input ./screenshots --ui vant --output ./src

对于桌面端UI库:

npx [email protected] --input ./designs --ui element-plus --output ./src
npx [email protected] --input ./designs --ui antd-vue --output ./src

如果包已全局安装,可以直接使用 ui-to-vue 命令:

npm install -g [email protected]
ui-to-vue --input ./screenshots --ui vant --output ./src

选项

选项描述默认值
--input设计图目录./screenshots
--uiUI库:vant、element-plus 或 antd-vuevant
--output输出目录./src
--config配置文件路径./.ui-to-vue.config.json

API密钥处理

转换器可以从配置文件或环境中读取DashScope凭据。在仓库中建议使用环境变量:

export DASHSCOPE_API_KEY=your_key

如果需要本地配置文件,请确保将其排除在版本控制之外:

{
  "apiKey": "your_dashscope_key",
  "input": "./designs",
  "ui": "vant",
  "output": "./src"
}
.ui-to-vue.config.json

安全与隐私

  • 将设计截图视为可能发送到外部模型API的源材料。
  • 未经许可,请勿对涉及客户隐私的设计执行此流程。
  • 在可重复的工作流中固定转换器版本,而不是使用 @latest。
  • 在提交之前审查生成的Vue代码。
  • 不要提交 .ui-to-vue.config.json、API密钥、生成的密钥或客户截图。

输出审查清单

  • 页面组件已在 views/ 或指定的输出目录下生成。
  • 重复的UI区域仅在复用明确的情况下被提取到 components/ 中。
  • 路由输出与目标项目的路由风格兼容。
  • 生成的组件一致地使用所请求的UI库。
  • 生成的CSS单位与设计基准匹配。
  • 代码通过项目的格式化工具、linter、类型检查器和构建流程。
  • 提交前检查了占位符文案、模拟数据和生成的资源。

故障排查

问题检查
401 或认证错误确认在运行命令的Shell中设置了 DASHSCOPE_API_KEY。
command not found: ui-to-vue使用 npx [email protected] 形式或全局安装该包。
切图被忽略确认资源目录名称是受支持的,并且嵌套在对应的页面或模块下。
组件忽略指定的UI库使用明确的 --ui 值重新运行,并检查生成的导入语句。
生成的布局尺寸不正确确认截图导出宽度与目标库的基准一致。

参考资料

  • npm包:ui-to-vue-converter

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

相关技能