App.vue 4.4 KB

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