| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- # app/router/index.coffee
- config = require 'app/config'
- # Middleware для проверки прав доступа
- authGuard = (to, from, next) ->
- log 'Проверка прав доступа для route:', to.path
- # Здесь будет логика проверки пользователя из глобального состояния
- if to.matched.some (record) -> record.meta.requiresAuth
- # Проверка авторизации
- next() # Временная заглушка - всегда разрешаем доступ
- else
- next()
- domainMiddleware = (to, from, next) ->
- log 'Обработка динамического домена для route'
- # Логика обработки домена будет интегрирована позже
- next()
- router = VueRouter.createRouter({
- history: VueRouter.createWebHistory()
- routes: [
- {
- path: '/'
- name: 'Home'
- component: require 'app/pages/Home/index.coffee'
- beforeEnter: [domainMiddleware]
- }
- {
- path: '/catalog'
- name: 'Catalog'
- component: require 'app/pages/Catalog/index.coffee'
- beforeEnter: [domainMiddleware]
- }
- {
- path: '/catalog/:category?'
- name: 'CatalogCategory'
- component: require 'app/pages/Catalog/index.coffee'
- beforeEnter: [domainMiddleware]
- }
- {
- path: '/product/:id'
- name: 'Product'
- component: require 'app/pages/Product/index.coffee'
- beforeEnter: [domainMiddleware]
- }
- {
- path: '/cart'
- name: 'Cart'
- component: require 'app/pages/Cart/index.coffee'
- beforeEnter: [domainMiddleware]
- }
- {
- path: '/admin'
- name: 'Admin'
- component: require 'app/pages/Admin/index.coffee'
- meta: { requiresAuth: true }
- beforeEnter: [domainMiddleware, authGuard]
- }
- {
- path: '/:pathMatch(.*)*'
- name: 'NotFound'
- component: require 'app/pages/NotFound/index.coffee'
- beforeEnter: [domainMiddleware]
- }
- ]
- })
- # Глобальные обработчики роутера
- router.beforeEach (to, from, next) ->
- #log "Переход с "+ from.fullPath +" на "+to.fullPath+""
- next()
- router.afterEach (to, from) ->
- #log "Навигация завершена на "+to.fullPath+""
- module.exports = router
|