# Подключение мета информации 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', '') globalThis.AppDB = new require('app/utils/AppDB') await globalThis.AppDB.init() # Маршруты 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._ = @ computed: currentLanguage: -> @appState.currentLanguage watch: currentLanguage: handler: (newDoc) -> debug.dir newDoc @loadDocumentForPath(window.location.pathname) immediate: true methods: parse: (md)-> marked.parse md 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 debug.log ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" doc = await AppDB.getDocumentByPath(path, AppDB.currentLanguage) debug.dir doc debug.log "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" @appState.currentDocument = doc @appState.loading = false # Устанавливаем заголовок страницы if doc?.title document.head.insertAdjacentHTML('beforeend', '