start with nuxt
This commit is contained in:
7
plugins/README.md
Normal file
7
plugins/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# PLUGINS
|
||||
|
||||
**This directory is not required, you can delete it if you don't want to use it.**
|
||||
|
||||
This directory contains Javascript plugins that you want to run before mounting the root Vue.js application.
|
||||
|
||||
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins).
|
||||
82
plugins/api.js
Normal file
82
plugins/api.js
Normal file
@@ -0,0 +1,82 @@
|
||||
import axios from 'axios'
|
||||
import { getters } from '@/store'
|
||||
const api = axios.create({
|
||||
baseURL: process.env.NODE_ENV === 'development' ? 'http://localhost:3000/api' : '/api',
|
||||
withCredentials: true,
|
||||
responseType: 'json',
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Credentials': 'true',
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
function get(path) {
|
||||
return api.get(path) //, { headers: { 'Authorization': getters.token } })
|
||||
.then(res => res.data)
|
||||
// .catch((e) => {
|
||||
// if (e.response.status === 403) {
|
||||
// // store.commit('logout') // TOFIX
|
||||
// return false
|
||||
// }
|
||||
// throw e.response && e.response.data &&
|
||||
// e.response.data.errors && e.response.data.errors[0].message
|
||||
// })
|
||||
}
|
||||
|
||||
function post(path, data) {
|
||||
return api.post(path, data, { headers: { 'Authorization': getters.token } })
|
||||
.then(res => res.data)
|
||||
// .catch((e) => {
|
||||
// if (e.response.status === 403) {
|
||||
// // store.commit('logout') // TOFIX
|
||||
// return false
|
||||
// }
|
||||
// throw e.response && e.response.data &&
|
||||
// e.response.data.errors && e.response.data.errors[0].message
|
||||
// })
|
||||
}
|
||||
function put(path, data) {
|
||||
return api.put(path, data, { headers: { 'Authorization': getters.token } })
|
||||
.then(ret => ret.data)
|
||||
}
|
||||
|
||||
function del(path) {
|
||||
return api.delete(path, { headers: { 'Authorization': getters.token } }).then(ret => ret.data)
|
||||
}
|
||||
|
||||
export default {
|
||||
login: (email, password) => post('/login', { email, password }),
|
||||
register: user => post('/user', user),
|
||||
|
||||
// password recovery
|
||||
forgotPassword: email => post('/user/recover', { email }),
|
||||
checkRecoverCode: recover_code => post('/user/check_recover_code', { recover_code }),
|
||||
recoverPassword: (recover_code, password) => post('/user/recover_password', { recover_code, password }),
|
||||
|
||||
getAllEvents: (month, year) => get(`/event/${year}/${month}/`),
|
||||
getUnconfirmedEvents: () => get('/event/unconfirmed'),
|
||||
|
||||
confirmEvent: id => get(`/event/confirm/${id}`),
|
||||
unconfirmEvent: id => get(`/event/unconfirm/${id}`),
|
||||
|
||||
addNotification: notification => post('/event/notification', notification),
|
||||
delNotification: code => del(`/event/notification/${code}`),
|
||||
|
||||
addEvent: event => post('/user/event', event),
|
||||
updateEvent: event => put('/user/event', event),
|
||||
|
||||
updatePlace: place => put('/place', place),
|
||||
delEvent: eventId => del(`/user/event/${eventId}`),
|
||||
getEvent: eventId => get(`/event/${eventId}`),
|
||||
getMeta: () => get('/event/meta'),
|
||||
getUser: () => get('/user'),
|
||||
getUsers: () => get('/users'),
|
||||
updateTag: tag => put('/tag', tag),
|
||||
updateUser: user => put('/user', user),
|
||||
getAuthURL: mastodonInstance => post('/user/getauthurl', mastodonInstance),
|
||||
setCode: code => post('/user/code', code),
|
||||
getAdminSettings: () => get('/settings')
|
||||
// setAdminSetting: (key, value) => post('/settings', { key, value })
|
||||
}
|
||||
6
plugins/bootstrap-vue.js
vendored
Normal file
6
plugins/bootstrap-vue.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import BootstrapVue from 'bootstrap-vue'
|
||||
|
||||
export default () => {
|
||||
Vue.use(BootstrapVue)
|
||||
}
|
||||
26
plugins/element-ui.js
Normal file
26
plugins/element-ui.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import Vue from 'vue'
|
||||
import { Button, Select, Tag, Option, Table, FormItem, Card,
|
||||
Form, Tabs, TabPane, Switch, Input, Loading, TimeSelect,
|
||||
TableColumn, ColorPicker, Pagination, Popover } from 'element-ui'
|
||||
// import locale from 'element-ui/lib/locale/lang/en'
|
||||
|
||||
export default () => {
|
||||
Vue.use(Button)
|
||||
Vue.use(Popover)
|
||||
Vue.use(Card)
|
||||
Vue.use(Select)
|
||||
Vue.use(Tag)
|
||||
Vue.use(Input)
|
||||
Vue.use(Tabs)
|
||||
Vue.use(TabPane)
|
||||
Vue.use(Option)
|
||||
Vue.use(Switch)
|
||||
Vue.use(ColorPicker)
|
||||
Vue.use(Table)
|
||||
Vue.use(TableColumn)
|
||||
Vue.use(Pagination)
|
||||
Vue.use(FormItem)
|
||||
Vue.use(Form)
|
||||
Vue.use(TimeSelect)
|
||||
Vue.use(Loading.directive)
|
||||
}
|
||||
8
plugins/filters.js
Normal file
8
plugins/filters.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import Vue from 'vue'
|
||||
import moment from 'dayjs'
|
||||
import 'dayjs/locale/it'
|
||||
moment.locale('it')
|
||||
|
||||
Vue.filter('datetime', value => moment(value).format('ddd, D MMMM HH:mm'))
|
||||
Vue.filter('short_datetime', value => moment(value).format('D/MM HH:mm'))
|
||||
Vue.filter('hour', value => moment(value).format('HH:mm'))
|
||||
25
plugins/i18n.js
Normal file
25
plugins/i18n.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Vue from 'vue'
|
||||
import VueI18n from 'vue-i18n'
|
||||
|
||||
Vue.use(VueI18n)
|
||||
|
||||
export default ({ app, store }) => {
|
||||
// Set i18n instance on app
|
||||
// This way we can use it in middleware and pages asyncData/fetch
|
||||
app.i18n = new VueI18n({
|
||||
locale: store.state.locale,
|
||||
fallbackLocale: 'en'
|
||||
// messages: {
|
||||
// 'en': require('~/locales/en.json'),
|
||||
// 'fr': require('~/locales/fr.json')
|
||||
// }
|
||||
})
|
||||
|
||||
app.i18n.path = (link) => {
|
||||
if (app.i18n.locale === app.i18n.fallbackLocale) {
|
||||
return `/${link}`
|
||||
}
|
||||
|
||||
return `/${app.i18n.locale}/${link}`
|
||||
}
|
||||
}
|
||||
6
plugins/magic-grid.js
Normal file
6
plugins/magic-grid.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import MagicGrid from 'vue-magic-grid'
|
||||
|
||||
export default () => {
|
||||
Vue.use(MagicGrid)
|
||||
}
|
||||
9
plugins/v-calendar.js
Normal file
9
plugins/v-calendar.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import Vue from 'vue'
|
||||
import VCalendar from 'v-calendar'
|
||||
import 'v-calendar/lib/v-calendar.min.css'
|
||||
|
||||
export default () => {
|
||||
Vue.use(VCalendar, {
|
||||
firstDayOfWeek: 2
|
||||
})
|
||||
}
|
||||
24
plugins/vue-awesome.js
Normal file
24
plugins/vue-awesome.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import Vue from 'vue'
|
||||
import 'vue-awesome/icons/lock'
|
||||
import 'vue-awesome/icons/user'
|
||||
import 'vue-awesome/icons/plus'
|
||||
import 'vue-awesome/icons/cog'
|
||||
import 'vue-awesome/icons/tools'
|
||||
import 'vue-awesome/icons/file-export'
|
||||
import 'vue-awesome/icons/sign-out-alt'
|
||||
import 'vue-awesome/icons/clock'
|
||||
import 'vue-awesome/icons/map-marker-alt'
|
||||
import 'vue-awesome/icons/file-alt'
|
||||
import 'vue-awesome/icons/image'
|
||||
import 'vue-awesome/icons/tag'
|
||||
import 'vue-awesome/icons/users'
|
||||
import 'vue-awesome/icons/calendar'
|
||||
import 'vue-awesome/icons/edit'
|
||||
import 'vue-awesome/icons/envelope-open-text'
|
||||
import 'vue-awesome/icons/user-secret'
|
||||
import 'vue-awesome/icons/question-circle'
|
||||
import Icon from 'vue-awesome/components/Icon'
|
||||
|
||||
export default () => {
|
||||
Vue.component('v-icon', Icon)
|
||||
}
|
||||
Reference in New Issue
Block a user