Описание изменений
This commit is contained in:
@@ -1,33 +1,30 @@
|
||||
<template>
|
||||
<nav class="main-nav">
|
||||
<div class="nav-brand">
|
||||
<router-link to="/">DApp for Business</router-link>
|
||||
<nav class="navbar">
|
||||
<div class="navbar-brand">
|
||||
<router-link to="/" class="navbar-logo">DApp for Business</router-link>
|
||||
</div>
|
||||
|
||||
<div class="nav-links">
|
||||
<router-link to="/" class="nav-link">Главная</router-link>
|
||||
<router-link to="/chat" class="nav-link">Чат</router-link>
|
||||
<router-link v-if="authStore.isAdmin" to="/admin" class="nav-link admin-link">
|
||||
Админ-панель
|
||||
</router-link>
|
||||
</div>
|
||||
|
||||
<div class="nav-auth">
|
||||
<template v-if="authStore.isAuthenticated">
|
||||
<div class="user-info">
|
||||
<span class="user-address">{{ formatAddress(authStore.address) }}</span>
|
||||
<span v-if="authStore.isAdmin" class="admin-badge">Админ</span>
|
||||
|
||||
<div class="navbar-menu">
|
||||
<div class="navbar-start">
|
||||
<router-link to="/" class="navbar-item">Главная</router-link>
|
||||
<router-link v-if="isAuthenticated" to="/chat" class="navbar-item">Чат</router-link>
|
||||
</div>
|
||||
|
||||
<div class="navbar-end">
|
||||
<div v-if="isAuthenticated" class="navbar-item user-info">
|
||||
<span v-if="userAddress" class="user-address">{{ formatAddress(userAddress) }}</span>
|
||||
<button @click="logout" class="logout-btn">Выйти</button>
|
||||
</div>
|
||||
<button @click="logout" class="btn-logout">Выйти</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<wallet-connection />
|
||||
</template>
|
||||
<div v-else class="navbar-item">
|
||||
<WalletConnection />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import WalletConnection from './WalletConnection.vue';
|
||||
@@ -35,10 +32,13 @@ import WalletConnection from './WalletConnection.vue';
|
||||
const router = useRouter();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const isAuthenticated = computed(() => authStore.isAuthenticated);
|
||||
const userAddress = computed(() => authStore.user?.address);
|
||||
|
||||
// Форматирование адреса кошелька
|
||||
function formatAddress(address) {
|
||||
if (!address) return '';
|
||||
return address.substring(0, 6) + '...' + address.substring(address.length - 4);
|
||||
return `${address.substring(0, 6)}...${address.substring(address.length - 4)}`;
|
||||
}
|
||||
|
||||
// Выход из системы
|
||||
@@ -49,85 +49,108 @@ async function logout() {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.main-nav {
|
||||
.navbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1rem;
|
||||
padding: 0.5rem 1rem;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.nav-brand a {
|
||||
.navbar-brand {
|
||||
font-weight: bold;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: #3498db;
|
||||
}
|
||||
|
||||
.navbar-logo {
|
||||
color: #1976d2;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
.navbar-menu {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: space-between;
|
||||
flex: 1;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
padding: 0.5rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.nav-link.router-link-active {
|
||||
color: #3498db;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.admin-link {
|
||||
color: #e74c3c;
|
||||
}
|
||||
|
||||
.nav-auth {
|
||||
.navbar-start, .navbar-end {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.navbar-item {
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
margin: 0 0.25rem;
|
||||
}
|
||||
|
||||
.navbar-item:hover {
|
||||
color: #1976d2;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.user-address {
|
||||
font-family: monospace;
|
||||
background-color: #f0f0f0;
|
||||
background-color: #f5f5f5;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.admin-badge {
|
||||
background-color: #e74c3c;
|
||||
.logout-btn {
|
||||
background-color: #f44336;
|
||||
color: white;
|
||||
padding: 0.1rem 0.3rem;
|
||||
border-radius: 4px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.btn-logout {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 4px;
|
||||
background-color: #f0f0f0;
|
||||
color: #333;
|
||||
border: none;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.btn-logout:hover {
|
||||
background-color: #e0e0e0;
|
||||
.logout-btn:hover {
|
||||
background-color: #d32f2f;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.navbar {
|
||||
flex-direction: column;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.navbar-menu {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
margin-left: 0;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.navbar-start, .navbar-end {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.navbar-item {
|
||||
padding: 0.5rem;
|
||||
margin: 0.25rem 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-address {
|
||||
margin-right: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user