diff --git a/package.json b/package.json index 5d50f98..dab4121 100755 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "license": "MIT", "private": true, "scripts": { - "build:clean": "rm ./public_html/js/bundle@*.js*", + "build:clean": "rm ./public_html/js/bundle@*.js*", "build:bundle": "cross-env NODE_ENV=production webpack --progress --hide-modules", - "build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules", - "dev": "npm run build:clean; npm run build:dev", - "build": "npm run build:clean; npm run build:bundle" + "build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules", + "dev": "npm run build:clean; npm run build:dev", + "build": "npm run build:clean; npm run build:bundle" }, "dependencies": { "vue": "^2.5.9" @@ -30,6 +30,7 @@ "file-loader": "^1.1.4", "vue-loader": "^13.0.5", "vue-template-compiler": "^2.5.9", + "vue-router": "^2.5.3", "webpack": "^3.8.1", "webpack-dev-server": "^2.9.5" } diff --git a/view/main.js b/view/main.js index 7c0d973..7f099df 100755 --- a/view/main.js +++ b/view/main.js @@ -2,11 +2,13 @@ ---------------------------------------------------------*/ /* (1) NPM libs */ import Vue from 'vue' +import VueRouter from 'vue-router' /* (2) Internal libs */ -import {API} from './lib/api-es6' -import {InfoBox} from './lib/infobox-es6' +import {API} from './lib/api-es6' +import {InfoBox} from './lib/infobox-es6' import {WSClient,WSClientBuilder} from './lib/ws-client-es6' +import routes from './routes' /* (3) Vues */ import wrapper_vue from './vue/wrapper.vue' @@ -25,13 +27,18 @@ require('./vue-config'); window.gstore.add('server', window._SERVER); window.infobox = new InfoBox(window.gstore.data.info); -/* (4) Render view */ +/* (4) Init vue router */ +Vue.use(VueRouter); +window.router = new VueRouter({ + mode: 'history', + routes: routes[0] +}); + +/* (5) Render view */ new Vue({ el: '#main-vue', - render: h => h(wrapper_vue), - data: { - gstore: window.gstore.data - } + router: window.router, + render: h => h(wrapper_vue) }) diff --git a/view/routes.js b/view/routes.js new file mode 100644 index 0000000..6820dcf --- /dev/null +++ b/view/routes.js @@ -0,0 +1,19 @@ +export default { 0: [ + + { + path: '/dashboard/', + component: require('./vue/container/dashboard.vue') + }, { + path: '/profile/', + component: require('./vue/container/profile.vue') + }, { + path: '/message/', + component: require('./vue/container/message.vue') + }, { + path: '/notifications/', + component: require('./vue/container/notifications.vue') + }, { + path: '*', + redirect: '/dashboard/' + } +]} \ No newline at end of file diff --git a/view/vue/wrapper.vue b/view/vue/wrapper.vue index 7dbfd4b..3d24162 100755 --- a/view/vue/wrapper.vue +++ b/view/vue/wrapper.vue @@ -8,10 +8,7 @@ - - - - + @@ -25,24 +22,14 @@ import header_vue from './header.vue'; import menu_vue from './menu.vue'; -import dashboardContainer_vue from './container/dashboard.vue'; -import profileContainer_vue from './container/profile.vue'; -import messageContainer_vue from './container/message.vue'; -import notificationsContainer_vue from './container/notifications.vue'; - - export default { name: 'wrapper', data(){ return { gstore: window.gstore.data }; }, components: { - 'HeaderComp': header_vue, - 'MenuComp': menu_vue, - 'DashboardContainer': dashboardContainer_vue, - 'ProfileContainer': profileContainer_vue, - 'MessageContainer': messageContainer_vue, - 'NotificationsContainer': notificationsContainer_vue + 'HeaderComp': header_vue, + 'MenuComp': menu_vue } } \ No newline at end of file