Commit 51dd6ba8 authored by jz's avatar jz

add common router

parent bbdec0a3
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
} }
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *vc = [[GMRouter sharedInstance] pushScheme:@"gengmei://common" completeBlock:^(NSDictionary * _Nonnull params) { UIViewController *vc = [[GMRouter sharedInstance] pushScheme:@"common" completeBlock:^(NSDictionary * _Nonnull params) {
}]; }];
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
extern NSString *const GMRouterProtocolPrefix;
@interface GMRouter (gm) @interface GMRouter (gm)
/** /**
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
NSString *const GMRouterActionPrefix = @"Action_"; NSString *const GMRouterActionPrefix = @"Action_";
NSString *const GMRouterActionSuffix = @":"; NSString *const GMRouterActionSuffix = @":";
NSString *const GMRouterTargetPrefix = @"Target_"; NSString *const GMRouterTargetPrefix = @"Target_";
NSString *const GMRouterProtocolPrefix = @"gengmei://";
/** /**
增加一个模块, 需要在路由做映射, 增加一个模块, 需要在路由做映射,
TODO: 后续改为数组的形式传过来 TODO: 后续改为数组的形式传过来
...@@ -81,7 +81,12 @@ static NSMutableDictionary *routeMap = nil; ...@@ -81,7 +81,12 @@ static NSMutableDictionary *routeMap = nil;
} }
- (id)pushScheme:(NSString *)urlScheme completeBlock:(GMRouterBlock)routerBlock { - (id)pushScheme:(NSString *)urlScheme completeBlock:(GMRouterBlock)routerBlock {
NSString *encodeUrlScheme = [self URLEncodeString:urlScheme]; NSString *encodeUrlScheme;
if ([encodeUrlScheme hasPrefix:GMRouterProtocolPrefix]) {
encodeUrlScheme = [self URLEncodeString:urlScheme];
} else {
encodeUrlScheme = [NSString stringWithFormat:@"%@%@", GMRouterProtocolPrefix ,urlScheme];
}
NSURL *url = [NSURL URLWithString:encodeUrlScheme]; NSURL *url = [NSURL URLWithString:encodeUrlScheme];
if (!url) { if (!url) {
// debugLog(@"协议出错了!"); // debugLog(@"协议出错了!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment