2022-04-21 18:20:39 +08:00
|
|
|
<script lang="ts" setup>
|
2022-04-22 01:16:02 +08:00
|
|
|
import { useRouter } from "vue-router"
|
2023-06-14 18:14:11 +08:00
|
|
|
import { storeToRefs } from "pinia"
|
2022-04-22 01:16:02 +08:00
|
|
|
import { useAppStore } from "@/store/modules/app"
|
|
|
|
import { useSettingsStore } from "@/store/modules/settings"
|
|
|
|
import { useUserStore } from "@/store/modules/user"
|
2022-04-22 12:47:04 +08:00
|
|
|
import { UserFilled } from "@element-plus/icons-vue"
|
2022-04-22 01:16:02 +08:00
|
|
|
import Hamburger from "../Hamburger/index.vue"
|
2023-07-06 13:02:52 +08:00
|
|
|
import Breadcrumb from "../Breadcrumb/index.vue"
|
2022-04-22 01:16:02 +08:00
|
|
|
import ThemeSwitch from "@/components/ThemeSwitch/index.vue"
|
|
|
|
import Screenfull from "@/components/Screenfull/index.vue"
|
2022-10-27 18:21:25 +08:00
|
|
|
import Notify from "@/components/Notify/index.vue"
|
2022-04-21 18:20:39 +08:00
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
const appStore = useAppStore()
|
|
|
|
const settingsStore = useSettingsStore()
|
|
|
|
const userStore = useUserStore()
|
2022-04-22 12:47:04 +08:00
|
|
|
|
2023-06-14 18:14:11 +08:00
|
|
|
const { sidebar } = storeToRefs(appStore)
|
|
|
|
const { showNotify, showThemeSwitch, showScreenfull } = storeToRefs(settingsStore)
|
2022-04-22 12:47:04 +08:00
|
|
|
|
2023-06-14 18:14:11 +08:00
|
|
|
/** 切换侧边栏 */
|
2022-08-23 15:07:29 +08:00
|
|
|
const toggleSidebar = () => {
|
|
|
|
appStore.toggleSidebar(false)
|
|
|
|
}
|
2023-06-14 18:14:11 +08:00
|
|
|
/** 登出 */
|
2022-08-23 15:07:29 +08:00
|
|
|
const logout = () => {
|
|
|
|
userStore.logout()
|
|
|
|
router.push("/login")
|
|
|
|
}
|
2022-04-21 18:20:39 +08:00
|
|
|
</script>
|
|
|
|
|
2022-04-22 12:47:04 +08:00
|
|
|
<template>
|
2022-08-23 14:36:43 +08:00
|
|
|
<div class="navigation-bar">
|
2022-08-23 15:07:29 +08:00
|
|
|
<Hamburger :is-active="sidebar.opened" class="hamburger" @toggle-click="toggleSidebar" />
|
2022-08-23 14:36:43 +08:00
|
|
|
<Breadcrumb class="breadcrumb" />
|
2022-04-22 12:47:04 +08:00
|
|
|
<div class="right-menu">
|
|
|
|
<Screenfull v-if="showScreenfull" class="right-menu-item" />
|
|
|
|
<ThemeSwitch v-if="showThemeSwitch" class="right-menu-item" />
|
2022-10-31 15:35:51 +08:00
|
|
|
<Notify v-if="showNotify" class="right-menu-item" />
|
2022-04-22 12:47:04 +08:00
|
|
|
<el-dropdown class="right-menu-item">
|
2022-11-02 16:57:43 +08:00
|
|
|
<div class="right-menu-avatar">
|
|
|
|
<el-avatar :icon="UserFilled" :size="30" />
|
|
|
|
<span>{{ userStore.username }}</span>
|
|
|
|
</div>
|
2022-04-22 12:47:04 +08:00
|
|
|
<template #dropdown>
|
|
|
|
<el-dropdown-menu>
|
2022-04-23 10:33:30 +08:00
|
|
|
<a target="_blank" href="https://juejin.cn/post/7089377403717287972">
|
2022-11-07 17:46:28 +08:00
|
|
|
<el-dropdown-item>中文文档</el-dropdown-item>
|
2022-04-22 15:16:01 +08:00
|
|
|
</a>
|
2022-04-22 12:47:04 +08:00
|
|
|
<a target="_blank" href="https://github.com/un-pany/v3-admin-vite">
|
2022-11-07 17:46:28 +08:00
|
|
|
<el-dropdown-item>GitHub</el-dropdown-item>
|
2022-04-22 12:47:04 +08:00
|
|
|
</a>
|
2022-04-23 10:33:30 +08:00
|
|
|
<a target="_blank" href="https://gitee.com/un-pany/v3-admin-vite">
|
2022-11-07 17:46:28 +08:00
|
|
|
<el-dropdown-item>Gitee</el-dropdown-item>
|
2022-04-22 12:47:04 +08:00
|
|
|
</a>
|
2022-08-23 15:07:29 +08:00
|
|
|
<el-dropdown-item divided @click="logout">
|
2022-04-22 12:47:04 +08:00
|
|
|
<span style="display: block">退出登录</span>
|
|
|
|
</el-dropdown-item>
|
|
|
|
</el-dropdown-menu>
|
|
|
|
</template>
|
|
|
|
</el-dropdown>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-04-21 18:20:39 +08:00
|
|
|
<style lang="scss" scoped>
|
2022-08-23 14:36:43 +08:00
|
|
|
.navigation-bar {
|
2022-05-25 21:53:38 +08:00
|
|
|
height: var(--v3-navigationbar-height);
|
2022-04-21 18:20:39 +08:00
|
|
|
overflow: hidden;
|
2023-07-06 13:02:52 +08:00
|
|
|
background: var(--v3-header-bg-color);
|
2022-04-21 18:20:39 +08:00
|
|
|
.hamburger {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
height: 100%;
|
|
|
|
float: left;
|
|
|
|
padding: 0 15px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.breadcrumb {
|
|
|
|
float: left;
|
2023-06-14 18:14:11 +08:00
|
|
|
// 参考 Bootstrap 的响应式设计将宽度设置为 576
|
2022-11-02 16:57:43 +08:00
|
|
|
@media screen and (max-width: 576px) {
|
|
|
|
display: none;
|
|
|
|
}
|
2022-04-21 18:20:39 +08:00
|
|
|
}
|
|
|
|
.right-menu {
|
|
|
|
float: right;
|
|
|
|
margin-right: 10px;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2022-05-10 19:59:50 +08:00
|
|
|
color: #606266;
|
2022-04-21 18:20:39 +08:00
|
|
|
.right-menu-item {
|
|
|
|
padding: 0 10px;
|
|
|
|
cursor: pointer;
|
2022-11-02 16:57:43 +08:00
|
|
|
.right-menu-avatar {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
.el-avatar {
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
|
|
|
span {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
}
|
2022-04-21 18:20:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|