ui-to-vue
affaan-m/ECC
使用 Vant、Element Plus 或 Ant Design Vue,将 UI 设计截图批量转换为 Vue 3 Composition API 组件。
...展开全部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 |
--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
安全与隐私
- 请将设计截图视为可能被发送至外部模型 API 的源材料。
- 未经许可,请勿对客户的私有设计运行此流程。
- 在可重复的工作流中固定转换器的版本,而不是使用
@latest. - 在提交生成的 Vue 代码之前,请先进行审查。
- 请勿提交
.ui-to-vue.config.json、API 密钥、生成的密钥或客户截图。
输出审查清单
- 页面组件已生成在
views/或所选的输出目录下生成。 - 重复的 UI 区域已提取到
components/仅在可复用性明确时才进行提取。 - 路由器输出与目标项目的路由器风格兼容。
- 生成的组件始终如一地使用指定的 UI 库。
- 生成的 CSS 单位符合设计基准。
- 代码通过了项目的格式化工具、代码检查器、类型检查器和构建流程。
- 占位符文本、模拟数据和生成的资源在提交前已通过审核。
故障排除
| 问题 | 检查 |
|---|---|
401 或身份验证错误 |
请确认 DASHSCOPE_API_KEY 是否已在运行该命令的 shell 中设置。 |
command not found: ui-to-vue |
请使用 npx [email protected] 表单或全局安装该软件包。 |
| 裁剪后的图片将被忽略 | 请确认资产目录名称受支持,且位于匹配的页面或模块之下。 |
| 组件忽略了请求的 UI 库 | 请使用显式的 --ui 值并检查生成的导入语句。 |
| 生成的布局尺寸看起来有误 | 请确认截图导出宽度与目标库的基准线一致。 |
参考资料
- npm 包:
ui-to-vue-converter
---
name: ui-to-vue
description: Batch-convert UI design screenshots into Vue 3 Composition API components using Vant, Element Plus, or Ant Design Vue.
---
# UI To Vue
Batch-convert UI design screenshots into Vue 3 Composition API component code.
## When to Use
- The user provides a directory of design screenshots or design-export images.
- The target application is Vue 3.
- The user wants a first pass of page components, shared components, and router wiring.
- The user specifies Vant, Element Plus, or Ant Design Vue as the component library.
## When Not to Use
- The user has only one screenshot and wants a bespoke component.
- The target project is not Vue.
- The design requires detailed interaction logic, data flow, or accessibility review.
- The screenshots contain private customer data that cannot be sent to an external model API.
## Inputs
Use an input directory that groups screenshots by module and page state:
```text
screenshots/
|-- HomePage/
| |-- List/
| | |-- [email protected]
| | `-- cut-images/
| |-- cut-images/
| `-- [email protected]
`-- cut-images/
```
Supported cut-image directory names include `assets`, `icons`, `sprites`, `cut`, `images`, and `cut-images`.
## Conversion Model
- Page grouping: combine related screenshots into one page component when they represent list, detail, form, loading, or empty states.
- UI library mapping: map native visual elements to Vant, Element Plus, or Ant Design Vue components where practical.
- Cut-image priority: prefer page-level assets, then module-level assets, then global shared assets.
- Component extraction: extract repeated UI regions into shared components when they appear more than once.
## CLI Usage
Run the converter with `npx` so the documented command works without relying on a global binary:
```bash
export DASHSCOPE_API_KEY=your_key
npx [email protected] --input ./screenshots --ui vant --output ./src
```
For desktop UI libraries:
```bash
npx [email protected] --input ./designs --ui element-plus --output ./src
npx [email protected] --input ./designs --ui antd-vue --output ./src
```
If the package is installed globally, the `ui-to-vue` binary can be used directly:
```bash
npm install -g [email protected]
ui-to-vue --input ./screenshots --ui vant --output ./src
```
## Options
| Option | Description | Default |
| --- | --- | --- |
| `--input` | Design image directory | `./screenshots` |
| `--ui` | UI library: `vant`, `element-plus`, or `antd-vue` | `vant` |
| `--output` | Output directory | `./src` |
| `--config` | Config file path | `./.ui-to-vue.config.json` |
## API Key Handling
The converter can read DashScope credentials from a config file or from the environment. Prefer an environment variable in repositories:
```bash
export DASHSCOPE_API_KEY=your_key
```
If a local config file is required, keep it out of version control:
```json
{
"apiKey": "your_dashscope_key",
"input": "./designs",
"ui": "vant",
"output": "./src"
}
```
```gitignore
.ui-to-vue.config.json
```
## Security and Privacy
- Treat design screenshots as source material that may be sent to an external model API.
- Do not run this flow on private customer designs without permission.
- Pin the converter version in repeatable workflows instead of using `@latest`.
- Review generated Vue code before committing it.
- Do not commit `.ui-to-vue.config.json`, API keys, generated secrets, or customer screenshots.
## Output Review Checklist
- [ ] Page components were generated under `views/` or the chosen output directory.
- [ ] Repeated UI regions were extracted into `components/` only when reuse is clear.
- [ ] Router output is compatible with the target project's router style.
- [ ] Generated components use the requested UI library consistently.
- [ ] Generated CSS units match the design baseline.
- [ ] The code passes the project's formatter, linter, type checker, and build.
- [ ] Placeholder copy, mock data, and generated assets were reviewed before commit.
## Troubleshooting
| Issue | Check |
| --- | --- |
| `401` or authentication error | Confirm `DASHSCOPE_API_KEY` is set in the shell running the command. |
| `command not found: ui-to-vue` | Use the `npx [email protected]` form or install the package globally. |
| Cut images are ignored | Confirm the asset directory name is supported and nested under the matching page or module. |
| Components ignore the requested UI library | Re-run with an explicit `--ui` value and inspect the generated imports. |
| Generated layout dimensions look wrong | Confirm the screenshot export width matches the target library baseline. |
## References
- npm package: `ui-to-vue-converter`
所有文件
1 个文件安装 ui-to-vue
下载技能文件并将其解压到 .claude/skills/ 目录中。
下载ZIP克隆仓库并复制技能文件到您的项目中。
git clone https://github.com/affaan-m/ECC/tree/main/skills/ui-to-vue # Copy SKILL.md to your .claude/skills/ directory
复制





首页
