- init unibest v4.4.0 base template - tabbar: 4 tabs (打卡/进度/测算/持仓) with carbon icons - pages/checkin: daily checklist, streak counter, monthly rate - pages/progress: asset snapshot, progress bar to 71万 target - pages/calculator, holdings: placeholder pages (stage 2) - store/checkin.ts + store/progress.ts with pinia persist - vite: host 0.0.0.0 for WSL2→Windows browser access Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3.4 KiB
3.4 KiB
AGENTS.md - unibest Development Guide
Project Overview
uniapp + Vue3 + TypeScript + Vite5 + UnoCSS template. Supports H5, WeChat Mini Program, App (Android/iOS/HarmonyOS).
Architecture
unibest 仓库 (refactor/monorepo 分支)
└── packages/cli/ # CLI 脚手架工具
└── 用户执行 pnpm create unibest 时,从 Git base 分支克隆模板
模板来源:
- 用户创建项目时,从
https://gitee.com/feige996/unibest.git的base分支克隆 - CLI 工具本身不包含模板代码
Essential Commands
# Development
pnpm dev # H5 dev server
pnpm dev:h5 # H5 with hot reload
pnpm dev:mp # WeChat Mini Program
pnpm dev:app # App development
# Build
pnpm build # Build current platform
pnpm build:h5 # H5 output (dist/build/h5)
pnpm build:mp # WeChat MP (dist/build/mp-weixin)
pnpm build:app # App output (dist/build/app)
# Lint & Type Check
pnpm lint # ESLint
pnpm lint:fix # ESLint auto-fix
pnpm type-check # TypeScript check
Code Style
TypeScript
- Use explicit types for params and return values
- Prefix interfaces with
I:IUserInfoRes,ILoginForm - Use
import typefor types only
Vue SFC
<script lang="ts" setup>
defineOptions({ name: 'PageName' })
definePage({ style: { navigationBarTitleText: 'Title' } })
</script>
<template>
<!-- content -->
</template>
<style lang="scss" scoped>
/* styles */
</style>
- Order: template → script → style
Imports
- Use
@/alias for src imports:import { http } from '@/http/http' - Group: external libs → Vue/UniApp → @/ → ../
Naming
| Type | Convention | Example |
|---|---|---|
| Components | PascalCase | TabbarItem.vue |
| Pages | kebab-case | login/index.vue |
| Stores | useXxxStore | useUserStore |
| API functions | camelCase | getUserInfo |
| Constants | UPPER_SNAKE_CASE | VITE_SERVER_BASEURL |
Error Handling
try {
const res = await http.post('/auth/login', data)
return res
}
catch (error) {
uni.showToast({ title: 'Failed', icon: 'error' })
throw error
}
UnoCSS
- Use utility classes:
flex justify-center items-center px-4 pt-safe - Theme colors:
text-primary,bg-primary - Safe areas:
pt-safe,pb-safe,p-safe
API Design
// Always specify response type
return http.get<IUserInfoRes>('/user/info')
return http.post<IAuthLoginRes>('/auth/login', data)
Pinia Stores
export const useUserStore = defineStore('user', () => {
const userInfo = ref<IUserInfoRes>(initialState)
const setUserInfo = (val: IUserInfoRes) => { ... }
return { userInfo, setUserInfo }
}, { persist: true })
File Structure
src/
├── api/ # API definitions
├── components/ # Vue components
├── hooks/ # Composable hooks
├── http/ # alova HTTP config
├── pages/ # Page components
├── store/ # Pinia stores
├── types/ # TypeScript types
└── utils/ # Utility functions
ESLint
- Uses
@uni-helper/eslint-config console.logallowed- Run
pnpm lint:fixbefore committing
Important Notes
- Auto-imports enabled for Vue APIs and uni-app APIs
- Generated files:
src/service/,auto-import.d.ts,uni-pages.d.ts - Pages auto-generated from
src/pages/ - App config in
manifest.config.ts