app.js 3.3 KB

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