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