Skip to content

Latest commit

 

History

History
102 lines (79 loc) · 2.54 KB

README_CN.md

File metadata and controls

102 lines (79 loc) · 2.54 KB

ACRouter

CI Status Version License Platform

简介

针对swift的页面路由 路由的理解

要求

swift3+ and xcode8+

安装

pod "ACRouter"

总体流程

sdf

快速使用

  1. 需要路由的控制器遵守协议ACRouterable, 并实现方法registerAction.
class CustomViewController: UIViewController, ACRouterable {
    static func registerAction(info: [String : AnyObject]) -> AnyObject {
        let newInstance = LoginViewController()
        if let title = info["username"] as? String {
            newInstance.title = title
        }
        return newInstance
    }
}
  1. 注册路由
ACRouter.addRouter("AA://bb/cc/:p1", classString: "CustomViewController")
  1. 通过URL打开控制器
ACRouter.openURL("AA://bb/cc/content?value1=testInfo")

便利方法

  • 快速添加路由映射关系
let registerDict = ["AA://bb/cc/:p1" : "CustomViewControllerOne", "AA://ee/ff" : "CustomViewControllerTwo"]
ACRouter.addRouter(registerDict)
  • 快速生成跳转URL
//自动将参数params和jumptype嵌入到注册的URL当中
ACRouter.generate(_ patternString: params:  jumpType: )
  • 检查跳转URL
canOpenURL(_ urlString: )
  • 移除路由
removeRouter(_ patternString: )

自定义使用

  1. 添加路由, 自己配置优先级和HandleBlock
//注册的路由将按优先级逆序排序
ACRouter.addRouter(patternString:  priority: handle: )
  1. 请求URL
//返回匹配的路由与所有解析出来的参数
ACRouter.requestURL(urlString: userInfo: )

Todo list

  • Add Interceptor for router
  • Add Test for router
  • Add openURL failed action
  • Add relocation
  • openURL not only support Viewcontroller jumping

致谢

JLRoutesMGJRouterARoutes

欢迎提出你们宝贵的意见, 你们的star与issue是我前进的动力

License

ACRouter is available under the MIT license. See the LICENSE file for more info.