up
This commit is contained in:
@@ -39,6 +39,17 @@
|
||||
Users
|
||||
</router-link>
|
||||
|
||||
<router-link
|
||||
to="/restaurants"
|
||||
class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors"
|
||||
:class="{ 'bg-primary-50 text-primary-700': $route.path === '/restaurants' }"
|
||||
>
|
||||
<svg class="w-5 h-5 mr-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
|
||||
</svg>
|
||||
Restaurants
|
||||
</router-link>
|
||||
|
||||
<router-link
|
||||
to="/settings"
|
||||
class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors"
|
||||
@@ -111,28 +122,28 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {computed, ref} from 'vue'
|
||||
import { computed, ref, onMounted } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const userName = ref('Loading...')
|
||||
const userLogin = ref('')
|
||||
|
||||
const userName = ref('Admin User')
|
||||
const userInitials = computed(() => {
|
||||
return userName.value.split(' ').map(n => n[0]).join('').toUpperCase()
|
||||
})
|
||||
|
||||
const pageTitle = computed(() => {
|
||||
const titles: Record<string, string> = {
|
||||
'/dashboard': 'Dashboard',
|
||||
'/users': 'Users Management',
|
||||
'/settings': 'Settings'
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await fetch('/api/admin/me')
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
userLogin.value = data.login
|
||||
userName.value = data.login // или можно сделать красивое отображение
|
||||
}
|
||||
} catch (e) {
|
||||
userName.value = 'User'
|
||||
}
|
||||
return titles[route.path] || 'Admin Panel'
|
||||
})
|
||||
|
||||
async function logout() {
|
||||
await fetch('/api/logout', { method: 'POST' })
|
||||
router.push('/login')
|
||||
}
|
||||
const userInitials = computed(() => {
|
||||
return (userName.value[0] || 'U').toUpperCase()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user