1
1
![ ] ( media/XRouter.png )
2
2
3
3
# XRRouter
4
+ [ ![ Hex.pm] ( https://img.shields.io/hexpm/l/plug.svg )] ( https://www.apache.org/licenses/LICENSE-2.0 )
4
5
5
6
#### 最新版本
6
7
7
- | 模块 | xrouter_annotation | xrouter_complier| xrouter_core|
8
- | ------------ | ------------ | ------------ | ------------ |
9
- | 最新版本 | 1.0.5| 1.0.5 | 1.0.5 |
10
-
11
-
8
+ | 模块 | xrouter-annotation | xrouter-compiler| xrouter-core| xrouter-plugin|
9
+ | ------------ | ------------ | ------------ | ------------ | ------------ |
10
+ | 最新版本 | [ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-annotation/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-annotation ) | [ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-compiler/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-compiler ) | [ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-core/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-core ) | [ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-plugin/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/io.github.wangshuwen1107/xrouter-plugin ) |
12
11
13
12
#### 添加依赖和配置
14
13
@@ -19,18 +18,30 @@ allprojects {
19
18
repositories {
20
19
mavenCentral()
21
20
}
21
+ dependencies {
22
+ classpath "io.github.wangshuwen1107:xrouter-plugin:x.x.x"
23
+ }
22
24
}
23
25
```
24
26
25
27
2.module build.gradle
26
28
27
29
``` gradle
28
30
dependencies {
29
- implementation 'cn.cheney.xrouter: core:x.x.x'
30
- annotationProcessor 'cn.cheney.xrouter: compiler:x.x.x'
31
+ implementation 'io.github.wangshuwen1107:xrouter- core:x.x.x'
32
+ annotationProcessor 'io.github.wangshuwen1107:xrouter- compiler:x.x.x'
31
33
}
32
34
```
33
35
36
+ 3.application build.gradle
37
+
38
+ ``` gradle
39
+ apply plugin: 'XRouter'
40
+ ```
41
+
42
+
43
+
44
+
34
45
#### 功能&说明
35
46
36
47
url : ` scheme://moduleName/methodName?key=value `
@@ -47,31 +58,13 @@ public class App extends Application {
47
58
48
59
@Override
49
60
public void onCreate () {
50
- super . onCreate();
51
- // 初始化
52
- XRouter . init(this , " scheme" );
53
- // 增加拦截器
54
- XRouter . getInstance(). addInterceptor(new RouterInterceptor () {
55
- @Override
56
- public Invokable intercept (Chain chain ) {
57
- BaseCall call = chain. call();
58
- String urlStr = call. getUri(). toString();
59
- Logger . d(" RouterInterceptor urlStr=" + urlStr);
60
- return chain. proceed(call);
61
- }
62
- });
63
- // 全局路由错误处理
64
- XRouter . getInstance(). setErroHandler(new RouterErrorHandler () {
65
- @Override
66
- public void onError (String url , String errorMsg ) {
67
- Logger . e(" Url:" + url + " errorMsg:" + errorMsg);
68
- }
69
- });
61
+ super . onCreate();
62
+ XRouter . init(this , " scheme" );
70
63
}
71
64
}
72
65
```
73
66
74
- 2.注解
67
+ 2.路由注册
75
68
76
69
``` java
77
70
@XRoute (path = " pageName" , module = " moduleName" )
@@ -105,7 +98,24 @@ public class YourModule{
105
98
}
106
99
```
107
100
108
- 3.调用
101
+ 3.拦截器注册
102
+
103
+ ``` java
104
+ @XInterceptor (modules = {" moduleA" }, priority = 1 )
105
+ public class TestInterceptorA implements RouterInterceptor {
106
+
107
+ @Override
108
+ public Object intercept (Chain chain ) {
109
+ Logger . d(" TestInterceptorA url=" + chain. call(). getUri(). toString());
110
+ return chain. proceed();
111
+ }
112
+
113
+ }
114
+ ```
115
+
116
+
117
+
118
+ 4.路由调用
109
119
110
120
``` java
111
121
// 跳转界面
0 commit comments