Ui to vue

From aaione/everything-claude-code-zh · View interactive version

Ui to vue is an AI agent skill from the GitHub repository aaione/everything-claude-code-zh. 当用户有 UI 截图或设计导出需要批量转换为 Vue 3 组件时使用,特别是使用 Vant、Element Plus 或 Ant Design Vue 时。

How to use this skill

Skill file

UI 转 Vue

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

何时使用

何时不使用

输入

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

screenshots/
|-- HomePage/
|   |-- List/
|   |   |-- HomePage-List-Default@3x.png
|   |   `-- cut-images/
|   |-- cut-images/
|   `-- HomePage-Default@3x.png
`-- cut-images/

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

转换模型

CLI 用法

使用 npx 运行转换器,使文档中的命令无需依赖全局二进制文件即可工作:

export DASHSCOPE_API_KEY=your_key
npx ui-to-vue-converter@1.0.2 --input ./screenshots --ui vant --output ./src

对于桌面 UI 库:

npx ui-to-vue-converter@1.0.2 --input ./designs --ui element-plus --output ./src
npx ui-to-vue-converter@1.0.2 --input ./designs --ui antd-vue --output ./src

如果包全局安装,可以直接使用 ui-to-vue 二进制文件:

npm install -g ui-to-vue-converter@1.0.2
ui-to-vue --input ./screenshots --ui vant --output ./src

选项

| 选项 | 描述 | 默认值 |

| --- | --- | --- |

| --input | 设计图片目录 | ./screenshots |

| --ui | UI 库:vant、element-plus 或 antd-vue | vant |

| --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

安全和隐私

输出审查检查清单

故障排除

| 问题 | 检查 |

| --- | --- |

| 401 或认证错误 | 确认运行命令的 Shell 中设置了 DASHSCOPE_API_KEY。 |

| command not found: ui-to-vue | 使用 npx ui-to-vue-converter@1.0.2 形式或全局安装包。 |

| 切图被忽略 | 确认资产目录名称受支持且嵌套在匹配的页面或模块下。 |

| 组件忽略请求的 UI 库 | 用显式 --ui 值重新运行并检查生成的导入。 |

| 生成的布局尺寸看起来不对 | 确认截图导出宽度与目标库基线匹配。 |

参考文献

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.