const.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package view
  2. import (
  3. "fmt"
  4. arcwar "go-common/app/service/main/archive/api"
  5. )
  6. // Goto
  7. const (
  8. GotoAv = "av"
  9. GotoWeb = "web"
  10. GotoBangumi = "bangumi"
  11. GotoLive = "live"
  12. GotoGame = "game"
  13. GotoArticle = "article"
  14. GotoSpecial = "special"
  15. GotoAudio = "audio"
  16. GotoSong = "song"
  17. GotoAudioTag = "audio_tag"
  18. GotoAlbum = "album"
  19. GotoClip = "clip"
  20. GotoDaily = "daily"
  21. )
  22. // FillURI deal app schema.
  23. func FillURI(gt, param string, f func(uri string) string) (uri string) {
  24. if param == "" {
  25. return
  26. }
  27. switch gt {
  28. case GotoAv, "":
  29. uri = "bilibili://video/" + param
  30. case GotoLive:
  31. uri = "bilibili://live/" + param
  32. case GotoBangumi:
  33. uri = "https://www.bilibili.com/bangumi/play/ss" + param
  34. case GotoArticle:
  35. uri = "bilibili://article/" + param
  36. case GotoGame:
  37. uri = param
  38. case GotoAudio:
  39. uri = "bilibili://music/menu/detail/" + param
  40. case GotoSong:
  41. uri = "bilibili://music/detail/" + param
  42. case GotoAudioTag:
  43. uri = "bilibili://music/categorydetail/" + param
  44. case GotoDaily:
  45. uri = "bilibili://pegasus/list/daily/" + param
  46. case GotoAlbum:
  47. uri = "bilibili://album/" + param
  48. case GotoClip:
  49. uri = "bilibili://clip/" + param
  50. case GotoWeb:
  51. uri = param
  52. }
  53. if f != nil {
  54. uri = f(uri)
  55. }
  56. return
  57. }
  58. // AvHandler logic
  59. var AvHandler = func(a *arcwar.Arc) func(uri string) string {
  60. return func(uri string) string {
  61. if a == nil {
  62. return uri
  63. }
  64. if a.Dimension.Height != 0 || a.Dimension.Width != 0 {
  65. return fmt.Sprintf("%s?player_width=%d&player_height=%d&player_rotate=%d", uri, a.Dimension.Width, a.Dimension.Height, a.Dimension.Rotate)
  66. }
  67. return uri
  68. }
  69. }