This commit is contained in:
2025-08-20 09:08:28 +08:00
parent 59b42526b5
commit 7787b3ee30
28 changed files with 253 additions and 61 deletions

View File

@@ -31,6 +31,7 @@
@property (weak, nonatomic) IBOutlet DSWebDragView *webDragView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *dragHeightConstarint;
@property (weak, nonatomic) IBOutlet DSWebMenuCollectionView *webMenuCollectionView;
@property (nonatomic, strong) UIView *subBgView;
@end
@@ -62,6 +63,11 @@
_webView.navigationDelegate = self;
[self.view addSubview:_webView];
self.subBgView = [[UIView alloc] initWithFrame:self.view.frame];
self.subBgView.backgroundColor = [UIColor whiteColor];
self.subBgView.hidden = YES;
[self.view addSubview:self.subBgView];
NSMutableArray *menuArray = @[].mutableCopy;
AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
NSInteger height = 0 ;
@@ -73,23 +79,32 @@
height = height + 60;
LinkConfig *config = [[LinkConfig alloc] init];
config.isGoBack = YES;
config.icon = @"";
config.name = @"HOME";
config.icon = @"home2";
config.name = @"HOME2";
config.linkUrl = appDelegate.mainURLString;
[menuArray addObject:config];
// height = height + 70;
//
// LinkConfig *config2 = [[LinkConfig alloc] init];
// config2.isGoBack = NO;
// config2.icon = @"missav2";
// config2.name = @"missav2";
// config2.linkUrl = @"https://zh.xhamster.com";
// [menuArray addObject:config2];
//
// if (!ISNULLSTR(appDelegate.data.linkConfig)) {
// NSError *jsonError;
// id linkConfigResponse = [NSJSONSerialization JSONObjectWithData:[appDelegate.data.linkConfig dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&jsonError];
// if (jsonError==nil && [linkConfigResponse isKindOfClass:[NSArray class]]) {
// NSArray *linkConfigArray = linkConfigResponse;
// height = height + linkConfigArray.count*70;
// for (NSDictionary *dic in linkConfigArray) {
// LinkConfig *linkModel = [LinkConfig modelWithDictionary:dic];
// [menuArray addObject:linkModel];
// }
// }
// }
if (!ISNULLSTR(appDelegate.data.linkConfig)) {
NSError *jsonError;
id linkConfigResponse = [NSJSONSerialization JSONObjectWithData:[appDelegate.data.linkConfig dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&jsonError];
if (jsonError==nil && [linkConfigResponse isKindOfClass:[NSArray class]]) {
NSArray *linkConfigArray = linkConfigResponse;
height = height + linkConfigArray.count*70;
for (NSDictionary *dic in linkConfigArray) {
LinkConfig *linkModel = [LinkConfig modelWithDictionary:dic];
[menuArray addObject:linkModel];
}
}
}
//
if (!ISNULLSTR(appDelegate.data.fbUrl)) {
height = height + 70;
@@ -163,11 +178,23 @@
self.mainURLString = link.linkUrl;
self.isPresent = NO;
[self intoMainWebView];
self.subBgView.hidden = YES;
NSArray *dataArr = [self.subBgView subviews];
for (UIView *subView in dataArr) {
[subView removeFromSuperview];
}
}
}else{
self.mainURLString = link.linkUrl;
self.isPresent = NO;
[self intoMainWebView];
self.subBgView.hidden = YES;
NSArray *dataArr = [self.subBgView subviews];
for (UIView *subView in dataArr) {
[subView removeFromSuperview];
}
}
}else if ([webMenuType isKindOfClass:[NSNumber class]]) {
NSNumber *number = webMenuType;
@@ -178,6 +205,12 @@
}else if (menuType == DSWebMenuRefreshType) {
self.isPresent = NO;
[self intoMainWebView];
self.subBgView.hidden = YES;
NSArray *dataArr = [self.subBgView subviews];
for (UIView *subView in dataArr) {
[subView removeFromSuperview];
}
}else if (menuType == DSWebMenuWhatsAppType) {
if (!ISNULLSTR(appDelegate.data.wsUrl)) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",appDelegate.data.wsUrl]] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
@@ -219,13 +252,23 @@
decisionHandler(WKNavigationActionPolicyAllow);
}
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
{
if (navigationAction.request.URL) {
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures {
NSString *urlStr = navigationAction.request.URL.absoluteString;
if (urlStr.length == 0) {
self.subBgView.hidden = NO;
CGRect frame = self.view.bounds;
WKWebView *newWebView = [[WKWebView alloc] initWithFrame:frame configuration:configuration];
newWebView.UIDelegate = self;
newWebView.navigationDelegate = self;
[self.subBgView addSubview:newWebView];
return newWebView;
}else if (navigationAction.request.URL) {
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
MainOldViewController *view = [sb instantiateViewControllerWithIdentifier:@"MainOldViewController"];
// MainOldViewController *view = [[MainOldViewController alloc] init];
view.gameURLString = navigationAction.request.URL.absoluteString;
view.gameURLString = urlStr;
view.isPresent = YES;
view.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:view animated:YES completion:^{}];