add .gitignore

This commit is contained in:
JoyWayer
2023-12-27 20:38:37 +08:00
parent b106a628a5
commit f6343426d6
515 changed files with 104217 additions and 199 deletions

340
msext/AppDelegate.m Normal file → Executable file
View File

@@ -7,37 +7,369 @@
//
#import "AppDelegate.h"
@interface AppDelegate ()
#import "RootVC.h"
#import "NewRootVC.h"
#import "NavgationController.h"
#import "WXApi.h"
#import "WXApiManager.h"
#import "ZipArchive.h"
#import "GDataXMLNode.h"
#import "APIKey.h"
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <Bugly/Bugly.h>
#import "RNCachingURLProtocol.h"
#import "JANALYTICSService.h"
#import "XianliaoApiManager.h"
@interface AppDelegate ()<BuglyDelegate>
{
BOOL flag;
}
@property (copy, nonatomic) NSString *gamedir;
@property (copy, nonatomic) NSString *gamestart;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [WXApi handleOpenURL:url delegate:[WXApiManager sharedManager]];
}
- (void)configureAPIKey
{
if ([APIKey length] == 0)
{
NSString *reason = [NSString stringWithFormat:@"apiKey为空请检查key是否正确设置。"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:reason delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
[AMapServices sharedServices].apiKey = (NSString *)APIKey;
}
- (void)setupBugly {
// Get the default config
BuglyConfig * config = [[BuglyConfig alloc] init];
// Open the debug mode to print the sdk log message.
// Default value is NO, please DISABLE it in your RELEASE version.
//#if DEBUG
// config.debugMode = YES;
//#endif
// Open the customized log record and report, BuglyLogLevelWarn will report Warn, Error log message.
// Default value is BuglyLogLevelSilent that means DISABLE it.
// You could change the value according to you need.
// config.reportLogLevel = BuglyLogLevelWarn;
// Open the STUCK scene data in MAIN thread record and report.
// Default value is NO
config.blockMonitorEnable = YES;
// Set the STUCK THRESHOLD time, when STUCK time > THRESHOLD it will record an event and report data when the app launched next time.
// Default value is 3.5 second.
config.blockMonitorTimeout = 1.5;
// Set the app channel to deployment
config.channel = @"Bugly";
config.delegate = self;
config.consolelogEnable = YES;
config.viewControllerTrackingEnable = YES;
// [Bugly startWithAppId:@"cff5401df0"];
// NOTE:Required
// Start the Bugly sdk with APP_ID and your config
[Bugly startWithAppId:@"222f47a4ea"
#if DEBUG
developmentDevice:YES
#endif
config:config];
// Set the customizd tag thats config in your APP registerd on the bugly.qq.com
// [Bugly setTag:1799];
[Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];
[Bugly setUserValue:[NSProcessInfo processInfo].processName forKey:@"Process"];
// NOTE: This is only TEST code for BuglyLog , please UNCOMMENT it in your code.
// [self performSelectorInBackground:@selector(testLogOnBackground) withObject:nil];
}
#pragma mark - BuglyDelegate
- (NSString *)attachmentForException:(NSException *)exception {
NSLog(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);
BLYLogError(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);
return @"This is an attachment";
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self configureAPIKey];
[self setupBugly];
[XianliaoApiManager registerApp:@"U1jJq3wgWluyB660"];
// [XianliaoApiManager showLog:YES];
//sleep(3);
//[[Countly sharedInstance] start:@"378dfc689042938950dc59a1b98d4ca9a0c48eb0" withHost:@"http://ct.eobook.com"];
//
JANALYTICSLaunchConfig * config = [[JANALYTICSLaunchConfig alloc] init];
config.appKey = @"3752badf07677981decdb7c2";
config.channel = @"tongji";
[JANALYTICSService setupWithConfig:config];
[NSURLProtocol registerClass:[RNCachingURLProtocol class]];
//
NSString *pathagent=[FuncPublic getFilePath:@"gamedir" PathType:3];//
NSFileManager* fm=[NSFileManager defaultManager];
if([fm fileExistsAtPath:pathagent]){
NSArray *files = [fm subpathsAtPath: pathagent ];
NSLog(@"%@",[files objectAtIndex:0]);
self.gamedir= [files objectAtIndex:0];
}
if(1)
{
NSString *pathagent=[FuncPublic getFilePath:@"gamestart" PathType:3];//
NSFileManager* fm=[NSFileManager defaultManager];
if([fm fileExistsAtPath:pathagent]){
NSArray *files = [fm subpathsAtPath: pathagent ];
NSLog(@"%@",[files objectAtIndex:0]);
self.gamestart= [files objectAtIndex:0];
}
}
application.applicationSupportsShakeToEdit = YES;
NSString *path=nil;
path=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@/%@/version.xml",self.gamedir,self.gamestart] PathType:2];
// NSString *path = [[NSBundle mainBundle] pathForResource:@"www/niuniu/version.xml" ofType:nil];
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:data options:0 error:nil];
NSArray *array = [doc nodesForXPath:@"/game/version" error:nil];
//CityName
GDataXMLElement *element = [array firstObject];
NSLog(@"name=%@ value=%@",element.name,[element attributeForName:@"value"].stringValue);
if(1)
{
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *filePath=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@",self.gamedir] PathType:2];
if ([fileManager fileExistsAtPath:filePath]) {
NSLog(@"文件abc.doc存在");
}else
{
NSString *booksDir=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@",self.gamedir] PathType:2];
NSString *zipsDir=[FuncPublic getFilePath:@"zips" PathType:2];
NSString *imagesDir=[FuncPublic getFilePath:@"images" PathType:2];
NSString *cachesDir=[FuncPublic getFilePath:@"caches" PathType:2];
[fileManager createDirectoryAtPath:booksDir withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createDirectoryAtPath:zipsDir withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createDirectoryAtPath:imagesDir withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createDirectoryAtPath:cachesDir withIntermediateDirectories:YES attributes:nil error:nil];
}
[fileManager release];
}
//gameversion>[[element attributeForName:@"value"].stringValue intValue]||
if (data==nil) {
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSString *filePathwww=[FuncPublic getFilePath:@"gamehall.zip" PathType:3];
NSString *filePath=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@",self.gamedir] PathType:2];
// NSFileManager *fileManager = [[NSFileManager alloc] init];
ZipArchive *zip = [[ZipArchive alloc] init];
if ([zip UnzipOpenFile:filePathwww])
{
if ([zip UnzipFileTo: filePath overWrite:YES])
{
//
}
}
[zip UnzipCloseFile];
[zip release];
[fileManager release];
}
flag=YES;
if(![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"])
{
//
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"everLaunched"];
[FuncPublic SaveDefaultInfo:@"0" Key:@"getcompareCode"];
[FuncPublic SaveDefaultInfo:@"set0" Key:@"FirstBOOL"];
[FuncPublic SaveDefaultInfo:@"set0" Key:@"SecondBOOL"];
[FuncPublic SaveDefaultInfo:@"set0" Key:@"ThirdBOOL"];
self.gamestart= [FuncPublic filename:@"gamestart"];
NSString *filePath=[FuncPublic getFilePath:[NSString stringWithFormat:@"%@/%@/app_gamesname.js",self.gamedir,self.gamestart] PathType:2];
NSString *info=[NSString stringWithFormat:@"var app_gamesname=new Array('%@');",self.gamestart];
NSData *txtData=[info dataUsingEncoding:NSUTF8StringEncoding];
[[NSFileManager defaultManager]createFileAtPath:filePath contents:txtData attributes:nil];
}
[FuncPublic SaveDefaultInfo:@"1.0" Key:@"VersionInfo"];
self.window = [[[CustomWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
if([UIDevice currentDevice].systemVersion.floatValue >= 9.0f) {
_newroot = [[NewRootVC alloc] initWithNibName:@"NewRootVC" bundle:nil];
NavgationController* nav = [[NavgationController alloc] initWithRootViewController:_newroot Navtype:NavgationTypeMaskPortrait];
nav.navigationBarHidden = NO;
self.window.rootViewController = nav;
}else
{
_root = [[RootVC alloc] initWithNibName:@"RootVC" bundle:nil];
NavgationController* nav = [[NavgationController alloc] initWithRootViewController:_root Navtype:NavgationTypeMaskPortrait];
nav.navigationBarHidden = NO;
self.window.rootViewController = nav;
}
application.statusBarHidden=NO;
UIApplication *myApp = [UIApplication sharedApplication];
[myApp setStatusBarStyle: UIStatusBarStyleDefault];
[self.window makeKeyAndVisible];
[WXApi registerApp:@"wxa5fcff77c40d721c" enableMTA:YES];
//
UInt64 typeFlag = MMAPP_SUPPORT_TEXT | MMAPP_SUPPORT_PICTURE | MMAPP_SUPPORT_LOCATION | MMAPP_SUPPORT_VIDEO |MMAPP_SUPPORT_AUDIO | MMAPP_SUPPORT_WEBPAGE | MMAPP_SUPPORT_DOC | MMAPP_SUPPORT_DOCX | MMAPP_SUPPORT_PPT | MMAPP_SUPPORT_PPTX | MMAPP_SUPPORT_XLS | MMAPP_SUPPORT_XLSX | MMAPP_SUPPORT_PDF;
[WXApi registerAppSupportContentFlag:typeFlag];
// [self configLocalHttpServer];
return YES;
}
#pragma mark -- --
#pragma mark -
#pragma mark -
- (void)configLocalHttpServer{
_localHttpServer = [[HTTPServer alloc] init];
[_localHttpServer setType:@"_http.tcp"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *path = webPathtcp;
NSLog(@">>>>[WebFilePath:]%@",path);
if (![fileManager fileExistsAtPath:webPathtcp]){
NSLog(@">>>> File path error!");
}else{
NSString *webLocalPath = webPathtcp;
[_localHttpServer setDocumentRoot:webLocalPath];
NSLog(@">>webLocalPath:%@",webLocalPath);
[self startServer];
}
}
- (void)startServer
{
NSError *error;
if([_localHttpServer start:&error]){
NSLog(@"Started HTTP Server on port %hu", [_localHttpServer listeningPort]);
self.port = [NSString stringWithFormat:@"%d",[_localHttpServer listeningPort]];
}
else{
NSLog(@"Error starting HTTP Server: %@", error);
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *) error {
NSLog(@"did Fail To Register For Remote Notifications With Error: %@", error);
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;
{
NSLog(@"系统内存不够,请清理应用数据,或者重启应用");
//[FuncPublic ShowAlert:@"系统内存不够,请重启应用"];
}
- (void)networkDidReceiveMessage:(NSNotification *)notification {
}
- (void)dealloc
{
[_window release];
//[_root release];
SG_RELEASE(_root);
SG_RELEASE(_newroot);
[super dealloc];
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
// return;
@try{
[[NSNotificationCenter defaultCenter] postNotificationName:@"enterForeground" object:nil];
} @catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
NSLog(@"enterForeground");
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
// return;
if(flag)
{
flag=NO;
@try{
[[NSNotificationCenter defaultCenter] postNotificationName:@"applicationWillResignActive" object:nil];
} @catch (NSException * e) {
NSLog(@"Exception: %@", e);
}
[self performSelector:@selector(OpenFlag) withObject:nil afterDelay:0.3];
NSLog(@"applicationWillResignActive");
}
}
-(void)OpenFlag
{
flag=YES;
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}