| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- # app/pages/Admin/index.coffee
- if globalThis.stylFns and globalThis.stylFns['app/pages/Admin/index.styl']
- styleElement = document.createElement('style')
- styleElement.type = 'text/css'
- styleElement.textContent = globalThis.stylFns['app/pages/Admin/index.styl']
- document.head.appendChild(styleElement)
- module.exports = {
- props:
- domainSettings:
- type: Object
- default: -> {}
- language:
- type: String
- default: 'ru'
- data: ->
- {
- user: null
- breadcrumbs: []
- }
- computed:
- currentRoute: -> @$route
- methods:
- logout: ->
- localStorage.removeItem('user')
- @$router.push('/')
- @$emit('show-notification', 'Вы вышли из админ-панели', 'info')
- updateBreadcrumbs: ->
- crumbs = [{ path: '/admin', name: 'Админ-панель' }]
-
- if @$route.matched.length > 1
- @$route.matched.slice(1).forEach (route) =>
- if route.meta?.breadcrumb
- crumbs.push({
- path: route.path,
- name: route.meta.breadcrumb
- })
-
- @breadcrumbs = crumbs
- getBreadcrumbName: (path, segment) ->
- names =
- '/admin': 'Админ-панель'
- '/admin/dashboard': 'Дашборд'
- '/admin/products': 'Товары'
- '/admin/categories': 'Категории'
- '/admin/import': 'Импорт'
- '/admin/media': 'Медиа'
-
- return names[path] || segment.charAt(0).toUpperCase() + segment.slice(1)
- watch:
- '$route.path': ->
- @updateBreadcrumbs()
- mounted: ->
- userData = localStorage.getItem('user')
- if userData
- try
- @user = JSON.parse(userData)
- catch
- @user = null
-
- @updateBreadcrumbs()
- render: (new Function '_ctx', '_cache', globalThis.renderFns['app/pages/Admin/index.pug'])()
- }
|