{"id":37017257,"url":"https://github.com/ma-jian/router","last_synced_at":"2026-01-14T01:58:51.399Z","repository":{"id":167156479,"uuid":"642692390","full_name":"ma-jian/router","owner":"ma-jian","description":"Activity Result API 方式启动的路由管理器、支持拦截、排序、自定义返回逻辑，多模块获取实例","archived":false,"fork":false,"pushed_at":"2025-07-16T07:58:18.000Z","size":348,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-17T10:56:14.452Z","etag":null,"topics":["kapt","kotlin","ksp","provider","router","serviceloader"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ma-jian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-19T06:22:33.000Z","updated_at":"2025-07-16T07:58:22.000Z","dependencies_parsed_at":"2024-06-17T09:58:25.953Z","dependency_job_id":"bf003688-44ed-484a-b570-92b9b0ad045d","html_url":"https://github.com/ma-jian/router","commit_stats":null,"previous_names":["ma-jian/router"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ma-jian/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ma-jian%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ma-jian%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ma-jian%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ma-jian%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ma-jian","download_url":"https://codeload.github.com/ma-jian/router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ma-jian%2Frouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"ssl_error","status_checked_at":"2026-01-14T01:40:32.775Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kapt","kotlin","ksp","provider","router","serviceloader"],"created_at":"2026-01-14T01:58:50.695Z","updated_at":"2026-01-14T01:58:51.391Z","avatar_url":"https://github.com/ma-jian.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# router\n\nActivity Result API 方式启动的路由管理器\n\n```groovy\nimplementation 'io.github.ma-jian:router-api:1.1.0'\n\n// kapt处理\nkapt 'io.github.ma-jian:router-compiler:1.1.0'\n// or ksp  kt代码优先使用ksp方式提升编译速度\nplugins {\n    id 'com.google.devtools.ksp'\n}\n\nksp 'io.github.ma-jian:router-ksp:1.1.0'\n```\n\n### **CHANGELOG**\n#### v1.1.0\n\n1. 新增降级策略\n2. 新增错误处理\n3. 优化代码\n\n#### v1.0.5\n\n1. 修改@Autowired 字段为必填时的错误提示\n2. 修改其他bug\n\n#### v1.0.3\n\n1. 新增注解[RouterInterceptor](router-annotation/src/main/java/com/mm/router/annotation/RouterInterceptor.kt) 路由拦截器，支持路由的自定义拦截\n   和路由拦截回调\n2. 新增 ksp 注解处理逻辑，原生生成kotlin代码提升编译速度\n3. 修改注解[ServiceProvider](router-annotation/src/main/java/com/mm/router/annotation/ServiceProvider.kt)处理逻辑，移除接口必须继承 IProvider 的限制\n4. 修改其他bug\n\n#### v1.0\n\n1. [RouterPath](router-annotation/src/main/java/com/mm/router/annotation/RouterPath.kt) 路由地址注册页面路径\n2. [ServiceProvider](router-annotation/src/main/java/com/mm/router/annotation/ServiceProvider.kt) 提供对外接口能力\n3. [Autowired](router-annotation/src/main/java/com/mm/router/annotation/Autowired.kt) 对标记字段自动赋值,需要在赋值页面注册\n   Router.init(this).autoWired(this)\n\n路由启动页面\n\nstartActivity\n\n```kotlin\nRouter.init(this).open(\"com.mm.second\").navigation()\n```\n\nstartActivityForResult\n\n```kotlin\nRouter.init().open(Router.Path.ACTION_CONTENT).navigation() {\n    if (it.resultCode == RESULT_OK) {\n        textView.text = textView.text.toString() + \"\\n ${it.data}\"\n    }\n}\n```\n路由降级策略\n```kotlin\nRouter.enableFallback = true\nRouter.defaultFallback (object : FallbackHandler {\n   override fun handleFallback(path: String, bundle: Bundle?) {\n       Router.init().open(\"com.mm.second\").withBundle(bundle).navigation()\n   }\n})\n```\n\n获取拦截器结果\n```kotlin\nRouter.init().open(\"/user/mine\").navigationResult {\n      //路由执行完毕并返回信息\n      it.onSuccess { result -\u003e\n\n      }\n      //路由被中断、通过在[Interceptor]中执行chain.interrupt()方法\n      it.onIntercepted {\n\n      }\n      //路由执行失败,返回值:true执行当前降级逻辑,false执行默认降级逻辑\n      it.onFailure {\n         false \n      } \n}\n```\n\n两种获取接口的方式\n\n@RouterPath 该方式获取Service 接口必须继承[IProvider](router-api/src/main/java/com/mm/router/IProvider.kt)\n\n```kotlin\n@RouterPath(value = \"/router/service/autowired\", des = \"自动注册赋值\")\nclass AutowiredServiceImpl : AutowiredService {\n    //...\n}\n\nval autowiredService = Router.init(this).open(\"/router/service/autowired\").doProvider\u003cAutowiredService\u003e()\n```\n\n@ServiceProvider 该方式无需接口继承IProvider，但必须是接口实现类\n\n```kotlin\n/**\n * 标记对外接口\n */\n@ServiceProvider(\"/service/provider\")\nclass ServiceProviderImpl (\n    private val string: String,\n    private val int: Int,\n    private val log: Long,\n    private val bol: Boolean\n) : IServiceProvider {\n    //...\n}\n\n//获取接口实例\nval provider = Router.init().open(\"/service/provider\").doProvider\u003cIServiceProvider\u003e(\"\",1,2L,false)\n```\n\n@RouterInterceptor\n\n```kotlin\n@RouterInterceptor(\"/router/path/match\", priority = 1, des = \"路由拦截器\")\nclass PathInterceptor : Interceptor {\n    override fun intercept(chain: Interceptor.Chain, intent: Intent) {\n\n    }\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fma-jian%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fma-jian%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fma-jian%2Frouter/lists"}