精简代码以及优化菜单

This commit is contained in:
iVampireSP.com 2023-03-06 09:09:05 +08:00
parent 0d38a27fd2
commit cdfadad2c6
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 3 additions and 16 deletions

View File

@ -21,7 +21,7 @@
<body>
<div id="app">
<nav class="navbar navbar-expand-lg bd-navbar sticky-top bg-body">
<nav class="navbar navbar-expand-lg bd-navbar sticky-top bg-body" id="nav">
<div class="container">
<a class="navbar-brand" href="{{ route('admin.index') }}">
管理员

View File

@ -160,24 +160,11 @@ class="d-none">
</div>
<script>
const nav = document.getElementById('nav');
@if (session('auth.password_confirmed_at'))
nav.style.backgroundColor = 'rgb(234 234 234 / 9%)';
const nav = document.getElementById('nav');
nav.style.backgroundColor = 'rgb(234 234 234 / 9%)';
nav.classList.remove('bg-body');
@endif
// 根据 URL 自动激活导航栏
const navLinks = document.querySelectorAll('#nav .nav-link, #nav .dropdown-item');
const currentUrl = window.location.href;
for (let i = 0; i < navLinks.length; i++) {
const navLink = navLinks[i];
if (currentUrl === navLink.href) {
navLink.classList.add('active');
}
}
</script>
</body>