reordered for custom views
This commit is contained in:
@@ -6,22 +6,26 @@
|
||||
{
|
||||
"name": "Login",
|
||||
"to": "/login",
|
||||
"icon": "fa-home"
|
||||
"icon": "fa-home",
|
||||
"content": "<login-form></login-form>"
|
||||
},
|
||||
{
|
||||
"name": "Dashboard",
|
||||
"to": "/",
|
||||
"icon": "fa-home"
|
||||
"icon": "fa-home",
|
||||
"content": "<dashboard></dashboard>"
|
||||
},
|
||||
{
|
||||
"name": "Userlist",
|
||||
"to": "/userlist",
|
||||
"icon": "fa-news"
|
||||
"icon": "fa-news",
|
||||
"content": "<userlist></userlist>"
|
||||
},
|
||||
{
|
||||
"name": "Logout",
|
||||
"to": "/logout",
|
||||
"icon": "fa-lock"
|
||||
"icon": "fa-lock",
|
||||
"content": "<logout></logout>"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Vue Example</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
.component-fade-enter-active, .component-fade-leave-active {
|
||||
transition: opacity .3s ease;
|
||||
@@ -14,7 +15,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="vue-app">
|
||||
<app :navigation-items="navItems"></app>
|
||||
<app></app>
|
||||
</div>
|
||||
<script src="build/app.js"></script>
|
||||
</body>
|
||||
|
||||
@@ -17,16 +17,9 @@ export default {
|
||||
components: {
|
||||
Navigation
|
||||
},
|
||||
props: {
|
||||
navigationItems: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [ ];
|
||||
}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
navigationItems: this.$store.state.navigation
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
59
src/main.js
59
src/main.js
@@ -5,37 +5,12 @@ import Axios from 'axios';
|
||||
import JwtDecode from 'jwt-decode';
|
||||
|
||||
import App from './app.vue';
|
||||
import Dashboard from './components/dashboard.vue';
|
||||
import LoginForm from './components/forms/login.vue';
|
||||
import Logout from './components/logout.vue';
|
||||
import Userlist from './components/userlist.vue';
|
||||
import Views from './views/views.js';
|
||||
|
||||
Vue.use(VueRouter);
|
||||
Vue.use(Vuex);
|
||||
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/login',
|
||||
component: LoginForm
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: Dashboard
|
||||
},
|
||||
{
|
||||
path: '/userlist',
|
||||
component: Userlist
|
||||
},
|
||||
{
|
||||
path: '/logout',
|
||||
component: Logout
|
||||
}
|
||||
];
|
||||
|
||||
const router = new VueRouter({
|
||||
routes
|
||||
});
|
||||
const router = new VueRouter();
|
||||
|
||||
const store = new Vuex.Store({
|
||||
state: {
|
||||
@@ -202,20 +177,36 @@ Axios.get('conf/init.json')
|
||||
alert('invalid data in init.json');
|
||||
return;
|
||||
}
|
||||
store.commit("setNavigation", results.data.navigation);
|
||||
let navigation = [];
|
||||
results.data.navigation.forEach(({name, to}) => navigation.push({name, to}));
|
||||
|
||||
store.commit("setNavigation", navigation);
|
||||
|
||||
// set api config in store
|
||||
store.commit("setAPI", results.data.api);
|
||||
|
||||
// add routes
|
||||
let routes = [];
|
||||
let rIdx = 0;
|
||||
results.data.navigation.forEach(({to, content, data}) => routes.push({
|
||||
path: to,
|
||||
component: Vue.component('main' + rIdx++, {
|
||||
template: '<div id="main'+ rIdx + '">' + content + '</div>',
|
||||
components: Views,
|
||||
data() {
|
||||
if (typeof data != 'object') {
|
||||
return {};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
})
|
||||
}));
|
||||
router.addRoutes(routes);
|
||||
|
||||
// load app, when init finishs
|
||||
new Vue({
|
||||
el: '#vue-app',
|
||||
components: {
|
||||
App
|
||||
},
|
||||
data: {
|
||||
navItems: store.state.navigation
|
||||
},
|
||||
render: h => h(App),
|
||||
router,
|
||||
store
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MyForm from '../my-form.vue';
|
||||
import MyForm from '../../components/my-form.vue';
|
||||
|
||||
export default {
|
||||
name: 'LoginForm',
|
||||
@@ -6,7 +6,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ScrollTable from './scroll-table.vue';
|
||||
import ScrollTable from '../../components/scroll-table.vue';
|
||||
|
||||
export default {
|
||||
name: "Userlist",
|
||||
11
src/views/views.js
Normal file
11
src/views/views.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import Dashboard from './dashboard.vue';
|
||||
import LoginForm from './forms/login.vue';
|
||||
import Logout from './forms/logout.vue';
|
||||
import Userlist from './lists/userlist.vue';
|
||||
|
||||
export default {
|
||||
Dashboard,
|
||||
LoginForm,
|
||||
Logout,
|
||||
Userlist
|
||||
}
|
||||
Reference in New Issue
Block a user