admin.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. const state = {};
  2. const getters = {};
  3. const actions = {};
  4. const mutations = {};
  5. const modules = {
  6. songs: {
  7. namespaced: true,
  8. state: {
  9. video: {
  10. player: null,
  11. paused: true,
  12. playerReady: false,
  13. autoPlayed: false
  14. },
  15. editing: {}
  16. },
  17. getters: {},
  18. actions: {
  19. editSong: ({ commit }, song) => commit("editSong", song),
  20. stopVideo: ({ commit }) => commit("stopVideo"),
  21. loadVideoById: ({ commit }, id, skipDuration) =>
  22. commit("loadVideoById", id, skipDuration),
  23. pauseVideo: ({ commit }, status) => commit("pauseVideo", status)
  24. },
  25. mutations: {
  26. editSong(state, song) {
  27. state.editing = { ...song };
  28. console.log("editing", state.editing);
  29. },
  30. stopVideo(state) {
  31. state.video.player.stopVideo();
  32. },
  33. loadVideoById(state, id, skipDuration) {
  34. state.video.player.loadVideoById(id, skipDuration);
  35. },
  36. pauseVideo(state, status) {
  37. if (status) state.video.player.pauseVideo();
  38. else state.video.player.playVideo();
  39. state.video.paused = status;
  40. }
  41. }
  42. },
  43. stations: {
  44. namespaced: true,
  45. state: {
  46. station: {},
  47. editing: {}
  48. },
  49. getters: {},
  50. actions: {
  51. editStation: ({ commit }, station) => commit("editStation", station)
  52. },
  53. mutations: {
  54. editStation(state, station) {
  55. state.editing = state.station = station;
  56. }
  57. }
  58. },
  59. punishments: {
  60. namespaced: true,
  61. state: {
  62. punishment: {}
  63. },
  64. getters: {},
  65. actions: {
  66. viewPunishment: ({ commit }, punishment) =>
  67. commit("viewPunishment", punishment)
  68. },
  69. mutations: {
  70. viewPunishment(state, punishment) {
  71. state.punishment = punishment;
  72. }
  73. }
  74. },
  75. users: {
  76. namespaced: true,
  77. state: {
  78. editing: {}
  79. },
  80. getters: {},
  81. actions: {
  82. editUser: ({ commit }, user) => commit("editUser", user)
  83. },
  84. mutations: {
  85. editUser(state, user) {
  86. state.editing = user;
  87. }
  88. }
  89. }
  90. };
  91. export default {
  92. namespaced: true,
  93. state,
  94. getters,
  95. actions,
  96. mutations,
  97. modules
  98. };