up frontend
This commit is contained in:
@@ -102,7 +102,7 @@
|
||||
</div>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-sm font-medium text-gray-900 truncate">{{ userName }}</p>
|
||||
<p class="text-xs text-gray-500 truncate">{{ userStore.role === 'admin' ? 'Administrator' : 'User' }}</p>
|
||||
<p class="text-xs text-gray-500 truncate">{{ userStore.role === 'admin' ? t('app.administrator') : t('app.user') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -124,7 +124,7 @@
|
||||
<div class="relative">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search..."
|
||||
:placeholder="t('app.search')"
|
||||
class="w-64 px-4 py-2 pl-10 text-sm border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500"
|
||||
/>
|
||||
<svg class="absolute left-3 top-2.5 w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
@@ -133,7 +133,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Notifications -->
|
||||
<button class="relative p-2 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors">
|
||||
<button class="relative p-2 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors" :title="t('app.notifications')">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9" />
|
||||
</svg>
|
||||
@@ -186,15 +186,12 @@ const { t, locale } = useI18n()
|
||||
const userName = computed(() => userStore.login || 'User')
|
||||
const userInitials = computed(() => (userName.value[0] || 'U').toUpperCase())
|
||||
|
||||
// Sidebar collapsed state with localStorage
|
||||
const SIDEBAR_STORAGE_KEY = 'admin_sidebar_collapsed'
|
||||
const sidebarCollapsed = ref(false)
|
||||
|
||||
onMounted(() => {
|
||||
const saved = localStorage.getItem(SIDEBAR_STORAGE_KEY)
|
||||
if (saved !== null) {
|
||||
sidebarCollapsed.value = saved === 'true'
|
||||
}
|
||||
if (saved !== null) sidebarCollapsed.value = saved === 'true'
|
||||
})
|
||||
|
||||
function toggleSidebar() {
|
||||
@@ -210,11 +207,20 @@ async function logout() {
|
||||
|
||||
async function toggleLanguage() {
|
||||
const newLang = locale.value === 'en' ? 'ru' : 'en'
|
||||
const ok = await userStore.updateProfile({ language: newLang })
|
||||
if (ok) {
|
||||
locale.value = newLang
|
||||
if (userStore.id) {
|
||||
const ok = await userStore.updateProfile({ language: newLang })
|
||||
if (ok) {
|
||||
locale.value = newLang
|
||||
localStorage.setItem('locale', newLang)
|
||||
} else {
|
||||
// В случае ошибки всё равно меняем локаль, но не сохраняем в БД
|
||||
locale.value = newLang
|
||||
localStorage.setItem('locale', newLang)
|
||||
}
|
||||
} else {
|
||||
// Для неавторизованных просто сохраняем в localStorage
|
||||
locale.value = newLang
|
||||
localStorage.setItem('locale', newLang)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user