App.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. .center {
  111. text-align: center;
  112. }
  113. #toast-container {
  114. z-index: 10000 !important;
  115. }
  116. html {
  117. overflow: auto !important;
  118. }
  119. .modal-card {
  120. margin: 0 !important;
  121. }
  122. .absolute-a {
  123. width: 100%;
  124. height: 100%;
  125. position: absolute;
  126. top: 0;
  127. left: 0;
  128. }
  129. .alert {
  130. padding: 20px;
  131. color: white;
  132. background-color: red;
  133. position: fixed;
  134. top: 50px;
  135. right: 50px;
  136. font-size: 2em;
  137. border-radius: 5px;
  138. z-index: 10000000;
  139. }
  140. .tooltip {
  141. position: relative;
  142. &:after {
  143. position: absolute;
  144. min-width: 80px;
  145. margin-left: -75%;
  146. text-align: center;
  147. padding: 7.5px 6px;
  148. border-radius: 2px;
  149. background-color: #323232;
  150. font-size: 0.9em;
  151. color: #fff;
  152. content: attr(data-tooltip);
  153. opacity: 0;
  154. transition: all 0.2s ease-in-out 0.1s;
  155. visibility: hidden;
  156. }
  157. &:hover:after {
  158. opacity: 1;
  159. visibility: visible;
  160. }
  161. }
  162. .tooltip-top {
  163. &:after {
  164. bottom: 150%;
  165. }
  166. &:hover {
  167. &:after {
  168. bottom: 120%;
  169. }
  170. }
  171. }
  172. .tooltip-bottom {
  173. &:after {
  174. top: 155%;
  175. }
  176. &:hover {
  177. &:after {
  178. top: 125%;
  179. }
  180. }
  181. }
  182. .tooltip-left {
  183. &:after {
  184. bottom: -10px;
  185. right: 130%;
  186. min-width: 100px;
  187. }
  188. &:hover {
  189. &:after {
  190. right: 110%;
  191. }
  192. }
  193. }
  194. .tooltip-right {
  195. &:after {
  196. bottom: -10px;
  197. left: 190%;
  198. min-width: 100px;
  199. }
  200. &:hover {
  201. &:after {
  202. left: 200%;
  203. }
  204. }
  205. }
  206. .button:focus,
  207. .button:active {
  208. border-color: #dbdbdb !important;
  209. }
  210. .input:focus,
  211. .input:active {
  212. border-color: #03a9f4 !important;
  213. }
  214. button.delete:focus {
  215. background-color: rgba(10, 10, 10, 0.3);
  216. }
  217. .tag {
  218. padding-right: 6px !important;
  219. }
  220. .button.is-success {
  221. background-color: #00b16a !important;
  222. }
  223. </style>