feat: подготовил дизайн (изменения из другого репозитория)
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 5s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 8s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 3s

This commit is contained in:
serega404 committed 2026-05-08 01:06:22 +03:00
1 parent 655ab1b5c5
commit 047611fd24
54 files changed
+4497 -28

No files matched your search

+90
View File
@@ -0,0 +1,90 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { User, UserRole } from '@/types'
const defaultUsers: Record<UserRole, User> = {
student: {
id: 'stu-1',
name: 'Алексей Морозов',
email: 'a.morozov@sfedu.ru',
role: 'student',
institute: 'ИКТИБ',
department: 'Программная инженерия',
year: 3,
direction: 'Программная инженерия',
coins: 340,
level: 3,
xp: 120,
lecturesAttended: 12,
hoursLearned: 18.5,
achievements: ['1', '2', '3'],
},
teacher: {
id: 't-1',
name: 'Михаил Сергеевич Волков',
email: 'm.volkov@sfedu.ru',
role: 'teacher',
institute: 'ИКТИБ',
department: 'каф. Информатики',
year: 0,
direction: 'Информатика и вычислительная техника',
coins: 90,
level: 4,
xp: 240,
lecturesAttended: 24,
hoursLearned: 56,
achievements: ['1', '2', '3', '4'],
},
admin: {
id: 'adm-1',
name: 'Виктор Алексеев',
email: 'admin@sfedu.ru',
role: 'admin',
institute: 'ЮФУ',
department: 'Администрация',
year: 0,
direction: 'Цифровое развитие',
coins: 0,
level: 5,
xp: 500,
lecturesAttended: 0,
hoursLearned: 0,
achievements: [],
},
}
export const useAuthStore = defineStore('auth', () => {
const user = ref<User | null>(null)
const isAuthenticated = ref(false)
const loading = ref(false)
const error = ref<string | null>(null)
async function login(role: UserRole = 'student', shouldFail = false) {
loading.value = true
error.value = null
await new Promise(r => setTimeout(r, 800))
if (shouldFail) {
loading.value = false
error.value = 'Не удалось подтвердить доступ через ЮФУ. Попробуйте еще раз.'
return false
}
user.value = { ...defaultUsers[role] }
isAuthenticated.value = true
loading.value = false
return true
}
function logout() {
user.value = null
isAuthenticated.value = false
}
function switchRole(role?: UserRole) {
if (!user.value) return
const roles: UserRole[] = ['student', 'teacher', 'admin']
const nextRole = (role ?? roles[(roles.indexOf(user.value.role) + 1) % roles.length]) as UserRole
user.value = { ...defaultUsers[nextRole] }
}
return { user, isAuthenticated, loading, error, login, logout, switchRole }
})