2022-04-21 18:20:39 +08:00
|
|
|
<script lang="ts" setup>
|
2024-11-18 19:40:44 +08:00
|
|
|
import Notify from "@/components/Notify/index.vue"
|
|
|
|
import Screenfull from "@/components/Screenfull/index.vue"
|
|
|
|
import SearchMenu from "@/components/SearchMenu/index.vue"
|
|
|
|
import ThemeSwitch from "@/components/ThemeSwitch/index.vue"
|
2024-11-21 20:41:48 +08:00
|
|
|
import { useDevice } from "@/composables/useDevice"
|
|
|
|
import { useLayoutMode } from "@/composables/useLayoutMode"
|
2024-11-21 21:03:09 +08:00
|
|
|
import { useAppStore } from "@/pinia/stores/app"
|
|
|
|
import { useSettingsStore } from "@/pinia/stores/settings"
|
|
|
|
import { useUserStore } from "@/pinia/stores/user"
|
2022-04-22 12:47:04 +08:00
|
|
|
import { UserFilled } from "@element-plus/icons-vue"
|
2024-11-18 19:40:44 +08:00
|
|
|
import { storeToRefs } from "pinia"
|
|
|
|
import { useRouter } from "vue-router"
|
2023-07-06 13:02:52 +08:00
|
|
|
import Breadcrumb from "../Breadcrumb/index.vue"
|
2024-11-18 19:40:44 +08:00
|
|
|
import Hamburger from "../Hamburger/index.vue"
|
2023-07-18 11:14:07 +08:00
|
|
|
import Sidebar from "../Sidebar/index.vue"
|
2022-04-21 18:20:39 +08:00
|
|
|
|
2024-02-06 13:39:56 +08:00
|
|
|
const { isMobile } = useDevice()
|
2024-02-06 15:25:16 +08:00
|
|
|
const { isTop } = useLayoutMode()
|
2022-04-21 18:20:39 +08:00
|
|
|
const router = useRouter()
|
|
|
|
const appStore = useAppStore()
|
|
|
|
const userStore = useUserStore()
|
2024-02-06 13:39:56 +08:00
|
|
|
const settingsStore = useSettingsStore()
|
2024-02-06 15:25:16 +08:00
|
|
|
const { showNotify, showThemeSwitch, showScreenfull, showSearchMenu } = storeToRefs(settingsStore)
|
2022-04-22 12:47:04 +08:00
|
|
|
|
2023-06-14 18:14:11 +08:00
|
|
|
/** 切换侧边栏 */
|
2024-11-18 19:40:44 +08:00
|
|
|
function toggleSidebar() {
|
2022-08-23 15:07:29 +08:00
|
|
|
appStore.toggleSidebar(false)
|
|
|
|
}
|
2023-07-18 11:14:07 +08:00
|
|
|
|
2023-06-14 18:14:11 +08:00
|
|
|
/** 登出 */
|
2024-11-18 19:40:44 +08:00
|
|
|
function logout() {
|
2022-08-23 15:07:29 +08:00
|
|
|
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">
|
2024-02-06 13:39:56 +08:00
|
|
|
<Hamburger
|
|
|
|
v-if="!isTop || isMobile"
|
|
|
|
:is-active="appStore.sidebar.opened"
|
|
|
|
class="hamburger"
|
|
|
|
@toggle-click="toggleSidebar"
|
|
|
|
/>
|
2023-07-18 11:14:07 +08:00
|
|
|
<Breadcrumb v-if="!isTop || isMobile" class="breadcrumb" />
|
|
|
|
<Sidebar v-if="isTop && !isMobile" class="sidebar" />
|
2022-04-22 12:47:04 +08:00
|
|
|
<div class="right-menu">
|
2023-08-10 14:48:22 +08:00
|
|
|
<SearchMenu v-if="showSearchMenu" class="right-menu-item" />
|
2022-04-22 12:47:04 +08:00
|
|
|
<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>
|
|
|
|
<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;
|
2024-03-28 21:34:24 +08:00
|
|
|
color: var(--v3-navigationbar-text-color);
|
2023-07-19 09:05:55 +08:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2022-04-21 18:20:39 +08:00
|
|
|
.hamburger {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
height: 100%;
|
|
|
|
padding: 0 15px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
.breadcrumb {
|
2023-07-19 09:05:55 +08:00
|
|
|
flex: 1;
|
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
|
|
|
}
|
2023-07-18 11:14:07 +08:00
|
|
|
.sidebar {
|
2023-07-19 09:05:55 +08:00
|
|
|
flex: 1;
|
2023-07-19 18:14:42 +08:00
|
|
|
// 设置 min-width 是为了让 Sidebar 里的 el-menu 宽度自适应
|
|
|
|
min-width: 0px;
|
2023-07-19 09:05:55 +08:00
|
|
|
:deep(.el-menu) {
|
|
|
|
background-color: transparent;
|
|
|
|
}
|
2023-07-19 13:11:52 +08:00
|
|
|
:deep(.el-sub-menu) {
|
|
|
|
&.is-active {
|
|
|
|
.el-sub-menu__title {
|
2024-11-21 11:03:40 +08:00
|
|
|
color: var(--el-color-primary);
|
2023-07-19 13:11:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-07-18 11:14:07 +08:00
|
|
|
}
|
2022-04-21 18:20:39 +08:00
|
|
|
.right-menu {
|
|
|
|
margin-right: 10px;
|
|
|
|
height: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
.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>
|