- feat(sync): SyncEngine 接入 EditorPage, 保存时 enqueue + 网络恢复自动 trySync - fix(editor): authorId 从 AuthBloc 获取, 替代硬编码 'local' - fix(bloc): class_bloc/calendar/profile/parent catch(_).全部改为 debugPrint - feat(editor): 编辑器工具栏拆分 (brush_panel/tag_panel/text_format_bar/dot_grid_painter) - feat(editor): EditorBloc 扩展 + EditorPage 增强 - feat(search): SearchBloc 扩展搜索功能 - feat(home): HomeBloc/HomePage 增强 - feat(auth): LoginPage 增强 - feat(templates): TemplateGalleryPage 重构 - fix(web): 管理端班级/日记页面修复 - fix(server): comment_service + theme_handler 修复 - docs: 添加全链路审计报告和验证截图
91 lines
2.2 KiB
Dart
91 lines
2.2 KiB
Dart
// 搜索状态 — SearchBloc 输出的 UI 状态
|
|
|
|
part of 'search_bloc.dart';
|
|
|
|
/// 搜索结果分类 tab
|
|
enum SearchResultTab {
|
|
all('全部'),
|
|
journal('日记'),
|
|
template('模板'),
|
|
tag('标签');
|
|
|
|
const SearchResultTab(this.label);
|
|
final String label;
|
|
}
|
|
|
|
/// 搜索状态基类
|
|
sealed class SearchState {
|
|
const SearchState();
|
|
}
|
|
|
|
/// 初始状态 — 未执行任何搜索
|
|
final class SearchInitial extends SearchState {
|
|
const SearchInitial();
|
|
}
|
|
|
|
/// 加载中 — 正在查询日记
|
|
final class SearchLoading extends SearchState {
|
|
const SearchLoading();
|
|
}
|
|
|
|
/// 搜索结果已加载
|
|
final class SearchLoaded extends SearchState {
|
|
/// 日记搜索结果列表
|
|
final List<JournalEntry> results;
|
|
|
|
/// 当前活跃的心情筛选条件
|
|
final String? activeMood;
|
|
|
|
/// 当前活跃的标签筛选条件
|
|
final String? activeTag;
|
|
|
|
/// 当前活跃的关键词
|
|
final String? activeKeyword;
|
|
|
|
/// 当前选中的结果分类 tab
|
|
final SearchResultTab activeTab;
|
|
|
|
/// 搜索历史(内存中保存,最多 10 条)
|
|
final List<String> searchHistory;
|
|
|
|
const SearchLoaded({
|
|
this.results = const [],
|
|
this.activeMood,
|
|
this.activeTag,
|
|
this.activeKeyword,
|
|
this.activeTab = SearchResultTab.all,
|
|
this.searchHistory = const [],
|
|
});
|
|
|
|
/// 是否有活跃的筛选条件
|
|
bool get hasActiveFilter =>
|
|
activeMood != null || activeTag != null || activeKeyword != null;
|
|
|
|
SearchLoaded copyWith({
|
|
List<JournalEntry>? results,
|
|
String? activeMood,
|
|
bool clearActiveMood = false,
|
|
String? activeTag,
|
|
bool clearActiveTag = false,
|
|
String? activeKeyword,
|
|
bool clearActiveKeyword = false,
|
|
SearchResultTab? activeTab,
|
|
List<String>? searchHistory,
|
|
}) =>
|
|
SearchLoaded(
|
|
results: results ?? this.results,
|
|
activeMood: clearActiveMood ? null : (activeMood ?? this.activeMood),
|
|
activeTag: clearActiveTag ? null : (activeTag ?? this.activeTag),
|
|
activeKeyword:
|
|
clearActiveKeyword ? null : (activeKeyword ?? this.activeKeyword),
|
|
activeTab: activeTab ?? this.activeTab,
|
|
searchHistory: searchHistory ?? this.searchHistory,
|
|
);
|
|
}
|
|
|
|
/// 搜索出错
|
|
final class SearchError extends SearchState {
|
|
final String message;
|
|
const SearchError(this.message);
|
|
}
|