const.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. package model
  2. // resource const
  3. const (
  4. // PlatAndroid is int8 for android.
  5. PlatAndroid = int8(0)
  6. // PlatIPhone is int8 for iphone.
  7. PlatIPhone = int8(1)
  8. // PlatIPad is int8 for ipad.
  9. PlatIPad = int8(2)
  10. // PlatWPhone is int8 for wphone.
  11. PlatWPhone = int8(3)
  12. // PlatAndroidG is int8 for Android Googleplay.
  13. PlatAndroidG = int8(4)
  14. // PlatIPhoneI is int8 for Iphone Global.
  15. PlatIPhoneI = int8(5)
  16. // PlatIPadI is int8 for IPAD Global.
  17. PlatIPadI = int8(6)
  18. // PlatAndroidTV is int8 for AndroidTV Global.
  19. PlatAndroidTV = int8(7)
  20. // PlatAndroidI is int8 for Android Global.
  21. PlatAndroidI = int8(8)
  22. // PlatAndroidB is int8 for Android Bule.
  23. PlatAndroidB = int8(9)
  24. // PlatWEB is int8 for web.
  25. PlatWEB = int8(99)
  26. // goto
  27. GotoAv = "av"
  28. GotoWeb = "web"
  29. GotoBangumi = "bangumi"
  30. GotoBangumiWeb = "bangumi_web"
  31. GotoSp = "sp"
  32. GotoLive = "live"
  33. GotoGame = "game"
  34. GotoArticle = "article"
  35. GotoActivity = "activity_new"
  36. GotoTopic = "topic_new"
  37. GotoDaily = "daily"
  38. GotoRank = "rank"
  39. GotoCard = "card"
  40. GotoVeidoCard = "video_card"
  41. GotoSpecialCard = "special_card"
  42. GotoTagCard = "tag_card"
  43. GotoColumn = "column"
  44. GotoColumnStage = "column_stage"
  45. GotoTagID = "tag_id"
  46. CardGotoAv = int8(1)
  47. CardGotoTopic = int8(2)
  48. CardGotoActivity = int8(3)
  49. )
  50. // InvalidBuild check source build is not allow by config build and condition.
  51. // eg: when condition is gt, means srcBuild must gt cfgBuild, otherwise is invalid srcBuild.
  52. func InvalidBuild(srcBuild, cfgBuild int, cfgCond string) bool {
  53. if cfgBuild != 0 && cfgCond != "" {
  54. switch cfgCond {
  55. case "gt":
  56. if cfgBuild >= srcBuild {
  57. return true
  58. }
  59. case "lt":
  60. if cfgBuild <= srcBuild {
  61. return true
  62. }
  63. case "eq":
  64. if cfgBuild != srcBuild {
  65. return true
  66. }
  67. case "ne":
  68. if cfgBuild == srcBuild {
  69. return true
  70. }
  71. }
  72. }
  73. return false
  74. }
  75. // InvalidChannel check source channel is not allow by config channel.
  76. func InvalidChannel(plat int8, srcCh, cfgCh string) bool {
  77. return plat == PlatAndroid && cfgCh != "*" && cfgCh != srcCh
  78. }
  79. // Plat return plat by platStr or mobiApp
  80. func Plat(mobiApp, device string) int8 {
  81. switch mobiApp {
  82. case "iphone":
  83. if device == "pad" {
  84. return PlatIPad
  85. }
  86. return PlatIPhone
  87. case "white":
  88. return PlatIPhone
  89. case "ipad":
  90. return PlatIPad
  91. case "android":
  92. return PlatAndroid
  93. case "win":
  94. return PlatWPhone
  95. case "android_G":
  96. return PlatAndroidG
  97. case "android_I":
  98. return PlatAndroidI
  99. case "iphone_I":
  100. if device == "pad" {
  101. return PlatIPadI
  102. }
  103. return PlatIPhoneI
  104. case "ipad_I":
  105. return PlatIPadI
  106. case "android_tv":
  107. return PlatAndroidTV
  108. }
  109. return PlatIPhone
  110. }
  111. // FillURI deal app schema.
  112. func FillURI(gt, param string) (uri string) {
  113. if param == "" {
  114. return
  115. }
  116. switch gt {
  117. case GotoAv, "":
  118. uri = "bilibili://video/" + param
  119. case GotoLive:
  120. uri = "bilibili://live/" + param
  121. case GotoBangumi:
  122. uri = "bilibili://bangumi/season/" + param
  123. case GotoBangumiWeb:
  124. uri = "http://bangumi.bilibili.com/anime/" + param
  125. case GotoGame:
  126. uri = "bilibili://game/" + param
  127. case GotoSp:
  128. uri = "bilibili://splist/" + param
  129. case GotoWeb:
  130. uri = param
  131. case GotoDaily:
  132. uri = "bilibili://daily/" + param
  133. case GotoColumn:
  134. uri = "bilibili://pegasus/list/column/" + param
  135. case GotoArticle:
  136. uri = "bilibili://article/" + param
  137. }
  138. return
  139. }