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





首頁
