所有一级页面和不分二级页面
This commit is contained in:
81
lib/features/v2/my/domain/entities/my_entities.dart
Normal file
81
lib/features/v2/my/domain/entities/my_entities.dart
Normal file
@@ -0,0 +1,81 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// 用户信息实体
|
||||
class UserProfileEntity extends Equatable {
|
||||
const UserProfileEntity({
|
||||
required this.name,
|
||||
required this.role,
|
||||
required this.avatar,
|
||||
required this.userId,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String role;
|
||||
final String avatar;
|
||||
final String userId;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [name, role, avatar, userId];
|
||||
|
||||
UserProfileEntity copyWith({
|
||||
String? name,
|
||||
String? role,
|
||||
String? avatar,
|
||||
String? userId,
|
||||
}) {
|
||||
return UserProfileEntity(
|
||||
name: name ?? this.name,
|
||||
role: role ?? this.role,
|
||||
avatar: avatar ?? this.avatar,
|
||||
userId: userId ?? this.userId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 我的页面菜单项实体
|
||||
class MenuItemEntity extends Equatable {
|
||||
const MenuItemEntity({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.icon,
|
||||
this.subTitle,
|
||||
this.hasSwitch = false,
|
||||
this.switchValue = false,
|
||||
this.hasBadge = false,
|
||||
this.badgeCount = 0,
|
||||
});
|
||||
|
||||
final String id;
|
||||
final String title;
|
||||
final String icon;
|
||||
final String? subTitle;
|
||||
final bool hasSwitch;
|
||||
final bool switchValue;
|
||||
final bool hasBadge;
|
||||
final int badgeCount;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id, title, icon, subTitle, hasSwitch, switchValue, hasBadge, badgeCount];
|
||||
|
||||
MenuItemEntity copyWith({
|
||||
String? id,
|
||||
String? title,
|
||||
String? icon,
|
||||
String? subTitle,
|
||||
bool? hasSwitch,
|
||||
bool? switchValue,
|
||||
bool? hasBadge,
|
||||
int? badgeCount,
|
||||
}) {
|
||||
return MenuItemEntity(
|
||||
id: id ?? this.id,
|
||||
title: title ?? this.title,
|
||||
icon: icon ?? this.icon,
|
||||
subTitle: subTitle ?? this.subTitle,
|
||||
hasSwitch: hasSwitch ?? this.hasSwitch,
|
||||
switchValue: switchValue ?? this.switchValue,
|
||||
hasBadge: hasBadge ?? this.hasBadge,
|
||||
badgeCount: badgeCount ?? this.badgeCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
18
lib/features/v2/my/domain/repositories/my_repository.dart
Normal file
18
lib/features/v2/my/domain/repositories/my_repository.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||||
|
||||
/// 我的页面仓储接口
|
||||
abstract class MyRepository {
|
||||
/// 获取用户信息
|
||||
Future<Either<Failure, UserProfileEntity>> getUserProfile();
|
||||
|
||||
/// 获取菜单列表
|
||||
Future<Either<Failure, List<MenuItemEntity>>> getMenuItems();
|
||||
|
||||
/// 切换夜间模式
|
||||
Future<Either<Failure, bool>> toggleNightMode(bool enabled);
|
||||
|
||||
/// 清除缓存
|
||||
Future<Either<Failure, bool>> clearCache();
|
||||
}
|
||||
14
lib/features/v2/my/domain/usecases/clear_cache_usecase.dart
Normal file
14
lib/features/v2/my/domain/usecases/clear_cache_usecase.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/repositories/my_repository.dart';
|
||||
|
||||
/// 清除缓存用例
|
||||
class ClearCacheUseCase {
|
||||
ClearCacheUseCase(this._repository);
|
||||
|
||||
final MyRepository _repository;
|
||||
|
||||
Future<Either<Failure, bool>> call() async {
|
||||
return await _repository.clearCache();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/entities/my_entities.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/repositories/my_repository.dart';
|
||||
|
||||
/// 获取菜单列表用例
|
||||
class GetMenuItemsUseCase {
|
||||
GetMenuItemsUseCase(this._repository);
|
||||
|
||||
final MyRepository _repository;
|
||||
|
||||
Future<Either<Failure, List<MenuItemEntity>>> call() async {
|
||||
return await _repository.getMenuItems();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
import 'package:maibu_satabot_v2/core/error/failure.dart';
|
||||
import 'package:maibu_satabot_v2/features/v2/my/domain/repositories/my_repository.dart';
|
||||
|
||||
/// 切换夜间模式用例
|
||||
class ToggleNightModeUseCase {
|
||||
ToggleNightModeUseCase(this._repository);
|
||||
|
||||
final MyRepository _repository;
|
||||
|
||||
Future<Either<Failure, bool>> call(bool enabled) async {
|
||||
return await _repository.toggleNightMode(enabled);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user