You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.6 KiB

6 years ago
  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 moment from 'moment'
  15. import VueMoment from 'vue-moment'
  16. import store from './store'
  17. // ====================================
  18. // Load Modules
  19. // ====================================
  20. import boot from './modules/boot'
  21. import localization from './modules/localization'
  22. // ====================================
  23. // Load Helpers
  24. // ====================================
  25. import helpers from './helpers'
  26. // ====================================
  27. // Initialize Global Vars
  28. // ====================================
  29. window.WIKI = null
  30. window.boot = boot
  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.use(VueMoment, { moment })
  57. Vue.prototype.Velocity = Velocity
  58. // ====================================
  59. // Register Vue Components
  60. // ====================================
  61. Vue.component('admin', () => import(/* webpackChunkName: "admin" */ './components/admin.vue'))
  62. Vue.component('editor', () => import(/* webpackChunkName: "editor" */ './components/editor.vue'))
  63. Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue'))
  64. Vue.component('nav-header', () => import(/* webpackMode: "eager" */ './components/nav-header.vue'))
  65. Vue.component('profile', () => import(/* webpackChunkName: "profile" */ './components/profile.vue'))
  66. Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue'))
  67. Vue.component('v-card-chin', () => import(/* webpackMode: "eager" */ './components/common/v-card-chin.vue'))
  68. let bootstrap = () => {
  69. // ====================================
  70. // Notifications
  71. // ====================================
  72. window.addEventListener('beforeunload', () => {
  73. store.dispatch('startLoading')
  74. })
  75. const apolloProvider = new VueApollo({
  76. defaultClient: window.graphQL
  77. })
  78. // ====================================
  79. // Bootstrap Vue
  80. // ====================================
  81. const i18n = localization.init()
  82. window.WIKI = new Vue({
  83. el: '#app',
  84. components: {},
  85. mixins: [helpers],
  86. provide: apolloProvider.provide(),
  87. store,
  88. i18n
  89. })
  90. // ----------------------------------
  91. // Dispatch boot ready
  92. // ----------------------------------
  93. window.boot.notify('vue')
  94. // ====================================
  95. // Load Icons
  96. // ====================================
  97. import(/* webpackChunkName: "icons" */ './svg/icons.svg').then(icons => {
  98. document.body.insertAdjacentHTML('beforeend', icons.default)
  99. })
  100. }
  101. window.boot.onDOMReady(bootstrap)