从cookie中取出用户

This commit is contained in:
Captain.B 2020-02-13 14:31:57 +08:00
parent 89fd3c1f6b
commit 163912046b
1 changed files with 11 additions and 1 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<el-dropdown size="medium" @command="handleCommand"> <el-dropdown size="medium" @command="handleCommand">
<span class="dropdown-link"> <span class="dropdown-link">
<i class="el-icon-caret-bottom el-icon--right"/> {{currentUser.name}}<i class="el-icon-caret-bottom el-icon--right"/>
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="personal">个人信息</el-dropdown-item> <el-dropdown-item command="personal">个人信息</el-dropdown-item>
@ -11,8 +11,18 @@
</template> </template>
<script> <script>
import Cookies from 'js-cookie';
const TokenKey = 'Admin-Token';
export default { export default {
name: "MsUser", name: "MsUser",
computed: {
currentUser: () => {
let user = Cookies.get(TokenKey);
return JSON.parse(user);
}
},
methods: { methods: {
handleCommand(command) { handleCommand(command) {
switch (command) { switch (command) {