feat 用户选项添加 用户显示和跳转

This commit is contained in:
oldHome 2025-06-27 17:22:08 +08:00
parent 63f4064b7c
commit 8a3bddb917
2 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,7 @@ export default {
namespaced: true,
state: {
token: null,
id: null,
name: null,
uname: null,
photo: null,
@ -19,6 +20,7 @@ export default {
if (state.token == null) {
if (localStorage.getItem('token') != null) {
state.token = localStorage.getItem('token')
state.id = localStorage.getItem('id')
state.name = localStorage.getItem('name')
state.uname = localStorage.getItem('uname')
state.photo = localStorage.getItem('photo')
@ -31,6 +33,7 @@ export default {
// 清除用户信息
destroyUser (state) {
state.token = null
state.id = null
state.name = null
state.uname = null
state.photo = null
@ -57,6 +60,7 @@ export default {
res => {
if (res.data.status === 1) {
localStorage.setItem('token', res.data.token)
localStorage.setItem('id', res.data.adminInfo.id)
localStorage.setItem('name', res.data.adminInfo.name)
localStorage.setItem('uname', res.data.adminInfo.uname)
localStorage.setItem('photo', res.data.adminInfo.photo)

View File

@ -20,6 +20,11 @@
</div>
<el-dropdown-menu slot="dropdown" class="user-dropdown">
<!-- 账号id显示 -->
<el-dropdown-item command="go-adminEdit">
<i class="el-icon-user-solid m-r-10"></i>
<font class="brandFontColor">{{ this.$store.state.user.name }}</font>
</el-dropdown-item>
<!-- 自定义语言设置为右侧弹出 -->
<el-dropdown-item>
<el-popover placement="right-start" width="150" trigger="hover" v-model="languagePopoverVisible">
@ -290,6 +295,8 @@ export default {
this.$router.push('/home/set')
} else if (command === 'logout') {
this.logout()
} else if (command === 'go-adminEdit') {
this.$router.push(`/admin/edit/${this.$store.state.user.id}`)
}
},
changeLang (lang) {