index.coffee 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Загрузка стилей компонента
  2. document.head.insertAdjacentHTML('beforeend','<style type="text/tailwindcss" page="Home">'+stylFns['app/pages/Home/index.styl']+'</style>')
  3. module.exports =
  4. name: 'HomePage'
  5. render: (new Function '_ctx', '_cache', renderFns['app/pages/Home/index.pug'])()
  6. data: ->
  7. featuredContent: []
  8. loading: true
  9. error: null
  10. beforeMount: ->
  11. @loadFeaturedContent()
  12. methods:
  13. loadFeaturedContent: ->
  14. try
  15. @loading = true
  16. # Загрузка различных типов контента
  17. promises = [
  18. AppDB.getSlides(limit: 6)
  19. AppDB.getUpcomingEvents(limit: 3)
  20. AppDB.getBlogPosts(limit: 3, featured: true)
  21. ]
  22. results = await Promise.all(promises)
  23. @featuredContent = [
  24. { type: 'slides', items: results[0], title: 'Главные события' }
  25. { type: 'events', items: results[1], title: 'Ближайшие мероприятия' }
  26. { type: 'blog', items: results[2], title: 'Последние новости' }
  27. ]
  28. @loading = false
  29. catch error
  30. @error = "Ошибка загрузки контента: "+error
  31. @loading = false
  32. # Получение текста с учетом текущего языка
  33. getText: (textArray) ->
  34. return AppDB.multilingual.getText(textArray, '')
  35. # Форматирование даты
  36. formatDate: (dateString) ->
  37. return new Date(dateString).toLocaleDateString('ru-RU', {
  38. year: 'numeric'
  39. month: 'long'
  40. day: 'numeric'
  41. })
  42. template: renderFns['app/pages/Home/index.pug']