Main.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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/yk7z7',
  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/p1y9a',
  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. type: 'simpleMenu',
  136. children: [
  137. {
  138. title: 'معرفی مجموعه',
  139. route: { name: 'Public.AboutUs' },
  140. type: 'itemMenu',
  141. permission: 'all',
  142. show: true
  143. },
  144. {
  145. title: 'تماس با ما',
  146. route: { name: 'Public.ContactUs' },
  147. type: 'itemMenu',
  148. permission: 'all',
  149. show: true
  150. },
  151. {
  152. title: 'معرفی دوره ها',
  153. route: { name: 'Public.Landing.Show', params: { slug: 'courses' } },
  154. type: 'itemMenu',
  155. permission: 'all',
  156. show: true
  157. }
  158. ],
  159. show: false,
  160. mobileMode: true
  161. },
  162. {
  163. title: 'سوالات متداول',
  164. route: { name: 'Public.FAQ' },
  165. type: 'itemMenu',
  166. permission: 'all',
  167. show: true
  168. }
  169. ]
  170. }
  171. },
  172. mounted() {
  173. window.addEventListener('resize', this.handleResize)
  174. this.handleResize()
  175. this.loadAuthData()
  176. },
  177. beforeUnmount() {
  178. window.removeEventListener('resize', this.handleResize)
  179. },
  180. methods: {
  181. loadAuthData () { // prevent Hydration node mismatch
  182. this.user = this.$store.getters['Auth/user']
  183. this.isAdmin = this.$store.getters['Auth/isAdmin']
  184. this.isUserLogin = this.$store.getters['Auth/isUserLogin']
  185. },
  186. handleResize() {
  187. const windowWidth = window.innerWidth
  188. this.menuItems.forEach(item => {
  189. if (item.mobileMode) {
  190. item.show = windowWidth < 1024
  191. }
  192. })
  193. },
  194. // updateMenuItems () {
  195. // if (!this.isUserLogin) {
  196. // this.titlesList.splice(0, 1)
  197. // }
  198. // },
  199. search (list, parentContain = false) {
  200. if (!list || list.length === 0) {
  201. return false
  202. }
  203. if (parentContain) {
  204. return true
  205. }
  206. let flag = false
  207. list.forEach(item => {
  208. const contain = item.title.includes(this.searchText)
  209. if (this.search(item.children, contain) || contain) {
  210. flag = true
  211. item.show = true
  212. item.open = true
  213. } else {
  214. item.open = false
  215. item.show = false
  216. }
  217. })
  218. return flag
  219. },
  220. logOut () {
  221. return this.$store.dispatch('Auth/logOut')
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .side-menu-main-layout {
  228. display: flex;
  229. flex-direction: column;
  230. overflow-y: auto;
  231. .side-logo {
  232. padding: 20px 90px;
  233. .btn-logo {
  234. width: 100%;
  235. }
  236. }
  237. .side-menu-body {
  238. display: grid;
  239. grid-template-rows: auto;
  240. .q-list {
  241. padding: 0;
  242. &.side-menu-list {
  243. margin: 0 24px 109px 24px;
  244. .top-separator {
  245. margin: 0 40px 32px 40px;
  246. @media screen and (max-width: 1919px) {
  247. margin: 0 30px 25px 30px;
  248. }
  249. @media screen and (max-width: 1439px) {
  250. margin: 0 45px 22px 45px;
  251. }
  252. }
  253. .q-item {
  254. padding: 0;
  255. min-height: 0;
  256. }
  257. .search-input {
  258. margin-bottom: 30px;
  259. }
  260. @media screen and (max-width: 1919px) {
  261. & {
  262. margin: 0 24px 34px 24px;
  263. }
  264. }
  265. @media screen and (max-width: 1439px) {
  266. & {
  267. margin: 0 21px 26px 21px;
  268. }
  269. }
  270. @media screen and (max-width: 599px) {
  271. & {
  272. margin: 0 18px 8px 18px;
  273. }
  274. }
  275. }
  276. }
  277. .log-out {
  278. align-self: end;
  279. font-size: 16px;
  280. font-weight: 500;
  281. cursor: pointer;
  282. height: 40px !important;
  283. //width: 232px;
  284. border-radius: 14px;
  285. display: flex;
  286. align-items: center;
  287. padding: 0 14px 0 10px;
  288. margin: 0 0 36px 27px;
  289. &:hover {
  290. background-color: rgba(255, 255, 255, 0.1);
  291. }
  292. .q-avatar {
  293. height: 22px;
  294. width: 22px;
  295. margin-right: 12px;
  296. transform: matrix(-1, 0, 0, 1, 0, 0);
  297. }
  298. @media screen and (max-width: 1439px) {
  299. & {
  300. margin: 0 31px 33px 31px;
  301. }
  302. }
  303. @media screen and (max-width: 599px) {
  304. & {
  305. margin: 0 30px 30px 30px;
  306. //padding: 0 0 0 10px;
  307. }
  308. }
  309. }
  310. }
  311. .log-out {
  312. font-size: 16px;
  313. font-weight: 500;
  314. cursor: pointer;
  315. height: 40px !important;
  316. //width: 232px;
  317. border-radius: 14px;
  318. display: flex;
  319. align-items: center;
  320. padding: 0 14px 0 10px;
  321. margin: 0 0 36px 27px;
  322. &:hover {
  323. background-color: rgba(255, 255, 255, 0.1);
  324. }
  325. .q-avatar {
  326. height: 22px;
  327. width: 22px;
  328. margin-right: 12px;
  329. transform: matrix(-1, 0, 0, 1, 0, 0);
  330. }
  331. @media screen and (max-width: 1439px) {
  332. & {
  333. margin: 0 31px 33px 31px;
  334. }
  335. }
  336. @media screen and (max-width: 599px) {
  337. & {
  338. margin: 0 30px 30px 30px;
  339. //padding: 0 0 0 10px;
  340. }
  341. }
  342. }
  343. &:deep(.side-menu-main-layout) {
  344. .q-expansion-item__container {
  345. .q-item {
  346. display: flex;
  347. padding: 0 10px !important;
  348. }
  349. .q-icon {
  350. font-size: 21px;
  351. }
  352. }
  353. }
  354. }
  355. </style>