MainHeader.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. <template>
  2. <div class="header-inside col"
  3. :class="{'isHomePage': isHomePage}">
  4. <div class="user-top-menu"
  5. :class="{'isHomePage': isHomePage}">
  6. <div class="right-side">
  7. <q-toolbar>
  8. <q-btn class="lt-md q-mr-md"
  9. icon="menu"
  10. color="primary"
  11. round
  12. flat
  13. text-color="gray"
  14. dense
  15. unelevated
  16. @click="toggleLeftDrawer" />
  17. <q-btn flat
  18. round
  19. dense
  20. class="top-menu-item top-menu-logo gt-sm"
  21. :to="{name: 'Public.Home'}">
  22. <q-img src="/assets/images/web/user-top-menu-logo.png"
  23. width="53" />
  24. </q-btn>
  25. <div class="gt-sm">
  26. <q-btn stretch
  27. flat
  28. label="اخبار و اطلاعیه ها"
  29. :to="{ name: 'Public.Post.List.News' }"
  30. class="top-menu-item" />
  31. <q-btn stretch
  32. flat
  33. label="راهنما"
  34. :to="{ name: 'Public.Post.List.Guide' }"
  35. class="top-menu-item" />
  36. <q-btn stretch
  37. flat
  38. label="فروشگاه"
  39. class="top-menu-item">
  40. <q-menu>
  41. <q-list style="min-width: 100px">
  42. <q-item v-close-popup
  43. href="https://formafzar.com/form/iv9cq"
  44. target="_blank"
  45. clickable>
  46. <q-item-section>کتب سطح یک</q-item-section>
  47. </q-item>
  48. <q-item v-close-popup
  49. href="https://formafzar.com/form/ch1om"
  50. target="_blank"
  51. clickable>
  52. <q-item-section>کتب جریان‌شناسی</q-item-section>
  53. </q-item>
  54. </q-list>
  55. </q-menu>
  56. </q-btn>
  57. <q-btn stretch
  58. flat
  59. label="درباره ما"
  60. :to="{ name: 'Public.AboutUs' }"
  61. class="top-menu-item" />
  62. <q-btn stretch
  63. flat
  64. label="تماس با ما"
  65. :to="{ name: 'Public.ContactUs' }"
  66. class="top-menu-item" />
  67. <q-btn stretch
  68. flat
  69. label="سوالات متداول"
  70. :to="{ name: 'Public.FAQ' }"
  71. class="top-menu-item" />
  72. </div>
  73. </q-toolbar>
  74. </div>
  75. <q-btn flat
  76. round
  77. dense
  78. class="center-logo lt-md"
  79. :to="{name: 'Public.Home'}">
  80. <q-img src="/assets/images/web/homepage-first-section-logo.png" />
  81. </q-btn>
  82. <div class="left-side">
  83. <q-btn v-if="user && user.id !== null"
  84. color="primary"
  85. @click="goToProperPanel">
  86. <svg id="_000000ff"
  87. data-name="#000000ff"
  88. xmlns="http://www.w3.org/2000/svg"
  89. width="19.995"
  90. height="19.995"
  91. viewBox="0 0 19.995 19.995">
  92. <path id="Path_29101"
  93. data-name="Path 29101"
  94. d="M5.87,0h8.253a6.009,6.009,0,0,1,5.509,3.949A6.133,6.133,0,0,1,20,5.873v8.214a6.011,6.011,0,0,1-4.645,5.752A6.293,6.293,0,0,1,14.124,20H5.873A6.008,6.008,0,0,1,0,14.085V5.872A6.012,6.012,0,0,1,5.87,0M5.526,1.356a4.673,4.673,0,0,0-4.195,4.66q0,4,0,8.005a4.676,4.676,0,0,0,4.684,4.643q4,0,8,0a4.675,4.675,0,0,0,4.645-4.644q0-4.024,0-8.047a4.673,4.673,0,0,0-3.974-4.589,8.038,8.038,0,0,0-1.257-.053H6.288A7.085,7.085,0,0,0,5.526,1.356Z"
  95. fill="#fff" />
  96. <path id="Path_29102"
  97. data-name="Path 29102"
  98. d="M157.367,85.315a4,4,0,1,1-2.651,1.25,4,4,0,0,1,2.651-1.25m-.228,1.373a2.666,2.666,0,1,0,1.776.286A2.674,2.674,0,0,0,157.139,86.688Z"
  99. transform="translate(-147.63 -81.975)"
  100. fill="#fff" />
  101. <path id="Path_29103"
  102. data-name="Path 29103"
  103. d="M122.8,324.315c.815-.016,1.63,0,2.446-.007a5.976,5.976,0,0,1,4.042,1.606.67.67,0,0,1,.145.733.651.651,0,0,1-.749.385,1.129,1.129,0,0,1-.5-.325,4.66,4.66,0,0,0-2.94-1.081q-1.093,0-2.187,0a4.66,4.66,0,0,0-3.1,1.23.694.694,0,0,1-.528.214.668.668,0,0,1-.457-1.121A5.994,5.994,0,0,1,122.8,324.315Z"
  104. transform="translate(-114.152 -311.642)"
  105. fill="#fff" />
  106. </svg>
  107. <span class="btn-label">
  108. حساب کاربری
  109. </span>
  110. <q-menu v-if="user.isAdmin() || user.isSuperUser()"
  111. fit>
  112. <q-list>
  113. <q-item v-close-popup
  114. clickable
  115. :to="{ name: 'UserPanel.Profile.UserInfo' }">
  116. <q-item-section>
  117. پنل کاربری
  118. </q-item-section>
  119. </q-item>
  120. <q-item v-close-popup
  121. clickable
  122. :to="{ name: 'Admin.User.Index' }">
  123. <q-item-section>
  124. پنل ادمین
  125. </q-item-section>
  126. </q-item>
  127. <q-item v-close-popup
  128. clickable
  129. @click="logOut">
  130. <q-item-section>
  131. خروج
  132. </q-item-section>
  133. </q-item>
  134. </q-list>
  135. </q-menu>
  136. </q-btn>
  137. <q-btn v-else
  138. color="primary"
  139. :to="{name: 'Login'}">
  140. <span class="btn-label">
  141. ورود / ثبت نام
  142. </span>
  143. <svg id="Login"
  144. xmlns="http://www.w3.org/2000/svg"
  145. width="18.479"
  146. height="20"
  147. viewBox="0 0 18.479 20">
  148. <path id="Combined_Shape"
  149. data-name="Combined Shape"
  150. d="M9.157,0A4.429,4.429,0,0,0,4.733,4.424v.942a.75.75,0,0,0,1.5,0V4.424A2.928,2.928,0,0,1,9.157,1.5h4.885a2.939,2.939,0,0,1,2.936,2.937V15.575A2.929,2.929,0,0,1,14.053,18.5H9.169a2.938,2.938,0,0,1-2.935-2.934v-.932a.75.75,0,1,0-1.5,0v.932A4.44,4.44,0,0,0,9.169,20h4.884a4.431,4.431,0,0,0,4.425-4.425V4.436A4.442,4.442,0,0,0,14.042,0Zm.176,6.556a.75.75,0,0,0,0,1.06L10.975,9.25H.75a.75.75,0,1,0,0,1.5H10.976L9.334,12.385a.75.75,0,1,0,1.058,1.062l2.929-2.916a.747.747,0,0,0,0-1.062L10.393,6.554a.75.75,0,0,0-1.06,0Z"
  151. transform="translate(18.479 20) rotate(180)"
  152. fill="#fff" />
  153. </svg>
  154. </q-btn>
  155. </div>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import { User } from 'src/models/User.js'
  161. import { mapGetters, mapMutations } from 'vuex'
  162. export default {
  163. name: 'templateHeader',
  164. data () {
  165. return {
  166. user: new User(),
  167. topMenuItems: [
  168. ]
  169. }
  170. },
  171. computed: {
  172. isAdminPage () {
  173. return this.$route.name && this.$route.name.includes('Admin.')
  174. },
  175. isProfilePage () {
  176. return this.$route.name && this.$route.name.includes('UserPanel.Profile.')
  177. },
  178. isHomePage () {
  179. return this.$route.name && this.$route.name === 'Public.Home'
  180. },
  181. ...mapGetters('AppLayout', [
  182. 'breadcrumbs',
  183. 'windowSize'
  184. ])
  185. },
  186. mounted () {
  187. this.loadAuthData()
  188. },
  189. methods: {
  190. ...mapMutations('AppLayout', [
  191. 'updateLayoutLeftDrawerVisible'
  192. ]),
  193. loadAuthData () {
  194. this.user = this.$store.getters['Auth/user']
  195. },
  196. goToProperPanel () {
  197. if (this.user.isSuperUser()) {
  198. // this.$router.push({ name: 'Admin.User.Index' })
  199. } else {
  200. this.$router.push({ name: 'UserPanel.Profile.UserInfo' })
  201. }
  202. },
  203. goToHome () {
  204. this.$router.push({ name: 'Public.Home' })
  205. },
  206. goToAdminDashboard () {
  207. this.$router.push({ name: 'Admin.Content.Index' })
  208. },
  209. logOut () {
  210. this.$store.dispatch('Auth/logOut')
  211. },
  212. toggleLeftDrawer () {
  213. this.updateLayoutLeftDrawerVisible(true)
  214. },
  215. hasRoute (route) {
  216. if (!route) {
  217. return
  218. }
  219. return !!(route.name || route.path)
  220. },
  221. getRoute (route) {
  222. if (!this.hasRoute(route)) {
  223. return { name: null }
  224. }
  225. if (route.name) {
  226. return { name: route.name }
  227. } else if (route.path) {
  228. return { path: route.path }
  229. } else {
  230. return { name: null }
  231. }
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .drawer-btn {
  238. display: none;
  239. @media screen and (max-width: 1439px) {
  240. display: block;
  241. }
  242. @media screen and (max-width: 599px) {
  243. margin-bottom: 10px;
  244. }
  245. }
  246. .right-side {
  247. display: flex;
  248. align-items: center;
  249. @media screen and (max-width: 1023px) {
  250. margin-left: 42px;
  251. }
  252. @media screen and (max-width: 599px) {
  253. margin-left: 0;
  254. }
  255. .breadcrumbs {
  256. &:deep(> *) {
  257. font-style: normal;
  258. font-weight: bold;
  259. font-size: 16px;
  260. line-height: 31px;
  261. text-align: right;
  262. color: #23263B;
  263. div:first-child {
  264. font-size: 18px;
  265. }
  266. }
  267. }
  268. }
  269. .left-side {
  270. display: flex;
  271. justify-content: flex-end;
  272. @media screen and (max-width: 1439px) {
  273. position: absolute;
  274. right: 0;
  275. }
  276. @media screen and (max-width: 1023px) {
  277. .q-btn {
  278. width: 40px;
  279. padding: 0;
  280. .btn-label {
  281. display: none;
  282. }
  283. }
  284. }
  285. @media screen and (max-width: 599px) {
  286. right: 16px;
  287. margin-bottom: 10px;
  288. }
  289. }
  290. </style>
  291. <style scoped lang="scss">
  292. .header-inside {
  293. height: 120px;
  294. background-color: #FBF4EA;
  295. color: #212121;
  296. @media only screen and (max-width: 1023px) {
  297. height: 70px;
  298. }
  299. //border-bottom: solid 1px #DFE1EC;
  300. &.isHomePage {
  301. background: transparent;
  302. @media only screen and (max-width: 1023px) {
  303. background-color: #FBF4EA;
  304. }
  305. }
  306. .admin-top-menu {
  307. display: flex;
  308. flex-flow: row;
  309. height: 100%;
  310. .top-menu-items {
  311. width: calc( 100% - 240px );
  312. display: flex;
  313. flex-flow: row;
  314. justify-content: space-between;
  315. .q-btn {
  316. height: 40px;
  317. svg {
  318. margin-right: 10px;
  319. }
  320. }
  321. .right-side {
  322. display: flex;
  323. flex-flow: row;
  324. align-items: center;
  325. padding-left: 50px;
  326. }
  327. .left-side {
  328. display: flex;
  329. flex-flow: row;
  330. align-items: center;
  331. padding-right: 50px;
  332. }
  333. }
  334. .logo {
  335. width: 240px;
  336. height: 100%;
  337. background: #FBF4EA;
  338. border-right: solid 1px #DFE1EC;
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. .logo-image {
  343. width: 106px;
  344. height: auto;
  345. }
  346. }
  347. }
  348. .user-top-menu {
  349. padding-top: 30px;
  350. margin-right: 100px;
  351. margin-left: 100px;
  352. margin-bottom: 22px;
  353. @media only screen and (max-width: 1500px) {
  354. margin-right: 10px;
  355. margin-left: 10px;
  356. }
  357. @media only screen and (max-width: 1023px) {
  358. padding-top: 0;
  359. margin-bottom: 0;
  360. }
  361. display: flex;
  362. flex-flow: row;
  363. justify-content: space-between;
  364. .q-btn {
  365. height: 40px;
  366. svg {
  367. margin-right: 10px;
  368. margin-left: 10px;
  369. }
  370. }
  371. .right-side {
  372. display: flex;
  373. flex-flow: row;
  374. align-items: center;
  375. .q-toolbar {
  376. min-height: 68px;
  377. .q-btn {
  378. align-self: center;
  379. }
  380. }
  381. }
  382. .center-logo {
  383. $width: 100px;
  384. $height: 55px;
  385. position: absolute;
  386. width: $width;
  387. height: 100%;
  388. top: 0;
  389. left: calc( 50% - (#{$width} / 2));
  390. }
  391. .left-side {
  392. display: flex;
  393. flex-flow: row;
  394. align-items: center;
  395. padding-right: 50px;
  396. @media only screen and (max-width: 1023px) {
  397. height: 100%;
  398. }
  399. @media only screen and (max-width: 599px) {
  400. padding-right: 0;
  401. }
  402. }
  403. &.isHomePage {
  404. .q-toolbar {
  405. .top-menu-item {
  406. color: white;
  407. }
  408. }
  409. }
  410. }
  411. }
  412. .top-menu-items {
  413. border-radius: 10px;
  414. @media only screen and (max-width: 1439px) {
  415. & {
  416. display: none !important;
  417. }
  418. }
  419. @media only screen and (max-width: 500px) {
  420. .q-btn__content {
  421. margin: 4px;
  422. font-size: 0.7rem;
  423. }
  424. }
  425. @media only screen and (max-width: 400px) {
  426. .q-btn__content {
  427. margin: 3px;
  428. font-size: 0.6rem;
  429. }
  430. }
  431. }
  432. .breadcrumbs {
  433. .q-breadcrumbs__separator {
  434. .q-icon {
  435. font-size: 22px;
  436. }
  437. }
  438. }
  439. .drawer-btn {
  440. .q-btn {
  441. flex-direction: row !important;
  442. &.toolbar-button {
  443. margin-left: 0 !important;
  444. }
  445. }
  446. }
  447. .q-btn {
  448. &.toolbar-button {
  449. margin-left: 12px;
  450. height: 48px;
  451. width: 48px;
  452. box-shadow: -2px -4px 10px rgba(255, 255, 255, 0.6), 2px 4px 10px rgba(112, 108, 162, 0.05);
  453. border-radius: 16px;
  454. border: solid 1px #c5c5c5;
  455. }
  456. }
  457. .left-side {
  458. .q-btn {
  459. &.toolbar-button {
  460. .q-btn__content {
  461. .q-btn-dropdown__arrow {
  462. display: none !important;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. </style>