主要变更: 1. 全局修复类型转换问题,将多处`as int?`改为`(num?)?.toInt()`兼容浮点/字符串类型的数字字段 2. 移除废弃的nearby_p2p配对方式和对应的依赖包 3. 优化鸿蒙端快捷方式、引导页、路由导航的稳定性 4. 合并日志输出避免鸿蒙端IDE卡顿 5. 修复安卓端蓝牙权限冗余声明
85 lines
3.3 KiB
Dart
85 lines
3.3 KiB
Dart
/// ============================================================
|
|
/// 闲言APP — 热搜榜数据模型
|
|
/// 创建时间: 2026-04-28
|
|
/// 更新时间: 2026-04-28
|
|
/// 作用: 热搜平台数据模型 + 热搜条目模型
|
|
/// 上次更新: 初始创建
|
|
/// ============================================================
|
|
|
|
class HotPlatform {
|
|
const HotPlatform({
|
|
required this.name,
|
|
required this.type,
|
|
required this.emoji,
|
|
this.items = const [],
|
|
this.status = 'ok',
|
|
});
|
|
|
|
final String name;
|
|
final String type;
|
|
final String emoji;
|
|
final List<HotItem> items;
|
|
final String status;
|
|
|
|
static const platformMap = <String, HotPlatform>{
|
|
'bai_du_hot': HotPlatform(name: '百度', type: 'bai_du_hot', emoji: '🔍'),
|
|
'wei_bo_hot': HotPlatform(name: '微博', type: 'wei_bo_hot', emoji: '📢'),
|
|
'zhi_hu_hot': HotPlatform(name: '知乎', type: 'zhi_hu_hot', emoji: '💡'),
|
|
'dou_yin_hot': HotPlatform(name: '抖音', type: 'dou_yin_hot', emoji: '🎵'),
|
|
'bili_bili_hot': HotPlatform(name: 'B站', type: 'bili_bili_hot', emoji: '📺'),
|
|
'tou_tiao_hot': HotPlatform(name: '头条', type: 'tou_tiao_hot', emoji: '📰'),
|
|
'csdn_hot': HotPlatform(name: 'CSDN', type: 'csdn_hot', emoji: '💻'),
|
|
'jue_jin_hot': HotPlatform(name: '掘金', type: 'jue_jin_hot', emoji: '⛏️'),
|
|
'ke_hot': HotPlatform(name: '稀土', type: 'ke_hot', emoji: '💎'),
|
|
'xue_qiu_hot': HotPlatform(name: '雪球', type: 'xue_qiu_hot', emoji: '📈'),
|
|
'it_hot': HotPlatform(name: 'IT之家', type: 'it_hot', emoji: '🖥️'),
|
|
'peng_pai_hot': HotPlatform(name: '澎湃', type: 'peng_pai_hot', emoji: '🌊'),
|
|
'teng_xun_hot': HotPlatform(name: '腾讯', type: 'teng_xun_hot', emoji: '🐧'),
|
|
'hu_pu_hot': HotPlatform(name: '虎扑', type: 'hu_pu_hot', emoji: '🏀'),
|
|
'tie_ba_hot': HotPlatform(name: '贴吧', type: 'tie_ba_hot', emoji: '💬'),
|
|
'sou_gou_hot': HotPlatform(name: '搜狗', type: 'sou_gou_hot', emoji: '🐕'),
|
|
'sou_sou_hot': HotPlatform(name: '搜搜', type: 'sou_sou_hot', emoji: '🔎'),
|
|
'ac_fun_hot': HotPlatform(name: 'AcFun', type: 'ac_fun_hot', emoji: '🐒'),
|
|
'sm_hot': HotPlatform(name: '什么值得买', type: 'sm_hot', emoji: '🛒'),
|
|
'woshipm_hot': HotPlatform(name: '人人PM', type: 'woshipm_hot', emoji: '📱'),
|
|
'zhong_guo_hot': HotPlatform(name: '中国网', type: 'zhong_guo_hot', emoji: '🇨🇳'),
|
|
};
|
|
|
|
factory HotPlatform.fromApi(String type, Map<String, dynamic> data) {
|
|
final platform = platformMap[type] ??
|
|
HotPlatform(name: type, type: type, emoji: '🔥');
|
|
final list = data['data'] as List<dynamic>? ?? [];
|
|
return HotPlatform(
|
|
name: data['name'] as String? ?? platform.name,
|
|
type: type,
|
|
emoji: platform.emoji,
|
|
status: data['status'] as String? ?? 'ok',
|
|
items: list
|
|
.whereType<Map<String, dynamic>>()
|
|
.map((e) => HotItem.fromApi(e))
|
|
.toList(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class HotItem {
|
|
const HotItem({
|
|
required this.title,
|
|
this.hotNum = '',
|
|
this.url = '',
|
|
this.rank = 0,
|
|
});
|
|
|
|
final String title;
|
|
final String hotNum;
|
|
final String url;
|
|
final int rank;
|
|
|
|
factory HotItem.fromApi(Map<String, dynamic> json) => HotItem(
|
|
title: json['title'] as String? ?? '',
|
|
hotNum: json['num']?.toString() ?? '',
|
|
url: json['url'] as String? ?? '',
|
|
rank: (json['rank'] as num?)?.toInt() ?? 0,
|
|
);
|
|
}
|