library-picturebook-activity/frontend/.cursor/rules/frontend-specific.mdc
aid 418aa57ea8 Day4: 超管端设计优化 + UGC绘本创作社区P0实现
一、超管端设计优化
- 文档管理SOP体系建立,docs目录重组
- 统一用户管理:跨租户全局视角,合并用户管理+公众用户
- 活动监管全模块重构:全部活动(统计卡片+阶段筛选+SuperDetail详情页)、报名数据/作品数据/评审进度(两层合一扁平列表)、成果发布(去Tab+统计+隐藏写操作)
- 菜单精简:移除评委管理/评审规则/通知管理
- Bug修复:租户编辑丢失隐藏菜单、pageSize限制、主色统一

二、UGC绘本创作社区P0
- 数据库:10张新表(user_works/user_work_pages/work_tags等)
- 子女账号独立化:Child升级为独立User,家长切换+独立登录
- 用户作品库:CRUD+发布审核,8个API
- AI创作流程:提交→生成→保存到作品库,4个API
- 作品广场:首页改造为推荐流,标签+搜索+排序
- 内容审核(超管端):作品审核+作品管理+标签管理
- 活动联动:WorkSelector作品选择器
- 布局改造:底部5Tab(发现/创作/活动/作品库/我的)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 22:20:25 +08:00

238 lines
4.7 KiB
Plaintext
Raw 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.

---
description: 前端特定的开发规范(仅作用于 frontend 目录)
globs:
alwaysApply: true
---
# 前端特定规范
本规则仅作用于 `frontend/` 目录。
## Ant Design Vue 组件使用
### 表格组件
```vue
<template>
<a-table
:columns="columns"
:data-source="dataSource"
:loading="loading"
:pagination="pagination"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<a-space>
<a-button type="link" @click="handleEdit(record)">编辑</a-button>
<a-popconfirm
title="确定要删除吗?"
@confirm="handleDelete(record.id)"
>
<a-button type="link" danger>删除</a-button>
</a-popconfirm>
</a-space>
</template>
</template>
</a-table>
</template>
```
### 表单组件
```vue
<template>
<a-form
:model="formState"
:rules="rules"
layout="vertical"
@finish="onFinish"
>
<a-form-item label="用户名" name="username">
<a-input v-model:value="formState.username" />
</a-form-item>
<a-form-item>
<a-button type="primary" html-type="submit">提交</a-button>
</a-form-item>
</a-form>
</template>
```
### Modal 弹窗
```vue
<template>
<a-modal
v-model:open="visible"
title="编辑用户"
@ok="handleOk"
>
<a-form :model="formState">
<!-- 表单内容 -->
</a-form>
</a-modal>
</template>
```
## 消息提示
```typescript
import { message, notification } from 'ant-design-vue';
// 成功提示
message.success('操作成功');
// 错误提示
message.error('操作失败');
// 通知
notification.success({
message: '成功',
description: '用户创建成功',
});
```
## Tailwind CSS 常用类
```html
<!-- 布局 -->
<div class="flex items-center justify-between">
<div class="grid grid-cols-3 gap-4">
<div class="p-4 m-2">
<!-- 响应式 -->
<div class="w-full md:w-1/2 lg:w-1/3">
<!-- 文本 -->
<p class="text-lg font-bold text-gray-800">
<!-- 状态 -->
<button class="hover:bg-blue-600 active:bg-blue-700">
```
## 权限指令
使用自定义指令 `v-permission`
```vue
<template>
<a-button v-permission="'user:create'" type="primary">
创建用户
</a-button>
<a-button v-permission="['user:update', 'user:delete']" type="link">
编辑
</a-button>
</template>
```
## 租户路由
所有路由必须包含租户编码:
```typescript
// ✅ 正确
router.push(`/${tenantCode}/users`);
// ❌ 错误
router.push('/users');
```
获取租户编码:
```typescript
import { useRoute } from 'vue-router';
const route = useRoute();
const tenantCode = route.params.tenantCode as string;
```
## 常用组合式函数
### 使用权限检查
```typescript
import { useAuthStore } from '@/stores/auth';
const authStore = useAuthStore();
// 检查权限
const hasPermission = authStore.hasPermission('user:create');
// 检查多个权限(任一)
const hasAnyPermission = authStore.hasAnyPermission(['user:create', 'user:update']);
```
### 表格分页
```typescript
import { ref, reactive } from 'vue';
const loading = ref(false);
const dataSource = ref([]);
const pagination = reactive({
current: 1,
pageSize: 10,
total: 0,
});
const handleTableChange = (pag: any) => {
pagination.current = pag.current;
pagination.pageSize = pag.pageSize;
fetchData();
};
const fetchData = async () => {
loading.value = true;
try {
const { data, total } = await getUsers({
skip: (pagination.current - 1) * pagination.pageSize,
take: pagination.pageSize,
});
dataSource.value = data;
pagination.total = total;
} finally {
loading.value = false;
}
};
```
## 项目结构
```
src/
├── api/ # API 接口
├── assets/ # 静态资源
├── components/ # 公共组件
├── composables/ # 组合式函数
├── directives/ # 自定义指令
├── layouts/ # 布局组件
├── router/ # 路由配置
├── stores/ # Pinia 状态
├── styles/ # 全局样式
├── types/ # TypeScript 类型
├── utils/ # 工具函数
└── views/ # 页面组件
├── auth/ # 认证相关
├── users/ # 用户管理
├── school/ # 学校管理
└── contests/ # 竞赛管理
```
## 常用脚本
```bash
# 开发
pnpm dev
# 构建
pnpm build
# 预览
pnpm preview
# 代码检查
pnpm lint
```