Home.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div class="app">
  3. <main-header></main-header>
  4. <div class="group" v-if="stations.official.length">
  5. <div class="group-title">Official Stations</div>
  6. <div class="group-stations">
  7. <div class="stations-station" v-for="station in stations.official" v-link="{ path: '/official/' + station._id }" @click="this.$dispatch('joinStation', station._id)">
  8. <img class="station-image" :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes.png'" />
  9. <div class="station-info">
  10. <div class="station-grid-left">
  11. <h3>{{ station.displayName }}</h3>
  12. <p>{{ station.description }}</p>
  13. </div>
  14. <div class="station-grid-right">
  15. <div>{{ station.userCount }}&nbsp;&nbsp;<i class="material-icons">perm_identity</i></div>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. <button @click="toggleModal('ccs')">CREATE COMMUNITY STATION</button>
  22. <div class="group" v-if="stations.community.length">
  23. <div class="group-title">Community Stations</div>
  24. <div class="group-stations">
  25. <div class="stations-station" v-for="station in stations.community" v-link="{ path: '/community/' + station._id }" @click="this.$dispatch('joinStation', station._id)">
  26. <img class="station-image" :src="station.currentSong.thumbnail" onerror="this.src='/assets/notes.png'" />
  27. <div class="station-info">
  28. <div class="station-grid-left">
  29. <h3>{{ station.displayName }}</h3>
  30. <p>{{ station.description }}</p>
  31. </div>
  32. <div class="station-grid-right">
  33. <div>{{ station.userCount }}&nbsp;&nbsp;<i class="material-icons">perm_identity</i></div>
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. <main-footer></main-footer>
  40. </div>
  41. </template>
  42. <script>
  43. import MainHeader from '../MainHeader.vue';
  44. import MainFooter from '../MainFooter.vue';
  45. export default {
  46. data() {
  47. return {
  48. isRegisterActive: false,
  49. isLoginActive: false,
  50. recaptcha: {
  51. key: ''
  52. },
  53. stations: {
  54. official: [],
  55. community: []
  56. }
  57. }
  58. },
  59. ready() {
  60. let _this = this;
  61. let socketInterval = setInterval(() => {
  62. if (!!_this.$parent.socket) {
  63. _this.socket = _this.$parent.socket;
  64. _this.socket.emit("stations.index", data => {
  65. if (data.status === "success") data.stations.forEach(station => {
  66. if (!station.currentSong) station.currentSong = { thumbnail: '/assets/notes.png' };
  67. if (station.type == 'official') _this.stations.official.push(station);
  68. else _this.stations.community.push(station);
  69. });
  70. });
  71. _this.socket.emit("apis.joinRoom", 'home', () => {});
  72. _this.socket.on('event:stations.created', station => {
  73. if (!station.currentSong) station.currentSong = {};
  74. _this.stations[station.type].push(station);
  75. });
  76. clearInterval(socketInterval);
  77. }
  78. }, 100);
  79. },
  80. methods: {
  81. toggleModal: function (type) {
  82. this.$dispatch('toggleModal', type);
  83. }
  84. },
  85. components: { MainHeader, MainFooter }
  86. }
  87. </script>
  88. <style lang="scss">
  89. @import 'theme.scss';
  90. * { box-sizing: border-box; }
  91. html {
  92. width: 100%;
  93. height: 100%;
  94. color: rgba(0, 0, 0, 0.87);
  95. body {
  96. width: 100%;
  97. height: 100%;
  98. margin: 0;
  99. padding: 0;
  100. }
  101. }
  102. @media only screen and (min-width: 1200px) {
  103. html {
  104. font-size: 15px;
  105. }
  106. }
  107. @media only screen and (min-width: 992px) {
  108. html {
  109. font-size: 14.5px;
  110. }
  111. }
  112. @media only screen and (min-width: 0) {
  113. html {
  114. font-size: 14px;
  115. }
  116. }
  117. .label {
  118. display: flex;
  119. }
  120. .g-recaptcha {
  121. display: flex;
  122. justify-content: center;
  123. margin-top: 20px;
  124. }
  125. .group {
  126. width: 100%;
  127. height: 448px;
  128. margin: 64px 0 0 0;
  129. .group-title {
  130. float: left;
  131. clear: none;
  132. width: 100%;
  133. height: 64px;
  134. line-height: 48px;
  135. text-align: center;
  136. font-size: 48px;
  137. }
  138. .group-stations {
  139. white-space: nowrap;
  140. text-align: center;
  141. overflow: hidden;
  142. float: left;
  143. clear: none;
  144. width: 100%;
  145. height: 400px;
  146. .stations-station {
  147. position: relative;
  148. top: 16px;
  149. display: inline-block;
  150. clear: none;
  151. width: 256px;
  152. height: 370px;
  153. margin: 0 16px 0 16px;
  154. box-shadow: 0 1px 6px 2px rgba(0, 0, 0, 0.25);
  155. cursor: pointer;
  156. .station-info {
  157. display: flex;
  158. flex-direction: row;
  159. align-items: center;
  160. }
  161. .station-image {
  162. width: 100%;
  163. height: 256px;
  164. object-fit: cover;
  165. }
  166. .station-grid-left {
  167. display: flex;
  168. flex-direction: column;
  169. width: 75%;
  170. text-align: left;
  171. padding-left: 10px;
  172. h3 {
  173. color: $blue;
  174. margin: 0;
  175. white-space: normal;
  176. padding-top: 10px;
  177. }
  178. p {
  179. margin: 0;
  180. white-space: normal;
  181. padding-top: 10px;
  182. }
  183. }
  184. .station-grid-right {
  185. display: flex;
  186. flex-direction: column;
  187. width: 25%;
  188. i {
  189. color: $blue;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>