fix(app): 修复 P2~P4 共 10 项前端问题
P2 必须修复: - 教师布置主题 classId 从硬编码改为班级下拉选择器 - 班级日记墙使用服务端 classId 过滤替代前端过滤 - Profile 统计栏接入 JournalRepository 真实数据 - WeeklyPage 从全硬编码改为 JournalRepository 数据驱动 P3 建议改进: - 提取 mood_utils.dart 公共函数,消除 4 处重复定义 - 贴纸库搜索框连接 StickerBloc 按名称过滤 P4 细节打磨: - 家长页多孩子时显示 DropdownButton 选择器 - 搜索结果日记卡片点击跳转 /editor?id= - MonthlyPage 照片数量从 JournalElement 统计 - calendar_page/mood_page/search_page 统一使用 moodToEmoji/moodToLabel
This commit is contained in:
@@ -261,11 +261,9 @@ class ClassBloc extends Bloc<ClassEvent, ClassState> {
|
||||
emit(current.copyWith(isLoadingWall: true));
|
||||
|
||||
try {
|
||||
// 加载属于该班级的公开日记
|
||||
final journals = await _journalRepo.getJournals();
|
||||
final classJournals = journals
|
||||
.where((j) => j.classId == event.classId && j.sharedToClass)
|
||||
.toList();
|
||||
// 服务端过滤:按 classId 查询班级公开日记(后端 API 已支持 ?class_id= 参数)
|
||||
final journals = await _journalRepo.getJournals(classId: event.classId);
|
||||
final classJournals = journals.where((j) => j.sharedToClass).toList();
|
||||
|
||||
emit(current.copyWith(diaryWall: classJournals, isLoadingWall: false));
|
||||
} catch (_) {
|
||||
@@ -345,9 +343,6 @@ class ClassBloc extends Bloc<ClassEvent, ClassState> {
|
||||
TopicAssign event,
|
||||
Emitter<ClassState> emit,
|
||||
) async {
|
||||
if (state is! ClassDetailLoaded) return;
|
||||
final current = state as ClassDetailLoaded;
|
||||
|
||||
try {
|
||||
final dto = await _classRepo.assignTopic(
|
||||
classId: event.classId,
|
||||
@@ -355,15 +350,20 @@ class ClassBloc extends Bloc<ClassEvent, ClassState> {
|
||||
description: event.description,
|
||||
dueDate: event.dueDate,
|
||||
);
|
||||
final newTopic = TopicAssignment(
|
||||
id: dto.id,
|
||||
classId: dto.classId,
|
||||
teacherId: dto.teacherId,
|
||||
title: dto.title,
|
||||
description: dto.description,
|
||||
dueDate: dto.dueDate,
|
||||
);
|
||||
emit(current.copyWith(topics: [newTopic, ...current.topics]));
|
||||
|
||||
// 更新本地 topics 列表(仅在班级详情视图中)
|
||||
if (state is ClassDetailLoaded) {
|
||||
final current = state as ClassDetailLoaded;
|
||||
final newTopic = TopicAssignment(
|
||||
id: dto.id,
|
||||
classId: dto.classId,
|
||||
teacherId: dto.teacherId,
|
||||
title: dto.title,
|
||||
description: dto.description,
|
||||
dueDate: dto.dueDate,
|
||||
);
|
||||
emit(current.copyWith(topics: [newTopic, ...current.topics]));
|
||||
}
|
||||
} catch (_) {
|
||||
// 静默失败
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user