Files
2026-08-31 11:33:59 +08:00

39 lines
842 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: frontend-web-store
description: Web 前台状态管理规范(Nuxt 4),基于 Pinia
globs:
- "frontend/web/app/stores/**/*.ts"
---
## 代码模板
```typescript
import { defineStore } from 'pinia';
export const use{Model}Store = defineStore('{model}', () => {
const list = ref<any[]>([]);
const total = ref(0);
async function fetchList(params?: any) {
const res = await get{Model}List(params);
list.value = res.data.items;
total.value = res.data.total;
}
return { list, total, fetchList };
});
```
## 关键约定
- 使用 Pinia `setup store` 语法(Composition API)
- Store 命名:`use{Name}Store`
- Store ID:`kebab-case`
- Nuxt 项目中 store 支持 SSR
## 检查清单
- [ ] 是否使用 setup store 语法
- [ ] Store 名称是否唯一
- [ ] SSR 场景是否正确处理 hydration