2021-11-30 09:55:37 +08:00
|
|
|
<template>
|
2025-12-16 11:41:45 +08:00
|
|
|
<div class="navbar" :class="'nav' + settingsStore.navType">
|
2022-05-29 21:40:32 +08:00
|
|
|
<hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
|
2025-12-16 11:41:45 +08:00
|
|
|
<breadcrumb v-if="settingsStore.navType == 1" id="breadcrumb-container" class="breadcrumb-container" />
|
|
|
|
|
<top-nav v-if="settingsStore.navType == 2" id="topmenu-container" class="topmenu-container" />
|
|
|
|
|
<template v-if="settingsStore.navType == 3">
|
|
|
|
|
<logo v-show="settingsStore.sidebarLogo" :collapse="false"></logo>
|
|
|
|
|
<top-bar id="topbar-container" class="topbar-container" />
|
|
|
|
|
</template>
|
2021-11-30 09:55:37 +08:00
|
|
|
|
|
|
|
|
<div class="right-menu">
|
2022-05-29 21:40:32 +08:00
|
|
|
<template v-if="appStore.device !== 'mobile'">
|
2021-11-30 09:55:37 +08:00
|
|
|
<header-search id="header-search" class="right-menu-item" />
|
|
|
|
|
|
|
|
|
|
<el-tooltip content="源码地址" effect="dark" placement="bottom">
|
|
|
|
|
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
|
|
|
|
<el-tooltip content="文档地址" effect="dark" placement="bottom">
|
|
|
|
|
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
|
|
|
|
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
|
|
|
|
|
2024-12-04 20:32:06 +08:00
|
|
|
<el-tooltip content="主题模式" effect="dark" placement="bottom">
|
|
|
|
|
<div class="right-menu-item hover-effect theme-switch-wrapper" @click="toggleTheme">
|
|
|
|
|
<svg-icon v-if="settingsStore.isDark" icon-class="sunny" />
|
|
|
|
|
<svg-icon v-if="!settingsStore.isDark" icon-class="moon" />
|
|
|
|
|
</div>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
2021-11-30 09:55:37 +08:00
|
|
|
<el-tooltip content="布局大小" effect="dark" placement="bottom">
|
|
|
|
|
<size-select id="size-select" class="right-menu-item hover-effect" />
|
|
|
|
|
</el-tooltip>
|
2026-03-20 10:37:58 +08:00
|
|
|
|
|
|
|
|
<el-tooltip content="消息通知" effect="dark" placement="bottom">
|
|
|
|
|
<header-notice id="header-notice" class="right-menu-item hover-effect" />
|
|
|
|
|
</el-tooltip>
|
2021-11-30 09:55:37 +08:00
|
|
|
</template>
|
2025-05-09 13:54:07 +08:00
|
|
|
|
|
|
|
|
<el-dropdown @command="handleCommand" class="avatar-container right-menu-item hover-effect" trigger="hover">
|
|
|
|
|
<div class="avatar-wrapper">
|
|
|
|
|
<img :src="userStore.avatar" class="user-avatar" />
|
|
|
|
|
<span class="user-nickname"> {{ userStore.nickName }} </span>
|
|
|
|
|
</div>
|
|
|
|
|
<template #dropdown>
|
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
<router-link to="/user/profile">
|
|
|
|
|
<el-dropdown-item>个人中心</el-dropdown-item>
|
|
|
|
|
</router-link>
|
2025-08-23 11:45:03 +08:00
|
|
|
<el-dropdown-item command="setLayout" v-if="settingsStore.showSettings">
|
|
|
|
|
<span>布局设置</span>
|
2026-03-20 22:13:44 +08:00
|
|
|
</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="lockScreen">
|
|
|
|
|
<span>锁定屏幕</span>
|
|
|
|
|
</el-dropdown-item>
|
2025-05-09 13:54:07 +08:00
|
|
|
<el-dropdown-item divided command="logout">
|
|
|
|
|
<span>退出登录</span>
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dropdown>
|
2021-11-30 09:55:37 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2026-01-28 12:21:57 +08:00
|
|
|
<script setup lang="ts">
|
2021-11-30 09:55:37 +08:00
|
|
|
import { ElMessageBox } from 'element-plus'
|
2026-01-28 12:21:57 +08:00
|
|
|
import Breadcrumb from '@/components/Breadcrumb/index.vue'
|
2026-04-03 22:34:08 +08:00
|
|
|
import TopNav from './TopNav/index.vue'
|
2026-01-28 12:21:57 +08:00
|
|
|
import TopBar from './TopBar/index.vue'
|
|
|
|
|
import Logo from './Sidebar/Logo.vue'
|
|
|
|
|
import Hamburger from '@/components/Hamburger/index.vue'
|
|
|
|
|
import Screenfull from '@/components/Screenfull/index.vue'
|
|
|
|
|
import SizeSelect from '@/components/SizeSelect/index.vue'
|
|
|
|
|
import HeaderSearch from '@/components/HeaderSearch/index.vue'
|
|
|
|
|
import RuoYiGit from '@/components/RuoYi/Git/index.vue'
|
|
|
|
|
import RuoYiDoc from '@/components/RuoYi/Doc/index.vue'
|
2022-05-29 21:40:32 +08:00
|
|
|
import useAppStore from '@/store/modules/app'
|
|
|
|
|
import useUserStore from '@/store/modules/user'
|
2026-03-20 22:13:44 +08:00
|
|
|
import useLockStore from '@/store/modules/lock'
|
2022-05-29 21:40:32 +08:00
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
2026-03-20 10:37:58 +08:00
|
|
|
import HeaderNotice from './HeaderNotice'
|
2021-11-30 09:55:37 +08:00
|
|
|
|
2026-03-20 22:13:44 +08:00
|
|
|
const route = useRoute()
|
|
|
|
|
const router = useRouter()
|
2022-05-29 21:40:32 +08:00
|
|
|
const appStore = useAppStore()
|
|
|
|
|
const userStore = useUserStore()
|
2026-03-20 22:13:44 +08:00
|
|
|
const lockStore = useLockStore()
|
2022-05-29 21:40:32 +08:00
|
|
|
const settingsStore = useSettingsStore()
|
2021-11-30 09:55:37 +08:00
|
|
|
|
2026-01-28 12:21:57 +08:00
|
|
|
function toggleSideBar(): void {
|
2022-05-29 21:40:32 +08:00
|
|
|
appStore.toggleSideBar()
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
2026-01-28 12:21:57 +08:00
|
|
|
function handleCommand(command: string): void {
|
2022-01-11 17:24:45 +08:00
|
|
|
switch (command) {
|
|
|
|
|
case "setLayout":
|
2025-04-27 09:58:29 +08:00
|
|
|
setLayout()
|
|
|
|
|
break
|
2026-03-20 22:13:44 +08:00
|
|
|
case "lockScreen":
|
|
|
|
|
lockScreen()
|
|
|
|
|
break
|
2022-01-11 17:24:45 +08:00
|
|
|
case "logout":
|
2025-04-27 09:58:29 +08:00
|
|
|
logout()
|
|
|
|
|
break
|
2022-01-11 17:24:45 +08:00
|
|
|
default:
|
2025-04-27 09:58:29 +08:00
|
|
|
break
|
2022-01-11 17:24:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-28 12:21:57 +08:00
|
|
|
function logout(): void {
|
2021-11-30 09:55:37 +08:00
|
|
|
ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
2022-05-29 21:40:32 +08:00
|
|
|
userStore.logOut().then(() => {
|
2025-04-27 09:58:29 +08:00
|
|
|
location.href = '/index'
|
2021-11-30 09:55:37 +08:00
|
|
|
})
|
2025-04-27 09:58:29 +08:00
|
|
|
}).catch(() => { })
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const emits = defineEmits(['setLayout'])
|
2026-01-28 12:21:57 +08:00
|
|
|
function setLayout(): void {
|
2025-04-27 09:58:29 +08:00
|
|
|
emits('setLayout')
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|
2024-12-04 20:32:06 +08:00
|
|
|
|
2026-03-20 22:13:44 +08:00
|
|
|
function lockScreen() {
|
|
|
|
|
const currentPath = route.fullPath
|
|
|
|
|
lockStore.lockScreen(currentPath)
|
|
|
|
|
router.push('/lock')
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-28 12:21:57 +08:00
|
|
|
async function toggleTheme(event?: MouseEvent): Promise<void> {
|
2026-01-04 14:41:59 +08:00
|
|
|
const x = event?.clientX || window.innerWidth / 2
|
|
|
|
|
const y = event?.clientY || window.innerHeight / 2
|
|
|
|
|
const wasDark = settingsStore.isDark
|
|
|
|
|
|
|
|
|
|
const isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
2026-01-28 12:21:57 +08:00
|
|
|
const isSupported = typeof (document as any).startViewTransition === 'function' && !isReducedMotion
|
2026-01-04 14:41:59 +08:00
|
|
|
|
|
|
|
|
if (!isSupported) {
|
|
|
|
|
settingsStore.toggleTheme()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const transition = document.startViewTransition(async () => {
|
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 10))
|
|
|
|
|
settingsStore.toggleTheme()
|
|
|
|
|
await nextTick()
|
|
|
|
|
})
|
|
|
|
|
await transition.ready
|
|
|
|
|
|
|
|
|
|
const endRadius = Math.hypot(Math.max(x, window.innerWidth - x), Math.max(y, window.innerHeight - y))
|
|
|
|
|
const clipPath = [`circle(0px at ${x}px ${y}px)`, `circle(${endRadius}px at ${x}px ${y}px)`]
|
|
|
|
|
document.documentElement.animate(
|
|
|
|
|
{
|
|
|
|
|
clipPath: !wasDark ? [...clipPath].reverse() : clipPath
|
|
|
|
|
}, {
|
|
|
|
|
duration: 650,
|
|
|
|
|
easing: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
|
|
|
fill: "forwards",
|
|
|
|
|
pseudoElement: !wasDark ? "::view-transition-old(root)" : "::view-transition-new(root)"
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
await transition.finished
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.warn("View transition failed, falling back to immediate toggle:", error)
|
|
|
|
|
settingsStore.toggleTheme()
|
|
|
|
|
}
|
2024-12-04 20:32:06 +08:00
|
|
|
}
|
2021-11-30 09:55:37 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang='scss' scoped>
|
2025-12-16 11:41:45 +08:00
|
|
|
.navbar.nav3 {
|
|
|
|
|
.hamburger-container {
|
|
|
|
|
display: none !important;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 09:55:37 +08:00
|
|
|
.navbar {
|
|
|
|
|
height: 50px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
position: relative;
|
2024-12-04 20:32:06 +08:00
|
|
|
background: var(--navbar-bg);
|
2021-11-30 09:55:37 +08:00
|
|
|
box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
2025-12-16 11:41:45 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
// padding: 0 8px;
|
|
|
|
|
box-sizing: border-box;
|
2021-11-30 09:55:37 +08:00
|
|
|
|
|
|
|
|
.hamburger-container {
|
|
|
|
|
line-height: 46px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: background 0.3s;
|
|
|
|
|
-webkit-tap-highlight-color: transparent;
|
2025-12-16 11:41:45 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
margin-right: 8px;
|
2021-11-30 09:55:37 +08:00
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
background: rgba(0, 0, 0, 0.025);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.breadcrumb-container {
|
2025-12-16 11:41:45 +08:00
|
|
|
flex-shrink: 0;
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.topmenu-container {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 50px;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-16 11:41:45 +08:00
|
|
|
.topbar-container {
|
|
|
|
|
flex: 1;
|
|
|
|
|
min-width: 0;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 09:55:37 +08:00
|
|
|
.right-menu {
|
|
|
|
|
height: 100%;
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
display: flex;
|
2025-12-16 11:41:45 +08:00
|
|
|
align-items: center;
|
|
|
|
|
margin-left: auto;
|
2021-11-30 09:55:37 +08:00
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
|
outline: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right-menu-item {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
padding: 0 8px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-size: 18px;
|
2025-05-09 13:54:07 +08:00
|
|
|
color: #5a5e66;
|
2021-11-30 09:55:37 +08:00
|
|
|
vertical-align: text-bottom;
|
|
|
|
|
|
|
|
|
|
&.hover-effect {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: background 0.3s;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
background: rgba(0, 0, 0, 0.025);
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-04 20:32:06 +08:00
|
|
|
|
|
|
|
|
&.theme-switch-wrapper {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
svg {
|
|
|
|
|
transition: transform 0.3s;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
transform: scale(1.15);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatar-container {
|
2025-05-09 13:54:07 +08:00
|
|
|
margin-right: 0px;
|
|
|
|
|
padding-right: 0px;
|
2021-11-30 09:55:37 +08:00
|
|
|
|
|
|
|
|
.avatar-wrapper {
|
2025-05-09 13:54:07 +08:00
|
|
|
margin-top: 10px;
|
2025-08-23 11:45:03 +08:00
|
|
|
right: 8px;
|
2021-11-30 09:55:37 +08:00
|
|
|
position: relative;
|
|
|
|
|
|
|
|
|
|
.user-avatar {
|
|
|
|
|
cursor: pointer;
|
2025-05-09 13:54:07 +08:00
|
|
|
width: 30px;
|
|
|
|
|
height: 30px;
|
2025-08-23 11:45:03 +08:00
|
|
|
margin-right: 8px;
|
2025-05-09 13:54:07 +08:00
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-nickname{
|
|
|
|
|
position: relative;
|
2025-08-23 11:45:03 +08:00
|
|
|
left: 0px;
|
2025-05-09 13:54:07 +08:00
|
|
|
bottom: 10px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
font-weight: bold;
|
2021-11-30 09:55:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: -20px;
|
|
|
|
|
top: 25px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|