Main.vue 8.6 KB

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