feat: добавил функцию форматирования имени пользователя и применил её в верхней панели и на главной странице
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 8s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 11s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 24s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 8s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 11s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 24s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s
This commit is contained in:
@@ -5,6 +5,7 @@ import { useAuthStore } from '@/stores/auth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import CoinChip from '@/components/ui/CoinChip.vue'
|
||||
import SearchInput from '@/components/ui/SearchInput.vue'
|
||||
import { formatUserName } from '@/utils/formatUserName'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const userStore = useUserStore()
|
||||
@@ -65,7 +66,7 @@ function openProfile() {
|
||||
@keydown.space.prevent="openProfile"
|
||||
>
|
||||
<span class="avatar-icon">👤</span>
|
||||
<span class="avatar-name" v-if="auth.user">{{ auth.user.name.split(' ')[0] }}</span>
|
||||
<span class="avatar-name" v-if="auth.user">{{ formatUserName(auth.user.name) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
export function formatUserName(name?: string | null) {
|
||||
if (!name) return ''
|
||||
|
||||
const parts = name.trim().split(' ').filter(Boolean)
|
||||
|
||||
// Если имя состоит из одного слова, оставляем его как есть.
|
||||
if (parts.length === 1) return parts[0]
|
||||
|
||||
// Бэкенд хранит displayName одной строкой, а в интерфейсе нам нужен формат
|
||||
// "имя + фамилия" для верхней панели и приветствия.
|
||||
return `${parts[1]} ${parts[0]}`
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import LectureCard from '@/components/ui/LectureCard.vue'
|
||||
import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||
import AchievementBadge from '@/components/ui/AchievementBadge.vue'
|
||||
import EmptyState from '@/components/ui/EmptyState.vue'
|
||||
import { formatUserName } from '@/utils/formatUserName'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const lectures = useLecturesStore()
|
||||
@@ -39,7 +40,7 @@ onMounted(async () => {
|
||||
<div class="dashboard page-content">
|
||||
<div class="dashboard-welcome">
|
||||
<div>
|
||||
<h1 class="page-title">Добрый день, {{ user.name.split(' ')[0] }}! 👋</h1>
|
||||
<h1 class="page-title">Добрый день, {{ formatUserName(user.name) }}! 👋</h1>
|
||||
<p class="text-secondary">{{ user.institute }} · {{ user.direction }} · {{ user.year }} курс</p>
|
||||
</div>
|
||||
<div class="quick-actions">
|
||||
|
||||
Reference in New Issue
Block a user