| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- document.head.insertAdjacentHTML('beforeend','<style type="text/css">'+stylFns['app/pages/Admin/index.styl']+'</style>')
- PouchDB = require 'app/utils/pouch'
- # Иконки для меню (упрощенные компоненты)
- MenuIcons =
- SliderIcon:
- template: '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8h16M4 16h16"></path></svg>'
-
- ProductsIcon:
- template: '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path></svg>'
-
- ClientsIcon:
- template: '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"></path></svg>'
-
- BlogIcon:
- template: '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path></svg>'
-
- RoutesIcon:
- template: '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"></path></svg>'
-
- SettingsIcon:
- template: '<svg fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>'
- module.exports =
- name: 'AdminPanel'
- components: MenuIcons
-
- render: (new Function '_ctx', '_cache', renderFns['app/pages/Admin/index.pug'])()
-
- data: ->
- return {
- currentDomain: window.location.hostname
- mobileMenuOpen: false
- menuItems: [
- {
- id: 'slider'
- name: 'Слайдер'
- path: '/admin/slider'
- icon: 'SliderIcon'
- }
- {
- id: 'products'
- name: 'Товары'
- path: '/admin/products'
- icon: 'ProductsIcon'
- }
- {
- id: 'clients'
- name: 'Клиенты'
- path: '/admin/clients'
- icon: 'ClientsIcon'
- }
- {
- id: 'blog'
- name: 'Блог'
- path: '/admin/blog'
- icon: 'BlogIcon'
- }
- {
- id: 'routes'
- name: 'Маршруты'
- path: '/admin/routes'
- icon: 'RoutesIcon'
- }
- {
- id: 'settings'
- name: 'Настройки'
- path: '/admin/settings'
- icon: 'SettingsIcon'
- }
- ]
- }
-
- computed:
- currentRoute: ->
- @$route.path.split('/').pop() || 'settings'
-
- showMobileMenuButton: ->
- window.innerWidth < 1024
-
- methods:
- navigateTo: (path) ->
- @mobileMenuOpen = false
- @$router.push(path)
-
- toggleMobileMenu: ->
- @mobileMenuOpen = !@mobileMenuOpen
-
- getMenuItemClass: (item) ->
- baseClass = 'admin__nav-item'
- isActive = @currentRoute == item.id
-
- if isActive
- return "#{baseClass} admin__nav-item--active"
- else
- return "#{baseClass} admin__nav-item--inactive"
-
- getSidebarClass: ->
- if @mobileMenuOpen
- return 'admin__sidebar--visible'
- else
- return 'admin__sidebar--hidden'
-
- loadDomainSettings: ->
- PouchDB.getDocument("domain_settings:#{@currentDomain}")
- .then (settings) =>
- @domainSettings = settings
- .catch (error) =>
- debug.log 'Настройки домена не найдены, используются значения по умолчанию'
- @domainSettings = null
-
- handleResize: ->
- if window.innerWidth >= 1024
- @mobileMenuOpen = false
-
- mounted: ->
- @loadDomainSettings()
- window.addEventListener 'resize', @handleResize
-
- beforeUnmount: ->
- window.removeEventListener 'resize', @handleResize
|