/
Gabryelf
/
Pixel-Orb
Обзор
Документация
Войти
/
Gabryelf
/
Pixel-Orb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/server/core/app.js
55 строк
1 KB
Valeev Serj
restruct_v0.0.1
07 авг 2026, 22:50
07 авг 2026, 22:50
41f78a4
Код
Авторство
О чём код?
import EventBus from './eventBus.js'; import Router from './router.js'; import AuthService from '../../services/authService.js'; import ProjectService from '../../services/projectService.js'; class App { constructor() { this.eventBus = new EventBus(); this.router = new Router(); this.currentUser = null; this.currentProject = null; this.init(); } async init() { await this.loadUser(); this.setupRoutes(); this.initUI(); this.eventBus.emit('app:ready'); } async loadUser() { const token = localStorage.getItem('pixelOrbToken'); if (token) { try { this.currentUser = await AuthService.getCurrentUser(token); this.eventBus.emit('user:loaded', this.currentUser); } catch (error) { console.error('Failed to load user:', error); this.createGuestUser(); } } else { this.createGuestUser(); } } async createGuestUser() { this.currentUser = await AuthService.createGuest(); this.eventBus.emit('user:guest', this.currentUser); } setupRoutes() { this.router.addRoute('/', () => this.showMain()); this.router.addRoute('/editor', () => this.showEditor()); this.router.addRoute('/gallery', () => this.showGallery()); this.router.addRoute('/profile', () => this.showProfile()); } initUI() { // Инициализация UI компонентов } } export default App;