| 1 |
import Vue from 'vue'; |
| 2 |
import UniqueId from 'vue-unique-id'; |
| 3 |
import VueRouter from 'vue-router' |
| 4 |
import axios from 'axios'; |
| 5 |
import Fragment from 'vue-fragment'; |
| 6 |
import VueSweetalert2 from 'vue-sweetalert2'; |
| 7 |
|
| 8 |
import OptionsScreen from './Pages/OptionsScreen'; |
| 9 |
import Stats from './Pages/Stats'; |
| 10 |
import Settings from './Pages/Settings'; |
| 11 |
import AdvancedSettings from './Pages/AdvancedSettings'; |
| 12 |
import License from './Pages/License'; |
| 13 |
|
| 14 |
window.axios = axios; |
| 15 |
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; |
| 16 |
window.axios.defaults.headers.common['X-WP-Nonce'] = window.ezcache.rest_nonce; |
| 17 |
|
| 18 |
Vue.use(UniqueId); |
| 19 |
Vue.use(VueRouter); |
| 20 |
Vue.use(Fragment.Plugin); |
| 21 |
Vue.use(VueSweetalert2); |
| 22 |
|
| 23 |
let {trans, ...ezcache} = window.ezcache; |
| 24 |
|
| 25 |
Vue.prototype.$window = window; |
| 26 |
Vue.prototype.$eventBus = new Vue(); |
| 27 |
Vue.prototype.$wp = { |
| 28 |
...ezcache, |
| 29 |
trans(key) { |
| 30 |
return trans[key] ? trans[key] : `__${key}__`; |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
Vue.component('ezc-options', OptionsScreen); |
| 35 |
|
| 36 |
Vue.mixin({ |
| 37 |
methods: { |
| 38 |
toast(text, type='success') { |
| 39 |
return this.$swal({ position: 'bottom-start', type: type, text: text, timer: 2000, toast: true, showCancelButton: false, showCloseButton: false, showConfirmButton: false }); |
| 40 |
} |
| 41 |
} |
| 42 |
}); |
| 43 |
|
| 44 |
const routes = [ |
| 45 |
{ path: '/', component: Stats }, |
| 46 |
{ path: '/settings', component: Settings }, |
| 47 |
{ path: '/advanced', component: AdvancedSettings }, |
| 48 |
{ path: '/license', component: License }, |
| 49 |
]; |
| 50 |
|
| 51 |
const router = new VueRouter({ routes }); |
| 52 |
|
| 53 |
new Vue({ router }).$mount('#ezcache-options'); |
| 54 |
|