NYSwRouter.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // NYSwRouter.swift
  3. // JSJP_Student_sw
  4. //
  5. // Created by Ning.ge on 2023/5/30.
  6. //
  7. import UIKit
  8. import URLNavigator
  9. enum NYSwPushType {
  10. case recommend_rank
  11. case trainee_search
  12. case trainee_list
  13. case mine_center
  14. case mine_uppassword
  15. }
  16. enum NYSwOpenType: String {
  17. case uprotocol = "https://ys.zzxcx.net/xy_jsjp.html"
  18. case all = "http://live.bilibili.com/app/all-live/"
  19. case login = "JiaPeiManage://app/login"
  20. }
  21. extension NYSwPushType {
  22. var path:String {
  23. switch self {
  24. case .recommend_rank:
  25. return "JiaPeiManage://recommend/rank"
  26. case .trainee_list:
  27. return "JiaPeiManage://me/trainee/list"
  28. case .trainee_search:
  29. return "JiaPeiManage://me/trainee/search"
  30. case .mine_center:
  31. return "JiaPeiManage://mine/center"
  32. case .mine_uppassword:
  33. return "JiaPeiManage://mine/updatepassword"
  34. }
  35. }
  36. }
  37. class NYSwRouter {
  38. @discardableResult
  39. class func push(_ type:NYSwPushType, context: Any? = nil) -> UIViewController? {
  40. return navigator.push(type.path, context: context)
  41. }
  42. @discardableResult
  43. class func push(_ url:String) -> UIViewController? {
  44. return navigator.push(url)
  45. }
  46. @discardableResult
  47. class func open(_ url:String) -> Bool? {
  48. guard let header = url.components(separatedBy: "?").first,
  49. let _ = NYSwOpenType(rawValue: header)
  50. else {
  51. NYSwToaster.show("需要跳转的路径未找到,请先注册!")
  52. return nil
  53. }
  54. return navigator.open(url)
  55. }
  56. }