skills/har-to-vue/SKILL.md
将 HAR(HTTP Archive)文件转换为 Vue 源代码。支持批量转换网络请求为 Vue 组件、API 调用或页面数据结构,用于复刻网站或快速生成基于现有 API 的 Vue 应用。当 Claude 需要处理 HAR 文件以:(1)从浏览器抓包数据生成 Vue 代码,(2)批量转换多个请求为 API 服务,(3)复刻现有网站的 Vue 技术栈实现,(4)生成带有数据绑定的组件模板时使用。
npx skillsauth add dwsy/agent har-to-vueInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
将 HAR 文件转换为 Vue 源代码,支持批量处理网络请求并生成可复用的 Vue 组件和 API 服务。
# 转换单个 HAR 文件为 Vue 组件
bun scripts/har_to_vue.ts input.har -o output.vue
# 批量转换所有请求为 API 服务
bun scripts/har_to_vue.ts input.har --mode api -o services/
复刻网站组件:
bun scripts/har_to_vue.ts capture.har --mode component --template composition -o components/
生成 API 服务:
bun scripts/har_to_vue.ts capture.har --mode api --library axios -o api/
完整页面生成:
bun scripts/har_to_vue.ts capture.har --mode page -o pages/home/
将 HAR 请求转换为 Vue 组件,包含数据绑定和模板结构。
生成内容:
选项:
--template <composition|options>: 使用 Composition API 或 Options API--typescript: 生成 TypeScript 类型定义--with-props: 从请求参数生成 props 定义将 HAR 请求转换为 API 服务函数。
生成内容:
选项:
--library <fetch|axios|ky>: HTTP 客户端库--base-url: 注入基础 URL--group-by <path|domain>: 分组策略生成完整的 Vue 页面,包含布局、路由和状态管理。
生成内容:
选项:
--with-router: 生成路由配置--with-store: 生成状态管理--layout <default|admin|blank>: 布局模板| HAR 字段 | Vue 映射 |
|---------|---------|
| request.method | HTTP 方法(GET/POST/PUT/DELETE) |
| request.url | API 端点路径 |
| request.headers | 请求头配置 |
| request.postData | 请求体(JSON/FormData) |
| response.content | 响应数据结构 |
?/api/users → getUsers)user_profile → UserProfile)getUserList → getList)UserList.vue
├── <script setup>
│ ├── imports(ref, onMounted, 等)
│ ├── types(接口定义)
│ ├── state(响应式数据)
│ ├── methods(数据获取)
│ └── lifecycle(onMounted)
├── <template>
│ └── 基于 JSON 结构的绑定
└── <style>
└── 基础样式
api/
├── index.ts # 导出所有 API
├── types.ts # 类型定义
├── users.ts # 用户相关 API
├── products.ts # 产品相关 API
└── utils.ts # 请求工具(拦截器、错误处理)
pages/
└── dashboard/
├── index.vue # 页面组件
├── api.ts # API 服务
├── types.ts # 类型定义
├── router.ts # 路由配置
└── store.ts # 状态管理
按 URL 模式自动分组 API:
# 按路径分组
bun scripts/har_to_vue.ts input.har --group-by path
# 按域名分组
bun scripts/har_to_vue.ts input.har --group-by domain
# 自定义分组规则
bun scripts/har_to_vue.ts input.har --group-config custom-rules.json
# 仅包含特定域名
bun scripts/har_to_vue.ts input.har --filter-domain api.example.com
# 排除静态资源
bun scripts/har_to_vue.ts input.har --exclude-extensions css,js,png,jpg
# 仅包含特定方法
bun scripts/har_to_vue.ts input.har --methods GET,POST
使用自定义模板文件:
bun scripts/har_to_vue.ts input.har --template-file templates/custom.vue
模板变量:
{{ requests }}: 请求列表{{ types }}: 类型定义{{ imports }}: 导入语句{{ componentName }}: 组件名称支持配置文件 har-to-vue.config.json:
{
"mode": "component",
"template": "composition",
"typescript": true,
"library": "axios",
"output": "./src",
"filter": {
"includeDomains": ["api.example.com"],
"excludeExtensions": ["css", "js", "png"]
},
"naming": {
"style": "camelCase",
"removePrefixes": ["get", "fetch"]
}
}
转换前清理不必要的请求:
手动优化生成的类型:
添加统一的错误处理:
// utils.ts
export async function fetchWithErrorHandler(url: string) {
try {
const response = await fetch(url);
if (!response.ok) throw new Error(response.statusText);
return await response.json();
} catch (error) {
console.error('API Error:', error);
throw error;
}
}
使用环境变量管理 API 配置:
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'https://api.example.com';
testing
Best practices for writing and maintaining high-quality role memories.
documentation
工作文档枢纽,强制执行 SSOT(Single Source of Truth)原则,管理 `docs/` 目录下的架构决策、设计文档、Issues(任务规划)、PRs(变更记录)。支持 GitHub 协作开发模式。
tools
Allows to interact with web pages by performing actions such as clicking buttons, filling out forms, and navigating links. It works by remote controlling Google Chrome or Chromium browsers using the Chrome DevTools Protocol (CDP). When Claude needs to browse the web, it can use this skill to do so.
development
Vercel 设计指南 - 构建高质量 Web 应用的最佳实践,包含现代 UI/UX 原则、性能优化和无障碍标准。