Comments (2)
我们是这样做的,你也可以通过配置json的方式
@Route(path = "xxx",params = {"needLogin", "true"})
public class MainActivity extends AppCompatActivity {
}
NavigatorKt.addRouterReplaceInterceptor(new RouterReplaceInterceptor() {
@Nullable
@Override
public RouteItem replace(@Nullable RouteItem routeItem) {
if (Boolean.valueOf(routeItem.getExtras().getString("needLogin"))) {
return loginRouterItem;
}
return routeItem;
}
});
在 /assets/therouter/routeMap.json
里面新增参数也可以达到等同于注解内添加的目的。
{
"path": "xxxxx",
"className": "xxxxx",
"action": "",
"description": "",
"params": {
"needLogin": "true"
}
}
from hll-wp-therouter-android.
我是通过拼接/needLogin
判断的
public class MainActivity extends AppCompatActivity {
}
addPathReplaceInterceptor(LoginInterceptor()
class LoginInterceptor : PathReplaceInterceptor() {
override fun replace(path: String?): String? {
if (path?.contains("/needLogin") == true) {
if (!UserHelper.isLogin()) {
//拦截操作,去调用登录
return CommRouter.login
}
}
return path
}
}
routeMap.json
类似
from hll-wp-therouter-android.
Related Issues (20)
- 修改Activity名称后,routeMap.json文件会重复生成 HOT 1
- 是用moduleImplementation 在 gradle 5.4.1 报错
- MethodHandle
- TheRouterPlugin与AutoService不兼容,无法编译 HOT 4
- 1.2.2-rc6 和Hilt冲突 HOT 2
- TheRouter插件会导致 AndroidStudio 卡死 HOT 2
- interface com.qx.common.provider.IRoomService is interface, but do not have @ServiceProvider HOT 2
- 获取Fragment说空指针 HOT 3
- java.lang.NoClassDefFoundError: Failed resolution of: La/RouterMap__TheRouter HOT 3
- groovy.lang.MissingMethodException: No signature of method: static com.therouter.plugin.utils.TheRouterPluginUtils.initProperties() is applicable for argument types: () values: [] HOT 1
- com.therouter.plugin.agp8.TheRouterGetAllClassesTask`: invocation of 'Task.project' at execution time is unsupported. HOT 2
- android studio直接导入main分支代码build 报错 HOT 1
- 哈喽 , 问一下怎么兼容ActivityResultLauncher这个API去使用? HOT 1
- Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory. HOT 3
- 编译异常问题 HOT 5
- apg8.0+ jdk17 gradle 8.2 项目在clean 会报错 HOT 2
- 每次改完代码之后不管clean、rebuild还是运行项目,都会报错一次,再重复一次操作就又好了 HOT 2
- Could not apply requested plugin [id: 'cn.therouter.agp8', version: '1.2.2'] as it does not provide a plugin with id 'cn.therouter.agp8'. This is caused by an incorrect plugin implementation. Please contact the plugin author(s) HOT 2
- 错误:常量字符串过长 HOT 1
- gradle-8.2 Android Studio Hedgehog | 2023.1.1 Patch 2 打包失败 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hll-wp-therouter-android.