From fc380c7c5186dffec1c7465e339fa8a13d6e2d2b Mon Sep 17 00:00:00 2001 From: Sergey Karmanov Date: Mon, 11 May 2026 02:04:42 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=B8=20=D0=BF=D1=80=D0=B8=D0=BC=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B5=D1=91=20=D0=B2=20=D0=B2=D0=B5=D1=80=D1=85=D0=BD?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=BF=D0=B0=D0=BD=D0=B5=D0=BB=D0=B8=20=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/layout/AppTopbar.vue | 3 ++- frontend/src/utils/formatUserName.ts | 12 ++++++++++++ frontend/src/views/student/DashboardView.vue | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 frontend/src/utils/formatUserName.ts diff --git a/frontend/src/components/layout/AppTopbar.vue b/frontend/src/components/layout/AppTopbar.vue index 22a4fa2..53af3d5 100644 --- a/frontend/src/components/layout/AppTopbar.vue +++ b/frontend/src/components/layout/AppTopbar.vue @@ -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" > 👤 - {{ auth.user.name.split(' ')[0] }} + {{ formatUserName(auth.user.name) }} diff --git a/frontend/src/utils/formatUserName.ts b/frontend/src/utils/formatUserName.ts new file mode 100644 index 0000000..5a23636 --- /dev/null +++ b/frontend/src/utils/formatUserName.ts @@ -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]}` +} diff --git a/frontend/src/views/student/DashboardView.vue b/frontend/src/views/student/DashboardView.vue index d890b4a..09535ec 100644 --- a/frontend/src/views/student/DashboardView.vue +++ b/frontend/src/views/student/DashboardView.vue @@ -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 () => {
-

Добрый день, {{ user.name.split(' ')[0] }}! 👋

+

Добрый день, {{ formatUserName(user.name) }}! 👋

{{ user.institute }} · {{ user.direction }} · {{ user.year }} курс