Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
GMRouter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
GMRouter
Commits
3c060557
Commit
3c060557
authored
Dec 23, 2019
by
jz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update GMRouter
parent
8160d8d4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
4 deletions
+35
-4
GMRouter+gm.m
GMRouter/Classes/GMRouter+gm.m
+35
-4
No files found.
GMRouter/Classes/GMRouter+gm.m
View file @
3c060557
...
...
@@ -36,7 +36,7 @@ static NSMutableDictionary *routeMap = nil;
-
(
void
)
initializeRouteMap
{
routeMap
=
[[
NSMutableDictionary
alloc
]
initWithCapacity
:
50
];
NSArray
*
arr
=
@[
GMRouterTargetAI
,
GMRouterTargetBanking
,
GMRouterTargetCommunity
,
GMRouterTargetWeb
];
NSArray
*
arr
=
@[
GMRouterTargetAI
,
GMRouterTargetBanking
,
GMRouterTargetCommunity
,
GMRouterTargetWeb
];
for
(
NSString
*
clsStr
in
arr
)
{
NSDictionary
*
dict
=
[
self
getMethods
:
clsStr
];
[
routeMap
addEntriesFromDictionary
:
dict
];
...
...
@@ -73,7 +73,8 @@ static NSMutableDictionary *routeMap = nil;
// 获取方法的参数列表
int
arguments
=
method_getNumberOfArguments
(
methods
[
i
]);
NSAssert
([
dict
.
allKeys
containsObject
:
name
],
@"Target_后不能为空!请注意Target"
);
NSString
*
promoteStr
=
[
NSString
stringWithFormat
:
@"%@-内有重复的方法名-%@"
,
clsStr
,
name
];
NSAssert
(
!
[
dict
.
allKeys
containsObject
:
name
],
promoteStr
);
//因为消息发送的时候会有两个默认的参数(消息接受者和方法名),所以需要减去2
dict
[
name
]
=
targetValue
;
...
...
@@ -125,14 +126,37 @@ static NSMutableDictionary *routeMap = nil;
}
-
(
id
)
pushScheme
:
(
NSString
*
)
urlScheme
{
NSString
*
encodeUrlScheme
=
[
self
URL
Decoded
String
:
urlScheme
];
NSString
*
encodeUrlScheme
=
[
self
URL
Encode
String
:
urlScheme
];
NSURL
*
url
=
[
NSURL
URLWithString
:
encodeUrlScheme
];
if
(
!
url
)
{
// debugLog(@"协议出错了!");
}
NSString
*
host
=
url
.
host
;
NSString
*
targetName
=
[
routeMap
objectForKey
:
host
];
NSDictionary
*
params
=
[
self
urlQueryToDictionary
:
encodeUrlScheme
];
NSDictionary
*
params
;
NSArray
*
array
=
[
encodeUrlScheme
componentsSeparatedByString
:
@"url="
];
if
(([
host
isEqualToString
:
@"third_webview"
]
||
[
host
isEqualToString
:
@"common_webview"
])
&&
array
.
count
>
1
)
{
NSString
*
value
=
array
[
1
];
while
([
value
rangeOfString
:
@"%"
].
length
!=
0
)
{
value
=
[
self
URLDecodedString
:
value
];
}
params
=
@{
@"url"
:
value
};
//拦截所有的即将调转的url(value),如果不在白名单之中,让其使用GMThirdWebViewController加载.
NSString
*
valueHost
=
[[
NSURL
URLWithString
:
value
]
host
];
// if ([GMServerDomains allowURLHost:valueHost] == NO) {
//#if defined DEBUG
// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"webView需添加白名单" message:value delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
// [alertView show];
//#endif
//
// host = @"third_webview";
// }
}
else
{
params
=
[
self
urlQueryToDictionary
:
encodeUrlScheme
];
}
// NSDictionary *params = [self urlQueryToDictionary:encodeUrlScheme];
return
[
self
performTarget
:
targetName
action
:
host
params
:
params
shouldCacheTarget
:
NO
];
}
...
...
@@ -148,6 +172,8 @@ static NSMutableDictionary *routeMap = nil;
return
[
self
performTarget
:
targetName
action
:
host
params
:
paramsDict
shouldCacheTarget
:
NO
];
}
#pragma mark - string to dict
-
(
NSDictionary
*
)
urlQueryToDictionary
:
(
NSString
*
)
urlScheme
{
NSURL
*
url1
=
[
NSURL
URLWithString
:
urlScheme
];
...
...
@@ -197,6 +223,11 @@ static NSMutableDictionary *routeMap = nil;
}
-
(
NSString
*
)
URLEncodeString
:
(
NSString
*
)
urlStr
{
NSString
*
encodedString
=
[
urlStr
stringByAddingPercentEncodingWithAllowedCharacters
:[
NSCharacterSet
URLQueryAllowedCharacterSet
]];
return
encodedString
;
}
@end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment