You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
6.9 KiB
Vue

2 years ago
<template>
<div class="header">
<div class="logo">可视化智能管控系统</div>
<v-sidebar></v-sidebar>
<div class="header-right">
<div class="header-user-con">
2 years ago
<el-select v-model="colorValue" @change="changeTheme">
<el-option
v-for="item in colorList"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
<!-- 全屏显示 -->
2 years ago
<!-- <div class="btn-fullscreen" @click="handleFullScreen">
<el-tooltip
effect="dark"
:content="fullscreen ? `取消全屏` : `全屏`"
placement="bottom"
>
<i class="el-icon-rank"></i>
</el-tooltip>
2 years ago
</div> -->
<!-- 用户头像 -->
<div class="user-avator">
<img src="../../assets/img/user.jpeg" />
2 years ago
</div>
<!-- 用户名下拉菜单 -->
<el-dropdown class="user-name" trigger="click" @command="handleCommand">
<span class="el-dropdown-link">
{{ username }}
<i class="el-icon-caret-bottom"></i>
</span>
<el-dropdown-menu slot="dropdown">
2 years ago
<el-dropdown-item command="noticeShow">公告</el-dropdown-item>
<el-dropdown-item command="changePwd"> 修改密码</el-dropdown-item>
<el-dropdown-item command="loginout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
2 years ago
</div>
2 years ago
<password-dialog
:dialogFormPsd="dialogFormPsd"
@psdDialogClose="psdDialogClose"
></password-dialog>
</div>
2 years ago
</template>
<script>
// import bus from '../common/bus';
2 years ago
import { mapState } from "vuex";
import updateElementUiTheme from "update-element-ui-theme";
import vSidebar from "./Sidebar.vue";
2 years ago
import passwordDialog from "@/views/components/passwordDialog.vue";
2 years ago
export default {
components: {
vSidebar,
2 years ago
passwordDialog,
},
data() {
return {
colorList: [
{
value: "#20a0ff",
label: "蓝色",
},
{
value: "#EE320C",
label: "红色",
},
{
value: "#25EE28",
label: "绿色",
},
{
value: "#f08200",
label: "橙色",
},
],
colorValue: "",
fullscreen: false,
2 years ago
dialogFormPsd: false,
};
},
computed: {
2 years ago
...mapState(["username"]),
username() {
2 years ago
let name = localStorage.getItem("username");
return name;
2 years ago
},
},
methods: {
//修改主题色
2 years ago
changeTheme(event) {
console.log(event);
let colorTheme = {};
colorTheme = this.colorList.find(function (item) {
return item.value === event;
}); //在change中获取到整条对象数据
2 years ago
console.log(colorTheme);
const app = document.getElementById("app");
console.log(app);
2 years ago
if (colorTheme.label === "蓝色") {
colorTheme.value = "#20a0ff";
app.classList.add("blueStyle");
app.classList.remove("redStyle", "greenStyle", "orangeStyle");
2 years ago
} else if (colorTheme.label === "红色") {
colorTheme.value = "#EE320C";
app.classList.remove("blueStyle", "greenStyle", "orangeStyle");
app.classList.add("redStyle");
2 years ago
} else if (colorTheme.label === "绿色") {
colorTheme.value = "#25EE28";
app.classList.add("greenStyle");
2 years ago
} else if (colorTheme.label === "橙色") {
colorTheme.value = "#f08200";
app.classList.remove("blueStyle", "greenStyle", "redStyle");
app.classList.add("orangeStyle");
}
2 years ago
updateElementUiTheme({
theme: colorTheme.value,
themeName: "--my-theme-name",
});
2 years ago
},
// 用户名下拉菜单选择事件
handleCommand(command) {
2 years ago
switch (command) {
case "noticeShow": //公告
console.log(command);
break;
case "changePwd": //修改密码
console.log(command);
this.dialogFormPsd = true;
break;
case "loginout": //退出登录
this.$store.commit("REMOVE_INFO");
this.$router.push("/login");
break;
}
2 years ago
// if (command == "loginout") {
// localStorage.removeItem("ms_username");
// this.$router.push("/login");
// }
2 years ago
},
2 years ago
//psdDialogClose 修改密码弹窗关闭
psdDialogClose() {
this.dialogFormPsd = false;
2 years ago
},
2 years ago
// 全屏事件
// handleFullScreen() {
// let element = document.documentElement;
// if (this.fullscreen) {
// if (document.exitFullscreen) {
// document.exitFullscreen();
// } else if (document.webkitCancelFullScreen) {
// document.webkitCancelFullScreen();
// } else if (document.mozCancelFullScreen) {
// document.mozCancelFullScreen();
// } else if (document.msExitFullscreen) {
// document.msExitFullscreen();
// }
// } else {
// if (element.requestFullscreen) {
// element.requestFullscreen();
// } else if (element.webkitRequestFullScreen) {
// element.webkitRequestFullScreen();
// } else if (element.mozRequestFullScreen) {
// element.mozRequestFullScreen();
// } else if (element.msRequestFullscreen) {
// // IE11
// element.msRequestFullscreen();
// }
// }
// this.fullscreen = !this.fullscreen;
// },
},
created() {
this.colorValue = this.colorList[0].label;
},
mounted() {},
2 years ago
};
</script>
<style lang="less">
.header {
position: relative;
box-sizing: border-box;
width: 100%;
height: 70px;
font-size: 22px;
color: @color-white;
background-color: @color-primary;
.collapse-btn {
float: left;
padding: 0 21px;
cursor: pointer;
line-height: 70px;
}
.logo {
float: left;
width: 250px;
line-height: 70px;
text-align: center;
}
.header-right {
float: right;
padding-right: 32px;
}
.header-user-con {
display: flex;
2 years ago
height: 70px;
align-items: center;
.el-select {
width: 90px;
2 years ago
}
}
.btn-fullscreen {
transform: rotate(45deg);
margin-right: 5px;
font-size: 24px;
}
.btn-bell,
.btn-fullscreen {
position: relative;
width: 30px;
height: 30px;
text-align: center;
border-radius: 15px;
cursor: pointer;
}
.btn-bell-badge {
position: absolute;
right: 0;
top: -2px;
width: 8px;
height: 8px;
border-radius: 4px;
background: #f56c6c;
color: @color-white;
}
.btn-bell .el-icon-bell {
color: @color-white;
}
.user-name {
margin-left: 10px;
}
.user-avator {
margin-left: 20px;
}
.user-avator img {
display: block;
width: 40px;
height: 40px;
border-radius: 50%;
}
.el-dropdown-link {
color: @color-white;
cursor: pointer;
}
.el-dropdown-menu__item {
text-align: center;
}
2 years ago
}
</style>