- 清理大量废弃的 barrel 导出文件,移除冗余的中间导出层 - 修复所有相对路径导入错误,统一调整为扁平化模块引用 - 更新多平台 pubspec 版本号与依赖库版本 - 补充后端功能问题管理后台与脚本工具 - 调整部分页面的快捷方式文案适配新功能 - 更新部分翻译覆盖率与API文档
1096 lines
32 KiB
Dart
1096 lines
32 KiB
Dart
/// ============================================================
|
||
/// 闲言APP — Spotlight搜索数据模型
|
||
/// 创建时间: 2026-06-07
|
||
/// 更新时间: 2026-06-08
|
||
/// 作用: 定义Spotlight搜索项数据结构、分类枚举、全局搜索数据源
|
||
/// 上次更新: 扩展搜索内容,添加工具中心全部工具及更多功能/设置项
|
||
/// ============================================================
|
||
|
||
import '../../../../core/router/app_routes.dart';
|
||
|
||
// ============================================================
|
||
// 搜索分类枚举
|
||
// ============================================================
|
||
|
||
/// Spotlight搜索分类
|
||
enum SpotlightCategory {
|
||
page('页面', '📄'),
|
||
feature('功能', '✨'),
|
||
tool('工具', '🔧'),
|
||
setting('设置', '⚙️'),
|
||
content('内容', '📑');
|
||
|
||
const SpotlightCategory(this.label, this.emoji);
|
||
|
||
/// 分类显示名称
|
||
final String label;
|
||
|
||
/// 分类图标 emoji
|
||
final String emoji;
|
||
}
|
||
|
||
// ============================================================
|
||
// 搜索项模型
|
||
// ============================================================
|
||
|
||
/// Spotlight搜索项
|
||
class SpotlightItem {
|
||
const SpotlightItem({
|
||
required this.name,
|
||
required this.category,
|
||
required this.route,
|
||
this.subtitle,
|
||
this.iconEmoji,
|
||
this.pinyin,
|
||
this.pinyinInitial,
|
||
this.keywords,
|
||
});
|
||
|
||
/// 显示名称
|
||
final String name;
|
||
|
||
/// 所属分类
|
||
final SpotlightCategory category;
|
||
|
||
/// 路由路径
|
||
final String route;
|
||
|
||
/// 副标题描述
|
||
final String? subtitle;
|
||
|
||
/// 图标 emoji
|
||
final String? iconEmoji;
|
||
|
||
/// 全拼(用于拼音搜索)
|
||
final String? pinyin;
|
||
|
||
/// 拼音首字母(用于首字母搜索)
|
||
final String? pinyinInitial;
|
||
|
||
/// 额外关键词
|
||
final List<String>? keywords;
|
||
|
||
/// 判断是否匹配搜索关键词(支持模糊匹配)
|
||
bool matches(String query) {
|
||
final q = query.toLowerCase();
|
||
if (name.toLowerCase().contains(q)) return true;
|
||
if (subtitle != null && subtitle!.toLowerCase().contains(q)) return true;
|
||
if (pinyin != null && pinyin!.toLowerCase().contains(q)) return true;
|
||
if (pinyinInitial != null && pinyinInitial!.toLowerCase().contains(q)) {
|
||
return true;
|
||
}
|
||
if (keywords != null) {
|
||
for (final kw in keywords!) {
|
||
if (kw.toLowerCase().contains(q)) return true;
|
||
}
|
||
}
|
||
// 模糊匹配:逐字符匹配(允许间隔)
|
||
if (q.length >= 2) {
|
||
bool fuzzyMatch(String source) {
|
||
int si = 0;
|
||
for (int qi = 0; qi < q.length && si < source.length; si++) {
|
||
if (source[si].toLowerCase() == q[qi]) qi++;
|
||
if (qi == q.length) return true;
|
||
}
|
||
return false;
|
||
}
|
||
if (fuzzyMatch(name)) return true;
|
||
if (pinyin != null && fuzzyMatch(pinyin!)) return true;
|
||
}
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// ============================================================
|
||
// 全局搜索数据源
|
||
// ============================================================
|
||
|
||
/// Spotlight搜索数据源 — 所有可搜索项
|
||
class SpotlightSearchData {
|
||
SpotlightSearchData._();
|
||
|
||
/// 全部搜索项
|
||
static final allItems = <SpotlightItem>[
|
||
// ──────────── 页面 ────────────
|
||
const SpotlightItem(
|
||
name: '首页',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.home,
|
||
iconEmoji: '🏠',
|
||
subtitle: '回到首页',
|
||
pinyin: 'shouye',
|
||
pinyinInitial: 'sy',
|
||
),
|
||
const SpotlightItem(
|
||
name: '发现',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.discover,
|
||
iconEmoji: '🔍',
|
||
subtitle: '发现精彩内容',
|
||
pinyin: 'faxian',
|
||
pinyinInitial: 'fx',
|
||
),
|
||
const SpotlightItem(
|
||
name: '个人中心',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.profile,
|
||
iconEmoji: '👤',
|
||
subtitle: '查看个人资料',
|
||
pinyin: 'gerenzhongxin',
|
||
pinyinInitial: 'grzx',
|
||
),
|
||
const SpotlightItem(
|
||
name: '搜索',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.search,
|
||
iconEmoji: '🔎',
|
||
subtitle: '搜索语录和内容',
|
||
pinyin: 'sousuo',
|
||
pinyinInitial: 'ss',
|
||
),
|
||
const SpotlightItem(
|
||
name: '收藏',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.favorites,
|
||
iconEmoji: '❤️',
|
||
subtitle: '我的收藏列表',
|
||
pinyin: 'shoucang',
|
||
pinyinInitial: 'sc',
|
||
),
|
||
const SpotlightItem(
|
||
name: '历史',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.history,
|
||
iconEmoji: '🕐',
|
||
subtitle: '浏览历史记录',
|
||
pinyin: 'lishi',
|
||
pinyinInitial: 'ls',
|
||
),
|
||
const SpotlightItem(
|
||
name: '用户中心',
|
||
category: SpotlightCategory.page,
|
||
route: AppRoutes.userCenter,
|
||
iconEmoji: '🧑',
|
||
subtitle: '账户与个人信息',
|
||
pinyin: 'yonghuzhongxin',
|
||
pinyinInitial: 'yhzx',
|
||
),
|
||
|
||
// ──────────── 功能 ────────────
|
||
const SpotlightItem(
|
||
name: '每日卡片',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.dailyCard,
|
||
iconEmoji: '🃏',
|
||
subtitle: '今日精选语录卡片',
|
||
pinyin: 'meirikapian',
|
||
pinyinInitial: 'mrkp',
|
||
),
|
||
const SpotlightItem(
|
||
name: '每日运势',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.dailyFortune,
|
||
iconEmoji: '🔮',
|
||
subtitle: '查看今日运势',
|
||
pinyin: 'meiriyunshi',
|
||
pinyinInitial: 'mrys',
|
||
),
|
||
const SpotlightItem(
|
||
name: '签到',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.signin,
|
||
iconEmoji: '✅',
|
||
subtitle: '每日签到领积分',
|
||
pinyin: 'qiandao',
|
||
pinyinInitial: 'qd',
|
||
),
|
||
const SpotlightItem(
|
||
name: '成就',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.achievement,
|
||
iconEmoji: '🏆',
|
||
subtitle: '查看成就徽章',
|
||
pinyin: 'chengjiu',
|
||
pinyinInitial: 'cj',
|
||
),
|
||
const SpotlightItem(
|
||
name: '每日任务',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.dailyTask,
|
||
iconEmoji: '📋',
|
||
subtitle: '完成每日任务',
|
||
pinyin: 'meirirenwu',
|
||
pinyinInitial: 'mrrw',
|
||
),
|
||
const SpotlightItem(
|
||
name: '阅读报告',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.readingReport,
|
||
iconEmoji: '📊',
|
||
subtitle: '阅读数据统计',
|
||
pinyin: 'yuedubaogao',
|
||
pinyinInitial: 'ydbg',
|
||
),
|
||
const SpotlightItem(
|
||
name: '灵感',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.inspiration,
|
||
iconEmoji: '💡',
|
||
subtitle: '随机灵感语录',
|
||
pinyin: 'linggan',
|
||
pinyinInitial: 'lg',
|
||
),
|
||
const SpotlightItem(
|
||
name: '笔记',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.noteList,
|
||
iconEmoji: '📝',
|
||
subtitle: '我的笔记列表',
|
||
pinyin: 'biji',
|
||
pinyinInitial: 'bj',
|
||
),
|
||
const SpotlightItem(
|
||
name: '编辑器',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.editor,
|
||
iconEmoji: '✏️',
|
||
subtitle: '创作语录卡片',
|
||
pinyin: 'bianjiqi',
|
||
pinyinInitial: 'bjq',
|
||
),
|
||
const SpotlightItem(
|
||
name: '进度',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.progress,
|
||
iconEmoji: '📊',
|
||
subtitle: '今日·本周·本月·年度·节日倒计时',
|
||
pinyin: 'jindu',
|
||
pinyinInitial: 'jd',
|
||
keywords: ['进度', '倒计时', '节日'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '足迹',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.footprint,
|
||
iconEmoji: '👣',
|
||
subtitle: '浏览足迹记录',
|
||
pinyin: 'zuji',
|
||
pinyinInitial: 'zj',
|
||
),
|
||
const SpotlightItem(
|
||
name: '稍后阅读',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.readLater,
|
||
iconEmoji: '🔖',
|
||
subtitle: '稍后再读列表',
|
||
pinyin: 'shaohouyuedu',
|
||
pinyinInitial: 'shyd',
|
||
keywords: ['稍后', '待读'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '模板画廊',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.templateGallery,
|
||
iconEmoji: '🖼️',
|
||
subtitle: '卡片模板精选',
|
||
pinyin: 'mobanhualang',
|
||
pinyinInitial: 'mbhl',
|
||
keywords: ['模板', '卡片'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '会员',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.member,
|
||
iconEmoji: '👑',
|
||
subtitle: '会员特权与权益',
|
||
pinyin: 'huiyuan',
|
||
pinyinInitial: 'hy',
|
||
keywords: ['VIP', '会员', '特权'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '排行榜',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.rank,
|
||
iconEmoji: '🏆',
|
||
subtitle: '积分排行榜',
|
||
pinyin: 'paihangbang',
|
||
pinyinInitial: 'phb',
|
||
keywords: ['排名', '排行', '积分'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '徽章墙',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.badgeWall,
|
||
iconEmoji: '🏅',
|
||
subtitle: '成就徽章展示',
|
||
pinyin: 'huizhangqiang',
|
||
pinyinInitial: 'hzq',
|
||
keywords: ['徽章', '勋章'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '我的文章',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.myArticles,
|
||
iconEmoji: '✍️',
|
||
subtitle: '我发布的文章',
|
||
pinyin: 'wodewenzhang',
|
||
pinyinInitial: 'wdwz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '内容纠错',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.correction,
|
||
iconEmoji: '✏️',
|
||
subtitle: '纠错与反馈',
|
||
pinyin: 'neirongjiucuo',
|
||
pinyinInitial: 'nrjc',
|
||
keywords: ['纠错', '反馈', '报错'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '分享历史',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.shareHistory,
|
||
iconEmoji: '📤',
|
||
subtitle: '分享记录查看',
|
||
pinyin: 'fenxianglishi',
|
||
pinyinInitial: 'fxls',
|
||
keywords: ['分享', '历史'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '二维码登录',
|
||
category: SpotlightCategory.feature,
|
||
route: AppRoutes.qrcodeLogin,
|
||
iconEmoji: '📱',
|
||
subtitle: '扫码登录其他设备',
|
||
pinyin: 'erweimadenglu',
|
||
pinyinInitial: 'ewmdl',
|
||
keywords: ['扫码', '登录', '二维码'],
|
||
),
|
||
|
||
// ──────────── 工具 — 基础 ────────────
|
||
const SpotlightItem(
|
||
name: '统计',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.statistics,
|
||
iconEmoji: '📈',
|
||
subtitle: '使用数据统计',
|
||
pinyin: 'tongji',
|
||
pinyinInitial: 'tj',
|
||
),
|
||
const SpotlightItem(
|
||
name: '天气',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.weather,
|
||
iconEmoji: '🌤️',
|
||
subtitle: '查看天气信息',
|
||
pinyin: 'tianqi',
|
||
pinyinInitial: 'tq',
|
||
),
|
||
const SpotlightItem(
|
||
name: '诗词',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.poetry,
|
||
iconEmoji: '📜',
|
||
subtitle: '古诗词欣赏',
|
||
pinyin: 'shici',
|
||
pinyinInitial: 'sc',
|
||
),
|
||
const SpotlightItem(
|
||
name: '番茄钟',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.pomodoro,
|
||
iconEmoji: '🍅',
|
||
subtitle: '专注计时器',
|
||
pinyin: 'fanqiezhong',
|
||
pinyinInitial: 'fqz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '倒计时',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.countdown,
|
||
iconEmoji: '⏳',
|
||
subtitle: '事件倒计时',
|
||
pinyin: 'daojishi',
|
||
pinyinInitial: 'djs',
|
||
),
|
||
const SpotlightItem(
|
||
name: '汇率换算',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.exchangeRate,
|
||
iconEmoji: '💱',
|
||
subtitle: '实时汇率转换',
|
||
pinyin: 'huilvhuansuan',
|
||
pinyinInitial: 'hlhs',
|
||
),
|
||
const SpotlightItem(
|
||
name: '翻译',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.translate,
|
||
iconEmoji: '🌐',
|
||
subtitle: '多语言翻译',
|
||
pinyin: 'fanyi',
|
||
pinyinInitial: 'fy',
|
||
),
|
||
const SpotlightItem(
|
||
name: '健康',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.health,
|
||
iconEmoji: '🏥',
|
||
subtitle: '药品·草药·食物相克',
|
||
pinyin: 'jiankang',
|
||
pinyinInitial: 'jk',
|
||
),
|
||
const SpotlightItem(
|
||
name: '休闲',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.leisure,
|
||
iconEmoji: '🎮',
|
||
subtitle: '休闲小游戏',
|
||
pinyin: 'xiuxian',
|
||
pinyinInitial: 'xx',
|
||
),
|
||
const SpotlightItem(
|
||
name: '经典',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.classics,
|
||
iconEmoji: '📖',
|
||
subtitle: '经典语录集',
|
||
pinyin: 'jingdian',
|
||
pinyinInitial: 'jd',
|
||
),
|
||
const SpotlightItem(
|
||
name: '二维码扫描',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.qrcodeScanner,
|
||
iconEmoji: '📱',
|
||
subtitle: '扫描二维码',
|
||
pinyin: 'erweimasomia',
|
||
pinyinInitial: 'ewmsm',
|
||
),
|
||
const SpotlightItem(
|
||
name: '文件传输',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.fileTransfer,
|
||
iconEmoji: '📁',
|
||
subtitle: '跨设备文件传输',
|
||
pinyin: 'wenjianchuanshu',
|
||
pinyinInitial: 'wjcs',
|
||
),
|
||
const SpotlightItem(
|
||
name: '汉字工具',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.hanziTool,
|
||
iconEmoji: '🔤',
|
||
subtitle: '综合汉字查询工具',
|
||
pinyin: 'hanzigongju',
|
||
pinyinInitial: 'hzgj',
|
||
keywords: ['汉字', '查询'],
|
||
),
|
||
|
||
// ──────────── 工具中心 — 创作 ────────────
|
||
const SpotlightItem(
|
||
name: '中国传统色',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/china_colors',
|
||
iconEmoji: '🎨',
|
||
subtitle: '传统色彩发现',
|
||
pinyin: 'zhongguochuantongse',
|
||
pinyinInitial: 'zgcts',
|
||
keywords: ['颜色', '色彩', '国色'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '网名生成',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/nick',
|
||
iconEmoji: '😎',
|
||
subtitle: '个性网名一键生成',
|
||
pinyin: 'wangmingshengcheng',
|
||
pinyinInitial: 'wmsc',
|
||
keywords: ['昵称', '名字', '起名'],
|
||
),
|
||
|
||
// ──────────── 工具中心 — 汉语 ────────────
|
||
const SpotlightItem(
|
||
name: '汉字查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/hanzi',
|
||
iconEmoji: '🔤',
|
||
subtitle: '查字·笔顺·释义',
|
||
pinyin: 'hanzichaxun',
|
||
pinyinInitial: 'hzcx',
|
||
keywords: ['查字', '笔画', '字典'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '成语词典',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/chengyu',
|
||
iconEmoji: '📚',
|
||
subtitle: '成语释义·典故',
|
||
pinyin: 'chengyucidian',
|
||
pinyinInitial: 'cycd',
|
||
keywords: ['成语', '典故', '四字'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '组词查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/zuci',
|
||
iconEmoji: '🔗',
|
||
subtitle: '汉字组词大全',
|
||
pinyin: 'zucichaxun',
|
||
pinyinInitial: 'zccx',
|
||
keywords: ['组词', '词语'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '词典查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/cidian',
|
||
iconEmoji: '📖',
|
||
subtitle: '词语释义·用法',
|
||
pinyin: 'cidianchaxun',
|
||
pinyinInitial: 'cdcx',
|
||
keywords: ['词典', '释义', '词语'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '近反义词',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/jinyici',
|
||
iconEmoji: '↔️',
|
||
subtitle: '近义词·反义词',
|
||
pinyin: 'jinfanyici',
|
||
pinyinInitial: 'jfyc',
|
||
keywords: ['近义词', '反义词', '同义词'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '句子查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/juzi',
|
||
iconEmoji: '💬',
|
||
subtitle: '关键词搜句子',
|
||
pinyin: 'juzichaxun',
|
||
pinyinInitial: 'jzcx',
|
||
keywords: ['句子', '造句'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '英语单词',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/danci',
|
||
iconEmoji: '🔤',
|
||
subtitle: '英汉词典查询',
|
||
pinyin: 'yingyudanci',
|
||
pinyinInitial: 'yydc',
|
||
keywords: ['英语', '单词', '翻译', 'English'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '英文缩写',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/suoxie',
|
||
iconEmoji: '📝',
|
||
subtitle: '缩写全称查询',
|
||
pinyin: 'yingwensuoxie',
|
||
pinyinInitial: 'ywsx',
|
||
keywords: ['缩写', '全称', 'abbreviation'],
|
||
),
|
||
|
||
// ──────────── 工具中心 — 发现 ────────────
|
||
const SpotlightItem(
|
||
name: 'RSS订阅',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/rss_reader',
|
||
iconEmoji: '📡',
|
||
subtitle: '自定义RSS订阅源',
|
||
pinyin: 'rssdingyue',
|
||
pinyinInitial: 'rssdy',
|
||
keywords: ['RSS', '订阅', '阅读'],
|
||
),
|
||
|
||
// ──────────── 工具中心 — 生活 ────────────
|
||
const SpotlightItem(
|
||
name: '酒方大全',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/jiufang',
|
||
iconEmoji: '🍶',
|
||
subtitle: '药酒偏方查询',
|
||
pinyin: 'jiufangdaquan',
|
||
pinyinInitial: 'jfdq',
|
||
keywords: ['药酒', '偏方', '酒方'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '药品查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/drug',
|
||
iconEmoji: '💊',
|
||
subtitle: '药品适应症查询',
|
||
pinyin: 'yaopinchaxun',
|
||
pinyinInitial: 'ypcx',
|
||
keywords: ['药品', '药物', '药'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '食物相克',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/food',
|
||
iconEmoji: '🍎',
|
||
subtitle: '食物相生相克',
|
||
pinyin: 'shiwuxiangke',
|
||
pinyinInitial: 'swxk',
|
||
keywords: ['食物', '相克', '饮食'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '中药材',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/herbal',
|
||
iconEmoji: '🌿',
|
||
subtitle: '中药材功效查询',
|
||
pinyin: 'zhongyaocai',
|
||
pinyinInitial: 'zyc',
|
||
keywords: ['中药', '草药', '药材'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '民间偏方',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/pianfang',
|
||
iconEmoji: '🧪',
|
||
subtitle: '民间偏方大全',
|
||
pinyin: 'minjianpianfang',
|
||
pinyinInitial: 'mjpf',
|
||
keywords: ['偏方', '秘方'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '药茶大全',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/tisana',
|
||
iconEmoji: '🍵',
|
||
subtitle: '药茶配方查询',
|
||
pinyin: 'yaochadaquan',
|
||
pinyinInitial: 'ycdq',
|
||
keywords: ['药茶', '茶', '配方'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '生活常识',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/changshi',
|
||
iconEmoji: '💡',
|
||
subtitle: '日常小知识',
|
||
pinyin: 'shenghuochangshi',
|
||
pinyinInitial: 'shcs',
|
||
keywords: ['常识', '知识', '小知识'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '周公解梦',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/zgjm',
|
||
iconEmoji: '🌙',
|
||
subtitle: '梦境解析查询',
|
||
pinyin: 'zhougongjiemeng',
|
||
pinyinInitial: 'zgjm',
|
||
keywords: ['解梦', '梦', '周公'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '疾病自查',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/illness',
|
||
iconEmoji: '🩺',
|
||
subtitle: '症状查疾病',
|
||
pinyin: 'jibingzicha',
|
||
pinyinInitial: 'jbzc',
|
||
keywords: ['疾病', '症状', '自查'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '姓氏起源',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/surname',
|
||
iconEmoji: '🏯',
|
||
subtitle: '姓氏文化查询',
|
||
pinyin: 'xingshiqiyuan',
|
||
pinyinInitial: 'xsqy',
|
||
keywords: ['姓氏', '百家姓', '起源'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '节气查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/jieqi',
|
||
iconEmoji: '🌾',
|
||
subtitle: '24节气详情',
|
||
pinyin: 'jieqichaxun',
|
||
pinyinInitial: 'jqcx',
|
||
keywords: ['节气', '二十四节气', '立春'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '国家查询',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/nation',
|
||
iconEmoji: '🌍',
|
||
subtitle: '世界各国信息',
|
||
pinyin: 'guojiachaxun',
|
||
pinyinInitial: 'gjcx',
|
||
keywords: ['国家', '世界', '国旗'],
|
||
),
|
||
|
||
// ──────────── 工具中心 — 工具 ────────────
|
||
const SpotlightItem(
|
||
name: 'OCR识别',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/ocr',
|
||
iconEmoji: '📷',
|
||
subtitle: '图片文字识别',
|
||
pinyin: 'ocrshibie',
|
||
pinyinInitial: 'ocrsb',
|
||
keywords: ['OCR', '识别', '文字识别', '图片'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '内容查重',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.check,
|
||
iconEmoji: '🔍',
|
||
subtitle: '精确·模糊·相似度查重',
|
||
pinyin: 'neirongchachong',
|
||
pinyinInitial: 'nrcc',
|
||
keywords: ['查重', '重复', '相似度'],
|
||
),
|
||
|
||
// ──────────── 工具中心 — 趣味 ────────────
|
||
const SpotlightItem(
|
||
name: '歇后语',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/xiehouyu',
|
||
iconEmoji: '😄',
|
||
subtitle: '歇后语大全',
|
||
pinyin: 'xiehouyu',
|
||
pinyinInitial: 'xhy',
|
||
keywords: ['歇后语', '俏皮话'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '谜语',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/riddle',
|
||
iconEmoji: '🧩',
|
||
subtitle: '趣味谜语猜猜看',
|
||
pinyin: 'miyu',
|
||
pinyinInitial: 'my',
|
||
keywords: ['谜语', '猜谜'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '脑筋急转弯',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/brainteaser',
|
||
iconEmoji: '🤔',
|
||
subtitle: '脑筋急转弯',
|
||
pinyin: 'naojinjizhuanwan',
|
||
pinyinInitial: 'njjzw',
|
||
keywords: ['急转弯', '脑筋', '智力题'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '对联大全',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/couplet',
|
||
iconEmoji: '🏮',
|
||
subtitle: '对联搜索·鉴赏',
|
||
pinyin: 'duiliandaquan',
|
||
pinyinInitial: 'dldq',
|
||
keywords: ['对联', '春联', '对子'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '名人名言',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/wisdom',
|
||
iconEmoji: '🌟',
|
||
subtitle: '名人名言录',
|
||
pinyin: 'mingrenmingyan',
|
||
pinyinInitial: 'mrmy',
|
||
keywords: ['名言', '格言', '名句'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '谚语大全',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/saying',
|
||
iconEmoji: '📝',
|
||
subtitle: '民间谚语集',
|
||
pinyin: 'yanyudaquan',
|
||
pinyinInitial: 'yydq',
|
||
keywords: ['谚语', '俗语', '俗话'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '十万个为什么',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/why',
|
||
iconEmoji: '❓',
|
||
subtitle: '知识百科问答',
|
||
pinyin: 'shiwanweishenme',
|
||
pinyinInitial: 'swsm',
|
||
keywords: ['为什么', '百科', '问答'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '笑话大全',
|
||
category: SpotlightCategory.tool,
|
||
route: '/tool/joke',
|
||
iconEmoji: '😂',
|
||
subtitle: '笑话搜索·开心一刻',
|
||
pinyin: 'xiaohuadaquan',
|
||
pinyinInitial: 'xhdq',
|
||
keywords: ['笑话', '段子', '搞笑'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '文字迷',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.game,
|
||
iconEmoji: '🎮',
|
||
subtitle: '诗词填空·成语接龙·谜语',
|
||
pinyin: 'wenzimi',
|
||
pinyinInitial: 'wzm',
|
||
keywords: ['游戏', '填空', '接龙'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '文章广场',
|
||
category: SpotlightCategory.tool,
|
||
route: AppRoutes.articles,
|
||
iconEmoji: '📝',
|
||
subtitle: '创作分享·阅读交流',
|
||
pinyin: 'wenzhangguangchang',
|
||
pinyinInitial: 'wzgc',
|
||
keywords: ['文章', '广场', '创作'],
|
||
),
|
||
|
||
// ──────────── 设置 ────────────
|
||
const SpotlightItem(
|
||
name: '主题设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.themeSettings,
|
||
iconEmoji: '🎨',
|
||
subtitle: '切换主题风格',
|
||
pinyin: 'zhutishezhi',
|
||
pinyinInitial: 'ztsz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '通用设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.generalSettings,
|
||
iconEmoji: '🔧',
|
||
subtitle: '应用通用设置',
|
||
pinyin: 'tongyongshezhi',
|
||
pinyinInitial: 'tysz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '账户设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.accountSettings,
|
||
iconEmoji: '🔐',
|
||
subtitle: '账户安全设置',
|
||
pinyin: 'zhanghushezhi',
|
||
pinyinInitial: 'zhsz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '数据管理',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.dataManagement,
|
||
iconEmoji: '💾',
|
||
subtitle: '数据备份与恢复',
|
||
pinyin: 'shujuguanli',
|
||
pinyinInitial: 'sjgl',
|
||
),
|
||
const SpotlightItem(
|
||
name: '字体管理',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.fontManagement,
|
||
iconEmoji: '🔤',
|
||
subtitle: '自定义字体',
|
||
pinyin: 'zitiguanli',
|
||
pinyinInitial: 'ztgl',
|
||
),
|
||
const SpotlightItem(
|
||
name: '通知设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.notificationSettings,
|
||
iconEmoji: '🔔',
|
||
subtitle: '推送通知管理',
|
||
pinyin: 'tongzhishezhi',
|
||
pinyinInitial: 'tzsz',
|
||
keywords: ['通知', '推送'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '权限管理',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.permissionManagement,
|
||
iconEmoji: '🛡️',
|
||
subtitle: '应用权限设置',
|
||
pinyin: 'quanquanguanli',
|
||
pinyinInitial: 'qqgl',
|
||
keywords: ['权限', '隐私'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '更多设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.moreSettings,
|
||
iconEmoji: '➕',
|
||
subtitle: '更多设置选项',
|
||
pinyin: 'gengduoshezhi',
|
||
pinyinInitial: 'gdsz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '实验性功能',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.experimentalFeatures,
|
||
iconEmoji: '🧪',
|
||
subtitle: '尝鲜实验功能',
|
||
pinyin: 'shiyanxinggongneng',
|
||
pinyinInitial: 'syxgn',
|
||
),
|
||
const SpotlightItem(
|
||
name: '语言设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.languageSettings,
|
||
iconEmoji: '🌐',
|
||
subtitle: '切换应用语言',
|
||
pinyin: 'yuyanshezhi',
|
||
pinyinInitial: 'yysz',
|
||
keywords: ['语言', '多语言', 'Language'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '桌面小部件',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.widgetManagement,
|
||
iconEmoji: '🧩',
|
||
subtitle: '桌面Widget管理',
|
||
pinyin: 'zhuomianxiaobujian',
|
||
pinyinInitial: 'zmxbj',
|
||
keywords: ['小部件', 'Widget', '桌面'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '句子来源',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.source,
|
||
iconEmoji: '📚',
|
||
subtitle: '语录来源设置',
|
||
pinyin: 'juzilaiyuan',
|
||
pinyinInitial: 'jzly',
|
||
keywords: ['来源', '句子来源'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '密码设置',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.passwordSettings,
|
||
iconEmoji: '🔑',
|
||
subtitle: '修改登录密码',
|
||
pinyin: 'mimashezhi',
|
||
pinyinInitial: 'mmsz',
|
||
keywords: ['密码', '修改密码'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '隐私政策',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.privacyPolicy,
|
||
iconEmoji: '🛡️',
|
||
subtitle: '隐私政策与条款',
|
||
pinyin: 'yinsizhengce',
|
||
pinyinInitial: 'yszc',
|
||
keywords: ['隐私', '政策', '条款'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '离线模式',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.offline,
|
||
iconEmoji: '📴',
|
||
subtitle: '离线内容管理',
|
||
pinyin: 'lixianmoshi',
|
||
pinyinInitial: 'lxms',
|
||
keywords: ['离线', '脱机'],
|
||
),
|
||
const SpotlightItem(
|
||
name: '缓存管理',
|
||
category: SpotlightCategory.setting,
|
||
route: AppRoutes.cacheManagement,
|
||
iconEmoji: '🗑️',
|
||
subtitle: '清理缓存数据',
|
||
pinyin: 'huancunguanli',
|
||
pinyinInitial: 'hcgl',
|
||
keywords: ['缓存', '清理', '存储'],
|
||
),
|
||
|
||
// ──────────── 内容 ────────────
|
||
const SpotlightItem(
|
||
name: '学习中心',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.learning,
|
||
iconEmoji: '📖',
|
||
subtitle: '学习进度与课程',
|
||
pinyin: 'xuexizhongxin',
|
||
pinyinInitial: 'xxzx',
|
||
),
|
||
const SpotlightItem(
|
||
name: '学习进度',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.learningProgress,
|
||
iconEmoji: '📈',
|
||
subtitle: '查看学习进度',
|
||
pinyin: 'xuexijindu',
|
||
pinyinInitial: 'xxjd',
|
||
),
|
||
const SpotlightItem(
|
||
name: '标签云',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.tagCloud,
|
||
iconEmoji: '🏷️',
|
||
subtitle: '内容标签管理',
|
||
pinyin: 'biaoqianyun',
|
||
pinyinInitial: 'bqy',
|
||
),
|
||
const SpotlightItem(
|
||
name: '知识图谱',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.knowledgeGraph,
|
||
iconEmoji: '🧠',
|
||
subtitle: '知识关系图谱',
|
||
pinyin: 'zhishitupu',
|
||
pinyinInitial: 'zstp',
|
||
),
|
||
const SpotlightItem(
|
||
name: '学习计划',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.studyPlan,
|
||
iconEmoji: '📅',
|
||
subtitle: '制定学习计划',
|
||
pinyin: 'xuexijihua',
|
||
pinyinInitial: 'xxjh',
|
||
),
|
||
const SpotlightItem(
|
||
name: '文章',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.articles,
|
||
iconEmoji: '📄',
|
||
subtitle: '精选文章阅读',
|
||
pinyin: 'wenzhang',
|
||
pinyinInitial: 'wz',
|
||
),
|
||
const SpotlightItem(
|
||
name: '关于',
|
||
category: SpotlightCategory.content,
|
||
route: AppRoutes.about,
|
||
iconEmoji: 'ℹ️',
|
||
subtitle: '关于闲言APP',
|
||
pinyin: 'guanyu',
|
||
pinyinInitial: 'gy',
|
||
),
|
||
];
|
||
|
||
/// 按关键词搜索,返回匹配的搜索项列表
|
||
static List<SpotlightItem> search(String query) {
|
||
if (query.isEmpty) return [];
|
||
return allItems.where((item) => item.matches(query)).toList();
|
||
}
|
||
|
||
/// 搜索建议(输入2字即触发)
|
||
static List<SpotlightItem> suggest(String query) {
|
||
if (query.length < 2) return [];
|
||
return search(query);
|
||
}
|
||
|
||
/// 按分类分组
|
||
static Map<SpotlightCategory, List<SpotlightItem>> groupByCategory(
|
||
List<SpotlightItem> items,
|
||
) {
|
||
final grouped = <SpotlightCategory, List<SpotlightItem>>{};
|
||
for (final item in items) {
|
||
grouped.putIfAbsent(item.category, () => []).add(item);
|
||
}
|
||
return grouped;
|
||
}
|
||
}
|