admin.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. currentTime: 0
  15. },
  16. editing: {}
  17. },
  18. getters: {},
  19. actions: {
  20. editSong: ({ commit }, song) => commit("editSong", song),
  21. stopVideo: ({ commit }) => commit("stopVideo"),
  22. loadVideoById: ({ commit }, id, skipDuration) =>
  23. commit("loadVideoById", id, skipDuration),
  24. pauseVideo: ({ commit }, status) => commit("pauseVideo", status),
  25. getCurrentTime: ({ commit, state }, fixedVal) => {
  26. return new Promise(resolve => {
  27. commit("getCurrentTime", fixedVal);
  28. resolve(state.video.currentTime);
  29. });
  30. }
  31. },
  32. mutations: {
  33. editSong(state, song) {
  34. state.editing = { ...song };
  35. },
  36. stopVideo(state) {
  37. state.video.player.stopVideo();
  38. },
  39. loadVideoById(state, id, skipDuration) {
  40. state.video.player.loadVideoById(id, skipDuration);
  41. },
  42. pauseVideo(state, status) {
  43. if (status) state.video.player.pauseVideo();
  44. else state.video.player.playVideo();
  45. state.video.paused = status;
  46. },
  47. getCurrentTime(state, fixedVal) {
  48. Promise.resolve(state.video.player.getCurrentTime()).then(
  49. time => {
  50. if (fixedVal)
  51. Promise.resolve(time.toFixed(fixedVal)).then(
  52. fixedTime => {
  53. state.video.currentTime = fixedTime;
  54. }
  55. );
  56. else state.video.currentTime = time;
  57. }
  58. );
  59. }
  60. }
  61. },
  62. stations: {
  63. namespaced: true,
  64. state: {
  65. station: {},
  66. editing: {}
  67. },
  68. getters: {},
  69. actions: {
  70. editStation: ({ commit }, station) => commit("editStation", station)
  71. },
  72. mutations: {
  73. editStation(state, station) {
  74. state.editing = state.station = station;
  75. }
  76. }
  77. },
  78. reports: {
  79. namespaced: true,
  80. state: {
  81. report: {}
  82. },
  83. getters: {},
  84. actions: {
  85. viewReport: ({ commit }, report) => commit("viewReport", report)
  86. },
  87. mutations: {
  88. viewReport(state, report) {
  89. state.report = report;
  90. }
  91. }
  92. },
  93. punishments: {
  94. namespaced: true,
  95. state: {
  96. punishment: {}
  97. },
  98. getters: {},
  99. actions: {
  100. viewPunishment: ({ commit }, punishment) =>
  101. commit("viewPunishment", punishment)
  102. },
  103. mutations: {
  104. viewPunishment(state, punishment) {
  105. state.punishment = punishment;
  106. }
  107. }
  108. },
  109. users: {
  110. namespaced: true,
  111. state: {
  112. editing: {}
  113. },
  114. getters: {},
  115. actions: {
  116. editUser: ({ commit }, user) => commit("editUser", user)
  117. },
  118. mutations: {
  119. editUser(state, user) {
  120. state.editing = user;
  121. }
  122. }
  123. }
  124. };
  125. export default {
  126. namespaced: true,
  127. state,
  128. getters,
  129. actions,
  130. mutations,
  131. modules
  132. };