header.vue
4.52 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<div>
<el-header id="header">
<span class="hideAside" @click="collapse"
><i class="fa fa-indent fa-lg"></i
></span>
<ul class="personal">
<li class="fullScreen" @click="fullScreen">
<el-tooltip
class="item"
effect="dark"
content="全屏"
placement="bottom"
><i class="fa fa-arrows-alt fa-lg"></i
></el-tooltip>
</li>
<!-- <li>
<langSelect></langSelect>
</li> -->
<li>{{ $t(`role.${this.$store.getters.info.role}`) }}</li>
<li>
<el-dropdown @command="handleCommand">
<span class="el-dropdown-link">
{{ $t(`${this.$store.getters.info.name}`) }}<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="info">{{
$t("userDropdownMenu.basicInfor")
}}</el-dropdown-item>
<el-dropdown-item command="editPassword">{{
$t("userDropdownMenu.changePassword")
}}</el-dropdown-item>
<el-dropdown-item command="logout" divided>{{
$t("userDropdownMenu.logout")
}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</li>
<li class="icon"><img :src="avatar" /></li>
</ul>
</el-header>
<!-- <tabNav></tabNav> -->
</div>
</template>
<script>
import Cookies from "js-cookie";
import langSelect from "../../../components/lang/langSelect";
import tabNav from "./tabNav";
import UserInfo from "../../../components/userForm/userInfo";
import EditPassword from "../../../components/userForm/editPassword";
export default {
name: "Header",
components: { EditPassword, tabNav, langSelect, UserInfo },
data() {
return {
isfullScreen: true,
avatar: require("@/assets/images/womandefault.png"),
dialogInfoVisible: false,
dialogPassVisible: false,
title: "",
userId: "",
};
},
methods: {
collapse() {
this.$store.dispatch("collapse");
},
successCallback() {
this.dialogInfoVisible = false;
},
editPwdCallback() {
this.dialogPassVisible = false;
},
fullScreen() {
if (this.isfullScreen) {
var docElm = document.documentElement;
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
}
this.isfullScreen = false;
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
this.isfullScreen = true;
}
},
handleCommand(command) {
if (command === "info") {
this.dialogInfoVisible = true;
this.title = "编辑信息";
// this.userId = this.$store.getters.info.uid
} else if (command === "editPassword") {
this.dialogPassVisible = true;
} else if (command === "logout") {
Cookies.remove("token");
location.reload();
}
},
},
};
</script>
<style lang="scss">
$top: top;
$bottom: bottom;
$left: left;
$right: right;
$leftright: ($left, $right);
%w100 {
width: 100%;
}
%h100 {
height: 100%;
}
%cursor {
cursor: pointer;
}
html,
body,
#app,
.el-container,
#asideNav,
ul.el-menu {
@extend %h100;
}
@mixin set-value($side, $value) {
@each $prop in $leftright {
#{$side}-#{$prop}: $value;
}
}
#header {
max-height: 50px;
line-height: 50px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
display: flex;
justify-content: space-between;
.hideAside {
@extend %cursor;
}
.personal {
display: flex;
flex-direction: row;
li {
@include set-value(margin, 13px);
font-size: 12px;
}
.fullScreen {
@extend %cursor;
}
.el-dropdown-link {
@extend %cursor;
}
.icon img {
margin-#{$top}: 7px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
width: 40px;
height: 40px;
}
}
}
</style>