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.

165 lines
6.0 KiB

  1. 'use strict'
  2. /* global siteConfig */
  3. /* eslint-disable no-new */
  4. import CONSTANTS from './constants'
  5. import Vue from 'vue'
  6. import VueResource from 'vue-resource'
  7. import VueClipboards from 'vue-clipboards'
  8. import VeeValidate from 'vee-validate'
  9. import { ApolloClient, createBatchingNetworkInterface } from 'apollo-client'
  10. import store from './store'
  11. // ====================================
  12. // Load Modules
  13. // ====================================
  14. import localization from './modules/localization'
  15. // ====================================
  16. // Load Helpers
  17. // ====================================
  18. import helpers from './helpers'
  19. // ====================================
  20. // Load Vue Components
  21. // ====================================
  22. import alertComponent from './components/alert.vue'
  23. import anchorComponent from './components/anchor.vue'
  24. import colorPickerComponent from './components/color-picker.vue'
  25. import editorCodeblockComponent from './components/editor-codeblock.vue'
  26. import editorFileComponent from './components/editor-file.vue'
  27. import editorVideoComponent from './components/editor-video.vue'
  28. import historyComponent from './components/history.vue'
  29. import loadingSpinnerComponent from './components/loading-spinner.vue'
  30. import loginComponent from './components/login.vue'
  31. import modalCreatePageComponent from './components/modal-create-page.vue'
  32. import modalCreateUserComponent from './components/modal-create-user.vue'
  33. import modalDeletePageComponent from './components/modal-delete-page.vue'
  34. import modalDeleteUserComponent from './components/modal-delete-user.vue'
  35. import modalDiscardPageComponent from './components/modal-discard-page.vue'
  36. import modalMovePageComponent from './components/modal-move-page.vue'
  37. import modalProfile2faComponent from './components/modal-profile-2fa.vue'
  38. import modalUpgradeSystemComponent from './components/modal-upgrade-system.vue'
  39. import pageLoaderComponent from './components/page-loader.vue'
  40. import searchComponent from './components/search.vue'
  41. import toggleComponent from './components/toggle.vue'
  42. import treeComponent from './components/tree.vue'
  43. import adminEditUserComponent from './pages/admin-edit-user.component.js'
  44. import adminProfileComponent from './pages/admin-profile.component.js'
  45. import adminSettingsComponent from './pages/admin-settings.component.js'
  46. import adminThemeComponent from './pages/admin-theme.component.js'
  47. import configManagerComponent from './components/config-manager.component.js'
  48. import contentViewComponent from './pages/content-view.component.js'
  49. import editorComponent from './components/editor.component.js'
  50. import sourceViewComponent from './pages/source-view.component.js'
  51. // ====================================
  52. // Initialize Global Vars
  53. // ====================================
  54. window.wiki = null
  55. window.CONSTANTS = CONSTANTS
  56. // ====================================
  57. // Initialize Apollo Client (GraphQL)
  58. // ====================================
  59. window.graphQL = new ApolloClient({
  60. networkInterface: createBatchingNetworkInterface({
  61. uri: window.location.protocol + '//' + window.location.host + siteConfig.path + '/graphql'
  62. }),
  63. connectToDevTools: true
  64. })
  65. // ====================================
  66. // Initialize Vue Modules
  67. // ====================================
  68. Vue.use(VueResource)
  69. Vue.use(VueClipboards)
  70. Vue.use(localization.VueI18Next)
  71. Vue.use(helpers)
  72. Vue.use(VeeValidate, {
  73. enableAutoClasses: true,
  74. classNames: {
  75. touched: 'is-touched', // the control has been blurred
  76. untouched: 'is-untouched', // the control hasn't been blurred
  77. valid: 'is-valid', // model is valid
  78. invalid: 'is-invalid', // model is invalid
  79. pristine: 'is-pristine', // control has not been interacted with
  80. dirty: 'is-dirty' // control has been interacted with
  81. }
  82. })
  83. // ====================================
  84. // Register Vue Components
  85. // ====================================
  86. Vue.component('alert', alertComponent)
  87. Vue.component('adminEditUser', adminEditUserComponent)
  88. Vue.component('adminProfile', adminProfileComponent)
  89. Vue.component('adminSettings', adminSettingsComponent)
  90. Vue.component('adminTheme', adminThemeComponent)
  91. Vue.component('anchor', anchorComponent)
  92. Vue.component('colorPicker', colorPickerComponent)
  93. Vue.component('configManager', configManagerComponent)
  94. Vue.component('contentView', contentViewComponent)
  95. Vue.component('editor', editorComponent)
  96. Vue.component('editorCodeblock', editorCodeblockComponent)
  97. Vue.component('editorFile', editorFileComponent)
  98. Vue.component('editorVideo', editorVideoComponent)
  99. Vue.component('history', historyComponent)
  100. Vue.component('loadingSpinner', loadingSpinnerComponent)
  101. Vue.component('login', loginComponent)
  102. Vue.component('modalCreatePage', modalCreatePageComponent)
  103. Vue.component('modalCreateUser', modalCreateUserComponent)
  104. Vue.component('modalDeletePage', modalDeletePageComponent)
  105. Vue.component('modalDeleteUser', modalDeleteUserComponent)
  106. Vue.component('modalDiscardPage', modalDiscardPageComponent)
  107. Vue.component('modalMovePage', modalMovePageComponent)
  108. Vue.component('modalProfile2fa', modalProfile2faComponent)
  109. Vue.component('modalUpgradeSystem', modalUpgradeSystemComponent)
  110. Vue.component('pageLoader', pageLoaderComponent)
  111. Vue.component('search', searchComponent)
  112. Vue.component('sourceView', sourceViewComponent)
  113. Vue.component('toggle', toggleComponent)
  114. Vue.component('tree', treeComponent)
  115. document.addEventListener('DOMContentLoaded', ev => {
  116. // ====================================
  117. // Notifications
  118. // ====================================
  119. window.addEventListener('beforeunload', () => {
  120. store.dispatch('startLoading')
  121. })
  122. // ====================================
  123. // Bootstrap Vue
  124. // ====================================
  125. const i18n = localization.init()
  126. window.wiki = new Vue({
  127. mixins: [helpers],
  128. components: {},
  129. store,
  130. i18n,
  131. el: '#app',
  132. methods: {
  133. changeTheme(opts) {
  134. this.$el.className = `has-stickynav is-primary-${opts.primary} is-alternate-${opts.alt}`
  135. this.$refs.header.className = `nav is-${opts.primary}`
  136. this.$refs.footer.className = `footer is-${opts.footer}`
  137. }
  138. },
  139. mounted() {
  140. }
  141. })
  142. })