YouKeChuanMei_VUE/src/layout/components/Navbar.vue

269 lines
6.8 KiB
Vue
Raw Normal View History

2025-07-22 21:42:20 +08:00
<template>
<div class="navbar">
2025-07-25 21:14:24 +08:00
<!-- <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container"
@toggleClick="toggleSideBar" /> -->
2025-07-22 21:42:20 +08:00
<breadcrumb v-if="!settingsStore.topNav" id="breadcrumb-container" class="breadcrumb-container" />
2025-07-25 21:14:24 +08:00
<div class="navContent">
<div class="systemLogoContent">
<img v-if="homeLogo" :src="homeLogo" class="sidebar-logo" />
</div>
<div class="topmenu-container">
<top-nav v-if="settingsStore.topNav" id="topmenu-container" />
</div>
<div class="right-menu">
<div class="el-dropdown avatar-container right-menu-item hover-effect">
<div class="avatar-wrapper">
2025-08-04 18:02:05 +08:00
<div class="feedback_icon">
<img :src="icon_feedback" class="custom-icon" @click="handleFeedBack" />
</div>
2025-07-25 21:14:24 +08:00
<img :src="userStore.avatar ? userStore.avatar : avatar_icon" class="user-avatar" />
<span class="user-nickname"> {{ userStore.nickName }} admin </span>
<div class="logout_icon">
<img :src="logout_icon" class="custom-icon" @click="logout" />
</div>
2025-07-22 21:42:20 +08:00
</div>
2025-08-04 18:02:05 +08:00
</div>
2025-07-25 21:14:24 +08:00
<div class="right-menu-item hover-effect setting" @click="setLayout" v-if="settingsStore.showSettings">
<svg-icon icon-class="more-up" />
2025-07-22 21:42:20 +08:00
</div>
</div>
</div>
</div>
2025-08-04 18:02:05 +08:00
<!-- 添加反馈对话框 -->
<el-dialog title="问题反馈" v-model="openFeedBack" width="800px" align-center class="my_dialog" append-to-body
:destroy-on-close="true" :close-on-click-modal="false">
<el-form ref="feedBackRef" :model="form" :rules="rules" label-width="120px" label-position="top"
class="myFeedBackForm">
<el-form-item label="输入反馈内容" prop="menuName">
<el-input v-model="form.menuName" style="width: 100%" :rows="12" type="textarea"
placeholder="欢迎提出您在使用过程中遇到的问题或宝贵建议" />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button class="my-cancel-btn" @click="cancel"> </el-button>
<el-button class="my-confirm-btn" type="primary" @click="submitForm"> </el-button>
</div>
</template>
</el-dialog>
2025-07-22 21:42:20 +08:00
</template>
<script setup>
import { ElMessageBox } from 'element-plus'
import Breadcrumb from '@/components/Breadcrumb'
2025-07-25 21:14:24 +08:00
import homeLogo from '@/assets/logo/homeLogo.png'
import avatar_icon from '@/assets/images/avatar_icon.png'
import logout_icon from '@/assets/images/logout_icon.png'
2025-08-04 18:02:05 +08:00
import icon_feedback from '@/assets/images/icon_feedback.png'
2025-07-22 21:42:20 +08:00
import TopNav from '@/components/TopNav'
import useAppStore from '@/store/modules/app'
import useUserStore from '@/store/modules/user'
import useSettingsStore from '@/store/modules/settings'
const appStore = useAppStore()
const userStore = useUserStore()
const settingsStore = useSettingsStore()
2025-08-04 18:02:05 +08:00
const { proxy } = getCurrentInstance()
2025-07-25 21:14:24 +08:00
console.log('settingsStore.topNav', settingsStore.topNav)
2025-07-22 21:42:20 +08:00
function toggleSideBar() {
appStore.toggleSideBar()
}
2025-07-25 21:14:24 +08:00
// 退出系统
const logout = () => {
2025-07-22 21:42:20 +08:00
ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
2025-08-04 18:02:05 +08:00
confirmButtonClass: 'custom-confirm-btn',
cancelButtonClass: 'custom-cancel-btn',
2025-07-28 18:56:20 +08:00
closeOnClickModal: false, // 禁止点击遮罩层关闭
2025-07-22 21:42:20 +08:00
type: 'warning'
}).then(() => {
userStore.logOut().then(() => {
location.href = '/index'
})
}).catch(() => { })
}
const emits = defineEmits(['setLayout'])
function setLayout() {
emits('setLayout')
}
function toggleTheme() {
settingsStore.toggleTheme()
}
2025-08-04 18:02:05 +08:00
const openFeedBack = ref(false)
const data = reactive({
form: {},
rules: {
menuName: [{ required: true, message: "反馈内容不能为空", trigger: "blur" }]
},
})
const { queryParams, form, rules } = toRefs(data)
const handleFeedBack = () => {
openFeedBack.value = true
}
const cancel = () => {
openFeedBack.value = false
form.value = {}
}
const submitForm = () => {
proxy.$refs["feedBackRef"].validate(valid => {
if (valid) {
openFeedBack.value = false
// addMenu(form.value).then(response => {
// proxy.$modal.msgSuccess("新增成功")
// open.value = false
// getList()
// })
}
})
}
2025-07-22 21:42:20 +08:00
</script>
<style lang='scss' scoped>
2025-07-25 21:14:24 +08:00
.myRow {
margin-left: 0 !important;
margin-right: 0 !important;
}
2025-07-22 21:42:20 +08:00
.navbar {
2025-07-25 21:14:24 +08:00
height: 80px;
2025-08-04 18:02:05 +08:00
width: 100%;
2025-07-22 21:42:20 +08:00
overflow: hidden;
2025-08-04 18:02:05 +08:00
position: fixed;
2025-07-25 21:14:24 +08:00
background: transparent;
box-shadow: none;
2025-08-04 18:02:05 +08:00
padding: 0 36px;
2025-07-25 21:14:24 +08:00
.navContent {
2025-08-04 18:02:05 +08:00
height: 43px;
margin: 19px 0px 18px 0px;
2025-07-25 21:14:24 +08:00
display: flex; // 添加flex布局
justify-content: space-between; // 使子元素平均分布
align-items: center; // 垂直居中
2025-07-22 21:42:20 +08:00
}
2025-07-25 21:14:24 +08:00
.systemLogoContent {
2025-08-04 18:02:05 +08:00
width: 220px;
2025-07-22 21:42:20 +08:00
}
2025-08-04 18:02:05 +08:00
.topmenu-container {
2025-07-25 21:14:24 +08:00
flex: 1; // 占据剩余空间
padding-left: 284px; // 替代原来的padding-left
2025-07-22 21:42:20 +08:00
}
.right-menu {
height: 100%;
2025-08-04 18:02:05 +08:00
width: 220px;
2025-07-25 21:14:24 +08:00
text-align: right;
line-height: normal; // 覆盖原来的line-height
display: flex; // 内部也使用flex
align-items: center; // 垂直居中
justify-content: flex-end; // 内容靠右
2025-07-22 21:42:20 +08:00
&:focus {
outline: none;
}
2025-08-04 18:02:05 +08:00
.right-menu-item {
2025-07-22 21:42:20 +08:00
height: 100%;
font-size: 18px;
color: #5a5e66;
vertical-align: text-bottom;
2025-08-04 18:02:05 +08:00
&.hover-effect {
2025-07-22 21:42:20 +08:00
transition: background 0.3s;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
&.theme-switch-wrapper {
display: flex;
align-items: center;
svg {
transition: transform 0.3s;
2025-07-25 21:14:24 +08:00
2025-07-22 21:42:20 +08:00
&:hover {
transform: scale(1.15);
}
}
}
}
.avatar-container {
margin-right: 0px;
padding-right: 0px;
2025-08-04 18:02:05 +08:00
.avatar-wrapper {
2025-07-25 21:14:24 +08:00
display: flex;
align-items: center;
2025-07-22 21:42:20 +08:00
.user-avatar {
width: 30px;
height: 30px;
border-radius: 50%;
}
2025-08-04 18:02:05 +08:00
.user-nickname {
2025-07-25 21:14:24 +08:00
bottom: 0 !important; // 移除原来的bottom定位
margin-left: 8px;
font-family: Microsoft YaHei;
font-weight: 400;
font-size: 18px;
color: #FFFFFF;
2025-07-22 21:42:20 +08:00
}
i {
cursor: pointer;
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
}
}
}
2025-07-25 21:14:24 +08:00
2025-08-04 18:02:05 +08:00
.feedback_icon {
margin-right: 34px;
cursor: pointer;
}
.logout_icon {
2025-07-25 21:14:24 +08:00
margin-left: 30px;
cursor: pointer;
}
}
2025-08-04 18:02:05 +08:00
2025-07-25 21:14:24 +08:00
.hamburger-container {
line-height: 46px;
height: 100%;
float: left;
cursor: pointer;
transition: background 0.3s;
-webkit-tap-highlight-color: transparent;
&:hover {
background: rgba(0, 0, 0, 0.025);
}
}
.breadcrumb-container {
float: left;
}
.errLog-container {
display: inline-block;
vertical-align: top;
2025-07-22 21:42:20 +08:00
}
</style>