|
4 | 4 | <router-link to="/" class="left-menu-item">HOME</router-link>
|
5 | 5 | <router-link to="/article/list" class="left-menu-item">LIST</router-link>
|
6 | 6 | <router-link to="/article/list" class="left-menu-item">ARCHIVE</router-link>
|
7 |
| - <router-link to="/article/create" class="left-menu-item">NEW</router-link> |
| 7 | + <router-link v-if=isAdmin to="/article/create" class="left-menu-item">NEW</router-link> |
8 | 8 |
|
9 | 9 | </div>
|
10 | 10 |
|
11 | 11 | <div class="right-menu">
|
12 |
| - <el-button class="right-menu-item"> <el-icon><SearchIcon /></el-icon></el-button> |
| 12 | + <el-button class="right-menu-item"> |
| 13 | + <el-icon> |
| 14 | + <SearchIcon/> |
| 15 | + </el-icon> |
| 16 | + </el-button> |
13 | 17 | <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
14 | 18 | <div class="avatar-wrapper">
|
15 | 19 | <el-avatar shape="square" :size="30" fit="fill" :src="avatar"></el-avatar>
|
16 |
| - <el-icon><CaretBottom /></el-icon> |
| 20 | + <el-icon> |
| 21 | + <CaretBottom/> |
| 22 | + </el-icon> |
17 | 23 | </div>
|
18 | 24 |
|
19 | 25 | <template #dropdown>
|
20 |
| - <el-dropdown-menu> |
21 |
| - <router-link to="/"> |
22 |
| - <el-dropdown-item>Home</el-dropdown-item> |
23 |
| - </router-link> |
24 |
| - <router-link to="/article/create"> |
25 |
| - <el-dropdown-item>New</el-dropdown-item> |
26 |
| - </router-link> |
27 |
| - |
28 |
| - <a target="_blank" href="https://github.com/pycoder404/blog-vue"> |
29 |
| - <el-dropdown-item>Github</el-dropdown-item> |
30 |
| - </a> |
31 |
| - <el-dropdown-item divided @click="logout"> |
32 |
| - <span style="display:block;">Log Out</span> |
33 |
| - </el-dropdown-item> |
34 |
| - </el-dropdown-menu> |
| 26 | + <el-dropdown-menu> |
| 27 | + <router-link to="/"> |
| 28 | + <el-dropdown-item>Home</el-dropdown-item> |
| 29 | + </router-link> |
| 30 | + <router-link to="/article/create"> |
| 31 | + <el-dropdown-item>New</el-dropdown-item> |
| 32 | + </router-link> |
| 33 | + |
| 34 | + <a target="_blank" href="https://github.com/pycoder404/blog-vue"> |
| 35 | + <el-dropdown-item>Github</el-dropdown-item> |
| 36 | + </a> |
| 37 | + <el-dropdown-item divided @click="logout"> |
| 38 | + <span style="display:block;">Log Out</span> |
| 39 | + </el-dropdown-item> |
| 40 | + </el-dropdown-menu> |
35 | 41 | </template>
|
36 | 42 | </el-dropdown>
|
37 | 43 | </div>
|
|
45 | 51 | import {mapGetters} from 'vuex'
|
46 | 52 | // import Breadcrumb from '@/components/Breadcrumb'
|
47 | 53 | // import Hamburger from '@/components/Hamburger'
|
48 |
| - import {ref} from 'vue' |
| 54 | + // import {ref} from 'vue' |
49 | 55 | import SvgIcon from '@/components/SvgIcon/index'
|
50 | 56 |
|
51 | 57 | export default {
|
52 | 58 | components: {
|
53 | 59 | SvgIcon
|
54 | 60 | },
|
55 | 61 | data() {
|
56 |
| - return { |
57 |
| - } |
| 62 | + return {} |
58 | 63 |
|
59 | 64 | },
|
60 | 65 |
|
61 | 66 | computed: {
|
62 | 67 | ...mapGetters([
|
63 |
| - 'avatar' |
| 68 | + 'avatar', |
| 69 | + 'isAdmin', |
64 | 70 | ])
|
65 | 71 | },
|
66 | 72 |
|
67 | 73 | methods: {
|
68 | 74 | async logout() {
|
69 | 75 | await this.$store.dispatch('user/logout')
|
| 76 | + // fixme if push to this.$route.fullPath, because the route path is not change, |
| 77 | + // fixme so the page is not reloaded |
| 78 | + // this.$router.push(this.$route.fullPath) |
70 | 79 | this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
71 | 80 | }
|
72 | 81 | }
|
|
82 | 91 | /*background:#304156;*/
|
83 | 92 | box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
|
84 | 93 | padding: 4px 32px;
|
| 94 | +
|
85 | 95 | .left-menu {
|
86 | 96 | float: left;
|
87 | 97 | height: 100%;
|
88 | 98 | /*line-height: 30px;*/
|
89 |
| - padding:10px 1px; |
| 99 | + padding: 10px 1px; |
90 | 100 |
|
91 | 101 | &:focus {
|
92 | 102 | outline: none;
|
|
209 | 219 | }
|
210 | 220 |
|
211 | 221 |
|
212 |
| -
|
213 |
| -
|
214 | 222 | </style>
|
0 commit comments