akkoma-fe/src/main.js

116 lines
3.3 KiB
JavaScript
Raw Normal View History

2016-10-26 14:46:32 +00:00
import Vue from 'vue'
2016-10-26 17:03:55 +00:00
import VueRouter from 'vue-router'
import Vuex from 'vuex'
import 'custom-event-polyfill'
import './lib/event_target_polyfill.js'
2018-09-09 16:36:13 +00:00
import interfaceModule from './modules/interface.js'
2018-09-09 18:21:23 +00:00
import instanceModule from './modules/instance.js'
2016-10-27 16:03:25 +00:00
import statusesModule from './modules/statuses.js'
import usersModule from './modules/users.js'
import apiModule from './modules/api.js'
import configModule from './modules/config.js'
import shoutModule from './modules/shout.js'
2018-10-26 13:16:23 +00:00
import oauthModule from './modules/oauth.js'
import authFlowModule from './modules/auth_flow.js'
import mediaViewerModule from './modules/media_viewer.js'
import oauthTokensModule from './modules/oauth_tokens.js'
2019-03-19 08:53:11 +00:00
import reportsModule from './modules/reports.js'
import pollsModule from './modules/polls.js'
import postStatusModule from './modules/postStatus.js'
2020-05-07 13:10:53 +00:00
import chatsModule from './modules/chats.js'
2016-10-26 17:03:55 +00:00
2017-11-07 14:14:37 +00:00
import VueI18n from 'vue-i18n'
import createPersistedState from './lib/persisted_state.js'
2018-12-25 13:43:18 +00:00
import pushNotifications from './lib/push_notifications_plugin.js'
2017-02-14 21:42:13 +00:00
2017-11-07 14:14:37 +00:00
import messages from './i18n/messages.js'
2019-04-02 17:18:36 +00:00
import VueClickOutside from 'v-click-outside'
2019-05-20 20:19:59 +00:00
import PortalVue from 'portal-vue'
2019-07-19 16:27:03 +00:00
import VBodyScrollLock from './directives/body_scroll_lock'
2018-01-26 14:11:34 +00:00
import { FontAwesomeIcon, FontAwesomeLayers } from '@fortawesome/vue-fontawesome'
2018-10-26 13:16:23 +00:00
import afterStoreSetup from './boot/after_store.js'
2017-11-08 20:18:42 +00:00
const currentLocale = (window.navigator.language || 'en').split('-')[0]
2016-10-26 17:03:55 +00:00
Vue.use(Vuex)
Vue.use(VueRouter)
2017-11-07 14:14:37 +00:00
Vue.use(VueI18n)
2019-04-02 17:18:36 +00:00
Vue.use(VueClickOutside)
2019-05-20 20:19:59 +00:00
Vue.use(PortalVue)
2019-07-19 16:27:03 +00:00
Vue.use(VBodyScrollLock)
2016-10-26 17:03:55 +00:00
Vue.component('FAIcon', FontAwesomeIcon)
Vue.component('FALayers', FontAwesomeLayers)
2017-11-07 14:14:37 +00:00
const i18n = new VueI18n({
// By default, use the browser locale, we will update it if neccessary
locale: 'en',
2017-11-07 14:14:37 +00:00
fallbackLocale: 'en',
messages: messages.default
2017-11-07 14:14:37 +00:00
})
messages.setLanguage(i18n, currentLocale)
2018-10-26 13:16:23 +00:00
const persistedStateOptions = {
paths: [
'config',
'users.lastLoginName',
'oauth'
]
2019-03-13 10:29:45 +00:00
};
2018-12-13 11:04:09 +00:00
2019-03-13 10:29:45 +00:00
(async () => {
let storageError = false
const plugins = [pushNotifications]
try {
const persistedState = await createPersistedState(persistedStateOptions)
plugins.push(persistedState)
} catch (e) {
console.error(e)
storageError = true
}
2018-10-26 13:16:23 +00:00
const store = new Vuex.Store({
modules: {
2019-04-01 01:59:18 +00:00
i18n: {
getters: {
i18n: () => i18n
}
},
2018-10-26 13:16:23 +00:00
interface: interfaceModule,
instance: instanceModule,
statuses: statusesModule,
users: usersModule,
api: apiModule,
config: configModule,
shout: shoutModule,
oauth: oauthModule,
authFlow: authFlowModule,
mediaViewer: mediaViewerModule,
2019-03-19 08:53:11 +00:00
oauthTokens: oauthTokensModule,
reports: reportsModule,
polls: pollsModule,
2020-05-07 13:10:53 +00:00
postStatus: postStatusModule,
chats: chatsModule
2018-10-26 13:16:23 +00:00
},
plugins,
2018-10-26 13:16:23 +00:00
strict: false // Socket modifies itself, let's ignore this for now.
// strict: process.env.NODE_ENV !== 'production'
2018-02-03 15:27:33 +00:00
})
if (storageError) {
store.dispatch('pushGlobalNotice', { messageKey: 'errors.storage_unavailable', level: 'error' })
}
afterStoreSetup({ store, i18n })
2019-03-13 10:29:45 +00:00
})()
// These are inlined by webpack's DefinePlugin
/* eslint-disable */
window.___pleromafe_mode = process.env
window.___pleromafe_commit_hash = COMMIT_HASH
window.___pleromafe_dev_overrides = DEV_OVERRIDES