v0.3
This commit is contained in:
1 parent
d1ee8edbbd
commit
7733a44362
429 files changed
+75840
-94
No files matched your search
+225
-74
@@ -1,13 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
const router = useRoute();
|
||||
const isLoginPage = computed(() => router.path === '/login');
|
||||
const isActiveNav = (path: string) => router.path === path;
|
||||
import { computed, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useUserInfoStore } from './stores/UserInfo'
|
||||
|
||||
const router = useRoute();
|
||||
const navigation = useRouter();
|
||||
const isLoginPage = computed(() => router.path === '/login');
|
||||
const isActiveNav = (path: string) => router.path === path;
|
||||
const userStore = useUserInfoStore();
|
||||
const role = computed(() => userStore.userInfo.role);
|
||||
const showLogoutMenu = ref(false);
|
||||
|
||||
function toggleLogoutMenu() {
|
||||
showLogoutMenu.value = !showLogoutMenu.value;
|
||||
}
|
||||
|
||||
function logout() {
|
||||
userStore.clearUserInfo();
|
||||
showLogoutMenu.value = false;
|
||||
localStorage.removeItem('token');
|
||||
navigation.push('/login');
|
||||
}
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<header v-if="!isLoginPage" class="topbar">
|
||||
<header v-if="!isLoginPage&&role != 'admin'&&role" class="topbar">
|
||||
<a class="brand" href="#">
|
||||
<span class="brand-mark">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
@@ -37,8 +54,52 @@
|
||||
<path d="M8 12h.01M12 12h.01M16 12h.01" />
|
||||
</svg>
|
||||
</button>
|
||||
<div class="user-avatar">泽</div>
|
||||
<span class="user-name">在线客服</span>
|
||||
<div class="user-menu" :class="{ open: showLogoutMenu }">
|
||||
<button class="user-trigger" type="button" aria-label="打开用户菜单" @click="toggleLogoutMenu">
|
||||
<span class="user-avatar">泽</span>
|
||||
<span class="user-name">在线客服</span>
|
||||
</button>
|
||||
<button class="logout-menu" type="button" @click="logout">退出登录</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<header v-if="!isLoginPage&&role == 'admin'" class="topbar">
|
||||
<a class="brand" href="#">
|
||||
<span class="brand-mark">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path
|
||||
d="M21 7.5a6.6 6.6 0 0 1-8.8 6.2L6.2 19.7a2.1 2.1 0 0 1-3-3l6-6A6.6 6.6 0 0 1 15.5 3l-2.7 2.7 1.5 1.5L17 4.5A6.6 6.6 0 0 1 21 7.5Z" />
|
||||
</svg>
|
||||
</span>
|
||||
<span>天泽汽修</span>
|
||||
</a>
|
||||
<nav class="nav-links" aria-label="主导航">
|
||||
<a :class="{ active: isActiveNav('/adduser') }" href="/adduser">添加用户</a>
|
||||
<a :class="{ active: isActiveNav('/search') }" href="/search">用户查询</a>
|
||||
<a :class="{ active: isActiveNav('/bill') }" href="/bill">维修服务</a>
|
||||
<a :class="{ active: isActiveNav('/contact') }" href="/contact">联系我们</a>
|
||||
</nav>
|
||||
<div class="topbar-actions">
|
||||
<button class="icon-button" aria-label="搜索服务">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<circle cx="10.8" cy="10.8" r="6.8" />
|
||||
<path d="m16 16 5 5" />
|
||||
</svg>
|
||||
</button>
|
||||
<button class="icon-button notification" aria-label="在线咨询">
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path
|
||||
d="M20 11.5a7.5 7.5 0 0 1-8 7.5 8.5 8.5 0 0 1-3.5-.8L4 20l1.5-3.5A7.3 7.3 0 0 1 4.5 12 7.5 7.5 0 0 1 12 4.5a7.5 7.5 0 0 1 8 7Z" />
|
||||
<path d="M8 12h.01M12 12h.01M16 12h.01" />
|
||||
</svg>
|
||||
</button>
|
||||
<div class="user-menu" :class="{ open: showLogoutMenu }">
|
||||
<button class="user-trigger" type="button" aria-label="打开用户菜单" @click="toggleLogoutMenu">
|
||||
<span class="user-avatar">泽</span>
|
||||
<span class="user-name">在线客服</span>
|
||||
</button>
|
||||
<button class="logout-menu" type="button" @click="logout">退出登录</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<router-view />
|
||||
@@ -57,19 +118,6 @@
|
||||
animation: nav-slide-down 0.55s cubic-bezier(.22, 1, .36, 1) both;
|
||||
}
|
||||
|
||||
.topbar::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: -1px;
|
||||
left: 0;
|
||||
height: 1px;
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
background: #1769e0;
|
||||
animation: nav-border-reveal 0.8s .2s ease-out both;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -107,6 +155,65 @@
|
||||
width: 22px;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
.user-menu {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.user-menu::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
width: 100px;
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
.user-trigger {
|
||||
display: flex;
|
||||
padding: 0;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #34415a;
|
||||
background: none;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
.logout-menu {
|
||||
position: absolute;
|
||||
z-index: 3;
|
||||
top: calc(100% + 10px);
|
||||
right: 0;
|
||||
width: 100px;
|
||||
padding: 10px 12px;
|
||||
color: #40506a;
|
||||
background: #fff;
|
||||
border: 1px solid #e8edf5;
|
||||
border-radius: 7px;
|
||||
box-shadow: 0 8px 20px #29466b1c;
|
||||
cursor: pointer;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(-5px);
|
||||
transition: opacity .2s ease, transform .2s ease;
|
||||
}
|
||||
|
||||
.logout-menu:hover {
|
||||
color: #dc635b;
|
||||
background: #fff7f6;
|
||||
}
|
||||
|
||||
.user-menu:hover .logout-menu,
|
||||
.user-menu.open .logout-menu {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
align-self: stretch;
|
||||
@@ -147,40 +254,11 @@
|
||||
}
|
||||
|
||||
.nav-links a.active {
|
||||
padding: 8px 13px;
|
||||
color: #1769e0;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.nav-links a.active::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 3px;
|
||||
transform: scaleX(1);
|
||||
transform-origin: center;
|
||||
background: #1769e0;
|
||||
border-radius: 3px 3px 0 0;
|
||||
animation: nav-underline-in .35s .35s cubic-bezier(.22, 1, .36, 1) both;
|
||||
}
|
||||
|
||||
.nav-links a:not(.active)::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
height: 3px;
|
||||
transform: scaleX(0);
|
||||
transform-origin: center;
|
||||
background: #1769e0;
|
||||
border-radius: 3px 3px 0 0;
|
||||
transition: transform .25s cubic-bezier(.22, 1, .36, 1);
|
||||
}
|
||||
|
||||
.nav-links a:not(.active):hover::after {
|
||||
transform: scaleX(1);
|
||||
background: #eaf2ff;
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
@keyframes nav-slide-down {
|
||||
@@ -188,46 +266,29 @@
|
||||
opacity: 0;
|
||||
transform: translateY(-18px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes nav-border-reveal {
|
||||
from {
|
||||
transform: scaleX(0);
|
||||
}
|
||||
to {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes nav-item-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes nav-underline-in {
|
||||
from {
|
||||
transform: scaleX(0);
|
||||
}
|
||||
to {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
|
||||
.topbar,
|
||||
.topbar::after,
|
||||
.nav-links a,
|
||||
.nav-links a.active::after {
|
||||
.nav-links a {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
@@ -235,4 +296,94 @@
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.topbar {
|
||||
height: auto;
|
||||
min-height: 68px;
|
||||
padding: 12px 18px 0;
|
||||
gap: 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.brand {
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 9px;
|
||||
}
|
||||
|
||||
.brand-mark svg {
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
margin-top: 8px;
|
||||
align-self: auto;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.nav-links::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-links a {
|
||||
flex: 0 0 auto;
|
||||
min-height: 32px;
|
||||
padding: 7px 10px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.nav-links a.active {
|
||||
padding: 7px 12px;
|
||||
}
|
||||
|
||||
.topbar-actions {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.topbar-actions .icon-button {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
.user-name {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.user-menu:hover .logout-menu {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.user-menu.open .logout-menu {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.user-avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.brand,
|
||||
.brand-mark,
|
||||
.nav-links a {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user