Main.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <div class="drawer-inside">
  3. <div class="side-menu-main-layout">
  4. <div class="side-logo">
  5. <q-btn flat
  6. round
  7. dense
  8. class="btn-logo"
  9. :to="{name: 'Public.Home'}">
  10. <q-img src="/assets/images/web/homepage-first-section-logo.png" />
  11. </q-btn>
  12. </div>
  13. <div class="side-menu-body">
  14. <q-list class="side-menu-list"
  15. padding>
  16. <menu-item :items="menuItems"
  17. :menu-items-color="'#5867dd'" />
  18. </q-list>
  19. <div v-if="isUserLogin"
  20. class="log-out"
  21. @click="logOut">
  22. <span>
  23. <q-avatar icon="isax:logout"
  24. size="30"
  25. dir="rtl" />
  26. </span>
  27. <span class="logout-text">خروج </span>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import { User } from 'src/models/User.js'
  35. import menuItem from 'src/components/Menu/SideMenu/MenuItem.vue'
  36. export default {
  37. name: 'MainSideBarTemplate',
  38. components: { menuItem },
  39. data () {
  40. return {
  41. user: new User(),
  42. isAdmin: false,
  43. isUserLogin: false,
  44. clickedItem: null,
  45. searchText: '',
  46. menuItems: [
  47. {
  48. title: 'اخبار و رویدادها',
  49. route: { name: 'Public.Post.List.News' },
  50. type: 'itemMenu',
  51. permission: 'all',
  52. show: true
  53. },
  54. {
  55. title: 'راهنما',
  56. route: { name: 'Public.Post.List.Guide' },
  57. type: 'itemMenu',
  58. permission: 'all',
  59. show: true
  60. },
  61. {
  62. title: 'فروشگاه',
  63. type: 'simpleMenu',
  64. children: [
  65. {
  66. title: 'کتب سطح یک',
  67. externalLink: 'https://formafzar.com/form/iv9cq',
  68. show: true
  69. },
  70. {
  71. title: 'کتب سطح چهار',
  72. externalLink: 'https://formafzar.com/form/dttpf',
  73. show: true
  74. },
  75. {
  76. title: 'کتب جریان‌شناسی',
  77. externalLink: 'https://formafzar.com/form/ch1om',
  78. show: true
  79. }
  80. ],
  81. show: false,
  82. mobileMode: true
  83. },
  84. {
  85. title: 'درباره ما',
  86. route: { name: 'Public.AboutUs' },
  87. type: 'itemMenu',
  88. permission: 'all',
  89. show: true
  90. },
  91. {
  92. title: 'تماس با ما',
  93. route: { name: 'Public.ContactUs' },
  94. type: 'itemMenu',
  95. permission: 'all',
  96. show: true
  97. },
  98. {
  99. title: 'سوالات متداول',
  100. route: { name: 'Public.FAQ' },
  101. type: 'itemMenu',
  102. permission: 'all',
  103. show: true
  104. }
  105. ]
  106. }
  107. },
  108. mounted() {
  109. window.addEventListener('resize', this.handleResize)
  110. this.handleResize()
  111. this.loadAuthData()
  112. },
  113. beforeUnmount() {
  114. window.removeEventListener('resize', this.handleResize)
  115. },
  116. methods: {
  117. loadAuthData () { // prevent Hydration node mismatch
  118. this.user = this.$store.getters['Auth/user']
  119. this.isAdmin = this.$store.getters['Auth/isAdmin']
  120. this.isUserLogin = this.$store.getters['Auth/isUserLogin']
  121. },
  122. handleResize() {
  123. const windowWidth = window.innerWidth
  124. this.menuItems.forEach(item => {
  125. if (item.mobileMode) {
  126. item.show = windowWidth < 1024
  127. }
  128. })
  129. },
  130. // updateMenuItems () {
  131. // if (!this.isUserLogin) {
  132. // this.titlesList.splice(0, 1)
  133. // }
  134. // },
  135. search (list, parentContain = false) {
  136. if (!list || list.length === 0) {
  137. return false
  138. }
  139. if (parentContain) {
  140. return true
  141. }
  142. let flag = false
  143. list.forEach(item => {
  144. const contain = item.title.includes(this.searchText)
  145. if (this.search(item.children, contain) || contain) {
  146. flag = true
  147. item.show = true
  148. item.open = true
  149. } else {
  150. item.open = false
  151. item.show = false
  152. }
  153. })
  154. return flag
  155. },
  156. logOut () {
  157. return this.$store.dispatch('Auth/logOut')
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .side-menu-main-layout {
  164. display: flex;
  165. flex-direction: column;
  166. overflow-y: auto;
  167. .side-logo {
  168. padding: 20px 90px;
  169. .btn-logo {
  170. width: 100%;
  171. }
  172. }
  173. .side-menu-body {
  174. display: grid;
  175. grid-template-rows: auto;
  176. .q-list {
  177. padding: 0;
  178. &.side-menu-list {
  179. .search-input {
  180. margin-bottom: 30px;
  181. }
  182. margin: 0 24px 109px 24px;
  183. @media screen and (max-width: 1919px) {
  184. margin: 0 24px 34px 24px;
  185. }
  186. @media screen and (max-width: 1439px) {
  187. margin: 0 21px 26px 21px;
  188. }
  189. @media screen and (max-width: 599px) {
  190. margin: 0 18px 8px 18px;
  191. }
  192. .top-separator {
  193. margin: 0 40px 32px 40px;
  194. @media screen and (max-width: 1919px) {
  195. margin: 0 30px 25px 30px;
  196. }
  197. @media screen and (max-width: 1439px) {
  198. margin: 0 45px 22px 45px;
  199. }
  200. }
  201. .q-item {
  202. padding: 0;
  203. min-height: 0;
  204. }
  205. }
  206. }
  207. .log-out {
  208. align-self: end;
  209. font-size: 16px;
  210. font-weight: 500;
  211. cursor: pointer;
  212. height: 40px !important;
  213. //width: 232px;
  214. border-radius: 14px;
  215. display: flex;
  216. align-items: center;
  217. padding: 0 14px 0 10px;
  218. margin: 0 0 36px 27px;
  219. @media screen and (max-width: 1439px) {
  220. margin: 0 31px 33px 31px;
  221. }
  222. @media screen and (max-width: 599px) {
  223. margin: 0 30px 30px 30px;
  224. //padding: 0 0 0 10px;
  225. }
  226. &:hover {
  227. background-color: rgba(255, 255, 255, 0.1);
  228. }
  229. .q-avatar {
  230. height: 22px;
  231. width: 22px;
  232. margin-right: 12px;
  233. transform: matrix(-1, 0, 0, 1, 0, 0);
  234. }
  235. }
  236. }
  237. .log-out {
  238. font-size: 16px;
  239. font-weight: 500;
  240. cursor: pointer;
  241. height: 40px !important;
  242. //width: 232px;
  243. border-radius: 14px;
  244. display: flex;
  245. align-items: center;
  246. padding: 0 14px 0 10px;
  247. margin: 0 0 36px 27px;
  248. @media screen and (max-width: 1439px) {
  249. margin: 0 31px 33px 31px;
  250. }
  251. @media screen and (max-width: 599px) {
  252. margin: 0 30px 30px 30px;
  253. //padding: 0 0 0 10px;
  254. }
  255. &:hover {
  256. background-color: rgba(255, 255, 255, 0.1);
  257. }
  258. .q-avatar {
  259. height: 22px;
  260. width: 22px;
  261. margin-right: 12px;
  262. transform: matrix(-1, 0, 0, 1, 0, 0);
  263. }
  264. }
  265. &:deep(.side-menu-main-layout) {
  266. .q-expansion-item__container {
  267. .q-item {
  268. display: flex;
  269. padding: 0 10px !important;
  270. }
  271. .q-icon {
  272. font-size: 21px;
  273. }
  274. }
  275. }
  276. }
  277. </style>