Navbar.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <v-toolbar dark>
  3. <nuxt-link to="/admin/publications" class="subheading">
  4. <div class="amic-logo-invert">
  5. <img :src="require('~/static/svg/symbol/amic-logo.svg')" />
  6. </div>
  7. </nuxt-link>
  8. <v-spacer></v-spacer>
  9. <client-only>
  10. <v-toolbar-items class="hidden-sm-and-down">
  11. <v-btn
  12. v-for="route in allowedRoutes"
  13. :key="route.code"
  14. link
  15. :to="route.url"
  16. >
  17. {{ route.title }}
  18. </v-btn>
  19. <v-btn link to="/user/profile">
  20. <v-icon left> mdi-account-outline </v-icon>
  21. </v-btn>
  22. </v-toolbar-items>
  23. </client-only>
  24. <!--<v-app-bar-nav-icon ></v-app-bar-nav-icon>-->
  25. </v-toolbar>
  26. </template>
  27. <script>
  28. export default {
  29. head() {
  30. return {
  31. title: "Административный кабинет",
  32. };
  33. },
  34. data: () => ({
  35. role: null,
  36. routes: [
  37. {
  38. code: "users",
  39. title: "Пользователи",
  40. url: "/admin/users",
  41. },
  42. {
  43. code: "publications",
  44. title: "Публикации",
  45. url: "/admin/publications",
  46. },
  47. {
  48. code: "comments",
  49. title: "Комментарии",
  50. url: "/admin/comments",
  51. },
  52. {
  53. code: "log",
  54. title: "Лог комментариев",
  55. url: "/admin/comments/log",
  56. },
  57. {
  58. code: "sections",
  59. title: "Секции",
  60. url: "/admin/sections",
  61. },
  62. {
  63. code: "sliders",
  64. title: "Слайдеры",
  65. url: "/admin/sliders",
  66. },
  67. {
  68. code: "advertising",
  69. title: "Реклама",
  70. url: "/admin/advertising",
  71. },
  72. {
  73. code: "pages",
  74. title: "Страницы",
  75. url: "/admin/pages",
  76. },
  77. {
  78. code: "menu",
  79. title: "Меню",
  80. url: "/admin/menu"
  81. }
  82. ],
  83. roles: [
  84. {
  85. code: 2,
  86. name: "Менеджер по рекламе",
  87. routes: ["advertising"],
  88. },
  89. {
  90. code: 3,
  91. name: "Репортер",
  92. routes: [
  93. "publications",
  94. "sections",
  95. "sliders"
  96. ],
  97. },
  98. {
  99. code: 4,
  100. name: "Модератор",
  101. routes: [
  102. "comments",
  103. "sections",
  104. "sliders"
  105. ],
  106. },
  107. {
  108. code: 5,
  109. name: "Администратор",
  110. routes: [
  111. "users",
  112. "publications",
  113. "comments",
  114. "log",
  115. "sections",
  116. "advertising",
  117. "pages",
  118. "menu",
  119. "sliders"
  120. ],
  121. },
  122. {
  123. code: 6,
  124. name: "ФСБ",
  125. routes: ["log"],
  126. },
  127. ],
  128. }),
  129. beforeMount() {
  130. this.roleCode = this.$auth.user.user_permission_group;
  131. },
  132. computed: {
  133. currentRole() {
  134. return this.roles.find((role) => role.code == this.roleCode);
  135. },
  136. allowedRoutes() {
  137. if (!this.currentRole) return [];
  138. return this.routes.filter((route) =>
  139. this.currentRole.routes.includes(route.code)
  140. );
  141. },
  142. },
  143. };
  144. </script>
  145. <style lang="less">
  146. .amic-logo-invert {
  147. filter: invert(100%);
  148. }
  149. </style>