From oh
UniApp + UnoCSS + WotUI page generator from designs. Converts screenshots or HTML/CSS to UniApp pages. Features: intelligent component mapping with priority (custom components, then WotUI, then built-in), 6 page templates (form, list, detail, tab, search, grid), auto-analyze custom components, cross-platform compatibility checks. Use for: creating UniApp pages, converting designs to code, mobile app/mini-program/H5 development. Actions: generate, create, build, convert, analyze, design. Tech: Vue3, UnoCSS, Wot Design Uni, UniApp.
npx claudepluginhub zwmmm/oh-my-claudecode --plugin ohThis skill uses the workspace's default tool permissions.
这个 skill 可以将设计稿(文本描述、HTML/CSS)自动转换为 UniApp + UnoCSS + Wot Design Uni 的生产就绪代码。通过智能组件映射和页面模板系统,快速生成跨平台兼容的移动应用页面。
Integrates uView UI library into UniApp projects with easycom configuration, pages.json/manifest.json setup, SCSS theming, and platform-specific handling for H5, mini-programs, App, and nvue.
References uni-helper ecosystem for uni-app: Vite plugins for routing, layouts, auto-imports, manifest; libraries like uni-use composables, network client; utilities, starters.
Guides uni-app development using Vue syntax for cross-platform apps, H5, and mini-programs, covering config, lifecycle, routing, APIs, components, and platform differences.
Share bugs, ideas, or general feedback.
这个 skill 可以将设计稿(文本描述、HTML/CSS)自动转换为 UniApp + UnoCSS + Wot Design Uni 的生产就绪代码。通过智能组件映射和页面模板系统,快速生成跨平台兼容的移动应用页面。
确保已安装 Python 3.8+:
python3 --version
如未安装,请按以下方式安装:
macOS:
brew install python3
Ubuntu/Linux:
sudo apt-get update && sudo apt-get install python3 python3-pip
Windows: 下载并安装 Python from https://www.python.org/downloads/
输入方式:
分析内容:
示例:
用户: 我需要一个商品列表页,包含搜索框、商品卡片(图片、标题、价格),支持下拉刷新和上拉加载更多。
使用搜索引擎匹配最合适的模板:
python3 scripts/search.py "list refresh load-more" --domain template
6 个可用模板:
优先级系统:
搜索命令:
# 搜索自定义组件(如果已运行 analyze_components.py)
python3 scripts/search.py "product card" --domain custom
# 搜索 WotUI 组件
python3 scripts/search.py "button primary" --domain wotui
python3 scripts/search.py "input text field" --domain wotui
python3 scripts/search.py "list cell" --domain wotui
# 搜索 UnoCSS 样式模式
python3 scripts/search.py "card container" --domain unocss
# 搜索最佳实践
python3 scripts/search.py "navigation" --domain best-practice
基于选定的模板和组件映射生成完整的 .vue 文件:
生成内容包括:
<template>, <script setup>, <style scoped>)自动检查并应用最佳实践:
# 搜索相关最佳实践
python3 scripts/search.py "form validation" --domain best-practice
python3 scripts/search.py "list performance" --domain best-practice
检查项包括:
运行质量检查清单(见下文"质量检查清单"章节)。
提供完整的、生产就绪的 .vue 文件代码。
如果你的项目已经有自定义组件(如 ProductCard、UserAvatar),应该优先使用这些组件而不是重复实现。
扫描项目并生成组件映射:
# 分析项目组件
python3 scripts/analyze_components.py /path/to/your/uniapp-project
# 指定输出文件
python3 scripts/analyze_components.py /path/to/your/uniapp-project -o data/components.csv
脚本会:
components/ 目录下的所有 .vue 文件components.csv 文件生成的 components.csv 示例:
No,Component Name,File Path,HTML Pattern,CSS Classes,Props,Slots,Events,Use Case,Category,Code Example,Priority
1,ProductCard,components/ProductCard.vue,<view class='product-card'>,product-card card-item,{"title":"string","price":"number","image":"string"},default,"click","商品展示卡片",card,"<ProductCard :title='商品' :price='99.9' />",1
| 域名 | 用途 | CSV 文件 | 示例查询 |
|---|---|---|---|
custom | 自定义组件 | components.csv | "product card image" |
wotui | WotUI 组件 | wotui.csv | "button primary large" |
template | 页面模板 | templates.csv | "form login submit" |
unocss | UnoCSS 模式 | unocss-patterns.csv | "flex center card" |
best-practice | 最佳实践 | best-practices.csv | "navigation storage" |
# 基础搜索
python3 scripts/search.py "<query>" --domain <domain>
# 限制结果数量
python3 scripts/search.py "<query>" --domain <domain> -n 5
# JSON 输出
python3 scripts/search.py "<query>" --domain <domain> --json
搜索 WotUI 组件:
# 按钮组件
python3 scripts/search.py "button primary action" --domain wotui
# 输入框组件
python3 scripts/search.py "input text clearable" --domain wotui
# 列表单元格
python3 scripts/search.py "cell list item link" --domain wotui
# 表单组件
python3 scripts/search.py "form validation" --domain wotui
搜索页面模板:
# 表单页模板
python3 scripts/search.py "form login register" --domain template
# 列表页模板
python3 scripts/search.py "list scroll refresh" --domain template
# 详情页模板
python3 scripts/search.py "detail product image" --domain template
搜索样式模式:
# 布局模式
python3 scripts/search.py "flex center" --domain unocss
python3 scripts/search.py "card container shadow" --domain unocss
# 按钮样式
python3 scripts/search.py "button full-width" --domain unocss
搜索最佳实践:
# 导航相关
python3 scripts/search.py "navigation" --domain best-practice
# 存储相关
python3 scripts/search.py "storage" --domain best-practice
# 性能优化
python3 scripts/search.py "performance list" --domain best-practice
<view>, <text>, <image> 等 UniApp 组件uni.* API 而非 Web API(如 uni.navigateTo 代替 router.push)<script setup> 语法defineProps<T>()defineEmits<T>()ref() 或 reactive()computed()[value]@event-nameStep 1: 描述需求
创建一个登录页面,包含:
- 用户名输入框
- 密码输入框(隐藏字符)
- "记住我"复选框
- 登录按钮(全宽、主色调)
- "忘记密码"链接
Step 2: 选择模板
python3 scripts/search.py "form login" --domain template
# 结果: form-page (表单页模板)
Step 3: 搜索组件
# 搜索输入框
python3 scripts/search.py "input text" --domain wotui
# 结果: wd-input
# 搜索密码框
python3 scripts/search.py "input password" --domain wotui
# 结果: wd-input (type="password")
# 搜索复选框
python3 scripts/search.py "checkbox" --domain wotui
# 结果: wd-checkbox
# 搜索按钮
python3 scripts/search.py "button primary block" --domain wotui
# 结果: wd-button
Step 4: 生成代码
生成的 login.vue:
<template>
<view class="flex flex-col h-screen bg-gray-50">
<wd-navbar title="登录" />
<scroll-view class="flex-1" scroll-y>
<view class="p-4">
<view class="text-center mb-8">
<text class="text-2xl font-bold text-gray-900">欢迎回来</text>
</view>
<wd-form ref="formRef" :model="formData" :rules="rules">
<wd-form-item label="用户名" prop="username">
<wd-input
v-model="formData.username"
prefix-icon="user"
placeholder="请输入用户名"
clearable
/>
</wd-form-item>
<wd-form-item label="密码" prop="password">
<wd-input
v-model="formData.password"
type="password"
prefix-icon="lock"
placeholder="请输入密码"
/>
</wd-form-item>
<wd-form-item>
<wd-checkbox v-model="remember">记住我</wd-checkbox>
</wd-form-item>
<wd-button
block
type="primary"
:loading="loading"
@click="handleLogin"
>
登录
</wd-button>
<view class="text-center mt-4">
<text
class="text-blue-500"
@click="goToForgotPassword"
>
忘记密码?
</text>
</view>
</wd-form>
</view>
</scroll-view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { FormInstance } from 'wot-design-uni'
const formRef = ref<FormInstance>()
const loading = ref(false)
const remember = ref(false)
const formData = ref({
username: '',
password: ''
})
const rules = {
username: [
{ required: true, message: '用户名不能为空' }
],
password: [
{ required: true, message: '密码不能为空' },
{ min: 6, message: '密码至少6个字符' }
]
}
const handleLogin = async () => {
try {
await formRef.value?.validate()
loading.value = true
// 登录逻辑
const res = await uni.request({
url: '/api/login',
method: 'POST',
data: formData.value
})
// 保存 token
uni.setStorageSync('token', res.data.token)
// 跳转到首页
uni.switchTab({ url: '/pages/index/index' })
} catch (error) {
uni.showToast({
title: '登录失败',
icon: 'error'
})
} finally {
loading.value = false
}
}
const goToForgotPassword = () => {
uni.navigateTo({ url: '/pages/forgot-password/index' })
}
</script>
Step 5: 检查最佳实践
python3 scripts/search.py "form validation navigation" --domain best-practice
Step 6: 质量检查
<script setup> 和 TypeScriptuni.* API(navigateTo, switchTab, setStorageSync)可执行脚本,用于搜索和分析:
CSV 数据库文件:
页面模板文件:
参考文档(按需加载):
A: 重新运行 analyze_components.py 脚本,它会自动扫描并更新 components.csv。
A: 检查是否使用了 Web-only API 或组件。运行质量检查清单中的跨平台兼容性检查。
A: 使用 UnoCSS 原子类或添加 scoped 样式。避免直接修改 WotUI 组件内部样式。
A: Wot Design Uni 支持暗黑模式。使用 CSS 变量进行主题定制。
A: 搜索最佳实践 python3 scripts/search.py "list performance" --domain best-practice,考虑使用虚拟滚动或分页加载。