# Подключение мета информации document.head.insertAdjacentHTML 'beforeend', '' document.head.insertAdjacentHTML 'beforeend', '' # Настройка tailwind #tailwind.config = require 'tailwind.config.js' # Подключение основных стилей document.head.insertAdjacentHTML('beforeend', '') document.head.insertAdjacentHTML('beforeend', '') document.head.insertAdjacentHTML('beforeend', '') # Маршруты routes = [ { path: '/', component: require 'app/pages/Home' } #{ path: '/:path*', component: require 'app/pages/DocumentPage' } ] globalThis._ = {} # Глобальное определение vuejs приложения globalThis.app = Vue.createApp name: 'app' data: () -> return { appState: currentDocument: null currentLanguage: 'ru' availableLanguages: ['ru', 'en', 'tj'] loading: true error: null } beforeMount: -> globalThis.AppDB = new (require 'app/utils/AppDB')() await globalThis.AppDB.init() globalThis._ = @ computed: currentLanguage: -> @appState.currentLanguage watch: currentLanguage: handler: (newDoc) -> debug.dir newDoc @loadDocumentForPath(window.location.pathname) immediate: true methods: initializeApp: -> # Определяем язык из URL или браузера @detectLanguage() # Загружаем документ для текущего пути @loadDocumentForPath(window.location.pathname) detectLanguage: -> # Простая логика определения языка pathLang = window.location.pathname.split('/')[1] if pathLang in @appState.availableLanguages @appState.currentLanguage = pathLang else browserLang = navigator.language.split('-')[0] if browserLang in @appState.availableLanguages @appState.currentLanguage = browserLang loadDocumentForPath: (path) -> try @appState.loading = true doc = await AppDB.getDocumentByPath(path, AppDB.currentLanguage) @appState.currentDocument = doc @appState.loading = false # Устанавливаем заголовок страницы if doc?.title document.head.insertAdjacentHTML('beforeend', '