Skills

Frontend Dev

前端开发规范,包含 Vue 3 编码规范、UI 风格约束、TypeScript 规范等

Install

npx skills add doccker/cc-use-exp --skill frontend-dev -g -a claude-code -y
Repository
doccker/cc-use-exp1.1k
Category
Design
Updated
2mo ago
License
See repository
Context cost
Mediumabout 2,804 tokens
Runs scripts
No, instructions only

What it does

前端开发规范,包含 Vue 3 编码规范、UI 风格约束、TypeScript 规范等

前端开发规范

参考来源: Vue 官方风格指南、Element Plus 最佳实践


UI 风格约束

严格禁止(常见 AI 风格)

  • ❌ 蓝紫色霓虹渐变、发光描边、玻璃拟态
  • ❌ 大面积渐变、过多装饰性几何图形
  • ❌ 赛博风、暗黑科技风、AI 风格 UI
  • ❌ UI 文案中使用 emoji

后台系统(默认风格)

要素要求
主题使用组件库默认主题
配色黑白灰为主 + 1 个主色点缀
动效克制,仅保留必要交互反馈

技术栈

层级Vue(首选)React(备选)
框架Vue 3 + TypeScriptReact 18 + TypeScript
构建ViteVite
路由Vue Router 4React Router 6
状态PiniaZustand
UI 库Element PlusAnt Design

Vue 编码规范

组件基础

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import type { User } from '@/types'

// Props & Emits
const props = defineProps<{ userId: number }>()
const emit = defineEmits<{ (e: 'update', value: string): void }>()

// 响应式状态
const loading = ref(false)
const user = ref<User | null>(null)

// 计算属性
const displayName = computed(() => user.value?.name ?? '未知用户')

// 生命周期
onMounted(async () => { await fetchUser() })

// 方法
async function fetchUser() {
  loading.value = true
  try {
    user.value = await api.getUser(props.userId)
  } finally {
    loading.value = false
  }
}
</script>

<template>
  <div class="user-card">
    <h3>{{ displayName }}</h3>
  </div>
</template>

<style scoped>
.user-card { padding: 16px; }
</style>

命名约定

类型约定示例
组件文件PascalCase.vueUserCard.vue
ComposablesuseXxx.tsuseAuth.ts
StoreuseXxxStore.tsuseUserStore.ts

状态管理(Pinia)

// stores/user.ts
export const useUserStore = defineStore('user', () => {
  const user = ref<User | null>(null)
  const token = ref<string>('')

  const isLoggedIn = computed(() => !!token.value)

  async function login(username: string, password: string) {
    const res = await api.login(username, password)
    token.value = res.token
    user.value = res.user
  }

  return { user, token, isLoggedIn, login }
})

交互状态处理

Read the whole SKILL.md on GitHub

More in Design