|
1 | 1 | <template>
|
2 | 2 | <div class="header">
|
| 3 | + <!-- 折叠按钮 --> |
3 | 4 | <div class="collapse-btn" @click="collapseChage">
|
4 | 5 | <i class="el-icon-menu"></i>
|
5 | 6 | </div>
|
6 | 7 | <div class="logo">后台管理系统</div>
|
7 |
| - <div class="user-info"> |
8 |
| - <el-dropdown trigger="click" @command="handleCommand"> |
9 |
| - <span class="el-dropdown-link"> |
10 |
| - <img class="user-logo" src="../../../static/img/img.jpg"> |
11 |
| - {{username}} |
12 |
| - </span> |
13 |
| - <el-dropdown-menu slot="dropdown"> |
14 |
| - <a href="http://blog.gdfengshuo.com/about/" target="_blank"> |
15 |
| - <el-dropdown-item>关于作者</el-dropdown-item> |
16 |
| - </a> |
17 |
| - <a href="https://github.com/lin-xin/vue-manage-system" target="_blank"> |
18 |
| - <el-dropdown-item>项目仓库</el-dropdown-item> |
19 |
| - </a> |
20 |
| - <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item> |
21 |
| - </el-dropdown-menu> |
22 |
| - </el-dropdown> |
| 8 | + <div class="header-right"> |
| 9 | + <div class="header-user-con"> |
| 10 | + <!-- 全屏显示 --> |
| 11 | + <div class="btn-fullscreen" @click="handleFullScreen"> |
| 12 | + <el-tooltip effect="dark" :content="fullscreen?`取消全屏`:`全屏`" placement="bottom"> |
| 13 | + <i class="el-icon-rank"></i> |
| 14 | + </el-tooltip> |
| 15 | + </div> |
| 16 | + <!-- 消息中心 --> |
| 17 | + <div class="btn-bell"> |
| 18 | + <el-tooltip effect="dark" :content="message?`有${message}条未读消息`:`消息中心`" placement="bottom"> |
| 19 | + <router-link to="/tabs"> |
| 20 | + <i class="el-icon-bell"></i> |
| 21 | + </router-link> |
| 22 | + </el-tooltip> |
| 23 | + <span class="btn-bell-badge" v-if="message"></span> |
| 24 | + </div> |
| 25 | + <!-- 用户头像 --> |
| 26 | + <div class="user-avator"><img src="static/img/img.jpg"></div> |
| 27 | + <!-- 用户名下拉菜单 --> |
| 28 | + <el-dropdown class="user-name" trigger="click" @command="handleCommand"> |
| 29 | + <span class="el-dropdown-link"> |
| 30 | + {{username}} <i class="el-icon-caret-bottom"></i> |
| 31 | + </span> |
| 32 | + <el-dropdown-menu slot="dropdown"> |
| 33 | + <a href="http://blog.gdfengshuo.com/about/" target="_blank"> |
| 34 | + <el-dropdown-item>关于作者</el-dropdown-item> |
| 35 | + </a> |
| 36 | + <a href="https://github.com/lin-xin/vue-manage-system" target="_blank"> |
| 37 | + <el-dropdown-item>项目仓库</el-dropdown-item> |
| 38 | + </a> |
| 39 | + <el-dropdown-item divided command="loginout">退出登录</el-dropdown-item> |
| 40 | + </el-dropdown-menu> |
| 41 | + </el-dropdown> |
| 42 | + </div> |
23 | 43 | </div>
|
24 | 44 | </div>
|
25 | 45 | </template>
|
|
29 | 49 | data() {
|
30 | 50 | return {
|
31 | 51 | collapse: false,
|
32 |
| - name: 'linxin' |
| 52 | + fullscreen: false, |
| 53 | + name: 'linxin', |
| 54 | + message: 2 |
33 | 55 | }
|
34 | 56 | },
|
35 | 57 | computed:{
|
|
39 | 61 | }
|
40 | 62 | },
|
41 | 63 | methods:{
|
| 64 | + // 用户名下拉菜单选择事件 |
42 | 65 | handleCommand(command) {
|
43 | 66 | if(command == 'loginout'){
|
44 | 67 | localStorage.removeItem('ms_username')
|
45 | 68 | this.$router.push('/login');
|
46 | 69 | }
|
47 | 70 | },
|
| 71 | + // 侧边栏折叠 |
48 | 72 | collapseChage(){
|
49 | 73 | this.collapse = !this.collapse;
|
50 | 74 | bus.$emit('collapse', this.collapse);
|
| 75 | + }, |
| 76 | + // 全屏事件 |
| 77 | + handleFullScreen(){ |
| 78 | + let element = document.documentElement; |
| 79 | + if (this.fullscreen) { |
| 80 | + if (document.exitFullscreen) { |
| 81 | + document.exitFullscreen(); |
| 82 | + } else if (document.webkitCancelFullScreen) { |
| 83 | + document.webkitCancelFullScreen(); |
| 84 | + } else if (document.mozCancelFullScreen) { |
| 85 | + document.mozCancelFullScreen(); |
| 86 | + } else if (document.msExitFullscreen) { |
| 87 | + document.msExitFullscreen(); |
| 88 | + } |
| 89 | + } else { |
| 90 | + if (element.requestFullscreen) { |
| 91 | + element.requestFullscreen(); |
| 92 | + } else if (element.webkitRequestFullScreen) { |
| 93 | + element.webkitRequestFullScreen(); |
| 94 | + } else if (element.mozRequestFullScreen) { |
| 95 | + element.mozRequestFullScreen(); |
| 96 | + } else if (element.msRequestFullscreen) { |
| 97 | + // IE11 |
| 98 | + element.msRequestFullscreen(); |
| 99 | + } |
| 100 | + } |
| 101 | + this.fullscreen = !this.fullscreen; |
51 | 102 | }
|
52 | 103 | }
|
53 | 104 | }
|
|
59 | 110 | width: 100%;
|
60 | 111 | height: 70px;
|
61 | 112 | font-size: 22px;
|
62 |
| - line-height: 70px; |
| 113 | + |
63 | 114 | color: #fff;
|
64 | 115 | }
|
65 | 116 | .collapse-btn{
|
66 | 117 | float: left;
|
67 | 118 | padding: 0 21px;
|
68 | 119 | cursor: pointer;
|
| 120 | + line-height: 70px; |
69 | 121 | }
|
70 | 122 | .collapse-btn:hover{
|
71 | 123 | background: rgb(40,52,70);
|
72 | 124 | }
|
73 | 125 | .header .logo{
|
74 | 126 | float: left;
|
75 | 127 | width:250px;
|
76 |
| - /* text-align: center; */ |
| 128 | + line-height: 70px; |
77 | 129 | }
|
78 |
| - .user-info { |
| 130 | + .header-right{ |
79 | 131 | float: right;
|
80 | 132 | padding-right: 50px;
|
81 |
| - font-size: 16px; |
82 |
| - color: #fff; |
83 | 133 | }
|
84 |
| - .user-info .el-dropdown-link{ |
| 134 | + .header-user-con{ |
| 135 | + display: flex; |
| 136 | + height: 70px; |
| 137 | + align-items: center; |
| 138 | + } |
| 139 | + .btn-fullscreen{ |
| 140 | + transform: rotate(45deg); |
| 141 | + margin-right: 5px; |
| 142 | + font-size: 24px; |
| 143 | + } |
| 144 | + .btn-bell, .btn-fullscreen{ |
85 | 145 | position: relative;
|
86 |
| - display: inline-block; |
87 |
| - padding-left: 50px; |
88 |
| - color: #fff; |
| 146 | + width: 30px; |
| 147 | + height: 30px; |
| 148 | + text-align: center; |
| 149 | + border-radius: 15px; |
89 | 150 | cursor: pointer;
|
90 |
| - vertical-align: middle; |
91 | 151 | }
|
92 |
| - .user-info .user-logo{ |
| 152 | + .btn-bell-badge{ |
93 | 153 | position: absolute;
|
94 |
| - left:0; |
95 |
| - top:15px; |
| 154 | + right: 0; |
| 155 | + top: -2px; |
| 156 | + width: 8px; |
| 157 | + height: 8px; |
| 158 | + border-radius: 4px; |
| 159 | + background: #f56c6c; |
| 160 | + color: #fff; |
| 161 | + } |
| 162 | + .btn-bell .el-icon-bell{ |
| 163 | + color: #fff; |
| 164 | + } |
| 165 | + .user-name{ |
| 166 | + margin-left: 10px; |
| 167 | + } |
| 168 | + .user-avator{ |
| 169 | + margin-left: 20px; |
| 170 | + } |
| 171 | + .user-avator img{ |
| 172 | + display: block; |
96 | 173 | width:40px;
|
97 | 174 | height:40px;
|
98 | 175 | border-radius: 50%;
|
99 | 176 | }
|
| 177 | + .el-dropdown-link{ |
| 178 | + color: #fff; |
| 179 | + cursor: pointer; |
| 180 | + } |
100 | 181 | .el-dropdown-menu__item{
|
101 | 182 | text-align: center;
|
102 | 183 | }
|
|
0 commit comments