chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
This commit is contained in:
121
YuMi/Global/BuglyManager.h
Normal file
121
YuMi/Global/BuglyManager.h
Normal file
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// BuglyManager.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by BuglyManager
|
||||
// Copyright © 2024 YuMi. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class BuglyManager;
|
||||
|
||||
/**
|
||||
* BuglyManager 代理协议
|
||||
* 用于监听卡顿和性能问题
|
||||
*/
|
||||
@protocol BuglyManagerDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
/**
|
||||
* 检测到卡顿时的回调
|
||||
* @param manager BuglyManager 实例
|
||||
* @param duration 卡顿持续时间(秒)
|
||||
*/
|
||||
- (void)buglyManager:(BuglyManager *)manager didDetectLag:(NSTimeInterval)duration;
|
||||
|
||||
/**
|
||||
* 检测到主线程阻塞时的回调
|
||||
* @param manager BuglyManager 实例
|
||||
* @param duration 阻塞持续时间(秒)
|
||||
*/
|
||||
- (void)buglyManager:(BuglyManager *)manager didDetectBlock:(NSTimeInterval)duration;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Bugly 统一管理类
|
||||
* 封装所有 Bugly 相关操作,提供统一的错误上报和性能监控接口
|
||||
*/
|
||||
@interface BuglyManager : NSObject
|
||||
|
||||
/**
|
||||
* 单例访问方法
|
||||
* @return BuglyManager 单例实例
|
||||
*/
|
||||
+ (instancetype)sharedManager;
|
||||
|
||||
/**
|
||||
* 设置代理对象
|
||||
*/
|
||||
@property (nonatomic, assign) id<BuglyManagerDelegate> delegate;
|
||||
|
||||
/**
|
||||
* 配置并启动 Bugly
|
||||
* @param appId Bugly 应用 ID
|
||||
* @param isDebug 是否为调试模式
|
||||
*/
|
||||
- (void)configureWithAppId:(NSString *)appId debug:(BOOL)isDebug;
|
||||
|
||||
/**
|
||||
* 上报错误信息
|
||||
* @param domain 错误域
|
||||
* @param code 错误码
|
||||
* @param userInfo 错误详细信息
|
||||
*/
|
||||
- (void)reportError:(NSString *)domain
|
||||
code:(NSInteger)code
|
||||
userInfo:(NSDictionary *)userInfo;
|
||||
|
||||
/**
|
||||
* 上报业务错误(简化版)
|
||||
* @param message 错误消息
|
||||
* @param code 错误码
|
||||
* @param context 错误上下文信息
|
||||
*/
|
||||
- (void)reportBusinessError:(NSString *)message
|
||||
code:(NSInteger)code
|
||||
context:(NSDictionary *)context;
|
||||
|
||||
/**
|
||||
* 上报网络请求异常
|
||||
* @param uid 用户ID
|
||||
* @param api 接口路径
|
||||
* @param code 错误码
|
||||
* @param userInfo 额外信息
|
||||
*/
|
||||
- (void)reportNetworkError:(NSString *)uid
|
||||
api:(NSString *)api
|
||||
code:(NSInteger)code
|
||||
userInfo:(NSDictionary *)userInfo;
|
||||
|
||||
/**
|
||||
* 上报内购相关错误
|
||||
* @param uid 用户ID
|
||||
* @param transactionId 交易ID
|
||||
* @param orderId 订单ID
|
||||
* @param status 状态码
|
||||
* @param context 上下文信息
|
||||
*/
|
||||
- (void)reportIAPError:(NSString *)uid
|
||||
transactionId:(NSString *)transactionId
|
||||
orderId:(NSString *)orderId
|
||||
status:(NSInteger)status
|
||||
context:(NSDictionary *)context;
|
||||
|
||||
/**
|
||||
* 手动触发卡顿检测
|
||||
*/
|
||||
- (void)startLagDetection;
|
||||
|
||||
/**
|
||||
* 模拟卡顿检测(测试用)
|
||||
* 用于测试按钮,直接增加计数
|
||||
*/
|
||||
- (void)simulateLagDetection;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
406
YuMi/Global/BuglyManager.m
Normal file
406
YuMi/Global/BuglyManager.m
Normal file
@@ -0,0 +1,406 @@
|
||||
//
|
||||
// BuglyManager.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by BuglyManager
|
||||
// Copyright © 2024 YuMi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BuglyManager.h"
|
||||
#import <Bugly/Bugly.h>
|
||||
#import "TurboModeStateManager.h"
|
||||
|
||||
@interface BuglyManager () <BuglyDelegate>
|
||||
|
||||
@property (nonatomic, strong) NSString *appId;
|
||||
@property (nonatomic, assign) BOOL isConfigured;
|
||||
|
||||
// 卡顿计数相关
|
||||
@property (nonatomic, assign) NSInteger lagCount;
|
||||
@property (nonatomic, assign) BOOL isInRoom;
|
||||
@property (nonatomic, assign) BOOL isTurboModeEnabled;
|
||||
|
||||
@end
|
||||
|
||||
@implementation BuglyManager
|
||||
|
||||
#pragma mark - Singleton
|
||||
|
||||
+ (instancetype)sharedManager {
|
||||
static BuglyManager *instance = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
instance = [[BuglyManager alloc] init];
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_isConfigured = NO;
|
||||
_lagCount = 0;
|
||||
_isInRoom = NO;
|
||||
_isTurboModeEnabled = NO;
|
||||
|
||||
// 监听 turbo mode 状态变化
|
||||
[self setupTurboModeNotifications];
|
||||
|
||||
// 🔧 修复:初始化时获取当前 turbo mode 状态
|
||||
[self updateTurboModeState];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - BuglyDelegate
|
||||
- (NSString * BLY_NULLABLE)attachmentForException:(NSException * BLY_NULLABLE)exception {
|
||||
NSString *message = [NSString stringWithFormat:@"%@ - %@", exception.name, exception.reason];
|
||||
[self handleLagDetection:message];
|
||||
return message;
|
||||
}
|
||||
|
||||
#pragma mark - Public Methods
|
||||
|
||||
- (void)configureWithAppId:(NSString *)appId debug:(BOOL)isDebug {
|
||||
if (self.isConfigured) {
|
||||
NSLog(@"[BuglyManager] Bugly 已经配置,跳过重复配置");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!appId || appId.length == 0) {
|
||||
NSLog(@"[BuglyManager] 错误:appId 不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
self.appId = appId;
|
||||
|
||||
// 创建 Bugly 配置
|
||||
BuglyConfig *config = [[BuglyConfig alloc] init];
|
||||
config.delegate = self;
|
||||
|
||||
// 基础配置
|
||||
config.blockMonitorTimeout = 3.0; // 卡顿监控超时时间:3秒
|
||||
config.blockMonitorEnable = YES; // 启用卡顿监控
|
||||
|
||||
// 调试模式配置
|
||||
if (isDebug) {
|
||||
config.debugMode = NO; // 生产环境关闭调试模式
|
||||
config.channel = [self getAppChannel];
|
||||
config.reportLogLevel = BuglyLogLevelWarn; // 设置日志级别
|
||||
} else {
|
||||
config.unexpectedTerminatingDetectionEnable = YES; // 非正常退出事件记录
|
||||
config.debugMode = NO;
|
||||
config.channel = [self getAppChannel];
|
||||
config.blockMonitorEnable = YES;
|
||||
config.reportLogLevel = BuglyLogLevelWarn;
|
||||
}
|
||||
// 启动 Bugly
|
||||
[Bugly startWithAppId:appId config:config];
|
||||
|
||||
self.isConfigured = YES;
|
||||
|
||||
NSLog(@"[BuglyManager] Bugly 配置完成 - AppID: %@, Debug: %@", appId, isDebug ? @"YES" : @"NO");
|
||||
}
|
||||
|
||||
- (void)reportError:(NSString *)domain
|
||||
code:(NSInteger)code
|
||||
userInfo:(NSDictionary *)userInfo {
|
||||
|
||||
if (!self.isConfigured) {
|
||||
NSLog(@"[BuglyManager] 错误:Bugly 未配置,无法上报错误");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!domain || domain.length == 0) {
|
||||
domain = @"UnknownError";
|
||||
}
|
||||
|
||||
// 创建错误对象
|
||||
NSError *error = [NSError errorWithDomain:domain
|
||||
code:code
|
||||
userInfo:userInfo];
|
||||
|
||||
// 异步上报错误
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[Bugly reportError:error];
|
||||
NSLog(@"[BuglyManager] 错误上报成功 - Domain: %@, Code: %ld", domain, (long)code);
|
||||
});
|
||||
}
|
||||
|
||||
- (void)reportBusinessError:(NSString *)message
|
||||
code:(NSInteger)code
|
||||
context:(NSDictionary *)context {
|
||||
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
|
||||
|
||||
// 添加基础信息
|
||||
if (message && message.length > 0) {
|
||||
[userInfo setObject:message forKey:@"error_message"];
|
||||
}
|
||||
[userInfo setObject:@(code) forKey:@"error_code"];
|
||||
[userInfo setObject:@"BusinessError" forKey:@"error_type"];
|
||||
|
||||
// 添加上下文信息
|
||||
if (context && context.count > 0) {
|
||||
[userInfo addEntriesFromDictionary:context];
|
||||
}
|
||||
|
||||
// 添加时间戳
|
||||
[userInfo setObject:@([[NSDate date] timeIntervalSince1970]) forKey:@"timestamp"];
|
||||
|
||||
[self reportError:@"BusinessError" code:code userInfo:userInfo];
|
||||
}
|
||||
|
||||
- (void)reportNetworkError:(NSString *)uid
|
||||
api:(NSString *)api
|
||||
code:(NSInteger)code
|
||||
userInfo:(NSDictionary *)userInfo {
|
||||
|
||||
NSMutableDictionary *errorInfo = [NSMutableDictionary dictionary];
|
||||
|
||||
// 添加网络错误特有信息
|
||||
if (uid && uid.length > 0) {
|
||||
[errorInfo setObject:uid forKey:@"user_id"];
|
||||
}
|
||||
if (api && api.length > 0) {
|
||||
[errorInfo setObject:api forKey:@"api_path"];
|
||||
}
|
||||
[errorInfo setObject:@(code) forKey:@"http_code"];
|
||||
[errorInfo setObject:@"NetworkError" forKey:@"error_type"];
|
||||
|
||||
// 添加调用栈信息
|
||||
[errorInfo setObject:[NSThread callStackSymbols] forKey:@"call_stack_symbols"];
|
||||
|
||||
// 合并额外信息
|
||||
if (userInfo && userInfo.count > 0) {
|
||||
[errorInfo addEntriesFromDictionary:userInfo];
|
||||
}
|
||||
|
||||
[self reportError:@"NetworkError" code:code userInfo:errorInfo];
|
||||
}
|
||||
|
||||
- (void)reportIAPError:(NSString *)uid
|
||||
transactionId:(NSString *)transactionId
|
||||
orderId:(NSString *)orderId
|
||||
status:(NSInteger)status
|
||||
context:(NSDictionary *)context {
|
||||
|
||||
NSMutableDictionary *errorInfo = [NSMutableDictionary dictionary];
|
||||
|
||||
// 添加内购错误特有信息
|
||||
if (uid && uid.length > 0) {
|
||||
[errorInfo setObject:uid forKey:@"user_id"];
|
||||
}
|
||||
if (transactionId && transactionId.length > 0) {
|
||||
[errorInfo setObject:transactionId forKey:@"transaction_id"];
|
||||
}
|
||||
if (orderId && orderId.length > 0) {
|
||||
[errorInfo setObject:orderId forKey:@"order_id"];
|
||||
}
|
||||
[errorInfo setObject:@(status) forKey:@"status_code"];
|
||||
[errorInfo setObject:@"IAPError" forKey:@"error_type"];
|
||||
|
||||
// 添加状态描述
|
||||
NSString *statusMsg = [self getIAPStatusMessage:status];
|
||||
if (statusMsg) {
|
||||
[errorInfo setObject:statusMsg forKey:@"status_message"];
|
||||
}
|
||||
|
||||
// 合并上下文信息
|
||||
if (context && context.count > 0) {
|
||||
[errorInfo addEntriesFromDictionary:context];
|
||||
}
|
||||
|
||||
// 生成错误码
|
||||
NSInteger errorCode = -20000 + status;
|
||||
|
||||
[self reportError:@"IAPError" code:errorCode userInfo:errorInfo];
|
||||
}
|
||||
|
||||
- (void)startLagDetection {
|
||||
if (!self.isConfigured) {
|
||||
NSLog(@"[BuglyManager] 错误:Bugly 未配置,无法启动卡顿检测");
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[BuglyManager] 手动启动卡顿检测");
|
||||
// Bugly 会自动进行卡顿检测,这里主要是日志记录
|
||||
}
|
||||
|
||||
#pragma mark - 测试方法
|
||||
|
||||
- (void)simulateLagDetection {
|
||||
NSLog(@"[BuglyManager] 🧪 模拟卡顿检测(测试按钮触发)");
|
||||
|
||||
// 模拟卡顿检测,触发计数逻辑
|
||||
[self handleLagCountWithDuration:3.0 stackTrace:@"模拟卡顿 - 测试按钮触发"];
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods
|
||||
|
||||
- (void)handleLagDetection:(NSString *)stackTrace {
|
||||
NSLog(@"[BuglyManager] 🚨 检测到卡顿 - StackTrace: %@", stackTrace);
|
||||
|
||||
// 计算卡顿持续时间(这里假设为3秒,实际应该从 Bugly 配置中获取)
|
||||
NSTimeInterval duration = 3.0;
|
||||
|
||||
// 通知代理
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(buglyManager:didDetectLag:)]) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[(id<BuglyManagerDelegate>)self.delegate buglyManager:self didDetectLag:duration];
|
||||
});
|
||||
}
|
||||
|
||||
// 🔧 新增:卡顿计数逻辑
|
||||
[self handleLagCountWithDuration:duration stackTrace:stackTrace];
|
||||
}
|
||||
|
||||
#pragma mark - 卡顿计数逻辑
|
||||
|
||||
- (void)handleLagCountWithDuration:(NSTimeInterval)duration stackTrace:(NSString *)stackTrace {
|
||||
// 规则2:当 turbo mode 开启时,不计数
|
||||
if (self.isTurboModeEnabled) {
|
||||
NSLog(@"[BuglyManager] 🎮 Turbo Mode 已开启,跳过卡顿计数");
|
||||
return;
|
||||
}
|
||||
|
||||
// 规则1:只有在房间内才计数
|
||||
if (!self.isInRoom) {
|
||||
NSLog(@"[BuglyManager] 🏠 不在房间内,跳过卡顿计数");
|
||||
return;
|
||||
}
|
||||
|
||||
// 增加计数
|
||||
self.lagCount++;
|
||||
NSLog(@"[BuglyManager] 📊 卡顿计数: %ld/3", (long)self.lagCount);
|
||||
|
||||
// 检查是否达到3次
|
||||
if (self.lagCount >= 3) {
|
||||
NSLog(@"[BuglyManager] 🚨 累计卡顿3次,触发 Turbo Mode Tips");
|
||||
|
||||
// 发送通知给 Tips Manager
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"BuglyManagerDidDetectLag"
|
||||
object:nil
|
||||
userInfo:@{@"duration": @(duration),
|
||||
@"stackTrace": stackTrace ?: @"",
|
||||
@"lagCount": @(self.lagCount),
|
||||
@"shouldShowTips": @YES}];
|
||||
});
|
||||
|
||||
// 重置计数
|
||||
self.lagCount = 0;
|
||||
} else {
|
||||
// 未达到3次,只发送计数通知
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"BuglyManagerDidDetectLag"
|
||||
object:nil
|
||||
userInfo:@{@"duration": @(duration),
|
||||
@"stackTrace": stackTrace ?: @"",
|
||||
@"lagCount": @(self.lagCount),
|
||||
@"shouldShowTips": @NO}];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setupTurboModeNotifications {
|
||||
// 监听 turbo mode 状态变化
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(turboModeStateChanged:)
|
||||
name:@"TurboModeStateChanged"
|
||||
object:nil];
|
||||
|
||||
// 监听房间进入/退出
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(roomDidEnter:)
|
||||
name:@"RoomDidEnter"
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(roomDidExit:)
|
||||
name:@"RoomDidExit"
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)turboModeStateChanged:(NSNotification *)notification {
|
||||
NSNumber *enabled = notification.userInfo[@"enabled"];
|
||||
if (enabled) {
|
||||
self.isTurboModeEnabled = [enabled boolValue];
|
||||
NSLog(@"[BuglyManager] 🎮 Turbo Mode 状态变化: %@", enabled.boolValue ? @"开启" : @"关闭");
|
||||
|
||||
// 规则2:当 turbo mode 开启时,计数复位为0
|
||||
if (enabled.boolValue) {
|
||||
self.lagCount = 0;
|
||||
NSLog(@"[BuglyManager] 🔄 Turbo Mode 开启,卡顿计数复位为0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)roomDidEnter:(NSNotification *)notification {
|
||||
self.isInRoom = YES;
|
||||
|
||||
// 🔧 修复:进入房间时主动获取当前 turbo mode 状态
|
||||
[self updateTurboModeState];
|
||||
|
||||
NSLog(@"[BuglyManager] 🏠 用户进入房间,开始卡顿监控 - Turbo Mode: %@",
|
||||
self.isTurboModeEnabled ? @"开启" : @"关闭");
|
||||
}
|
||||
|
||||
- (void)roomDidExit:(NSNotification *)notification {
|
||||
self.isInRoom = NO;
|
||||
// 规则3:当用户退出房间时,计数复位为0
|
||||
self.lagCount = 0;
|
||||
NSLog(@"[BuglyManager] 🚪 用户退出房间,卡顿计数复位为0");
|
||||
}
|
||||
|
||||
#pragma mark - 状态更新方法
|
||||
|
||||
- (void)updateTurboModeState {
|
||||
// 从 TurboModeStateManager 获取当前状态
|
||||
BOOL currentTurboModeState = [[TurboModeStateManager sharedManager] isTurboModeEnabled];
|
||||
|
||||
if (self.isTurboModeEnabled != currentTurboModeState) {
|
||||
self.isTurboModeEnabled = currentTurboModeState;
|
||||
NSLog(@"[BuglyManager] 🔄 主动更新 Turbo Mode 状态: %@",
|
||||
currentTurboModeState ? @"开启" : @"关闭");
|
||||
|
||||
// 如果 turbo mode 开启,计数复位为0
|
||||
if (currentTurboModeState) {
|
||||
self.lagCount = 0;
|
||||
NSLog(@"[BuglyManager] 🔄 Turbo Mode 开启,卡顿计数复位为0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)getAppChannel {
|
||||
// 这里应该调用项目中的工具方法获取渠道信息
|
||||
// 暂时返回默认值
|
||||
return @"AppStore";
|
||||
}
|
||||
|
||||
#pragma mark - Dealloc
|
||||
|
||||
- (void)dealloc {
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (NSString *)getIAPStatusMessage:(NSInteger)status {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return @"尝试验单";
|
||||
case 1:
|
||||
return @"验单-补单成功";
|
||||
case 2:
|
||||
return @"验单-补单失败";
|
||||
case 3:
|
||||
return @"验单-补单 id 异常";
|
||||
case 4:
|
||||
return @"重试次数过多";
|
||||
case 5:
|
||||
return @"过期交易清理";
|
||||
default:
|
||||
return @"未知状态";
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
42
YuMi/Global/BuglyManagerExample.h
Normal file
42
YuMi/Global/BuglyManagerExample.h
Normal file
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// BuglyManagerExample.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by BuglyManager Example
|
||||
// Copyright © 2024 YuMi. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BuglyManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* BuglyManager 使用示例类
|
||||
* 展示如何使用 BuglyManager 的各种功能
|
||||
*/
|
||||
@interface BuglyManagerExample : NSObject <BuglyManagerDelegate>
|
||||
|
||||
/**
|
||||
* 设置 Bugly 代理
|
||||
*/
|
||||
- (void)setupBuglyDelegate;
|
||||
|
||||
/**
|
||||
* 上报业务错误示例
|
||||
*/
|
||||
- (void)reportBusinessErrorExample;
|
||||
|
||||
/**
|
||||
* 上报网络错误示例
|
||||
*/
|
||||
- (void)reportNetworkErrorExample;
|
||||
|
||||
/**
|
||||
* 上报内购错误示例
|
||||
*/
|
||||
- (void)reportIAPErrorExample;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
79
YuMi/Global/BuglyManagerExample.m
Normal file
79
YuMi/Global/BuglyManagerExample.m
Normal file
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// BuglyManagerExample.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by BuglyManager Example
|
||||
// Copyright © 2024 YuMi. All rights reserved.
|
||||
//
|
||||
|
||||
#import "BuglyManagerExample.h"
|
||||
#import "BuglyManager.h"
|
||||
|
||||
@implementation BuglyManagerExample
|
||||
|
||||
#pragma mark - 使用示例
|
||||
|
||||
// 示例1:设置代理监听卡顿
|
||||
- (void)setupBuglyDelegate {
|
||||
[BuglyManager sharedManager].delegate = self;
|
||||
}
|
||||
|
||||
// 示例2:上报业务错误
|
||||
- (void)reportBusinessErrorExample {
|
||||
NSDictionary *context = @{
|
||||
@"page": @"HomePage",
|
||||
@"action": @"loadData",
|
||||
@"timestamp": @([[NSDate date] timeIntervalSince1970])
|
||||
};
|
||||
|
||||
[[BuglyManager sharedManager] reportBusinessError:@"数据加载失败"
|
||||
code:1001
|
||||
context:context];
|
||||
}
|
||||
|
||||
// 示例3:上报网络错误
|
||||
- (void)reportNetworkErrorExample {
|
||||
NSDictionary *userInfo = @{
|
||||
@"requestParams": @{@"userId": @"12345"},
|
||||
@"responseData": @"服务器错误"
|
||||
};
|
||||
|
||||
[[BuglyManager sharedManager] reportNetworkError:@"user123"
|
||||
api:@"user/profile"
|
||||
code:500
|
||||
userInfo:userInfo];
|
||||
}
|
||||
|
||||
// 示例4:上报内购错误
|
||||
- (void)reportIAPErrorExample {
|
||||
NSDictionary *context = @{
|
||||
@"retryCount": @3,
|
||||
@"productId": @"com.yumi.coin100"
|
||||
};
|
||||
|
||||
[[BuglyManager sharedManager] reportIAPError:@"user123"
|
||||
transactionId:@"txn_123456"
|
||||
orderId:@"order_789"
|
||||
status:2
|
||||
context:context];
|
||||
}
|
||||
|
||||
#pragma mark - BuglyManagerDelegate
|
||||
|
||||
- (void)buglyManager:(BuglyManager *)manager didDetectLag:(NSTimeInterval)duration {
|
||||
NSLog(@"[Example] 检测到卡顿,持续时间: %.2f 秒", duration);
|
||||
|
||||
// TODO: 在这里实现卡顿通知逻辑
|
||||
// 1. 记录到本地日志
|
||||
// 2. 发送本地通知
|
||||
// 3. 上报到性能监控系统
|
||||
// 4. 触发用户反馈机制
|
||||
}
|
||||
|
||||
- (void)buglyManager:(BuglyManager *)manager didDetectBlock:(NSTimeInterval)duration {
|
||||
NSLog(@"[Example] 检测到主线程阻塞,持续时间: %.2f 秒", duration);
|
||||
|
||||
// TODO: 在这里实现阻塞通知逻辑
|
||||
}
|
||||
|
||||
@end
|
129
YuMi/Global/BuglyManager_README.md
Normal file
129
YuMi/Global/BuglyManager_README.md
Normal file
@@ -0,0 +1,129 @@
|
||||
# BuglyManager 使用说明
|
||||
|
||||
## 概述
|
||||
|
||||
`BuglyManager` 是一个统一的 Bugly 管理类,封装了所有 Bugly 相关操作,提供统一的错误上报和性能监控接口。
|
||||
|
||||
## 主要功能
|
||||
|
||||
### 1. 统一错误上报
|
||||
- 业务错误上报
|
||||
- 网络错误上报
|
||||
- 内购错误上报
|
||||
- 自定义错误上报
|
||||
|
||||
### 2. 卡顿监听
|
||||
- 自动检测主线程卡顿
|
||||
- 支持代理回调通知
|
||||
- 可配置卡顿阈值
|
||||
|
||||
### 3. 性能监控
|
||||
- 主线程阻塞检测
|
||||
- 异常退出检测
|
||||
- 自定义日志级别
|
||||
|
||||
## 使用方法
|
||||
|
||||
### 1. 初始化配置
|
||||
|
||||
```objc
|
||||
// 在 AppDelegate 中配置
|
||||
#ifdef DEBUG
|
||||
[[BuglyManager sharedManager] configureWithAppId:@"c937fd00f7" debug:YES];
|
||||
#else
|
||||
[[BuglyManager sharedManager] configureWithAppId:@"8627948559" debug:NO];
|
||||
#endif
|
||||
```
|
||||
|
||||
### 2. 设置代理监听卡顿
|
||||
|
||||
```objc
|
||||
// 在需要监听卡顿的类中
|
||||
@interface YourClass : NSObject <BuglyManagerDelegate>
|
||||
@end
|
||||
|
||||
@implementation YourClass
|
||||
- (void)setupBuglyDelegate {
|
||||
[BuglyManager sharedManager].delegate = self;
|
||||
}
|
||||
|
||||
- (void)buglyManager:(BuglyManager *)manager didDetectLag:(NSTimeInterval)duration {
|
||||
NSLog(@"检测到卡顿,持续时间: %.2f 秒", duration);
|
||||
// TODO: 实现卡顿通知逻辑
|
||||
}
|
||||
@end
|
||||
```
|
||||
|
||||
### 3. 错误上报
|
||||
|
||||
#### 业务错误上报
|
||||
```objc
|
||||
NSDictionary *context = @{
|
||||
@"page": @"HomePage",
|
||||
@"action": @"loadData"
|
||||
};
|
||||
|
||||
[[BuglyManager sharedManager] reportBusinessError:@"数据加载失败"
|
||||
code:1001
|
||||
context:context];
|
||||
```
|
||||
|
||||
#### 网络错误上报
|
||||
```objc
|
||||
NSDictionary *userInfo = @{
|
||||
@"requestParams": @{@"userId": @"12345"},
|
||||
@"responseData": @"服务器错误"
|
||||
};
|
||||
|
||||
[[BuglyManager sharedManager] reportNetworkError:@"user123"
|
||||
api:@"user/profile"
|
||||
code:500
|
||||
userInfo:userInfo];
|
||||
```
|
||||
|
||||
#### 内购错误上报
|
||||
```objc
|
||||
NSDictionary *context = @{
|
||||
@"retryCount": @3,
|
||||
@"productId": @"com.yumi.coin100"
|
||||
};
|
||||
|
||||
[[BuglyManager sharedManager] reportIAPError:@"user123"
|
||||
transactionId:@"txn_123456"
|
||||
orderId:@"order_789"
|
||||
status:2
|
||||
context:context];
|
||||
```
|
||||
|
||||
## 重构完成情况
|
||||
|
||||
### ✅ 已完成
|
||||
1. 创建 `BuglyManager.h` 和 `BuglyManager.m`
|
||||
2. 修改 `AppDelegate+ThirdConfig.m` 使用 BuglyManager
|
||||
3. 修改 `IAPManager.m` 使用 BuglyManager
|
||||
4. 修改 `HttpRequestHelper.m` 使用 BuglyManager
|
||||
5. 修改 `GiftComboManager.m` 使用 BuglyManager
|
||||
6. 创建使用示例和文档
|
||||
|
||||
### 🔄 进行中
|
||||
1. 修改 `XPGiftPresenter.m` 使用 BuglyManager
|
||||
|
||||
### 📋 待完成
|
||||
1. 测试验证所有功能
|
||||
2. 完善卡顿通知逻辑
|
||||
3. 性能优化
|
||||
|
||||
## 优势
|
||||
|
||||
1. **统一管理**:所有 Bugly 相关操作集中在一个类中
|
||||
2. **降低耦合**:其他模块无需直接引入 Bugly 头文件
|
||||
3. **易于维护**:统一的接口和错误处理逻辑
|
||||
4. **功能扩展**:支持卡顿监听和自定义通知
|
||||
5. **向后兼容**:保持现有功能完全不变
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. 确保在真机环境下编译,模拟器可能无法正确导入 Bugly 头文件
|
||||
2. 卡顿监听功能需要在实际设备上测试
|
||||
3. 错误上报是异步操作,不会阻塞主线程
|
||||
4. 建议在 AppDelegate 中尽早初始化 BuglyManager
|
47
YuMi/Global/YUMIConstant.h
Normal file
47
YuMi/Global/YUMIConstant.h
Normal file
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// YMConstant.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/13.
|
||||
//
|
||||
///一些项目中所用到的key
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface YUMIConstant : NSObject
|
||||
|
||||
UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
UIKIT_EXTERN NSString * const kVisitorUnReadCountNotificationKey;
|
||||
UIKIT_EXTERN NSString * const kHadShowNewUserGiftKey;
|
||||
UIKIT_EXTERN NSString * const kRedPacketHistory;
|
||||
UIKIT_EXTERN NSString * const kTuWenMessageHistory;///图文消息已读记录
|
||||
UIKIT_EXTERN NSString * const kRoomQuickMessageCloseCount;
|
||||
UIKIT_EXTERN NSString * const kLoginMethod;
|
||||
UIKIT_EXTERN NSString * const kMessageFromPublicRoomWithAttachmentNotification;
|
||||
UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
typedef NS_ENUM(NSUInteger, Pi_KeyType) {
|
||||
KeyType_PasswordEncode,///密码 des 加密的
|
||||
KeyType_TRTC,///TRTC key
|
||||
KeyType_NetEase,///云信的key
|
||||
keyType_YiDunBussinessId,///易盾的id
|
||||
keyType_YiDunPhotoBussinessId,///易盾图片的id
|
||||
KeyType_FacePwdEncode, ///表情包解密key
|
||||
KeyType_SudGameAppID,///小游戏APPID
|
||||
KeyType_SudGameAppKey,///小游戏APPKey
|
||||
///家族公会key
|
||||
KeyType_GuildUidKey,
|
||||
///系统通知
|
||||
KeyType_SystemNotifiUidKey,
|
||||
///小秘书
|
||||
KeyType_SecretaryUidKey,
|
||||
///参数加密
|
||||
KeyType_Sign,
|
||||
};
|
||||
|
||||
/// 获取当前项目中所用到的 type 所对应的 value 的值 type 类型
|
||||
NSString * const KeyWithType(Pi_KeyType type);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
109
YuMi/Global/YUMIConstant.m
Normal file
109
YuMi/Global/YUMIConstant.m
Normal file
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// YMConstant.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/13.
|
||||
//
|
||||
|
||||
#import "YUMIConstant.h"
|
||||
#import "AESUtils.h"
|
||||
@implementation YUMIConstant
|
||||
/// AES miyao 14257fewedfgh 偏移 abcedgf
|
||||
NSString * const kRoomMiniNotificationKey = @"ESkVolktPxd1sZsH4yccGD5S49crhLjAGMVnH3TeQjw=";
|
||||
NSString * const kRoomGiftEffectUpdateNotificationKey = @"vNba94B4Zlh56Eb1VTbkLO1dVTROgaL5uVHAkQz9A92JkuP/lD+63ZgfhDId93Sm";
|
||||
NSString * const kHomeMoreScrollPageKey = @"gf6PRnJmby4FIMvi75ZSRqCO4udLaWxSUj6b26l7HOE=";
|
||||
NSString * const kVisitorUnReadCountNotificationKey = @"gebsDgmM0iXmwnTEcqgP9EIC8aLUT0lK4t05kHYQADjBhVJmLIafi90V/wXgWPM7";
|
||||
NSString * const kRoomBackMusicCaptureVolumeKey = @"9N5Ei+Ch6nkmH1LzZET4ZjYSzXKFbavt+6lU+45eQa8=";///房间背景音乐 人声大小的key
|
||||
NSString * const kRoomBackMusicAudioMixingVolumeKey = @"JuJZKfNgZQ7s25PjQcGG97za686ecXI1lylS9PSLrayNeY2l1me4NyyYUXHGaJP0";///房间背景音乐 背景音乐的大小
|
||||
NSString * const kRoomBackMusicPlayMusicOrderKey = @"xjtpOpnLgX00F9HgwT1FISMQPkxXj5cpE2vYc2acOR0=";///房间背景音乐 播放顺序 单曲 顺序 1 0
|
||||
NSString * const kRoomBackMusicPlayMusicFinishKey = @"xjtpOpnLgX00F9HgwT1FIf5yt3rZb+KP9BT0F9AgD7I8M+2JTSYq+jDIEx1e6qdC";///房间背景音乐 播放完毕的key
|
||||
NSString * const kHadShowNewUserGiftKey = @"OHIPXsTBvyt1zwNqr4f6YJkIycUshwhKIpC5Pm2nVVU=";//新用户房间礼物
|
||||
NSString * const kNewUserRechargeKey = @"fmslcb104aFPWxdSGkMg6lmyehgB3uCu9V/FqzVpL+8=";//新用户充值优惠 不同于房间内首充
|
||||
NSString * const kFromSearchToHomeViewKey = @"pr5yHog50uSsZLKj2nA6Ono3Mq/bLTDyngBNDVRkhgg=";//用户第一次从搜索页返回首页
|
||||
NSString * const kTabShowAnchorCardKey = @"MIO0LwD8MCBISnBOps47VF1waAwY+/XFOm2C3luic/k="; //tab展示主播卡片
|
||||
NSString * const kRedPacketHistory = @"nwKkblakw5CH37vvs9YcSjHhVHcOoeZMmE09gg7Ymhk";
|
||||
NSString * const kTuWenMessageHistory = @"AMRtf6yOWYapbYqqOBK+m5IUPsFN5hfbOpPkrYvOr1E=";//图文消息已读记录
|
||||
NSString * const kRoomQuickMessageCloseCount = @"bUi7KnisS+mmUMj45e9s4VycnvRvBViGvd/ouRS4SHo=";//房间快捷发言关闭次数
|
||||
NSString * const kShieldingNotification = @"a1NoaWVsZGluZ05vdGlmaWNhdGlvbg==";///屏蔽房间
|
||||
NSString * const kRoomKickoutTime = @"a1Jvb21LaWNrb3V0VGltZQ==";///被踢时间
|
||||
|
||||
///每日转赠钻石总额限制
|
||||
NSString * const kGiveDiamondDailyNum = @"a0dpdmVEaWFtb25kRGFpbHlOdW0=";
|
||||
|
||||
///邀请成员成功
|
||||
NSString * const kInviteMemeberSuccess = @"a0ludml0ZU1lbWViZXJTdWNjZXNz";
|
||||
NSString * const kUserFirstRegisterKey = @"kUserFirstRegisterKey";
|
||||
///登录方式
|
||||
NSString * const kLoginMethod = @"a0xvZ2luTWV0aG9k";
|
||||
NSString * const kRequestTicket = @"a1JlcXVlc3RSaWNrZXQ=";
|
||||
NSString * const kUpdateSoundInfo = @"kUpdateSoundInfo";
|
||||
NSString * const kMineInfoDelTag = @"kMineInfoDelTag";
|
||||
NSString * const kOpenRoomNotification = @"kOpenRoomNotification";///进房
|
||||
NSString * const kRoomRoomLittleGameMiniStageNotificationKey = @"kRoomRoomLittleGameMiniStageNotificationKey";///小游戏最小化坑位的通知的健
|
||||
|
||||
|
||||
NSString * const kFreeGiftCountdownNotification = @"kFreeGiftCountdownNotification";///免费礼物倒计时
|
||||
NSString * const kMessageFromPublicRoomWithAttachmentNotification = @"MessageFromPublicRoomWithAttachmentNotification";///公共房间消息转发通知
|
||||
|
||||
///在里面进行判断当前环境是什么
|
||||
NSString * const KeyWithType(Pi_KeyType type) {
|
||||
BOOL isRelase = YES;
|
||||
#ifdef DEBUG
|
||||
NSString *isProduction = [[NSUserDefaults standardUserDefaults]valueForKey:@"kIsProductionEnvironment"];
|
||||
if([isProduction isEqualToString:@"YES"]){
|
||||
isRelase = YES;
|
||||
}else{
|
||||
isRelase = NO;
|
||||
}
|
||||
#else
|
||||
isRelase = YES;
|
||||
#endif
|
||||
///测试环境
|
||||
if(isRelase == NO){
|
||||
|
||||
NSDictionary * dic = @{
|
||||
@(KeyType_PasswordEncode) : @"1ea53d260ecf11e7b56e00163e046a26",
|
||||
@(KeyType_TRTC) : @"1400741885",
|
||||
@(KeyType_NetEase) : @"79bc37000f4018a2a24ea9dc6ca08d32",
|
||||
// @(keyType_YiDunBussinessId) : @"3611b99d0457202a7f69151288183236",
|
||||
// @(keyType_YiDunPhotoBussinessId) : @"",
|
||||
@(KeyType_FacePwdEncode) : @"1ea53d260ecf11e7b56e00163e046a26",
|
||||
@(KeyType_SudGameAppID) : @"1578948593831571457",
|
||||
@(KeyType_SudGameAppKey) : @"J9lHOXvFWkAZiTfl4SK7IGt0wDnW3fWd",
|
||||
@(KeyType_GuildUidKey) : @"938284",
|
||||
@(KeyType_SystemNotifiUidKey) : @"938283",
|
||||
@(KeyType_SecretaryUidKey) : @"938282",
|
||||
@(KeyType_Sign) : @"rpbs6us1m8r2j9g6u06ff2bo18orwaya"
|
||||
};
|
||||
NSString * value = [dic objectForKey:@(type)];
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
NSDictionary *newDic = @{
|
||||
@(KeyType_SudGameAppID) : @"1578948593831571457",///小游戏
|
||||
@(KeyType_SudGameAppKey) : @"J9lHOXvFWkAZiTfl4SK7IGt0wDnW3fWd",///小游戏
|
||||
// @(keyType_YiDunBussinessId) : @"f459972b432106844b89fd58c92b8061",
|
||||
// @(keyType_YiDunPhotoBussinessId) : @"",
|
||||
@(KeyType_TRTC) : @"1400823228",///
|
||||
@(KeyType_NetEase) : @"7371d729710cd6ce3a50163b956b5eb6",///
|
||||
@(KeyType_FacePwdEncode) : @"1ea53d260ecf11e7b56e00163e046a26",///
|
||||
@(KeyType_PasswordEncode) : @"1ea53d260ecf11e7b56e00163e046a26",///
|
||||
@(KeyType_Sign) : @"rpbs6us1m8r2j9g6u06ff2bo18orwaya"
|
||||
};
|
||||
NSString * newValue = [newDic objectForKey:@(type)];
|
||||
if(newValue != nil){
|
||||
return newValue;
|
||||
}
|
||||
|
||||
NSDictionary * dic = @{
|
||||
@(KeyType_GuildUidKey) : @"umyLNHTFzWIPw2FWQcYIeQ==",
|
||||
@(KeyType_SystemNotifiUidKey) : @"ZacsLJGoW2hbNoXo32DnaA==",
|
||||
@(KeyType_SecretaryUidKey) : @"cHTJhjYL9UXGs8NJSFxhdg=="
|
||||
};
|
||||
NSString * value = [dic objectForKey:@(type)];
|
||||
NSString * number = [AESUtils aesDecrypt:value];
|
||||
return number;
|
||||
}
|
||||
|
||||
@end
|
129
YuMi/Global/YUMIHtmlUrl.h
Normal file
129
YuMi/Global/YUMIHtmlUrl.h
Normal file
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// YMHtmlUrl.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/13.
|
||||
//
|
||||
///放置h5的链接地址
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface YUMIHtmlUrl : NSObject
|
||||
|
||||
typedef NS_ENUM(NSUInteger, URLType) {
|
||||
kPrivacyURL,///隐私政策
|
||||
kPrivacySDKURL,// 隐私政策-SDK
|
||||
kPrivacyPersonalURL,// 隐私政策-个人信息
|
||||
kPrivacyDeviceURL,// 隐私政策-设备权限
|
||||
kUserProtocalURL, ///用户协议
|
||||
kUserInviteFriendURL, ///邀请好友
|
||||
kFAQURL,///帮助
|
||||
kIdentityURL,///实名认证
|
||||
kGameBindAccountURL,
|
||||
kNurseryURL,///护苗计划
|
||||
kRechargePrivacyURL,////充值协议
|
||||
kReportRoomURL,///举报房间
|
||||
///分享房间
|
||||
kShareRoomURL,
|
||||
/// 获奖记录
|
||||
kCandyTreeRecordURL,
|
||||
/// 糖果树玩法规则
|
||||
kCandyTreeRuleURL,
|
||||
///房间魅力榜
|
||||
kRoomCharmRankURL,
|
||||
///房间榜
|
||||
kRoomRankURL,
|
||||
///房间小时榜
|
||||
kRoomHourRankURL,
|
||||
///用户等级
|
||||
kUserLevelURL,
|
||||
///平台榜单入口
|
||||
kHomeRankURL,
|
||||
///相亲规则介绍
|
||||
kRoomDatingRule,
|
||||
///VIP规则
|
||||
kNobleRuleURL,
|
||||
///VIP排行榜
|
||||
kNobleRankURL,
|
||||
///用户充值协议
|
||||
kUserRechargeAgrURL,
|
||||
//用户注册服务协议
|
||||
kUserRegiServiceAgrURL,
|
||||
///直播服务协议
|
||||
kLiveServiceAgrURL,
|
||||
///社区规范
|
||||
kCommunitySpecURL,
|
||||
///账号注销协议
|
||||
kAccountlogoutAgrURL,
|
||||
///账号注销
|
||||
kAccountlogoutURL,
|
||||
kAccountlogoutConfirmURL,
|
||||
///主播粉丝团-铭牌申请
|
||||
kAnchorFansOpenURL,
|
||||
///主播粉丝团-粉丝列表
|
||||
kAnchorFansListURL,
|
||||
///主播粉丝团-粉丝排行
|
||||
kAnchorFansRankURL,
|
||||
///主播粉丝团-粉丝团规则
|
||||
kAnchorFansRuleURL,
|
||||
///周星礼物-周星榜
|
||||
kNewWeekStarURL,
|
||||
///牌照房间小时榜
|
||||
kLicenseHourRankURL,
|
||||
///幸运礼物玩法说明
|
||||
kLuckyGiftPlayRuleURL,
|
||||
///航海中奖记录
|
||||
kSailingRecordURL,
|
||||
///航海玩法说明
|
||||
kSailingPlayDescdURL,
|
||||
///活动地址
|
||||
kSailingActivityURL,
|
||||
///网络整治乱象
|
||||
kNetworkRenovateURL,
|
||||
///动态分享
|
||||
kMonentsShareURL,
|
||||
///红包规则
|
||||
kRedPacketRuleURL,
|
||||
///星座入口
|
||||
kXinZuoStarURL,
|
||||
///收益记录
|
||||
kMineEarningsRecord,
|
||||
///金币收益记录
|
||||
kGoldEarningsRecord,
|
||||
///夺宝券购买
|
||||
kTreasureTicketBuyURL,
|
||||
///夺宝榜单达人
|
||||
kTreasureRankListURL,
|
||||
///夺宝券规则说明
|
||||
kTreasureRuleURL,
|
||||
///夺宝记录
|
||||
kTreasureRecordURL,
|
||||
kChannelUrl,
|
||||
///LUDO排行榜路径
|
||||
kLUDOUrl,
|
||||
/// CP 規則頁
|
||||
kCPRule,
|
||||
/// 火箭规则
|
||||
KBoomRule,
|
||||
/// 房间等级说明
|
||||
KRoomLevelRule,
|
||||
/// 红包规则说明
|
||||
KLuckyPackageRule,
|
||||
/// 人機驗證
|
||||
kCaptchaSwitchPath,
|
||||
/// 活动详情页
|
||||
kEventDetailPath,
|
||||
// 新排行榜
|
||||
kRankV2,
|
||||
kVIP,
|
||||
kTransfer,
|
||||
kFirstChargeHomeIndex,
|
||||
kFirstChargeBanner,
|
||||
};
|
||||
|
||||
NSString * const URLWithType(URLType type);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
97
YuMi/Global/YUMIHtmlUrl.m
Normal file
97
YuMi/Global/YUMIHtmlUrl.m
Normal file
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// YMHtmlUrl.m
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/13.
|
||||
//
|
||||
|
||||
#import "YUMIHtmlUrl.h"
|
||||
#import "AESUtils.h"
|
||||
#import "Base64.h"
|
||||
#import <Base64/MF_Base64Additions.h>
|
||||
@implementation YUMIHtmlUrl
|
||||
|
||||
NSString * const URLWithType(URLType type) {
|
||||
NSString * prefix = @"molistar";
|
||||
NSDictionary *newDic = @{
|
||||
@(kTreasureTicketBuyURL) : @"modules/act-treasureSnatching/index.html",///夺宝购买
|
||||
@(kTreasureRankListURL) : @"modules/act-treasureSnatching/list.html",///夺宝达人
|
||||
@(kTreasureRuleURL) : @"modules/act-treasureSnatching/rule.html",///夺宝规则说明
|
||||
@(kTreasureRecordURL) : @"modules/act-treasureSnatching/record.html",///夺宝记录
|
||||
@(kNobleRankURL) : @"modules/noble/index.html",///排行榜
|
||||
@(kGoldEarningsRecord) : @"modules/myincome/index.html#/GoldLog",///金币收益记录
|
||||
@(kCandyTreeRuleURL) : @"modules/rule/newWishingWellRule.html",///糖果树规则 modules/rank/index.html#/wishingWellRule
|
||||
@(kChannelUrl) : @"modules/%@/index.html?channelType=%@&deviceId=%@",
|
||||
@(kLUDOUrl) : @"modules/gameRank/index.html",///LUDO排行榜路径
|
||||
@(kCPRule) : @"modules/rule/cpRule.html",
|
||||
@(KBoomRule) : @"modules/rule/boom.html?partitionId=",///收益记录,
|
||||
@(KRoomLevelRule) : @"modules/roomLevel/index.html",///房间等级,
|
||||
@(KLuckyPackageRule) : @"modules/luckyBagRules/index.html",///红包礼物,
|
||||
@(kCaptchaSwitchPath) : @"modules/humanMachineVerification/index.html",
|
||||
@(kAccountlogoutConfirmURL) : @"modules/logout/confirm.html",
|
||||
@(kEventDetailPath) : @"modules/eventDetails/index.html?eventId=",
|
||||
@(kRankV2) : @"modules/newRank/index.html",
|
||||
@(kVIP) : @"modules/vip_Center/index.html",
|
||||
@(kTransfer) : @"modules/rechargeAgent/index.html#/myTransfer",
|
||||
@(kFirstChargeBanner) : @"modules/firstRechargeBonus/First_Bonus.html",
|
||||
@(kFirstChargeHomeIndex) : @"modules/firstRechargeBonus/index.html",
|
||||
|
||||
};
|
||||
NSString * newUrl = [newDic objectForKey:@(type)];
|
||||
if(newUrl != nil){
|
||||
NSString * url = [newDic objectForKey:@(type)];
|
||||
return [NSString stringWithFormat:@"%@/%@",prefix, url];
|
||||
}
|
||||
|
||||
NSDictionary * dic = @{
|
||||
@(kPrivacyURL) : @"sPa8x4YF1hFEeCeH5v+RMOulemxgjjZLbxkN8ZrBSM8=",//隐私政策 modules/rule/privacy-wap.html
|
||||
@(kPrivacySDKURL) : @"EXbb0qKoel1tyEL3rQ3//BQ6p/uA56xs9iAOyFI7TRU=",//隐私政策-SDK modules/rule/sdk.html
|
||||
@(kPrivacyPersonalURL) : @"u+t46y/9x4S49BgHUeSXxxu2D69UtZtmyhA93HUTvzI=",//隐私政策-个人信息 modules/rule/personal-info.html
|
||||
@(kPrivacyDeviceURL) : @"u+t46y/9x4S49BgHUeSXx/rPFwLB78TiQyN+xJKENGQ=",//隐私政策-设备权限 modules/rule/permissions.html
|
||||
@(kUserProtocalURL) : @"0sBhBaRqf7oBlYvNK4azCrVPTFjv9FYF0A2v9+qkSxg=",///用户协议 modules/rule/protocol.html
|
||||
@(kUserInviteFriendURL) : @"HInhWCyiR3L4dAlHrmQ/GttrZqXhOtq85WujAcETPPI=",///邀请好友
|
||||
@(kFAQURL) : @"k/Bqnh8nGkuhV8KhU6xN5a8EkxEQrbDMAWNBtaAdJCo=",//常见问题 modules/rule/guide.html
|
||||
@(kIdentityURL) : @"EQtrsRlCX2+rJN89+qyAT6JtfEnprTylInFU0tTPyLA=",//实人认证 modules/identity/new.html
|
||||
@(kGameBindAccountURL) : @"5s9YWzw5Lt6ro86UN4pUFETAyuCsIL3wl00gLK5rCek=",///绑定账号 modules/game/bindAccount.html
|
||||
@(kNurseryURL) : @"ZT1/YWK/T7gXs1rGDAYnbqG0OrzjhPKJfaebh80/1ro=",///护苗计划 activity/cleanNet/index.html
|
||||
@(kRechargePrivacyURL) : @"boJayVmf9bj+vVXabUop2cc110U9LaDdAJhHfbinDzXLhlBtiv3h7J6Sivv3v1Lr",//充值协议 modules/rule/rechargeAgreement.html
|
||||
@(kReportRoomURL) : @"TbIA4vIU9O5Z/RGJKEELZNe7SFzF9ig/Lvo6D1upv/g=",///举报房间
|
||||
@(kShareRoomURL) : @"k+TyUH/PriZr4MWmS/rq8BUYAu34MX3ZyAZsDLF0Eck=",///分享房间 modules/share_room/index.html
|
||||
@(kCandyTreeRecordURL) : @"V6XAvR9DZVl5TTczQ/JABDNKGpFSnSP/r6WLbu91uPKWKlwVlmlYvkETALeLk7Jz",///糖果树记录 modules/rank/index.html#/newWishingWellRecord
|
||||
@(kRoomCharmRankURL) : @"a5qVnItWuLLh148cl8R/+VuVNfOSOd1nzVzfSFbAxUA=",//房间魅力榜 modules/charm/index.html
|
||||
@(kRoomRankURL) : @"DqPWO/9EdbpkGl4PoRVQy4+hE8o8EuE30v2vN/yeZFg=", //房间榜 modules/room_rank/index.html
|
||||
@(kRoomHourRankURL) : @"DqPWO/9EdbpkGl4PoRVQy7m9/mGnCSpoi673bWBnwBc=", //房间小时榜 modules/room_rank/hourRank.html
|
||||
@(kUserLevelURL) : @"NE+tamYZsEj7S9BySlTpcCyRDMdxsWDzm6KrZTs9Lbo=",//我的等级 modules/level/index.html
|
||||
@(kHomeRankURL) : @"V6XAvR9DZVl5TTczQ/JABNoH8I7E1sQ4oZmqs01zOfc=", // 排行榜 modules/rank/index.html#/rank
|
||||
@(kRoomDatingRule) : @"BbMeRujqQH/yCud2VyM4tZMYe8oHwrQCEcP50kTTxgQ=",//相亲玩法 modules/rule/dating.html
|
||||
@(kNobleRuleURL) : @"4x4Blbka3DFMAyZGSVqxAp0jXvE4/JUx48YfowufzircU1vr/Du8GqrouZUzD9Uq", // VIP规则 modules/rule/introduction-patrician.html
|
||||
|
||||
@(kUserRechargeAgrURL) : @"boJayVmf9bj+vVXabUop2cc110U9LaDdAJhHfbinDzXLhlBtiv3h7J6Sivv3v1Lr", ///用户充值协议
|
||||
@(kUserRegiServiceAgrURL): @"0sBhBaRqf7oBlYvNK4azCrVPTFjv9FYF0A2v9+qkSxg=",//用户注册服务协议 modules/rule/protocol.html
|
||||
@(kLiveServiceAgrURL) : @"83qLuhoOlxXOw3gwkchLAnb0iz5PEjqOS5dKRRzIxVw=", ///直播服务协议 modules/rule/live-protocol.html
|
||||
@(kCommunitySpecURL) : @"oZs0ygpb9qtOkpZG1zcj1qS3fx0xzBArL1h358e1NM3hbbSU8qTOBmxkpJ03iq+K", ///社区规范 modules/rule/community-norms.html
|
||||
@(kAccountlogoutAgrURL) : @"8pzk0dLk9GPSIKjn894dHtmPvxfIJTkUYNP5qTE7GzYpYAG7LWwF1pK7NWb4E0D9", ///账号注销协议
|
||||
@(kAccountlogoutURL) : @"8pzk0dLk9GPSIKjn894dHmMgQS2OHgRpZ6NNmxGMZ7E=", ///账号注销 modules/rule/loginout.html
|
||||
@(kAnchorFansOpenURL) : @"mLMTNiyvF2Tbv4qan6+ogPrhx2U0FdD+3WkY/LdNbduiPL2qYSUiF2VJ2Dfbgnpn", ///主播粉丝团-铭牌申请v modules/fans_club/nameplate.html
|
||||
@(kAnchorFansListURL) : @"mLMTNiyvF2Tbv4qan6+ogDXuGLEHnNEEiALV6JCC/gE=", ///主播粉丝团-粉丝列表 modules/fans_club/myfans.html
|
||||
@(kAnchorFansRankURL) : @"mLMTNiyvF2Tbv4qan6+ogCO6lES2UPVnrnZbAxJMj9o+Oz0MAqy0RX8j1QuItbfT", ///主播粉丝团-粉丝排行 modules/fans_club/fans_rank.html
|
||||
@(kAnchorFansRuleURL) : @"mLMTNiyvF2Tbv4qan6+ogG32ymd/DYTOoOeZFye3U9A=", ///主播粉丝团-粉丝团规则 modules/fans_club/rule.html
|
||||
@(kNewWeekStarURL) : @"GmT6HOvcXNUSbxa4g7oNm8j+6DnTtsNc9nMk6SrEyCdP95p3Jwz84r/fjSNcBBRi", ///周星礼物-周星榜 modules/weekStar/newWeekStar.html
|
||||
@(kLicenseHourRankURL) : @"DqPWO/9EdbpkGl4PoRVQyyMfaOgNqIr7sGIOi+kLkijf1EAcL9tVSblMXjNuq+Qy",///牌照房小时榜礼物 modules/room_rank/hourRankLicense.html
|
||||
@(kLuckyGiftPlayRuleURL) : @"DcADpWwvzNDc5QYX9hmrJDFatpu+zp4ynUPdb+KeBx0+iFBaBI/MRU80MenYMHKQ",///幸运礼物玩法说明 modules/rule/luckyGiftRule.html?giftID=%@
|
||||
@(kSailingActivityURL) : @"ZrQv+cP5sXzlvQp0nvUa20JB5cyCS6X8LTGvUroUfxk=", ///航海活动地址 activity/act-sail/more.html
|
||||
@(kSailingPlayDescdURL) : @"ZrQv+cP5sXzlvQp0nvUa23RXydMeqE8YfwP1J1xHCv3PdHFTlEJiRJ1vhrmu25pu", ///航海玩法规则 activity/act-sail/play_explain.html
|
||||
@(kSailingRecordURL) : @"ZrQv+cP5sXzlvQp0nvUa2w5kpdXwSP1aQbPEWUi/gPvrXEWTD9m43qlvhznGtWx1", ///航海中奖记录 activity/act-sail/win_record.html
|
||||
@(kNetworkRenovateURL) : @"vMZOLHkGF9uAzm9Ii2dzmQVhtZPf5IUKeg8H7/5FGcWE3YbMNrK59iMSV91HEHz/",///网络整治乱象 activity/activemodel/index.html?code=ZBGG
|
||||
@(kMonentsShareURL) : @"s06Uv+UqjOdDhupnk0YpKKnSCSFCZssMEJxKZdf+s0Ge3zIFKv3knVVNr710Y5eF",///分享动态 modules/world/share-page/index.html
|
||||
@(kRedPacketRuleURL) : @"nRMNKGz9zmwOEcoRr/bGneWzsrl+qHbvUGgXJhFAfVGcldkazbiNrc/v2rR0HFw+",///红包规则 modules/rule/red-packet-rule.html
|
||||
@(kXinZuoStarURL) : @"3l3NxeDKO2bNAESpzjZ76mvJa2D26Bgqy+nNusiuH1UHYM+bYk+MM/TNM4VRqk1K",///星座礼物 activity/act-constellation/index.html
|
||||
@(kMineEarningsRecord) : @"0HJ5o+40NtYGeHo1KRoQE3VdLhFQnvGyqgph9CCLjyU53rS29T2nD7UEh3CpX2BG",///收益记录
|
||||
|
||||
|
||||
};
|
||||
NSString * url = [dic objectForKey:@(type)];
|
||||
NSString * webUrl = [AESUtils aesDecrypt:url];
|
||||
return [NSString stringWithFormat:@"%@/%@",prefix, webUrl];
|
||||
}
|
||||
@end
|
84
YuMi/Global/YUMIMacroUitls.h
Normal file
84
YuMi/Global/YUMIMacroUitls.h
Normal file
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// YMMacro.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/10.
|
||||
//
|
||||
///一些宏
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "../Tools/Bundle/NSBundle+Localizable.h"
|
||||
|
||||
#ifndef YUMIMacroUitls_h
|
||||
#define YUMIMacroUitls_h
|
||||
|
||||
#import "../Tools/Bundle/YMLanguageConfig.h"
|
||||
|
||||
//iPhoneX系列设备(刘海屏设备)
|
||||
#define iPhoneXSeries \
|
||||
({BOOL isPhoneXSeries = NO;\
|
||||
if (@available(iOS 11.0, *)) {\
|
||||
isPhoneXSeries = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
|
||||
}\
|
||||
(isPhoneXSeries);})
|
||||
|
||||
#define KScreenWidth [[UIScreen mainScreen] bounds].size.width
|
||||
#define KScreenHeight [[UIScreen mainScreen] bounds].size.height
|
||||
#define statusbarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
|
||||
#define kStatusBarHeight statusbarHeight
|
||||
#define kSafeAreaBottomHeight (iPhoneXSeries ? 34 : 0)
|
||||
#define kSafeAreaTopHeight (iPhoneXSeries ? 24 : 0)
|
||||
#define kNavigationHeight (kStatusBarHeight + 44)
|
||||
#define kTabBarHeight (iPhoneXSeries ? 49.0+34.0 : 49.0)
|
||||
#define kScreenScale ((CGFloat)KScreenWidth / (CGFloat)375)
|
||||
#define kScreenHeightScale ((CGFloat)KScreenHeight / (CGFloat)812)
|
||||
#define kHalfScreenHeight KScreenHeight * 0.65
|
||||
#define kGetScaleWidth(width) kRoundValue(width)
|
||||
#define kRoundValue(value) round(kScreenScale * value)
|
||||
#define kWeakify(o) try{}@finally{} __weak typeof(o) o##Weak = o;
|
||||
#define kStrongify(o) autoreleasepool{} __strong typeof(o) o = o##Weak;
|
||||
///keyWindow
|
||||
#define kWindow [UIApplication sharedApplication].keyWindow
|
||||
#define kImage(image) [UIImage imageNamed:image]
|
||||
|
||||
///UIFont
|
||||
#define kFontLight(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightLight]
|
||||
#define kFontRegular(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightRegular]
|
||||
#define kFontMedium(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightMedium]
|
||||
#define kFontSemibold(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightSemibold]
|
||||
#define kFontBold(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightBold]
|
||||
#define kFontHeavy(font) [UIFont systemFontOfSize:kGetScaleWidth(font) weight:UIFontWeightHeavy]
|
||||
|
||||
///内置版本号
|
||||
#define PI_App_Version @"1.0.31"
|
||||
///渠道
|
||||
#define PI_App_Source @"appstore"
|
||||
#define PI_Test_Flight @"TestFlight"
|
||||
#define ISTestFlight 0
|
||||
///正式环境
|
||||
#define API_HOST_URL @"https://api.hfighting.com"
|
||||
///测试环境
|
||||
#define API_HOST_TEST_URL @"http://beta.api.pekolive.com" // http://beta.api.pekolive.com | http://beta.api.molistar.xyz
|
||||
|
||||
#define API_Image_URL @"https://image.hfighting.com"
|
||||
|
||||
#define YMLocalizedString(key) \
|
||||
[NSBundle ymLocalizedStringForKey:(key)]
|
||||
|
||||
#define isMSRTL() [YMLanguageConfig isRTLanguage:[NSBundle getLanguageText]]
|
||||
///是否是中文
|
||||
#define isMSZH() [[NSBundle getLanguageText] hasPrefix:@"zh"]
|
||||
///是否是英文
|
||||
#define isMSEN() [[NSBundle getLanguageText] hasPrefix:@"en"]
|
||||
///是否土耳其语
|
||||
#define isMSTR() [[NSBundle getLanguageText] hasPrefix:@"tr"]
|
||||
///是否葡萄牙语
|
||||
#define isMSPT() [[NSBundle getLanguageText] hasPrefix:@"pt"]
|
||||
///是否西班牙语
|
||||
#define isMSES() [[NSBundle getLanguageText] hasPrefix:@"es"]
|
||||
///是否俄语
|
||||
#define isMSRU() [[NSBundle getLanguageText] hasPrefix:@"ru"]
|
||||
///是否乌兹别克语
|
||||
#define isMSUZ() [[NSBundle getLanguageText] hasPrefix:@"uz"]
|
||||
|
||||
|
||||
#endif /* YUMIMacroUitls_h */
|
91
YuMi/Global/YUMINNNN.h
Normal file
91
YuMi/Global/YUMINNNN.h
Normal file
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// YMEnum.h
|
||||
// YUMI
|
||||
//
|
||||
// Created by YUMI on 2021/9/13.
|
||||
//
|
||||
///放置一些全局的枚举
|
||||
#ifndef YUMINNNN_h
|
||||
#define YUMINNNN_h
|
||||
|
||||
typedef NS_ENUM(NSUInteger, ThirdLoginType) {
|
||||
ThirdLoginType_WeChat = 1,///微信
|
||||
ThirdLoginType_QQ = 2,///QQ
|
||||
ThirdLoginType_FB = 10,///FackBook
|
||||
ThirdLoginType_Line = 9,///Line
|
||||
ThirdLoginType_Gmail = 8,///谷歌
|
||||
ThirdLoginType_Apple = 5,///苹果登录
|
||||
ThirdLoginType_Phone = 11,///手机号登录
|
||||
};
|
||||
|
||||
/// @param type 类型 业务类型,必填,1注册,2登录,3重设密码,4绑定手机,5绑定xczAccount,6重设xcz密码,7解绑手机
|
||||
typedef NS_ENUM(NSUInteger, GetSmsType) {
|
||||
GetSmsType_Regist = 1,///注册
|
||||
GetSmsType_Login = 2,///登录
|
||||
GetSmsType_Reset_Password = 3,///重设密码
|
||||
GetSmsType_Bind_Phone = 4, ///绑定手机
|
||||
GetSmsType_Bind_ZF = 5,///绑定支付宝
|
||||
GetSmsType_Reset_ZF = 6,///重设支付密码
|
||||
GetSmsType_Unbind_Phone = 7, ///解绑手机
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, GenderType) {
|
||||
GenderType_Male = 1,///男性
|
||||
GenderType_Female = 2,///女性
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, DressUpLabelType) {
|
||||
DressUpLabelType_New = 1, //新品
|
||||
DressUpLabelType_Discount = 2, //折扣
|
||||
DressUpLabelType_Limit = 3,//限定
|
||||
DressUpLabelType_Exclusive = 4//专属
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, GroupType) {
|
||||
GroupType_default = 0,//默认
|
||||
GroupType_Blue = 1,//蓝队 男神
|
||||
GroupType_Red = 2, //红队 女神
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, UserEnterRoomFromType) {
|
||||
///首页推荐
|
||||
UserEnterRoomFromType_Home_Recommend = 1,
|
||||
///跟随用户
|
||||
UserEnterRoomFromType_Follow_User = 2,
|
||||
///赛事详情
|
||||
UserEnterRoomFromType_Follow_Game_Detail = 8,
|
||||
///跨房PK
|
||||
UserEnterRoomFromType_Cross_Room_PK = 9,
|
||||
///新用户打招呼
|
||||
UserEnterRoomFromType_New_User_Greet = 10
|
||||
};
|
||||
typedef NS_ENUM(NSInteger, LittleGamePlayStatus) {
|
||||
LittleGamePlayStatus_NoIn = 0,//未加入
|
||||
LittleGamePlayStatus_IsIn = 1,//已加入
|
||||
LittleGamePlayStatus_Ready = 2, //已准备
|
||||
LittleGamePlayStatus_Plying = 3,//游戏中
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, RoomPKVoteModeType){
|
||||
RoomPKVoteModeType_GiftValue = 1,//礼物价值
|
||||
RoomPKVoteModeType_NumberPerson = 2, //按送礼物的人数
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, RoomPKResultType) {
|
||||
RoomPKResultType_Draw = 0,//平局
|
||||
RoomPKResultType_Blue = 1,//蓝方胜
|
||||
RoomPKResultType_Red = 2, //红方胜
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSInteger, ContactUseingType) {
|
||||
///默认
|
||||
ContactUseingType_Normal = 0,
|
||||
///在房间内
|
||||
ContactUseingType_In_Room = 1,
|
||||
///分享
|
||||
ContactUseingType_Share = 2,
|
||||
///消息
|
||||
ContactUseingType_In_Session = 3
|
||||
};
|
||||
|
||||
#endif /* YUMINNNN_h */
|
Reference in New Issue
Block a user