1
1
<script setup>
2
-
3
- import {useDark } from " @vueuse/core" ;
4
- import {useReaderStore } from " @/stores/reader.js" ;
5
- import {useTokenStore } from " @/stores/token.js" ;
6
- import {useAdminStore } from " @/stores/admin.js" ;
7
- import {ref } from ' vue'
8
- import {Link , Moon , Sunny , SwitchButton } from " @element-plus/icons-vue" ;
2
+ import { useDark } from " @vueuse/core" ;
3
+ import { useReaderStore } from " @/stores/reader.js" ;
4
+ import { useTokenStore } from " @/stores/token.js" ;
5
+ import { useAdminStore } from " @/stores/admin.js" ;
6
+ import { ref } from " vue" ;
7
+ import { Link , Moon , Sunny , SwitchButton } from " @element-plus/icons-vue" ;
9
8
import router from " @/router/index.js" ;
10
9
11
10
const adminStore = useAdminStore ();
@@ -27,21 +26,20 @@ const isDark = useDark();
27
26
28
27
// 头像下拉菜单命令
29
28
const handleCommand = function (command ) {
30
- if (command === ' logout' ) {
29
+ if (command === " logout" ) {
31
30
// 退出后清除token和reader信息
32
31
tokenStore .setToken (null );
33
32
readerStore .setReader (null );
34
- router .push (' /login' );
35
- } else if (command === ' frontend' ) {
36
- window .open (' https://github.com/TankingCao/vue3-vite' );
37
- } else if (command === ' backend' ) {
38
- window .open (' https://github.com/TankingCao/java_design' );
33
+ router .push (" /login" );
34
+ } else if (command === " frontend" ) {
35
+ window .open (" https://github.com/TankingCao/vue3-vite" );
36
+ } else if (command === " backend" ) {
37
+ window .open (" https://github.com/TankingCao/java_design" );
39
38
}
40
39
};
41
40
42
41
// 头像图片
43
- const url = ref (' https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif' );
44
-
42
+ const url = ref (" https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif" );
45
43
</script >
46
44
47
45
<template >
@@ -50,8 +48,13 @@ const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
50
48
<!-- 头像-->
51
49
<el-dropdown @command =" handleCommand" >
52
50
<el-menu-item index =" 1" >
53
- <el-avatar @click =" router.push('/user')" shape =" square"
54
- :size =" 42" :fit =" 'cover'" :src =" url" />
51
+ <el-avatar
52
+ @click =" router.push('/user')"
53
+ shape =" square"
54
+ :size =" 42"
55
+ :fit =" 'cover'"
56
+ :src =" url"
57
+ />
55
58
</el-menu-item >
56
59
<template #dropdown >
57
60
<el-dropdown-menu >
@@ -64,7 +67,9 @@ const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
64
67
</el-dropdown-item >
65
68
66
69
<el-dropdown-item command =" logout" >
67
- <el-button link type =" danger" :icon =" SwitchButton" >退出登录</el-button >
70
+ <el-button link type =" danger" :icon =" SwitchButton"
71
+ >退出登录</el-button
72
+ >
68
73
</el-dropdown-item >
69
74
</el-dropdown-menu >
70
75
</template >
@@ -81,19 +86,22 @@ const url = ref('https://pic.imgdb.cn/item/65a271fe871b83018a8f9a8f.gif');
81
86
<el-tag v-if =" isAdmin" type =" warning" size =" large" round >
82
87
管理员
83
88
</el-tag >
89
+ <el-tag v-else type =" primary" size =" large" round > 读者 </el-tag >
84
90
</el-menu-item >
85
91
86
92
<!-- 深浅色图标-->
87
93
<el-menu-item >
88
94
<el-switch
89
- v-model =" isDark" size =" large"
90
- :active-action-icon =" Moon"
91
- :inactive-action-icon =" Sunny"
92
- style =" --el-switch-on-color : rgba (19 ,206 ,102 ,0.7 ); --el-switch-off-color : rgba (141 ,141 ,141 ,0.79 )" />
95
+ v-model =" isDark"
96
+ size =" large"
97
+ :active-action-icon =" Moon"
98
+ :inactive-action-icon =" Sunny"
99
+ style ="
100
+ --el-switch-on-color : rgba (19 , 206 , 102 , 0.7 );
101
+ --el-switch-off-color : rgba (141 , 141 , 141 , 0.79 );
102
+ "
103
+ />
93
104
</el-menu-item >
94
-
95
105
</el-menu >
96
106
</div >
97
107
</template >
98
-
99
-
0 commit comments