Skip to content

Commit 787a0f5

Browse files
committed
Implemented home button navigation
Also fixed uncaught exceptions when redirecting with `router.push`, see vuejs/vue-router#2932
1 parent df82dc3 commit 787a0f5

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

mts-frontend/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width,initial-scale=1.0">
77
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
8-
<link rel="stylesheet" href="./fonts.css" />
8+
<link rel="stylesheet" type="text/css" href="./fonts.css" />
99
<title>OpenMTS</title>
1010
</head>
1111
<body>

mts-frontend/src/components/Navbar.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<header id="navbar">
3-
<div id="navbar-title" :class="{collapsed : menuCollapsed}">
3+
<div id="navbar-title" :class="{collapsed : menuCollapsed}" @click="navigateHome">
44
<i class="el-icon-s-home" v-if="menuCollapsed" />
55
<span id="navbar-title-text" v-else>OpenMTS</span>
66
</div>
@@ -55,18 +55,24 @@ export default {
5555
},
5656
},
5757
methods: {
58+
navigateHome: function() {
59+
this.$router.push({ path: '/' }, () => {});
60+
},
5861
toggleSidebar: function() {
5962
this.$store.commit('toggleSidebar');
6063
},
6164
userMenuAction: function(command) {
6265
switch (command) {
6366
case 'account':
64-
this.$router.push({ name: command });
67+
this.$router.push({ path: '/private/' + command });
6568
break;
6669
case 'logout':
6770
this.$store.commit('logout');
6871
this.$store.commit('expandSidebar');
69-
this.$router.push({ path: '/' });
72+
this.$router.push({ path: '/login' }, () => {});
73+
break;
74+
default:
75+
console.error(`Invalid user menu action '${command}' was triggered.`);
7076
break;
7177
}
7278
},
@@ -95,6 +101,9 @@ export default {
95101
background-color: $color-dark-accent;
96102
overflow: hidden;
97103
transition: all 0.5s ease-in-out;
104+
&:hover {
105+
cursor: pointer;
106+
}
98107
&.collapsed {
99108
width: 47px;
100109
}

mts-frontend/src/router/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import store from '../store';
1414
const routes = [
1515
{
1616
path: '/',
17-
name: 'home',
1817
beforeEnter: (_to, _from, next) => {
1918
if (store.state.token === null) {
2019
next({ path: '/login' });
@@ -25,28 +24,25 @@ const routes = [
2524
},
2625
{
2726
path: '/login',
28-
name: 'public',
2927
component: Public,
3028
},
3129
{
3230
path: '/private',
33-
name: 'private',
3431
component: Private,
3532
beforeEnter: function(_to, _from, next) {
3633
if (store.state.token === null) {
37-
next({ path: '/' });
34+
next({ path: '/login' });
3835
} else {
3936
next();
4037
}
4138
},
4239
children: [
4340
{
44-
path: '/',
41+
path: '',
4542
component: Dashboard,
4643
},
4744
{
48-
path: '/account',
49-
name: 'account',
45+
path: 'account',
5046
component: Account,
5147
},
5248
],

0 commit comments

Comments
 (0)