Files
xianyan/lib/features/daily_fortune/fortune_mock_data.dart
Developer f91be94e9c refactor: 完成项目架构重构,统一模块导入路径
- 清理大量废弃的 barrel 导出文件,移除冗余的中间导出层
- 修复所有相对路径导入错误,统一调整为扁平化模块引用
- 更新多平台 pubspec 版本号与依赖库版本
- 补充后端功能问题管理后台与脚本工具
- 调整部分页面的快捷方式文案适配新功能
- 更新部分翻译覆盖率与API文档
2026-06-12 08:53:57 +08:00

369 lines
11 KiB
Dart

/// ============================================================
/// 闲言APP — 运势Mock数据
/// 创建时间: 2026-05-28
/// 更新时间: 2026-06-12
/// 作用: 提供离线/未登录时的运势模拟数据
/// 上次更新: 从data/子目录提升至daily_fortune根目录
/// ============================================================
import 'fortune_models.dart';
class FortuneMockData {
FortuneMockData._();
/// 构建今日运势Mock数据
static FortuneRecord buildMockToday() {
final now = DateTime.now();
final todayStr = _formatDate(now);
return FortuneRecord(
date: todayStr,
uid: 'guest',
fortuneLevel: FortuneLevel.daji,
fortuneScore: 92,
signText: '鹏程万里风正举\n一帆风顺向天涯\n贵人相助逢佳运\n事事如意福无涯',
dimensions: [
const FortuneDimension(
key: 'love',
name: '感情',
iconSvg: 'heart',
level: FortuneLevel.zhongji,
score: 78,
),
const FortuneDimension(
key: 'career',
name: '事业',
iconSvg: 'briefcase',
level: FortuneLevel.ji,
score: 85,
),
const FortuneDimension(
key: 'wealth',
name: '财运',
iconSvg: 'dollar',
level: FortuneLevel.xiaoji,
score: 70,
),
const FortuneDimension(
key: 'health',
name: '健康',
iconSvg: 'pulse',
level: FortuneLevel.daji,
score: 95,
),
const FortuneDimension(
key: 'study',
name: '学业',
iconSvg: 'book',
level: FortuneLevel.moji,
score: 60,
),
const FortuneDimension(
key: 'social',
name: '人际',
iconSvg: 'users',
level: FortuneLevel.zhongji,
score: 75,
),
],
lucky: const FortuneLucky(
number: 7,
color: '朱红',
direction: '东南',
constellation: '天秤',
),
suitable: ['求财', '出行', '签约'],
unsuitable: ['动土', '嫁娶'],
theme: FortuneCardStyle.ancient,
isToday: true,
canRegenerate: true,
regenCount: 0,
imageUrl: '',
createdAt: now.millisecondsSinceEpoch ~/ 1000,
);
}
/// 构建历史运势Mock数据
static List<FortuneRecord> buildMockHistory() {
final now = DateTime.now();
return [
FortuneRecord(
date: _formatDate(now.subtract(const Duration(days: 1))),
uid: 'guest',
fortuneLevel: FortuneLevel.zhongji,
fortuneScore: 78,
signText: '春风化雨润无声\n静待花开自有情\n莫道前路多坎坷\n柳暗花明又一村',
dimensions: [
const FortuneDimension(
key: 'love',
name: '感情',
iconSvg: 'heart',
level: FortuneLevel.ji,
score: 82,
),
const FortuneDimension(
key: 'career',
name: '事业',
iconSvg: 'briefcase',
level: FortuneLevel.xiaoji,
score: 68,
),
const FortuneDimension(
key: 'wealth',
name: '财运',
iconSvg: 'dollar',
level: FortuneLevel.zhongji,
score: 78,
),
const FortuneDimension(
key: 'health',
name: '健康',
iconSvg: 'pulse',
level: FortuneLevel.ji,
score: 80,
),
const FortuneDimension(
key: 'study',
name: '学业',
iconSvg: 'book',
level: FortuneLevel.moji,
score: 55,
),
const FortuneDimension(
key: 'social',
name: '人际',
iconSvg: 'users',
level: FortuneLevel.xiaoji,
score: 65,
),
],
lucky: const FortuneLucky(
number: 3,
color: '靛蓝',
direction: '西北',
constellation: '双鱼',
),
suitable: ['纳财', '安床'],
unsuitable: ['开市', '出行'],
theme: FortuneCardStyle.ancient,
isToday: false,
canRegenerate: false,
regenCount: 0,
imageUrl: '',
createdAt:
now.subtract(const Duration(days: 1)).millisecondsSinceEpoch ~/
1000,
),
FortuneRecord(
date: _formatDate(now.subtract(const Duration(days: 2))),
uid: 'guest',
fortuneLevel: FortuneLevel.ji,
fortuneScore: 75,
signText: '山高水远路漫漫\n行到尽头是坦途\n莫愁前路无知己\n天下谁人不识君',
dimensions: [
const FortuneDimension(
key: 'love',
name: '感情',
iconSvg: 'heart',
level: FortuneLevel.moji,
score: 55,
),
const FortuneDimension(
key: 'career',
name: '事业',
iconSvg: 'briefcase',
level: FortuneLevel.zhongji,
score: 78,
),
const FortuneDimension(
key: 'wealth',
name: '财运',
iconSvg: 'dollar',
level: FortuneLevel.ji,
score: 75,
),
const FortuneDimension(
key: 'health',
name: '健康',
iconSvg: 'pulse',
level: FortuneLevel.xiaoji,
score: 68,
),
const FortuneDimension(
key: 'study',
name: '学业',
iconSvg: 'book',
level: FortuneLevel.zhongji,
score: 76,
),
const FortuneDimension(
key: 'social',
name: '人际',
iconSvg: 'users',
level: FortuneLevel.ji,
score: 80,
),
],
lucky: const FortuneLucky(
number: 5,
color: '翠绿',
direction: '正南',
constellation: '射手',
),
suitable: ['祭祀', '修造'],
unsuitable: ['嫁娶', '入宅'],
theme: FortuneCardStyle.ancient,
isToday: false,
canRegenerate: false,
regenCount: 0,
imageUrl: '',
createdAt:
now.subtract(const Duration(days: 2)).millisecondsSinceEpoch ~/
1000,
),
FortuneRecord(
date: _formatDate(now.subtract(const Duration(days: 3))),
uid: 'guest',
fortuneLevel: FortuneLevel.xiaoji,
fortuneScore: 65,
signText: '月到中天分外明\n守得云开见月明\n但将冷眼观螃蟹\n看你横行到几时',
dimensions: [
const FortuneDimension(
key: 'love',
name: '感情',
iconSvg: 'heart',
level: FortuneLevel.xiaoji,
score: 65,
),
const FortuneDimension(
key: 'career',
name: '事业',
iconSvg: 'briefcase',
level: FortuneLevel.moji,
score: 58,
),
const FortuneDimension(
key: 'wealth',
name: '财运',
iconSvg: 'dollar',
level: FortuneLevel.xiaoji,
score: 62,
),
const FortuneDimension(
key: 'health',
name: '健康',
iconSvg: 'pulse',
level: FortuneLevel.ji,
score: 80,
),
const FortuneDimension(
key: 'study',
name: '学业',
iconSvg: 'book',
level: FortuneLevel.zhongji,
score: 72,
),
const FortuneDimension(
key: 'social',
name: '人际',
iconSvg: 'users',
level: FortuneLevel.moji,
score: 55,
),
],
lucky: const FortuneLucky(
number: 9,
color: '琥珀',
direction: '东北',
constellation: '双子',
),
suitable: ['祈福', '求嗣'],
unsuitable: ['动土', '安葬'],
theme: FortuneCardStyle.ancient,
isToday: false,
canRegenerate: false,
regenCount: 0,
imageUrl: '',
createdAt:
now.subtract(const Duration(days: 3)).millisecondsSinceEpoch ~/
1000,
),
];
}
/// Mock换签 — 基于当前运势重新生成
static FortuneRecord regenerate(FortuneRecord current) {
final levels = FortuneLevel.values.sublist(0, 5);
final newLevel = levels[DateTime.now().millisecond % levels.length];
final newScore = newLevel.baseScore + (DateTime.now().millisecond % 15);
final mockSigns = [
'天行健君子以自强不息\n地势坤君子以厚德载物',
'云开雾散见青天\n否极泰来好运连',
'一叶知秋早为谋\n未雨绸缪福自留',
'千里之行始足下\n万丈高楼平地起',
'春风得意马蹄疾\n一日看尽长安花',
];
return FortuneRecord(
date: current.date,
uid: current.uid,
fortuneLevel: newLevel,
fortuneScore: newScore,
signText: mockSigns[DateTime.now().millisecond % mockSigns.length],
dimensions: current.dimensions.map((d) {
final newDimScore = (d.score + DateTime.now().millisecond % 20 - 10)
.clamp(30, 99);
FortuneLevel dimLevel;
if (newDimScore >= 90)
dimLevel = FortuneLevel.daji;
else if (newDimScore >= 78)
dimLevel = FortuneLevel.zhongji;
else if (newDimScore >= 68)
dimLevel = FortuneLevel.xiaoji;
else if (newDimScore >= 58)
dimLevel = FortuneLevel.ji;
else if (newDimScore >= 48)
dimLevel = FortuneLevel.moji;
else
dimLevel = FortuneLevel.xiong;
return FortuneDimension(
key: d.key,
name: d.name,
iconSvg: d.iconSvg,
level: dimLevel,
score: newDimScore,
);
}).toList(),
lucky: FortuneLucky(
number: 1 + DateTime.now().millisecond % 9,
color: const [
'朱红',
'靛蓝',
'翠绿',
'琥珀',
'紫金',
][DateTime.now().millisecond % 5],
direction: const [
'东南',
'西北',
'正南',
'东北',
'正东',
][DateTime.now().millisecond % 5],
constellation: current.lucky.constellation,
),
suitable: current.suitable,
unsuitable: current.unsuitable,
theme: current.theme,
isToday: true,
canRegenerate: true,
regenCount: current.regenCount + 1,
imageUrl: '',
createdAt: current.createdAt,
);
}
static String _formatDate(DateTime d) =>
'${d.year}-${d.month.toString().padLeft(2, '0')}-${d.day.toString().padLeft(2, '0')}';
}