{"id":15481567,"url":"https://github.com/jdongkhan/jdrouter","last_synced_at":"2025-04-22T15:41:02.111Z","repository":{"id":56915817,"uuid":"98520224","full_name":"JDongKhan/JDRouter","owner":"JDongKhan","description":"iOS路由，根据MGJRouter修改、完善的方案，还有一个类Spring注解配置的简易方案","archived":false,"fork":false,"pushed_at":"2023-11-30T01:57:31.000Z","size":591,"stargazers_count":30,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T18:16:18.315Z","etag":null,"topics":["objective-c"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JDongKhan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-27T09:46:35.000Z","updated_at":"2025-03-14T02:54:53.000Z","dependencies_parsed_at":"2022-08-20T21:20:19.629Z","dependency_job_id":null,"html_url":"https://github.com/JDongKhan/JDRouter","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDongKhan%2FJDRouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDongKhan%2FJDRouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDongKhan%2FJDRouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDongKhan%2FJDRouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JDongKhan","download_url":"https://codeload.github.com/JDongKhan/JDRouter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250269852,"owners_count":21402950,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["objective-c"],"created_at":"2024-10-02T05:04:56.983Z","updated_at":"2025-04-22T15:41:02.081Z","avatar_url":"https://github.com/JDongKhan.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n注：本项目只是一个介绍有关组件解耦以及router思路的项目，很多细节没有完善。\n\n\n## 一、Annotation实现，模仿spring的机制。\n\n本方案特色是模拟java的注解方案。\n\n我们可以通过@JDModule注册模块，通过@JDService注册服务，用@JDRouter注册路由。\n\n使用方式：\n\n##### 一、module\n\n1、模块内定义一个实现了JDApplicationDelegate协议的类并实现该协议方法\n\n2、在实现类的.m里面增加\n\n```objc\n# import \u003cJDRouter/JDAnnotation.h\u003e\n\n@JDModule(className)\n```\n\n3、在AppDelegate里面的-application:didFinishLaunchingWithOptions:方法增加\n\n```objc\nreturn [[JDModuleManager sharedInstance] application:application  didFinishLaunchingWithOptions:launchOptions];\n```\n\n可查看  https://github.com/JDongKhan/JDComponentBased.git  使用细则\n\n\n\n##### 二、service\n\n1、定义协议：JDUserProtocol，并定义实现类 如JDUserService。\n\n2、在.m里面加入下面代码进行注册\n\n```objc\n# import \u003cJDRouter/JDAnnotation.h\u003e\n\n@JDService(JDUserProtocol,JDUserService) \n```\n\n3、通过JDServiceCenter中取得实例进行调用。\n\n  ```objc\nid\u003cJDUserProtocol\u003e user = [JDServiceCenter serviceForProtocol:@protocol(JDUserProtocol)];\n      \nNSString *userName = user.userName;\n  ```\n\n\n\n##### 三、router：\n\n1、定义路由类，如JDNextViewController。\n\n2、在JDNextViewController中增加以下代码\n\n```objective-c\n# import \u003cJDRouter/JDAnnotation.h\u003e\n\n@JDRouter(\"bb://user/name\",JDNextViewController)\n```\n\n3、让类实现handleWithLink:parameters:routerFrom:即可。\n\n4、使用者就可以通过openURL来跳转了。\n\n如下\n\n```objc\n[JDRouterCenter openURL:@\"bb://user/name\" parameters:@{@\"key\":@\"value\"} routerFrom:self completion:^(void) {\n        NSLog(@\"completion\");\n    }];\n```\n\n\n\n本方案存在部分约定。\n\n注：不需要在做任何配置！不需要在做任何配置！不需要在做任何配置！可以达到解耦效果，谁开发谁配置。\n\n\n\n## 二、JDIntent \n\n从URL来分析，用NSInvocation来跳转，就不用动态注册了\n\n\n```c\n\n[JDIntent openUrl:@\"bb://user/gotoNext\" completion:^(id info) {\nNSLog(@\"%@\",info);\n}];\n```\n\n通过约定将执行到UserIntent类里面的 action:gotoNext:completion:方法里\n\n\n本方案约定大于设计。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdongkhan%2Fjdrouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdongkhan%2Fjdrouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdongkhan%2Fjdrouter/lists"}