Initial commit: 91dj android client dev_1.0.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/// 广告类型枚举
|
||||
/// 对应埋点中的 ad_type 字段:icon、banner、feed、player、splash、text
|
||||
enum AdTypeEnum {
|
||||
/// 图标广告
|
||||
icon(label: 'icon'),
|
||||
|
||||
/// 横幅广告
|
||||
banner(label: 'banner'),
|
||||
|
||||
/// 信息流广告
|
||||
feed(label: 'feed'),
|
||||
|
||||
/// 播放器内广告
|
||||
player(label: 'player'),
|
||||
|
||||
/// 开屏广告
|
||||
splash(label: 'splash'),
|
||||
|
||||
/// 文字广告
|
||||
text(label: 'text'),
|
||||
|
||||
;
|
||||
|
||||
/// 上报时使用的字符串值
|
||||
final String label;
|
||||
|
||||
const AdTypeEnum({
|
||||
required this.label,
|
||||
});
|
||||
|
||||
/// 根据字符串解析为枚举,未匹配时返回 null
|
||||
static AdTypeEnum? fromLabel(String? value) {
|
||||
if (value == null || value.isEmpty) return null;
|
||||
for (final e in AdTypeEnum.values) {
|
||||
if (e.label == value) return e;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/// 认证/注册/登录方式枚举
|
||||
/// 对应文档中的 type 字段:phone、deviceid、email、username
|
||||
enum AuthTypeEnum {
|
||||
/// 手机号
|
||||
PHONE(label: 'phone'),
|
||||
|
||||
/// 设备ID
|
||||
DEVICE_ID(label: 'deviceid'),
|
||||
|
||||
/// 邮箱
|
||||
EMAIL(label: 'email'),
|
||||
|
||||
/// 用户名/账号
|
||||
USERNAME(label: 'username'),
|
||||
|
||||
;
|
||||
|
||||
/// 上报时使用的字符串值
|
||||
final String label;
|
||||
|
||||
const AuthTypeEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
enum BannerEventEnum{
|
||||
CLICK(label: 'click'),
|
||||
CLOSE(label: 'close'),
|
||||
SHOW(label: 'show');
|
||||
|
||||
final String label;
|
||||
|
||||
const BannerEventEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/// 点击项目类型。
|
||||
///
|
||||
/// 可直接使用预定义常量,也可传入自定义字符串:
|
||||
/// ```dart
|
||||
/// ClickItemTypeEnum.video // 预定义
|
||||
/// ClickItemTypeEnum('manga', '漫画类') // 自定义
|
||||
/// ```
|
||||
///
|
||||
/// 字段规则(debug 模式下触发 assert):
|
||||
/// - [key]:仅限字母、数字、`_`、`-`
|
||||
/// - [name]:字母、数字、`_`、`-`、中文
|
||||
class ClickItemTypeEnum {
|
||||
final String key;
|
||||
final String name;
|
||||
|
||||
const ClickItemTypeEnum._internal(this.key, this.name);
|
||||
|
||||
/// 自定义类型。[key] 仅限字母/数字/`_`/`-`;[name] 允许中文。
|
||||
factory ClickItemTypeEnum(String key, String name) {
|
||||
assert(
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(key),
|
||||
'ClickItemTypeEnum.key 仅支持字母、数字、_ 和 -,实际传入: "$key"',
|
||||
);
|
||||
assert(
|
||||
RegExp(r'^[\u4e00-\u9fa5A-Za-z0-9_-]+$').hasMatch(name),
|
||||
'ClickItemTypeEnum.name 仅支持字母、数字、_、- 和中文,实际传入: "$name"',
|
||||
);
|
||||
return ClickItemTypeEnum._internal(key, name);
|
||||
}
|
||||
|
||||
static const VIDEO = ClickItemTypeEnum._internal('video', '视频');
|
||||
static const NOVEL = ClickItemTypeEnum._internal('novel', '小说');
|
||||
static const COMIC = ClickItemTypeEnum._internal('comic', '漫画');
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// 金币消耗原因枚举
|
||||
/// 对应文档中的 consume_reason_key 字段:
|
||||
/// - video_unlock(视频解锁)
|
||||
/// - gift_send(礼物赠送)
|
||||
/// - content_purchase(内容购买)
|
||||
enum ConsumeReasonEnum {
|
||||
/// 视频解锁
|
||||
VIDEO_UNLOCK(label: 'video_unlock'),
|
||||
|
||||
/// 礼物赠送
|
||||
GIFT_SEND(label: 'gift_send'),
|
||||
|
||||
/// 内容购买
|
||||
CONTENT_PURCHASE(label: 'content_purchase'),
|
||||
|
||||
;
|
||||
|
||||
/// 上报时使用的字符串值
|
||||
final String label;
|
||||
|
||||
const ConsumeReasonEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/// 货币类型枚举
|
||||
/// 对应文档中的 currency 字段:CNY(人民币), USD(美元)
|
||||
enum CurrencyEnum {
|
||||
/// 人民币
|
||||
CNY(label: 'CNY'),
|
||||
|
||||
/// 美元
|
||||
USD(label: 'USD'),
|
||||
|
||||
;
|
||||
|
||||
/// 上报时使用的字符串值
|
||||
final String label;
|
||||
|
||||
const CurrencyEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
enum DeviceEnum {
|
||||
Android(label: 'Android'),
|
||||
iOS(label: 'iOS'),
|
||||
PC(label: 'PC');
|
||||
|
||||
final String label;
|
||||
|
||||
const DeviceEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/// 订单类型枚举
|
||||
/// 对应文档中的 order_type 字段:coin_purchase(金币购买), vip_subscription(VIP订阅)
|
||||
enum OrderTypeEnum {
|
||||
/// 金币购买
|
||||
COIN_PURCHASE(label: 'coin_purchase'),
|
||||
|
||||
/// VIP 订阅
|
||||
VIP_SUBSCRIPTION(label: 'vip_subscription'),
|
||||
|
||||
;
|
||||
|
||||
/// 上报时使用的字符串值
|
||||
final String label;
|
||||
|
||||
const OrderTypeEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/// 预定义页面路由枚举,提供标准 [key](页面唯一标识)和 [name](展示名称)。
|
||||
///
|
||||
/// **用法示例**
|
||||
///
|
||||
/// ```dart
|
||||
/// // 上报导航事件
|
||||
/// AnalyticsSdk.instance.trackNavigation(
|
||||
/// pageKey: AppPageEnum.video.key,
|
||||
/// pageName: AppPageEnum.video.name,
|
||||
/// );
|
||||
///
|
||||
/// // 配置底部/顶部 Tab
|
||||
/// BottomNavigationBar(...).withAnalytics(tabs: [
|
||||
/// AnalyticsTab(AppPageEnum.home.key, AppPageEnum.home.name),
|
||||
/// AnalyticsTab(AppPageEnum.video.key, AppPageEnum.video.name),
|
||||
/// AnalyticsTab(AppPageEnum.mine.key, AppPageEnum.mine.name),
|
||||
/// ]);
|
||||
///
|
||||
/// // PageView 子页面同步
|
||||
/// AnalyticsSdk.instance.updateCurrentPage(
|
||||
/// pageKey: AppPageEnum.videoList.key,
|
||||
/// pageName: AppPageEnum.videoList.name,
|
||||
/// );
|
||||
/// ```
|
||||
///
|
||||
/// **自定义页面**:直接传入字符串即可,无需扩展枚举:
|
||||
/// ```dart
|
||||
/// AnalyticsSdk.instance.trackNavigation(
|
||||
/// pageKey: 'live_room',
|
||||
/// pageName: '直播间',
|
||||
/// );
|
||||
/// ```
|
||||
enum AppPageEnum {
|
||||
// ── 公共类 ──────────────────────────────────────────────────
|
||||
|
||||
/// 启动页
|
||||
launch('launch', '启动页'),
|
||||
|
||||
/// 引导页(新用户首次打开时展示)
|
||||
guide('guide', '引导页'),
|
||||
|
||||
/// 首页(底部导航第一 Tab 常用值)
|
||||
home('home', '首页'),
|
||||
|
||||
/// 主页
|
||||
mainPage('main_page', '主页'),
|
||||
|
||||
/// 发现页
|
||||
discover('discover', '发现页'),
|
||||
|
||||
/// 搜索页(搜索入口页,含搜索框和热搜)
|
||||
search('search', '搜索页'),
|
||||
|
||||
/// 搜索结果页
|
||||
searchResult('search_result', '搜索结果页'),
|
||||
|
||||
/// 应用中心
|
||||
appCenter('app_center', '应用中心'),
|
||||
|
||||
/// 社区页
|
||||
community('community', '社区页'),
|
||||
|
||||
/// 广场页
|
||||
square('square', '广场页'),
|
||||
|
||||
/// 我的(底部导航"我的"Tab)
|
||||
mine('mine', '我的'),
|
||||
|
||||
/// 个人中心(登录用户的详情页)
|
||||
userCenter('user_center', '个人中心'),
|
||||
|
||||
/// 用户主页(查看他人主页)
|
||||
userHome('user_home', '用户主页'),
|
||||
|
||||
/// 作者主页
|
||||
authorHome('author_home', '作者主页'),
|
||||
|
||||
/// 登录页
|
||||
login('login', '登录页'),
|
||||
|
||||
/// 注册页
|
||||
register('register', '注册页'),
|
||||
|
||||
/// 消息中心
|
||||
messageCenter('message_center', '消息中心'),
|
||||
|
||||
/// 设置页
|
||||
setting('setting', '设置页'),
|
||||
|
||||
/// 充值页
|
||||
recharge('recharge', '充值页'),
|
||||
|
||||
/// 充值记录页
|
||||
rechargeRecord('recharge_record', '充值记录页'),
|
||||
|
||||
/// 我的收藏
|
||||
mineCollect('mine_collect', '我的收藏'),
|
||||
|
||||
/// 我的历史
|
||||
mineHistory('mine_history', '我的历史'),
|
||||
|
||||
/// 会员中心页
|
||||
mineVip('mine_vip', '会员中心页'),
|
||||
|
||||
// ── 视频类 ──────────────────────────────────────────────────
|
||||
|
||||
/// 视频列表页
|
||||
videoList('video_list', '视频列表页'),
|
||||
|
||||
/// 视频分类页
|
||||
videoCategory('video_category', '视频分类页'),
|
||||
|
||||
/// 视频榜单页
|
||||
videoRank('video_rank', '视频榜单页'),
|
||||
|
||||
/// 视频搜索页
|
||||
videoSearch('video_search', '视频搜索页'),
|
||||
|
||||
/// 视频详情页
|
||||
videoDetail('video_detail', '视频详情页'),
|
||||
|
||||
/// 视频播放页
|
||||
videoPlay('video_play', '视频播放页'),
|
||||
|
||||
// ── 小说类 ──────────────────────────────────────────────────
|
||||
|
||||
/// 小说列表页
|
||||
novelList('novel_list', '小说列表页'),
|
||||
|
||||
/// 小说分类页
|
||||
novelCategory('novel_category', '小说分类页'),
|
||||
|
||||
/// 小说榜单页
|
||||
novelRank('novel_rank', '小说榜单页'),
|
||||
|
||||
/// 小说详情页
|
||||
novelDetail('novel_detail', '小说详情页'),
|
||||
|
||||
/// 小说阅读页
|
||||
novelRead('novel_read', '小说阅读页'),
|
||||
|
||||
/// 小说章节页
|
||||
novelChapterList('novel_chapter_list', '小说章节页'),
|
||||
|
||||
// ── 漫画类 ──────────────────────────────────────────────────
|
||||
|
||||
/// 漫画列表页
|
||||
comicList('comic_list', '漫画列表页'),
|
||||
|
||||
/// 漫画分类页
|
||||
comicCategory('comic_category', '漫画分类页'),
|
||||
|
||||
/// 漫画榜单页
|
||||
comicRank('comic_rank', '漫画榜单页'),
|
||||
|
||||
/// 漫画详情页
|
||||
comicDetail('comic_detail', '漫画详情页'),
|
||||
|
||||
/// 漫画阅读页
|
||||
comicRead('comic_read', '漫画阅读页'),
|
||||
|
||||
/// 漫画章节页
|
||||
comicChapterList('comic_chapter_list', '漫画章节页');
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
const AppPageEnum(this.key, this.name);
|
||||
|
||||
/// 页面唯一标识,用于 `page_key` 字段。
|
||||
final String key;
|
||||
|
||||
/// 页面展示名称,用于 `page_name` 字段。
|
||||
final String name;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// 支付方式枚举
|
||||
/// 对应文档中的 pay_type 字段:wechat, alipay, bank_card, apple_pay 等
|
||||
enum PayTypeEnum {
|
||||
/// 微信支付
|
||||
WECHAT(label: 'wechat'),
|
||||
|
||||
/// 支付宝
|
||||
ALIPAY(label: 'alipay'),
|
||||
|
||||
/// 银行卡
|
||||
BANK_CARD(label: 'bank_card'),
|
||||
|
||||
/// Apple Pay
|
||||
APPLE_PAY(label: 'apple_pay'),
|
||||
|
||||
;
|
||||
|
||||
/// 上报时使用的字符串值
|
||||
final String label;
|
||||
|
||||
const PayTypeEnum({
|
||||
required this.label,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/// 阅读行为类型,用于小说和漫画事件。
|
||||
///
|
||||
/// 可使用预定义常量,也可传入自定义字符串:
|
||||
/// ```dart
|
||||
/// ReadBehaviorEnum.view
|
||||
/// ReadBehaviorEnum('custom_key', '自定义行为')
|
||||
/// ```
|
||||
///
|
||||
/// 字段规则(debug 模式下触发 assert):
|
||||
/// - [key]:仅限字母、数字、`_`、`-`
|
||||
/// - [name]:字母、数字、`_`、`-`、中文
|
||||
class ReadBehaviorEnum {
|
||||
final String key;
|
||||
final String name;
|
||||
|
||||
const ReadBehaviorEnum._internal(this.key, this.name);
|
||||
|
||||
/// 自定义行为类型。[key] 仅限字母/数字/`_`/`-`;[name] 允许中文。
|
||||
factory ReadBehaviorEnum(String key, String name) {
|
||||
assert(
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(key),
|
||||
'ReadBehaviorEnum.key 仅支持字母、数字、_ 和 -,实际传入: "$key"',
|
||||
);
|
||||
assert(
|
||||
RegExp(r'^[\u4e00-\u9fa5A-Za-z0-9_-]+$').hasMatch(name),
|
||||
'ReadBehaviorEnum.name 仅支持字母、数字、_、- 和中文,实际传入: "$name"',
|
||||
);
|
||||
return ReadBehaviorEnum._internal(key, name);
|
||||
}
|
||||
|
||||
static const VIEW = ReadBehaviorEnum._internal('view', '展示');
|
||||
static const PAGE_NEXT = ReadBehaviorEnum._internal('page_next', '下一页');
|
||||
static const PAGE_PREV = ReadBehaviorEnum._internal('page_prev', '上一页');
|
||||
static const COMPLETE = ReadBehaviorEnum._internal('complete', '读完');
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// 推荐列表内容类型,用于推荐列表展示/点击事件。
|
||||
///
|
||||
/// 可使用预定义常量,也可传入自定义字符串:
|
||||
/// ```dart
|
||||
/// RecommendContentTypeEnum.video
|
||||
/// RecommendContentTypeEnum('podcast')
|
||||
/// ```
|
||||
///
|
||||
/// 字段规则(debug 模式下触发 assert):
|
||||
/// - [label]:仅限字母、数字、`_`、`-`
|
||||
class RecommendContentTypeEnum {
|
||||
final String label;
|
||||
|
||||
const RecommendContentTypeEnum._internal(this.label);
|
||||
|
||||
/// 自定义内容类型。[label] 仅限字母/数字/`_`/`-`。
|
||||
factory RecommendContentTypeEnum(String label) {
|
||||
assert(
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(label),
|
||||
'RecommendContentTypeEnum.label 仅支持字母、数字、_ 和 -,实际传入: "$label"',
|
||||
);
|
||||
return RecommendContentTypeEnum._internal(label);
|
||||
}
|
||||
|
||||
static const VIDEO = RecommendContentTypeEnum._internal('video');
|
||||
static const NOVEL = RecommendContentTypeEnum._internal('novel');
|
||||
static const COMIC = RecommendContentTypeEnum._internal('comic');
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// 用户类型,用于上报用户身份信息。
|
||||
///
|
||||
/// 可使用预定义常量,也可传入自定义字符串:
|
||||
/// ```dart
|
||||
/// UserTypeEnum.normal
|
||||
/// UserTypeEnum.vip
|
||||
/// UserTypeEnum('svip')
|
||||
/// ```
|
||||
///
|
||||
/// 字段规则(debug 模式下触发 assert):
|
||||
/// - [label]:仅限字母、数字、`_`、`-`
|
||||
class UserTypeEnum {
|
||||
final String label;
|
||||
|
||||
const UserTypeEnum._internal(this.label);
|
||||
|
||||
/// 自定义用户类型。[label] 仅限字母/数字/`_`/`-`。
|
||||
factory UserTypeEnum(String label) {
|
||||
assert(
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(label),
|
||||
'UserTypeEnum.label 仅支持字母、数字、_ 和 -,实际传入: "$label"',
|
||||
);
|
||||
return UserTypeEnum._internal(label);
|
||||
}
|
||||
|
||||
static const normal = UserTypeEnum._internal('normal');
|
||||
static const vip = UserTypeEnum._internal('vip');
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/// 视频内容类型,用于视频事件。
|
||||
///
|
||||
/// 可使用预定义常量,也可传入自定义字符串:
|
||||
/// ```dart
|
||||
/// VideoContentTypeEnum.video
|
||||
/// VideoContentTypeEnum('live')
|
||||
/// ```
|
||||
///
|
||||
/// 字段规则(debug 模式下触发 assert):
|
||||
/// - [label]:仅限字母、数字、`_`、`-`
|
||||
class VideoContentTypeEnum {
|
||||
final String label;
|
||||
|
||||
const VideoContentTypeEnum._internal(this.label);
|
||||
|
||||
/// 自定义内容类型。[label] 仅限字母/数字/`_`/`-`。
|
||||
factory VideoContentTypeEnum(String label) {
|
||||
assert(
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(label),
|
||||
'VideoContentTypeEnum.label 仅支持字母、数字、_ 和 -,实际传入: "$label"',
|
||||
);
|
||||
return VideoContentTypeEnum._internal(label);
|
||||
}
|
||||
|
||||
/// 长视频
|
||||
static const video = VideoContentTypeEnum._internal('video');
|
||||
|
||||
/// 短视频
|
||||
static const shortVideo = VideoContentTypeEnum._internal('short_video');
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/// 视频行为类型,用于视频事件。
|
||||
///
|
||||
/// 可使用预定义常量,也可传入自定义字符串:
|
||||
/// ```dart
|
||||
/// VideoEventEnum.play
|
||||
/// VideoEventEnum('custom_key', '自定义行为')
|
||||
/// ```
|
||||
///
|
||||
/// 字段规则(debug 模式下触发 assert):
|
||||
/// - [key]:仅限字母、数字、`_`、`-`
|
||||
/// - [name]:字母、数字、`_`、`-`、中文
|
||||
class VideoEventEnum {
|
||||
final String key;
|
||||
final String name;
|
||||
|
||||
const VideoEventEnum._internal(this.key, this.name);
|
||||
|
||||
/// 自定义行为类型。[key] 仅限字母/数字/`_`/`-`;[name] 允许中文。
|
||||
factory VideoEventEnum(String key, String name) {
|
||||
assert(
|
||||
RegExp(r'^[A-Za-z0-9_-]+$').hasMatch(key),
|
||||
'VideoEventEnum.key 仅支持字母、数字、_ 和 -,实际传入: "$key"',
|
||||
);
|
||||
assert(
|
||||
RegExp(r'^[\u4e00-\u9fa5A-Za-z0-9_-]+$').hasMatch(name),
|
||||
'VideoEventEnum.name 仅支持字母、数字、_、- 和中文,实际传入: "$name"',
|
||||
);
|
||||
return VideoEventEnum._internal(key, name);
|
||||
}
|
||||
|
||||
static const VIDEO_VIEW = VideoEventEnum._internal('video_view', '视频展示');
|
||||
static const VIDEO_PLAY = VideoEventEnum._internal('video_play', '视频播放');
|
||||
static const VIDEO_PAUSE = VideoEventEnum._internal('video_pause', '暂停');
|
||||
static const VIDEO_SHARE = VideoEventEnum._internal('video_share', '分享');
|
||||
static const VIDEO_COMPLETE = VideoEventEnum._internal('video_complete', '播放完成');
|
||||
static const VIDEO_FORWARD = VideoEventEnum._internal('video_forward', '快进');
|
||||
static const VIDEO_REWIND = VideoEventEnum._internal('video_rewind', '快退');
|
||||
}
|
||||
Reference in New Issue
Block a user