const.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package model
  2. const (
  3. // PlatAndroid is int8 for android.
  4. PlatAndroid = int8(0)
  5. // PlatIPhone is int8 for iphone.
  6. PlatIPhone = int8(1)
  7. // PlatIPad is int8 for ipad.
  8. PlatIPad = int8(2)
  9. // PlatWPhone is int8 for wphone.
  10. PlatWPhone = int8(3)
  11. // PlatAndroidG is int8 for Android Global.
  12. PlatAndroidG = int8(4)
  13. // PlatIPhoneI is int8 for Iphone Global.
  14. PlatIPhoneI = int8(5)
  15. // PlatIPadI is int8 for IPAD Global.
  16. PlatIPadI = int8(6)
  17. // PlatAndroidTV is int8 for AndroidTV Global.
  18. PlatAndroidTV = int8(7)
  19. // PlatAndroidI is int8 for Android Global.
  20. PlatAndroidI = int8(8)
  21. // PlatIpadHD is int8 for IpadHD
  22. PlatIpadHD = int8(9)
  23. // PlatAndroidB is int8 for Android Blue.
  24. PlatAndroidB = int8(10)
  25. // PlatIphoneB is int8 for Iphone Blue
  26. PlatIphoneB = int8(11)
  27. )
  28. // IsAndroid check plat is android or ipad.
  29. func IsAndroid(plat int8) bool {
  30. return plat == PlatAndroid
  31. }
  32. // IsIOS check plat is iphone or ipad.
  33. func IsIOS(plat int8) bool {
  34. return plat == PlatIPad || plat == PlatIPhone || plat == PlatIPadI || plat == PlatIPhoneI
  35. }
  36. // IsIphone check plat is iphone.
  37. func IsIphone(plat int8) bool {
  38. return plat == PlatIPhone
  39. }
  40. // IsIPad check plat is pad.
  41. func IsIPad(plat int8) bool {
  42. return plat == PlatIPad
  43. }
  44. // IsIPadHD check plat is padHD.
  45. func IsIPadHD(plat int8) bool {
  46. return plat == PlatIpadHD
  47. }
  48. // IsOverseas is overseas
  49. func IsOverseas(plat int8) bool {
  50. return plat == PlatAndroidI || plat == PlatIPhoneI || plat == PlatIPadI
  51. }
  52. // Plat return plat by platStr or mobiApp
  53. func Plat(mobiApp, device string) int8 {
  54. switch mobiApp {
  55. case "iphone":
  56. if device == "pad" {
  57. return PlatIPad
  58. }
  59. return PlatIPhone
  60. case "white":
  61. return PlatIPhone
  62. case "ipad":
  63. return PlatIpadHD
  64. case "android", "android_b":
  65. return PlatAndroid
  66. case "win":
  67. return PlatWPhone
  68. case "android_G":
  69. return PlatAndroidG
  70. case "android_i":
  71. return PlatAndroidI
  72. case "iphone_i":
  73. if device == "pad" {
  74. return PlatIPadI
  75. }
  76. return PlatIPhoneI
  77. case "ipad_i":
  78. return PlatIPadI
  79. case "android_tv":
  80. return PlatAndroidTV
  81. case "iphone_b":
  82. return PlatIphoneB
  83. }
  84. return PlatIPhone
  85. }