UnisKB/ui/src/layout/components/top-bar/avatar/index.vue

38 lines
1.1 KiB
Vue
Raw Normal View History

2023-10-13 08:11:54 +00:00
<template>
<el-dropdown trigger="click" type="primary">
2023-10-25 10:35:28 +00:00
<AppAvatar :name="user.userInfo?.username" />
2023-10-13 08:11:54 +00:00
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="openResetPassword">
<AppIcon iconName="Lock"></AppIcon><span style="margin-left: 5px">修改密码</span>
</el-dropdown-item>
<el-dropdown-item @click="logout">
<AppIcon iconName="app-exit"></AppIcon><span style="margin-left: 5px">退出</span>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
<ResetPassword ref="resetPasswordRef"></ResetPassword>
2023-09-15 09:40:35 +00:00
</template>
<script setup lang="ts">
2023-10-25 10:35:28 +00:00
import { ref } from 'vue'
import useStore from '@/stores'
2023-10-13 08:11:54 +00:00
import { useRouter } from 'vue-router'
2023-10-16 10:58:51 +00:00
import ResetPassword from './ResetPasssword.vue'
2023-10-25 10:35:28 +00:00
const { user } = useStore()
2023-09-15 09:40:35 +00:00
const router = useRouter()
2023-10-25 10:35:28 +00:00
2023-10-13 08:11:54 +00:00
const resetPasswordRef = ref<InstanceType<typeof ResetPassword>>()
2023-09-15 09:40:35 +00:00
const openResetPassword = () => {
2023-10-13 08:11:54 +00:00
resetPasswordRef.value?.open()
2023-09-15 09:40:35 +00:00
}
const logout = () => {
2023-10-19 10:18:45 +00:00
user.logout().then(() => {
2023-10-13 08:11:54 +00:00
router.push({ name: 'login' })
})
2023-09-15 09:40:35 +00:00
}
</script>
2023-10-25 10:35:28 +00:00
<style lang="scss" scoped></style>