index.vue
2.81 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
<template>
<n-dropdown trigger="hover" @select="handleSelect" :show-arrow="true" :options="options">
<div class="user-info-box">
<person-icon v-if="fallback"></person-icon>
<n-avatar v-if="!fallback" round object-fit="cover" size="medium" :src="Person" @error="errorHandle"></n-avatar>
</div>
</n-dropdown>
<!-- 系统设置 model -->
<go-system-set v-model:modelShow="modelShow"></go-system-set>
<!-- 关于软件 model -->
<go-system-info v-model:modelShow="modelShowInfo"></go-system-info>
</template>
<script lang="ts" setup>
import { h, ref } from 'vue'
import { NAvatar, NText } from 'naive-ui'
import { renderIcon } from '@/utils'
import { logout, renderLang } from '@/utils'
import { GoSystemSet } from '@/components/GoSystemSet/index'
import { GoSystemInfo } from '@/components/GoSystemInfo/index'
import Person from './person.png'
import { icon } from '@/plugins'
import { useUserStore } from '@/store/external/module/user'
const { ChatboxEllipsesIcon, PersonIcon, LogOutOutlineIcon, SettingsSharpIcon } = icon.ionicons5
const t = window['$t']
const modelShowInfo = ref(false)
const modelShow = ref(false)
// 是否失败
const fallback = ref(false)
// 用户图标渲染
const renderUserInfo = () => {
return h(
'div',
{
style: 'display: flex; align-items: center; padding: 8px 12px;'
},
[
h(NAvatar, {
round: true,
style: 'margin-right: 12px;',
src: Person
}),
h('div', null, [h('div', null, [h(NText, { depth: 2 }, { default: () => '奔跑的面条' })])])
]
)
}
const options = ref([
{
label: '我的信息',
key: 'info',
type: 'render',
render: renderUserInfo
},
{
type: 'divider',
key: 'd1'
},
{
label: renderLang('global.sys_set'),
key: 'sysSet',
icon: renderIcon(SettingsSharpIcon)
},
// THINGS_KIT 隐藏关于软件
// {
// label: renderLang('global.contact'),
// key: 'contact',
// icon: renderIcon(ChatboxEllipsesIcon)
// },
{
type: 'divider',
key: 'd3'
},
{
label: renderLang('global.logout'),
key: 'logout',
icon: renderIcon(LogOutOutlineIcon)
}
])
// 图片渲染错误
const errorHandle = (e: Event) => {
fallback.value = true
}
// 系统设置
const sysSetHandle = () => {
modelShow.value = true
}
// 系统设置
const sysInfoHandle = () => {
modelShowInfo.value = true
}
// THINGS_KIT 修改退出登录
const userStore = useUserStore()
const handleSelect = (key: string) => {
switch (key) {
case 'contact':
sysInfoHandle()
break
case 'sysSet':
sysSetHandle()
break
case 'logout':
// THINGS_KIT 修改退出登录
userStore.logout(true)
// logout()
break
}
}
</script>
<style lang="scss" scoped>
.user-info-box {
cursor: pointer;
transform: scale(0.7);
}
</style>