Skip to content

Commit 6c6f2cf

Browse files
got menu to close on logout
1 parent 767a12c commit 6c6f2cf

File tree

3 files changed

+73
-46
lines changed

3 files changed

+73
-46
lines changed

Diff for: src/App.vue

+6-45
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,21 @@
11
<template>
22
<ion-app>
33
<ion-split-pane content-id="main">
4-
<ion-menu content-id="main" v-if="$store.state.user">
5-
<ion-header>
6-
<ion-toolbar color="primary">
7-
<ion-title>Menu</ion-title>
8-
</ion-toolbar>
9-
</ion-header>
10-
11-
<ion-content>
12-
<ion-list>
13-
<ion-list-header>Navigate</ion-list-header>
14-
<ion-menu-toggle auto-hide="false">
15-
<ion-item button @click="$router.push('/')">
16-
<ion-icon name="home"></ion-icon>
17-
<ion-label>
18-
<span :class="[{boldLabel : isActive('/') }, 'menu-label']">Home</span>
19-
</ion-label>
20-
</ion-item>
21-
</ion-menu-toggle>
22-
<ion-menu-toggle auto-hide="false">
23-
<ion-item button @click="$router.push('/about')">
24-
<ion-icon name="help"></ion-icon>
25-
<ion-label>
26-
<span :class="[{boldLabel : isActive('/about') }, 'menu-label']">About</span>
27-
</ion-label>
28-
</ion-item>
29-
</ion-menu-toggle>
30-
</ion-list>
31-
</ion-content>
32-
<ion-footer style="text-align:center" class="ion-padding">
33-
<ion-button @click="logout()">LOGOUT</ion-button>
34-
</ion-footer>
35-
</ion-menu>
36-
4+
<Menu />
375
<ion-vue-router id="main"></ion-vue-router>
386
</ion-split-pane>
397
</ion-app>
408
</template>
419

4210
<script>
43-
import store from "./store";
44-
11+
import Menu from "./components/Menu";
4512
export default {
4613
name: "App",
47-
components: {},
14+
components: {
15+
Menu
16+
},
4817
computed: {},
49-
methods: {
50-
isActive(_path) {
51-
return this.$route.path == _path;
52-
},
53-
async logout() {
54-
await store.dispatch("user/logout");
55-
this.$router.replace("/login");
56-
}
57-
}
18+
methods: {}
5819
};
5920
</script>
6021
<style scoped>

Diff for: src/components/Menu.vue

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* eslint-disable no-debugger */
2+
<template>
3+
<ion-menu content-id="main" side="start" id="main-menu" v-if="$store.state.user.user">
4+
<ion-header>
5+
<ion-toolbar color="primary">
6+
<ion-title>Menu</ion-title>
7+
</ion-toolbar>
8+
</ion-header>
9+
10+
<ion-content>
11+
<ion-list>
12+
<ion-list-header>
13+
<h2>{{$store.state.user.user.email}}</h2>
14+
</ion-list-header>
15+
<ion-menu-toggle auto-hide="false">
16+
<ion-item button @click="$router.push('/')">
17+
<ion-icon name="home"></ion-icon>
18+
<ion-label>
19+
<span :class="[{boldLabel : isActive('/') }, 'menu-label']">Home</span>
20+
</ion-label>
21+
</ion-item>
22+
</ion-menu-toggle>
23+
<ion-menu-toggle auto-hide="false">
24+
<ion-item button @click="$router.push('/about')">
25+
<ion-icon name="help"></ion-icon>
26+
<ion-label>
27+
<span :class="[{boldLabel : isActive('/about') }, 'menu-label']">About</span>
28+
</ion-label>
29+
</ion-item>
30+
</ion-menu-toggle>
31+
</ion-list>
32+
</ion-content>
33+
<ion-footer style="text-align:center" class="ion-padding">
34+
<ion-button @click="logout()">LOGOUT</ion-button>
35+
</ion-footer>
36+
</ion-menu>
37+
</template>
38+
39+
<script>
40+
import store from "../store";
41+
export default {
42+
name: "Menu",
43+
components: {},
44+
computed: {},
45+
methods: {
46+
isActive(_path) {
47+
return this.$route.path == _path;
48+
},
49+
async logout() {
50+
let menuController = document.querySelector("#main-menu");
51+
await menuController.close(true);
52+
await store.dispatch("user/logout");
53+
this.$router.replace("/login");
54+
}
55+
}
56+
};
57+
</script>
58+
59+
<style scoped>
60+
.menu-label {
61+
padding-left: 0.5em !important;
62+
}
63+
.boldLabel {
64+
font-weight: bold;
65+
}
66+
</style>

Diff for: src/store/auth-store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default {
2222
});
2323
},
2424
login({ commit }, payload) {
25-
if (payload.email == "[email protected]") {
25+
if (payload.email !== "") {
2626
commit("hasUser", { ...payload });
2727
return true;
2828
} else {

0 commit comments

Comments
 (0)