App.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <div>
  3. <banned v-if="banned" />
  4. <div v-else>
  5. <h1 v-if="!socketConnected" class="alert">
  6. Could not connect to the server.
  7. </h1>
  8. <!-- should be a persistant toast -->
  9. <router-view />
  10. <toast />
  11. <what-is-new />
  12. <mobile-alert />
  13. <login-modal v-if="modals.header.login" />
  14. <register-modal v-if="modals.header.register" />
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { mapState, mapActions } from "vuex";
  20. import { Toast } from "vue-roaster";
  21. import Banned from "./components/pages/Banned.vue";
  22. import WhatIsNew from "./components/Modals/WhatIsNew.vue";
  23. import MobileAlert from "./components/Modals/MobileAlert.vue";
  24. import LoginModal from "./components/Modals/Login.vue";
  25. import RegisterModal from "./components/Modals/Register.vue";
  26. import io from "./io";
  27. export default {
  28. replace: false,
  29. data() {
  30. return {
  31. serverDomain: "",
  32. socketConnected: true
  33. };
  34. },
  35. computed: mapState({
  36. loggedIn: state => state.user.auth.loggedIn,
  37. role: state => state.user.auth.role,
  38. username: state => state.user.auth.username,
  39. userId: state => state.user.auth.userId,
  40. banned: state => state.user.auth.banned,
  41. modals: state => state.modals.modals,
  42. currentlyActive: state => state.modals.currentlyActive
  43. }),
  44. methods: {
  45. submitOnEnter: (cb, event) => {
  46. if (event.which === 13) cb();
  47. },
  48. ...mapActions("modals", ["closeCurrentModal"])
  49. },
  50. mounted() {
  51. document.onkeydown = ev => {
  52. const event = ev || window.event;
  53. if (
  54. event.keyCode === 27 &&
  55. Object.keys(this.currentlyActive).length !== 0
  56. )
  57. this.closeCurrentModal();
  58. };
  59. if (localStorage.getItem("github_redirect")) {
  60. this.$router.go(localStorage.getItem("github_redirect"));
  61. localStorage.removeItem("github_redirect");
  62. }
  63. io.onConnect(true, () => {
  64. this.socketConnected = true;
  65. });
  66. io.onConnectError(true, () => {
  67. this.socketConnected = false;
  68. });
  69. io.onDisconnect(true, () => {
  70. this.socketConnected = false;
  71. });
  72. lofig.get("serverDomain", res => {
  73. this.serverDomain = res;
  74. });
  75. this.$router.onReady(() => {
  76. if (this.$route.query.err) {
  77. let { err } = this.$route.query;
  78. err = err
  79. .replace(new RegExp("<", "g"), "&lt;")
  80. .replace(new RegExp(">", "g"), "&gt;");
  81. this.$router.push({ query: {} });
  82. Toast.methods.addToast(err, 20000);
  83. }
  84. if (this.$route.query.msg) {
  85. let { msg } = this.$route.query;
  86. msg = msg
  87. .replace(new RegExp("<", "g"), "&lt;")
  88. .replace(new RegExp(">", "g"), "&gt;");
  89. this.$router.push({ query: {} });
  90. Toast.methods.addToast(msg, 20000);
  91. }
  92. });
  93. io.getSocket(true, socket => {
  94. socket.on("keep.event:user.session.removed", () => {
  95. window.location.reload();
  96. });
  97. });
  98. },
  99. components: {
  100. Toast,
  101. WhatIsNew,
  102. MobileAlert,
  103. LoginModal,
  104. RegisterModal,
  105. Banned
  106. }
  107. };
  108. </script>
  109. <style lang="scss">
  110. @import "styles/global.scss";
  111. #toast-container {
  112. z-index: 10000 !important;
  113. }
  114. html {
  115. overflow: auto !important;
  116. }
  117. .modal-card {
  118. margin: 0 !important;
  119. }
  120. .absolute-a {
  121. width: 100%;
  122. height: 100%;
  123. position: absolute;
  124. top: 0;
  125. left: 0;
  126. }
  127. .alert {
  128. padding: 20px;
  129. color: $white;
  130. background-color: $red;
  131. position: fixed;
  132. top: 50px;
  133. right: 50px;
  134. font-size: 2em;
  135. border-radius: 5px;
  136. z-index: 10000000;
  137. }
  138. .tooltip {
  139. position: relative;
  140. &:after {
  141. position: absolute;
  142. min-width: 80px;
  143. margin-left: -75%;
  144. text-align: center;
  145. padding: 7.5px 6px;
  146. border-radius: 2px;
  147. background-color: $dark-grey;
  148. font-size: 0.9em;
  149. color: $white;
  150. content: attr(data-tooltip);
  151. opacity: 0;
  152. transition: all 0.2s ease-in-out 0.1s;
  153. visibility: hidden;
  154. }
  155. &:hover:after {
  156. opacity: 1;
  157. visibility: visible;
  158. }
  159. }
  160. .tooltip-top {
  161. &:after {
  162. bottom: 150%;
  163. }
  164. &:hover {
  165. &:after {
  166. bottom: 120%;
  167. }
  168. }
  169. }
  170. .tooltip-bottom {
  171. &:after {
  172. top: 155%;
  173. }
  174. &:hover {
  175. &:after {
  176. top: 125%;
  177. }
  178. }
  179. }
  180. .tooltip-left {
  181. &:after {
  182. bottom: -10px;
  183. right: 130%;
  184. min-width: 100px;
  185. }
  186. &:hover {
  187. &:after {
  188. right: 110%;
  189. }
  190. }
  191. }
  192. .tooltip-right {
  193. &:after {
  194. bottom: -10px;
  195. left: 190%;
  196. min-width: 100px;
  197. }
  198. &:hover {
  199. &:after {
  200. left: 200%;
  201. }
  202. }
  203. }
  204. .button:focus,
  205. .button:active {
  206. border-color: #dbdbdb !important;
  207. }
  208. .input:focus,
  209. .input:active {
  210. border-color: $primary-color !important;
  211. }
  212. button.delete:focus {
  213. background-color: rgba(10, 10, 10, 0.3);
  214. }
  215. .tag {
  216. padding-right: 6px !important;
  217. }
  218. </style>