Commit 51dd6ba8 authored by jz's avatar jz

add common router

parent bbdec0a3
......@@ -46,7 +46,7 @@
}
- (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 @@
NS_ASSUME_NONNULL_BEGIN
extern NSString *const GMRouterProtocolPrefix;
@interface GMRouter (gm)
/**
......
......@@ -18,7 +18,7 @@
NSString *const GMRouterActionPrefix = @"Action_";
NSString *const GMRouterActionSuffix = @":";
NSString *const GMRouterTargetPrefix = @"Target_";
NSString *const GMRouterProtocolPrefix = @"gengmei://";
/**
增加一个模块, 需要在路由做映射,
TODO: 后续改为数组的形式传过来
......@@ -81,7 +81,12 @@ static NSMutableDictionary *routeMap = nil;
}
- (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];
if (!url) {
// 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