mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
update router folder
This commit is contained in:
parent
9d17ea22d6
commit
c3d25e3a38
4 changed files with 27 additions and 24 deletions
|
@ -1,14 +1,18 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import './plugins/bootstrap-vue'
|
import BootstrapVue from 'bootstrap-vue'
|
||||||
|
|
||||||
import i18n from './i18n'
|
import i18n from './i18n'
|
||||||
import router from './plugins/router'
|
import router from './router'
|
||||||
import store from './store'
|
import store from './store'
|
||||||
|
|
||||||
import * as globalsComponents from './components/globals'
|
import * as globalsComponents from './components/globals'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
// Styles are imported in `src/App.vue` <style>
|
||||||
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
// Register global components
|
// Register global components
|
||||||
for (const component of Object.values(globalsComponents)) {
|
for (const component of Object.values(globalsComponents)) {
|
||||||
Vue.component(component.name, component)
|
Vue.component(component.name, component)
|
||||||
|
|
12
app/src/router/hooks.js
Normal file
12
app/src/router/hooks.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import router from './index.js'
|
||||||
|
import store from '@/store'
|
||||||
|
|
||||||
|
// Before each route request hook
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
// Allow if connected or route is not protected
|
||||||
|
if (store.getters.connected || to.meta.noAuth) {
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
next({ name: 'login', query: { redirect: to.path } })
|
||||||
|
}
|
||||||
|
})
|
|
@ -1,24 +1,11 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router'
|
||||||
import routes from '../routes'
|
import routes from './routes'
|
||||||
import store from '@/store'
|
|
||||||
|
|
||||||
Vue.use(VueRouter)
|
Vue.use(VueRouter)
|
||||||
|
|
||||||
const router = new VueRouter({
|
export default new VueRouter({
|
||||||
// mode: 'history', // this allow all routes to be real ones (without '#')
|
// mode: 'history', // this allow all routes to be real ones (without '#')
|
||||||
base: process.env.BASE_URL,
|
base: process.env.BASE_URL,
|
||||||
routes
|
routes
|
||||||
})
|
})
|
||||||
|
|
||||||
// Before each route request hook
|
|
||||||
router.beforeEach((to, from, next) => {
|
|
||||||
// Allow if connected or route is not protected
|
|
||||||
if (store.getters.connected || to.meta.noAuth) {
|
|
||||||
next()
|
|
||||||
} else {
|
|
||||||
next({ name: 'login', query: { redirect: to.path } })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default router
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import Home from './views/Home'
|
import Home from '@/views/Home'
|
||||||
import Login from './views/Login'
|
import Login from '@/views/Login'
|
||||||
import { UserList, UserCreate, UserInfo, UserEdit } from './views/user'
|
import { UserList, UserCreate, UserInfo, UserEdit } from '@/views/user'
|
||||||
import { GroupList, GroupCreate } from './views/group'
|
import { GroupList, GroupCreate } from '@/views/group'
|
||||||
import { DomainList, DomainAdd, DomainInfo, DomainDns, DomainCert } from './views/domain'
|
import { DomainList, DomainAdd, DomainInfo, DomainDns, DomainCert } from '@/views/domain'
|
||||||
import { ServiceList, ServiceInfo } from './views/service'
|
import { ServiceList, ServiceInfo } from '@/views/service'
|
||||||
import { ToolList, ToolLogs } from './views/tool'
|
import { ToolList, ToolLogs } from '@/views/tool'
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{ name: 'home', path: '/', component: Home },
|
{ name: 'home', path: '/', component: Home },
|
||||||
|
|
Loading…
Add table
Reference in a new issue