Home.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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) {
  67. station.currentSong = {thumbnail: '/assets/notes.png'};
  68. }
  69. if (station.type == 'official') _this.stations.official.push(station);
  70. else _this.stations.community.push(station);
  71. });
  72. });
  73. _this.socket.emit("apis.joinRoom", 'home', () => {});
  74. _this.socket.on('event:stations.created', (station) => {
  75. if (!station.currentSong) {
  76. station.currentSong = {};
  77. }
  78. _this.stations[station.type].push(station);
  79. });
  80. clearInterval(socketInterval);
  81. }
  82. }, 100);
  83. },
  84. methods: {
  85. toggleModal: function (type) {
  86. this.$dispatch('toggleModal', type);
  87. }
  88. },
  89. components: { MainHeader, MainFooter }
  90. }
  91. </script>
  92. <style lang="scss">
  93. @import 'theme.scss';
  94. * { box-sizing: border-box; }
  95. html {
  96. width: 100%;
  97. height: 100%;
  98. color: rgba(0, 0, 0, 0.87);
  99. body {
  100. width: 100%;
  101. height: 100%;
  102. margin: 0;
  103. padding: 0;
  104. }
  105. }
  106. @media only screen and (min-width: 1200px) {
  107. html {
  108. font-size: 15px;
  109. }
  110. }
  111. @media only screen and (min-width: 992px) {
  112. html {
  113. font-size: 14.5px;
  114. }
  115. }
  116. @media only screen and (min-width: 0) {
  117. html {
  118. font-size: 14px;
  119. }
  120. }
  121. .label {
  122. display: flex;
  123. }
  124. .g-recaptcha {
  125. display: flex;
  126. justify-content: center;
  127. margin-top: 20px;
  128. }
  129. .group {
  130. width: 100%;
  131. height: 448px;
  132. margin: 64px 0 0 0;
  133. .group-title {
  134. float: left;
  135. clear: none;
  136. width: 100%;
  137. height: 64px;
  138. line-height: 48px;
  139. text-align: center;
  140. font-size: 48px;
  141. }
  142. .group-stations {
  143. white-space: nowrap;
  144. text-align: center;
  145. overflow: hidden;
  146. float: left;
  147. clear: none;
  148. width: 100%;
  149. height: 400px;
  150. .stations-station {
  151. position: relative;
  152. top: 16px;
  153. display: inline-block;
  154. clear: none;
  155. width: 256px;
  156. height: 370px;
  157. margin: 0 16px 0 16px;
  158. box-shadow: 0 1px 6px 2px rgba(0, 0, 0, 0.25);
  159. cursor: pointer;
  160. .station-info {
  161. display: flex;
  162. flex-direction: row;
  163. align-items: center;
  164. }
  165. .station-image {
  166. width: 100%;
  167. height: 256px;
  168. object-fit: cover;
  169. }
  170. .station-grid-left {
  171. display: flex;
  172. flex-direction: column;
  173. width: 75%;
  174. text-align: left;
  175. padding-left: 10px;
  176. h3 {
  177. color: $blue;
  178. margin: 0;
  179. white-space: normal;
  180. padding-top: 10px;
  181. }
  182. p {
  183. margin: 0;
  184. white-space: normal;
  185. padding-top: 10px;
  186. }
  187. }
  188. .station-grid-right {
  189. display: flex;
  190. flex-direction: column;
  191. width: 25%;
  192. i {
  193. color: $blue;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. </style>