app.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. 'use strict'
  2. import CONSTANTS from './constants'
  3. import Vue from 'vue'
  4. import VueRouter from 'vue-router'
  5. import VueClipboards from 'vue-clipboards'
  6. import VueSimpleBreakpoints from 'vue-simple-breakpoints'
  7. import VeeValidate from 'vee-validate'
  8. import { ApolloClient } from 'apollo-client'
  9. import { BatchHttpLink } from 'apollo-link-batch-http'
  10. import { InMemoryCache } from 'apollo-cache-inmemory'
  11. import VueApollo from 'vue-apollo'
  12. import Vuetify from 'vuetify'
  13. import Velocity from 'velocity-animate'
  14. import Hammer from 'hammerjs'
  15. import store from './store'
  16. // ====================================
  17. // Load Modules
  18. // ====================================
  19. import boot from './modules/boot'
  20. import localization from './modules/localization'
  21. // ====================================
  22. // Load Helpers
  23. // ====================================
  24. import helpers from './helpers'
  25. // ====================================
  26. // Initialize Global Vars
  27. // ====================================
  28. window.WIKI = null
  29. window.boot = boot
  30. window.CONSTANTS = CONSTANTS
  31. window.Hammer = Hammer
  32. // ====================================
  33. // Initialize Apollo Client (GraphQL)
  34. // ====================================
  35. const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql'
  36. window.graphQL = new ApolloClient({
  37. link: new BatchHttpLink({
  38. uri: graphQLEndpoint,
  39. credentials: 'include'
  40. }),
  41. cache: new InMemoryCache(),
  42. connectToDevTools: (process.env.node_env === 'development')
  43. })
  44. // ====================================
  45. // Initialize Vue Modules
  46. // ====================================
  47. Vue.config.productionTip = false
  48. Vue.use(VueRouter)
  49. Vue.use(VueApollo)
  50. Vue.use(VueClipboards)
  51. Vue.use(VueSimpleBreakpoints)
  52. Vue.use(localization.VueI18Next)
  53. Vue.use(helpers)
  54. Vue.use(VeeValidate, { events: '' })
  55. Vue.use(Vuetify)
  56. Vue.prototype.Velocity = Velocity
  57. // ====================================
  58. // Register Vue Components
  59. // ====================================
  60. Vue.component('admin', () => import(/* webpackChunkName: "admin" */ './components/admin.vue'))
  61. Vue.component('editor', () => import(/* webpackChunkName: "editor" */ './components/editor.vue'))
  62. Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue'))
  63. Vue.component('nav-header', () => import(/* webpackMode: "eager" */ './components/nav-header.vue'))
  64. Vue.component('navigator', () => import(/* webpackMode: "eager" */ './components/navigator.vue'))
  65. Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue'))
  66. let bootstrap = () => {
  67. // ====================================
  68. // Notifications
  69. // ====================================
  70. window.addEventListener('beforeunload', () => {
  71. store.dispatch('startLoading')
  72. })
  73. const apolloProvider = new VueApollo({
  74. defaultClient: window.graphQL
  75. })
  76. // ====================================
  77. // Bootstrap Vue
  78. // ====================================
  79. const i18n = localization.init()
  80. window.WIKI = new Vue({
  81. el: '#app',
  82. components: {},
  83. mixins: [helpers],
  84. provide: apolloProvider.provide(),
  85. store,
  86. i18n
  87. })
  88. // ----------------------------------
  89. // Dispatch boot ready
  90. // ----------------------------------
  91. window.boot.notify('vue')
  92. // ====================================
  93. // Load Icons
  94. // ====================================
  95. import(/* webpackChunkName: "icons" */ './svg/icons.svg').then(icons => {
  96. document.body.insertAdjacentHTML('beforeend', icons.default)
  97. })
  98. }
  99. window.boot.onDOMReady(bootstrap)