Main.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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/zmvhh',
  73. show: true
  74. },
  75. {
  76. title: 'کتب سطح چهار',
  77. externalLink: 'https://formafzar.com/form/dttpf',
  78. show: true
  79. },
  80. {
  81. title: 'کتب سطح پنج',
  82. externalLink: 'https://formafzar.com/form/qlif0',
  83. show: true
  84. }
  85. {
  86. title: 'کتب جریان‌شناسی',
  87. externalLink: 'https://formafzar.com/form/ch1om',
  88. show: true
  89. },
  90. {
  91. title: 'کتب جریان‌شناسی سطح دو',
  92. externalLink: 'https://formafzar.com/form/xskmo',
  93. show: true
  94. },
  95. {
  96. title: 'کتاب تشکیلات بهشتی',
  97. externalLink: 'https://formafzar.com/form/j3x1d',
  98. show: true
  99. }
  100. ],
  101. show: false,
  102. mobileMode: true
  103. },
  104. {
  105. title: 'درباره ما',
  106. route: { name: 'Public.AboutUs' },
  107. type: 'itemMenu',
  108. permission: 'all',
  109. show: true
  110. },
  111. {
  112. title: 'تماس با ما',
  113. route: { name: 'Public.ContactUs' },
  114. type: 'itemMenu',
  115. permission: 'all',
  116. show: true
  117. },
  118. {
  119. title: 'سوالات متداول',
  120. route: { name: 'Public.FAQ' },
  121. type: 'itemMenu',
  122. permission: 'all',
  123. show: true
  124. }
  125. ]
  126. }
  127. },
  128. mounted() {
  129. window.addEventListener('resize', this.handleResize)
  130. this.handleResize()
  131. this.loadAuthData()
  132. },
  133. beforeUnmount() {
  134. window.removeEventListener('resize', this.handleResize)
  135. },
  136. methods: {
  137. loadAuthData () { // prevent Hydration node mismatch
  138. this.user = this.$store.getters['Auth/user']
  139. this.isAdmin = this.$store.getters['Auth/isAdmin']
  140. this.isUserLogin = this.$store.getters['Auth/isUserLogin']
  141. },
  142. handleResize() {
  143. const windowWidth = window.innerWidth
  144. this.menuItems.forEach(item => {
  145. if (item.mobileMode) {
  146. item.show = windowWidth < 1024
  147. }
  148. })
  149. },
  150. // updateMenuItems () {
  151. // if (!this.isUserLogin) {
  152. // this.titlesList.splice(0, 1)
  153. // }
  154. // },
  155. search (list, parentContain = false) {
  156. if (!list || list.length === 0) {
  157. return false
  158. }
  159. if (parentContain) {
  160. return true
  161. }
  162. let flag = false
  163. list.forEach(item => {
  164. const contain = item.title.includes(this.searchText)
  165. if (this.search(item.children, contain) || contain) {
  166. flag = true
  167. item.show = true
  168. item.open = true
  169. } else {
  170. item.open = false
  171. item.show = false
  172. }
  173. })
  174. return flag
  175. },
  176. logOut () {
  177. return this.$store.dispatch('Auth/logOut')
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .side-menu-main-layout {
  184. display: flex;
  185. flex-direction: column;
  186. overflow-y: auto;
  187. .side-logo {
  188. padding: 20px 90px;
  189. .btn-logo {
  190. width: 100%;
  191. }
  192. }
  193. .side-menu-body {
  194. display: grid;
  195. grid-template-rows: auto;
  196. .q-list {
  197. padding: 0;
  198. &.side-menu-list {
  199. .search-input {
  200. margin-bottom: 30px;
  201. }
  202. margin: 0 24px 109px 24px;
  203. @media screen and (max-width: 1919px) {
  204. margin: 0 24px 34px 24px;
  205. }
  206. @media screen and (max-width: 1439px) {
  207. margin: 0 21px 26px 21px;
  208. }
  209. @media screen and (max-width: 599px) {
  210. margin: 0 18px 8px 18px;
  211. }
  212. .top-separator {
  213. margin: 0 40px 32px 40px;
  214. @media screen and (max-width: 1919px) {
  215. margin: 0 30px 25px 30px;
  216. }
  217. @media screen and (max-width: 1439px) {
  218. margin: 0 45px 22px 45px;
  219. }
  220. }
  221. .q-item {
  222. padding: 0;
  223. min-height: 0;
  224. }
  225. }
  226. }
  227. .log-out {
  228. align-self: end;
  229. font-size: 16px;
  230. font-weight: 500;
  231. cursor: pointer;
  232. height: 40px !important;
  233. //width: 232px;
  234. border-radius: 14px;
  235. display: flex;
  236. align-items: center;
  237. padding: 0 14px 0 10px;
  238. margin: 0 0 36px 27px;
  239. @media screen and (max-width: 1439px) {
  240. margin: 0 31px 33px 31px;
  241. }
  242. @media screen and (max-width: 599px) {
  243. margin: 0 30px 30px 30px;
  244. //padding: 0 0 0 10px;
  245. }
  246. &:hover {
  247. background-color: rgba(255, 255, 255, 0.1);
  248. }
  249. .q-avatar {
  250. height: 22px;
  251. width: 22px;
  252. margin-right: 12px;
  253. transform: matrix(-1, 0, 0, 1, 0, 0);
  254. }
  255. }
  256. }
  257. .log-out {
  258. font-size: 16px;
  259. font-weight: 500;
  260. cursor: pointer;
  261. height: 40px !important;
  262. //width: 232px;
  263. border-radius: 14px;
  264. display: flex;
  265. align-items: center;
  266. padding: 0 14px 0 10px;
  267. margin: 0 0 36px 27px;
  268. @media screen and (max-width: 1439px) {
  269. margin: 0 31px 33px 31px;
  270. }
  271. @media screen and (max-width: 599px) {
  272. margin: 0 30px 30px 30px;
  273. //padding: 0 0 0 10px;
  274. }
  275. &:hover {
  276. background-color: rgba(255, 255, 255, 0.1);
  277. }
  278. .q-avatar {
  279. height: 22px;
  280. width: 22px;
  281. margin-right: 12px;
  282. transform: matrix(-1, 0, 0, 1, 0, 0);
  283. }
  284. }
  285. &:deep(.side-menu-main-layout) {
  286. .q-expansion-item__container {
  287. .q-item {
  288. display: flex;
  289. padding: 0 10px !important;
  290. }
  291. .q-icon {
  292. font-size: 21px;
  293. }
  294. }
  295. }
  296. }
  297. </style>