mirror of https://github.com/requarks/wiki
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.
146 lines
4.0 KiB
146 lines
4.0 KiB
8 years ago
|
'use strict'
|
||
8 years ago
|
|
||
7 years ago
|
/* global siteConfig */
|
||
8 years ago
|
|
||
7 years ago
|
import CONSTANTS from './constants'
|
||
|
|
||
8 years ago
|
import Vue from 'vue'
|
||
8 years ago
|
import VueClipboards from 'vue-clipboards'
|
||
7 years ago
|
import VueSimpleBreakpoints from 'vue-simple-breakpoints'
|
||
7 years ago
|
import VeeValidate from 'vee-validate'
|
||
7 years ago
|
import { ApolloClient } from 'apollo-client'
|
||
7 years ago
|
import { ApolloLink } from 'apollo-link'
|
||
|
import { createApolloFetch } from 'apollo-fetch'
|
||
|
import { BatchHttpLink } from 'apollo-link-batch-http'
|
||
7 years ago
|
import { InMemoryCache } from 'apollo-cache-inmemory'
|
||
7 years ago
|
import Vuetify from 'vuetify'
|
||
7 years ago
|
import Hammer from 'hammerjs'
|
||
8 years ago
|
import store from './store'
|
||
7 years ago
|
|
||
7 years ago
|
// ====================================
|
||
|
// Load Modules
|
||
|
// ====================================
|
||
|
|
||
7 years ago
|
import boot from './modules/boot'
|
||
7 years ago
|
import localization from './modules/localization'
|
||
8 years ago
|
|
||
8 years ago
|
// ====================================
|
||
|
// Load Helpers
|
||
|
// ====================================
|
||
|
|
||
|
import helpers from './helpers'
|
||
|
|
||
7 years ago
|
// ====================================
|
||
|
// Initialize Global Vars
|
||
|
// ====================================
|
||
|
|
||
|
window.wiki = null
|
||
7 years ago
|
window.boot = boot
|
||
7 years ago
|
window.CONSTANTS = CONSTANTS
|
||
7 years ago
|
window.Hammer = Hammer
|
||
7 years ago
|
|
||
7 years ago
|
// ====================================
|
||
|
// Initialize Apollo Client (GraphQL)
|
||
|
// ====================================
|
||
|
|
||
7 years ago
|
const graphQLEndpoint = window.location.protocol + '//' + window.location.host + siteConfig.path + 'graphql'
|
||
|
|
||
|
const apolloFetch = createApolloFetch({
|
||
|
uri: graphQLEndpoint,
|
||
|
constructOptions: (requestOrRequests, options) => ({
|
||
|
...options,
|
||
|
method: 'POST',
|
||
|
body: JSON.stringify(requestOrRequests),
|
||
|
credentials: 'include'
|
||
|
})
|
||
|
})
|
||
|
|
||
7 years ago
|
window.graphQL = new ApolloClient({
|
||
7 years ago
|
link: ApolloLink.from([
|
||
|
new ApolloLink((operation, forward) => {
|
||
|
operation.setContext({
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
}
|
||
|
})
|
||
|
|
||
|
return forward(operation)
|
||
|
}),
|
||
|
new BatchHttpLink({
|
||
|
fetch: apolloFetch
|
||
|
})
|
||
|
]),
|
||
7 years ago
|
cache: new InMemoryCache(),
|
||
|
connectToDevTools: (process.env.node_env === 'development')
|
||
7 years ago
|
})
|
||
|
|
||
8 years ago
|
// ====================================
|
||
8 years ago
|
// Initialize Vue Modules
|
||
8 years ago
|
// ====================================
|
||
|
|
||
8 years ago
|
Vue.use(VueClipboards)
|
||
7 years ago
|
Vue.use(VueSimpleBreakpoints)
|
||
7 years ago
|
Vue.use(localization.VueI18Next)
|
||
8 years ago
|
Vue.use(helpers)
|
||
7 years ago
|
Vue.use(VeeValidate, {
|
||
|
enableAutoClasses: true,
|
||
|
classNames: {
|
||
|
touched: 'is-touched', // the control has been blurred
|
||
|
untouched: 'is-untouched', // the control hasn't been blurred
|
||
|
valid: 'is-valid', // model is valid
|
||
|
invalid: 'is-invalid', // model is invalid
|
||
|
pristine: 'is-pristine', // control has not been interacted with
|
||
|
dirty: 'is-dirty' // control has been interacted with
|
||
|
}
|
||
|
})
|
||
7 years ago
|
Vue.use(Vuetify)
|
||
8 years ago
|
|
||
7 years ago
|
// ====================================
|
||
|
// Register Vue Components
|
||
|
// ====================================
|
||
|
|
||
7 years ago
|
Vue.component('editor', () => import(/* webpackChunkName: "editor" */ './components/editor.vue'))
|
||
7 years ago
|
Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue'))
|
||
|
Vue.component('navigator', () => import(/* webpackMode: "eager" */ './components/navigator.vue'))
|
||
7 years ago
|
Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue'))
|
||
7 years ago
|
Vue.component('toggle', () => import(/* webpackMode: "eager" */ './components/toggle.vue'))
|
||
7 years ago
|
|
||
7 years ago
|
let bootstrap = () => {
|
||
8 years ago
|
// ====================================
|
||
|
// Notifications
|
||
|
// ====================================
|
||
8 years ago
|
|
||
7 years ago
|
window.addEventListener('beforeunload', () => {
|
||
8 years ago
|
store.dispatch('startLoading')
|
||
8 years ago
|
})
|
||
8 years ago
|
|
||
8 years ago
|
// ====================================
|
||
|
// Bootstrap Vue
|
||
|
// ====================================
|
||
|
|
||
7 years ago
|
const i18n = localization.init()
|
||
7 years ago
|
window.wiki = new Vue({
|
||
7 years ago
|
el: '#app',
|
||
7 years ago
|
components: {},
|
||
7 years ago
|
mixins: [helpers],
|
||
8 years ago
|
store,
|
||
7 years ago
|
i18n
|
||
8 years ago
|
})
|
||
7 years ago
|
|
||
7 years ago
|
// ----------------------------------
|
||
|
// Dispatch boot ready
|
||
|
// ----------------------------------
|
||
|
|
||
|
window.boot.notify('vue')
|
||
|
|
||
7 years ago
|
// ====================================
|
||
|
// Load Icons
|
||
|
// ====================================
|
||
|
|
||
7 years ago
|
import(/* webpackChunkName: "icons" */ './svg/icons.svg').then(icons => {
|
||
7 years ago
|
document.body.insertAdjacentHTML('beforeend', icons)
|
||
|
})
|
||
7 years ago
|
}
|
||
|
|
||
|
window.boot.onDOMReady(bootstrap)
|