index.vue
4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<script lang="ts" setup name="Tools">
import { useFullscreen } from '@vueuse/core'
import eventBus from '@/utils/eventBus'
import useSettingsStore from '@/store/modules/settings'
import useUserStore from '@/store/modules/user'
const router = useRouter()
const settingsStore = useSettingsStore()
const userStore = useUserStore()
const mainPage = useMainPage()
const { isFullscreen, toggle } = useFullscreen()
function userCommand(command: 'home' | 'setting' | 'updatePwd' | 'hotkeys' | 'logout') {
switch (command) {
case 'home':
router.push({
name: 'home',
})
break
case 'setting':
router.push({
name: 'personalSetting',
})
break
case 'updatePwd':
router.push({
name: 'personalEditPassword',
})
break
case 'hotkeys':
eventBus.emit('global-hotkeys-intro-toggle')
break
case 'logout':
userStore.logout()
break
}
}
function pro() {
window.open('https://hooray.gitee.io/fantastic-admin-pro-example/', '_blank')
}
const loaclStorageInfo: any = localStorage.getItem("userData")
onMounted(() => {
console.log('mounted', JSON.parse(userStore.userData).abbreviation)
})
</script>
<template>
<div class="tools">
<!-- <div class="buttons">
<span v-if="settingsStore.mode === 'pc' && settingsStore.settings.toolbar.enableFullscreen" class="item" @click="toggle">
<el-icon>
<svg-icon :name="isFullscreen ? 'fullscreen-exit' : 'fullscreen'" />
</el-icon>
</span>
</div> -->
<el-dropdown class="user-container" size="default" @command="userCommand">
<div class="user-wrapper">
<el-avatar size="small">
<el-icon>
<svg-icon name="ep:user-filled" />
</el-icon>
</el-avatar>
<div class="v-uerinfo">
<div class="v-top">{{ userStore.userName }}</div>
<div class="v-top"> {{ JSON.parse(loaclStorageInfo).abbreviation }}</div>
</div>
<div>
<el-icon>
<svg-icon name="ep:caret-bottom" />
</el-icon>
</div>
</div>
<template #dropdown>
<el-dropdown-menu class="user-dropdown">
<!-- <el-dropdown-item command="setting">
个人设置
</el-dropdown-item> -->
<el-dropdown-item command="updatePwd">
修改密码
</el-dropdown-item>
<el-dropdown-item divided command="logout">
退出登录
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
<style lang="scss" scoped>
.tools {
display: flex;
align-items: center;
padding: 0 20px;
white-space: nowrap;
.buttons {
margin-right: 20px;
.item {
display: inline-flex;
align-items: center;
justify-content: center;
height: 24px;
width: 34px;
cursor: pointer;
vertical-align: middle;
.el-icon {
color: var(--el-text-color-primary);
transition: var(--el-transition-color);
}
}
.item-pro {
display: inline-flex;
align-items: center;
width: auto;
padding: 0 10px;
transform-origin: right center;
animation: pro-text 3s ease-out infinite;
@keyframes pro-text {
0%,
20% {
transform: scale(1);
}
50%,
70% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
.title {
padding-left: 5px;
font-weight: bold;
font-size: 14px;
background-image: linear-gradient(to right, #ffa237, #fc455d);
background-clip: text;
-webkit-text-fill-color: transparent;
}
}
}
}
:deep(.user-container) {
display: inline-block;
height: 24px;
line-height: 24px;
cursor: pointer;
.user-wrapper {
display: flex;
align-items: center;
height: 100%;
.v-uerinfo {
display: flex;
flex-direction: column;
font-size: 12px;
.v-top {
height: 18px;
line-height: 18px;
}
}
.el-avatar {
vertical-align: middle;
margin-top: -2px;
margin-right: 4px;
}
}
}
</style>