Skip to content

Commit a3b4852

Browse files
author
wangshuwen15222
committed
feat:支持多路由匹配一个页面
1 parent 73b9365 commit a3b4852

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

m_test/src/main/java/cn/cheney/mtest/activity/ActivityA.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import cn.cheney.xrouter.annotation.XRoute;
2020
import cn.cheney.xrouter.core.XRouter;
2121

22-
@XRoute(module = "moduleA", path = "page/a")
22+
@XRoute(module = "moduleA", path = {"page/a","page/a/copy"})
2323
public class ActivityA extends AppCompatActivity {
2424
@XParam()
2525
Book book;

m_test/src/main/java/cn/cheney/mtest/module/ModuleA.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static void getAsyncBookName(@XParam(name = XParam.RequestId) String requ
2929
XRouter.getInstance().invokeCallback(requestId, map);
3030
}
3131

32-
@XMethod(name = "setBookList")
32+
@XMethod(name = "setBookInfo")
3333
public static Boolean setBookList(Context context, List<Book> bookList, String strValue) {
3434
Log.i(TAG, "setBookList bookList=" + JSON.toJSONString(bookList));
3535
Log.i(TAG, "setBookList strValue=" + strValue);

xrouter_annotation/src/main/java/cn/cheney/xrouter/annotation/XRoute.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@Retention(RetentionPolicy.CLASS)
1010
public @interface XRoute {
1111

12-
String path() default "";
12+
String[] path() default {} ;
1313

1414
String module();
1515

xrouter_compiler/src/main/java/cn/cheney/xrouter/compiler/generator/ModuleClassGenerator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ private MethodSpec.Builder loadMethodBuilder() {
9090
/**
9191
* routeMap.put("/test2",new MethodInvoke() or new ActivityInvoke());
9292
*/
93-
public void generateSeg(TypeElement classType, String path) {
93+
public void generateSeg(TypeElement classType, String[] paths) {
9494
TypeMirror typeActivity = holder.elementUtils
9595
.getTypeElement(XTypeMirror.ACTIVITY).asType();
9696
if (holder.types.isSubtype(classType.asType(), typeActivity)) {
97-
addActivityInvoke(classType, path);
97+
for (String path : paths) {
98+
addActivityInvoke(classType, path);
99+
}
98100
}
99101
for (Element element : classType.getEnclosedElements()) {
100102
if (element instanceof ExecutableElement) {

0 commit comments

Comments
 (0)