93 lines
1.9 KiB
Vue
93 lines
1.9 KiB
Vue
<template>
|
|
<div class="user-bar">
|
|
<!-- 业务侧注入的顶栏部件(headerWidgets),按序渲染在语言切换左侧 -->
|
|
<component :is="w" v-for="(w, i) in vueAdmin.headerWidgets" :key="i" />
|
|
<LangSwitch class="panel-item" />
|
|
<div class="panel-item" @click="screen">
|
|
<el-icon><el-icon-full-screen /></el-icon>
|
|
</div>
|
|
<el-dropdown class="user" trigger="click" @command="handleUser">
|
|
<div class="user-avatar dropdown-panel-item">
|
|
<label>{{ vueAdmin.userName || 'Admin' }}</label>
|
|
<el-icon class="el-icon--right"><el-icon-arrow-down /></el-icon>
|
|
</div>
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item command="clearCache">{{ $t("base.clearCache") }}</el-dropdown-item>
|
|
<el-dropdown-item divided command="outLogin">{{ $t("base.logout") }}</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { vueAdmin } from "../VueAdmin";
|
|
import LangSwitch from "./ShrimpLangSwitch.vue";
|
|
|
|
function screen() {
|
|
vueAdmin.fullscreen();
|
|
}
|
|
function handleUser(command: string) {
|
|
switch (command) {
|
|
case "clearCache":
|
|
vueAdmin.clearCache();
|
|
vueAdmin.reset();
|
|
break;
|
|
case "outLogin":
|
|
vueAdmin.reset();
|
|
break;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.user-bar {
|
|
display: flex;
|
|
align-items: center;
|
|
height: 100%;
|
|
}
|
|
|
|
.user-bar .panel-item {
|
|
padding: 0 10px;
|
|
cursor: pointer;
|
|
height: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.user-bar .panel-item i {
|
|
font-size: 16px;
|
|
}
|
|
|
|
.user-bar .panel-item:hover {
|
|
background: rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.dropdown-panel-item {
|
|
padding: 0 10px;
|
|
cursor: pointer;
|
|
height: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.dropdown-panel-item:hover {
|
|
background: rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.user-bar .user-avatar {
|
|
height: 49px;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.user-bar .user-avatar label {
|
|
display: inline-block;
|
|
margin-left: 5px;
|
|
font-size: 12px;
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
|