MainHeader.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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="isax:menu-1"
  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. class="top-menu-item" />
  30. <q-btn stretch
  31. flat
  32. label="بلاگ"
  33. :to="{name: 'Public.Post.List'}"
  34. class="top-menu-item" />
  35. <q-btn stretch
  36. flat
  37. label="سامانه آموزش"
  38. class="top-menu-item" />
  39. <q-btn-dropdown stretch
  40. flat
  41. label="آرشیو محتوایی"
  42. class="top-menu-item">
  43. <q-list>
  44. <q-item-label header>عنوان یک</q-item-label>
  45. <q-item v-for="n in 3"
  46. :key="`x.${n}`"
  47. v-close-popup
  48. clickable
  49. tabindex="0">
  50. <q-item-section>
  51. <q-item-label>زیر عنوان</q-item-label>
  52. </q-item-section>
  53. </q-item>
  54. <q-separator inset
  55. spaced />
  56. <q-item-label header>عنوان دو</q-item-label>
  57. <q-item v-for="n in 3"
  58. :key="`y.${n}`"
  59. v-close-popup
  60. clickable
  61. tabindex="0">
  62. <q-item-section>
  63. <q-item-label>زیر عنوان</q-item-label>
  64. </q-item-section>
  65. </q-item>
  66. </q-list>
  67. </q-btn-dropdown>
  68. <q-btn stretch
  69. flat
  70. label="فروشگاه"
  71. class="top-menu-item" />
  72. <q-btn stretch
  73. flat
  74. label="پخش زنده"
  75. class="top-menu-item" />
  76. <q-btn stretch
  77. flat
  78. label="درباره ما"
  79. class="top-menu-item" />
  80. <q-btn stretch
  81. flat
  82. label="تماس با ما"
  83. class="top-menu-item" />
  84. </div>
  85. </q-toolbar>
  86. </div>
  87. <q-btn flat
  88. round
  89. dense
  90. class="center-logo lt-md"
  91. :to="{name: 'Public.Home'}">
  92. <q-img src="/assets/images/web/homepage-first-section-logo.png" />
  93. </q-btn>
  94. <div class="left-side">
  95. <q-btn v-if="user && user.id !== null"
  96. color="primary"
  97. @click="goToProperPanel">
  98. <svg id="_000000ff"
  99. data-name="#000000ff"
  100. xmlns="http://www.w3.org/2000/svg"
  101. width="19.995"
  102. height="19.995"
  103. viewBox="0 0 19.995 19.995">
  104. <path id="Path_29101"
  105. data-name="Path 29101"
  106. 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"
  107. fill="#fff" />
  108. <path id="Path_29102"
  109. data-name="Path 29102"
  110. 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"
  111. transform="translate(-147.63 -81.975)"
  112. fill="#fff" />
  113. <path id="Path_29103"
  114. data-name="Path 29103"
  115. 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"
  116. transform="translate(-114.152 -311.642)"
  117. fill="#fff" />
  118. </svg>
  119. <span class="btn-label">
  120. حساب کاربری
  121. </span>
  122. <q-menu v-if="user.isAdmin() || user.isSuperUser()"
  123. fit>
  124. <q-list>
  125. <q-item v-close-popup
  126. clickable
  127. :to="{ name: 'UserPanel.Profile.UserInfo' }">
  128. <q-item-section>
  129. پنل کاربری
  130. </q-item-section>
  131. </q-item>
  132. <q-item v-close-popup
  133. clickable
  134. :to="{ name: 'Admin.User.Index' }">
  135. <q-item-section>
  136. پنل ادمین
  137. </q-item-section>
  138. </q-item>
  139. <q-item v-close-popup
  140. clickable
  141. @click="logOut">
  142. <q-item-section>
  143. خروج
  144. </q-item-section>
  145. </q-item>
  146. </q-list>
  147. </q-menu>
  148. </q-btn>
  149. <q-btn v-else
  150. color="primary"
  151. :to="{name: 'Login'}">
  152. <span class="btn-label">
  153. ورود / ثبت نام
  154. </span>
  155. <svg id="Login"
  156. xmlns="http://www.w3.org/2000/svg"
  157. width="18.479"
  158. height="20"
  159. viewBox="0 0 18.479 20">
  160. <path id="Combined_Shape"
  161. data-name="Combined Shape"
  162. 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"
  163. transform="translate(18.479 20) rotate(180)"
  164. fill="#fff" />
  165. </svg>
  166. </q-btn>
  167. </div>
  168. </div>
  169. </div>
  170. </template>
  171. <script>
  172. import { User } from 'src/models/User.js'
  173. import { mapGetters, mapMutations } from 'vuex'
  174. export default {
  175. name: 'templateHeader',
  176. data () {
  177. return {
  178. user: new User(),
  179. topMenuItems: [
  180. ]
  181. }
  182. },
  183. computed: {
  184. isAdminPage () {
  185. return this.$route.name && this.$route.name.includes('Admin.')
  186. },
  187. isProfilePage () {
  188. return this.$route.name && this.$route.name.includes('UserPanel.Profile.')
  189. },
  190. isHomePage () {
  191. return this.$route.name && this.$route.name === 'Public.Home'
  192. },
  193. ...mapGetters('AppLayout', [
  194. 'breadcrumbs',
  195. 'windowSize'
  196. ])
  197. },
  198. mounted () {
  199. this.loadAuthData()
  200. },
  201. methods: {
  202. ...mapMutations('AppLayout', [
  203. 'updateLayoutLeftDrawerVisible'
  204. ]),
  205. loadAuthData () {
  206. this.user = this.$store.getters['Auth/user']
  207. },
  208. goToProperPanel () {
  209. if (this.user.isSuperUser()) {
  210. // this.$router.push({ name: 'Admin.User.Index' })
  211. } else {
  212. this.$router.push({ name: 'UserPanel.Profile.UserInfo' })
  213. }
  214. },
  215. goToHome () {
  216. this.$router.push({ name: 'Public.Home' })
  217. },
  218. goToAdminDashboard () {
  219. this.$router.push({ name: 'Admin.Content.Index' })
  220. },
  221. logOut () {
  222. this.$store.dispatch('Auth/logOut')
  223. },
  224. toggleLeftDrawer () {
  225. this.updateLayoutLeftDrawerVisible(true)
  226. },
  227. hasRoute (route) {
  228. if (!route) {
  229. return
  230. }
  231. return !!(route.name || route.path)
  232. },
  233. getRoute (route) {
  234. if (!this.hasRoute(route)) {
  235. return { name: null }
  236. }
  237. if (route.name) {
  238. return { name: route.name }
  239. } else if (route.path) {
  240. return { path: route.path }
  241. } else {
  242. return { name: null }
  243. }
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. .drawer-btn {
  250. display: none;
  251. @media screen and (max-width: 1439px) {
  252. display: block;
  253. }
  254. @media screen and (max-width: 599px) {
  255. margin-bottom: 10px;
  256. }
  257. }
  258. .right-side {
  259. display: flex;
  260. align-items: center;
  261. @media screen and (max-width: 1023px) {
  262. margin-left: 42px;
  263. }
  264. @media screen and (max-width: 599px) {
  265. margin-left: 0;
  266. }
  267. .breadcrumbs {
  268. &:deep(> *) {
  269. font-style: normal;
  270. font-weight: bold;
  271. font-size: 16px;
  272. line-height: 31px;
  273. text-align: right;
  274. color: #23263B;
  275. div:first-child {
  276. font-size: 18px;
  277. }
  278. }
  279. }
  280. }
  281. .left-side {
  282. display: flex;
  283. justify-content: flex-end;
  284. @media screen and (max-width: 1439px) {
  285. position: absolute;
  286. right: 0;
  287. }
  288. @media screen and (max-width: 1023px) {
  289. .q-btn {
  290. width: 40px;
  291. padding: 0;
  292. .btn-label {
  293. display: none;
  294. }
  295. }
  296. }
  297. @media screen and (max-width: 599px) {
  298. right: 16px;
  299. margin-bottom: 10px;
  300. }
  301. }
  302. </style>
  303. <style scoped lang="scss">
  304. .header-inside {
  305. height: 120px;
  306. background-color: #FBF4EA;
  307. color: #212121;
  308. @media only screen and (max-width: 1023px) {
  309. height: 70px;
  310. }
  311. //border-bottom: solid 1px #DFE1EC;
  312. &.isHomePage {
  313. background: transparent;
  314. @media only screen and (max-width: 1023px) {
  315. background-color: #FBF4EA;
  316. }
  317. }
  318. .admin-top-menu {
  319. display: flex;
  320. flex-flow: row;
  321. height: 100%;
  322. .top-menu-items {
  323. width: calc( 100% - 240px );
  324. display: flex;
  325. flex-flow: row;
  326. justify-content: space-between;
  327. .q-btn {
  328. height: 40px;
  329. svg {
  330. margin-right: 10px;
  331. }
  332. }
  333. .right-side {
  334. display: flex;
  335. flex-flow: row;
  336. align-items: center;
  337. padding-left: 50px;
  338. }
  339. .left-side {
  340. display: flex;
  341. flex-flow: row;
  342. align-items: center;
  343. padding-right: 50px;
  344. }
  345. }
  346. .logo {
  347. width: 240px;
  348. height: 100%;
  349. background: #FBF4EA;
  350. border-right: solid 1px #DFE1EC;
  351. display: flex;
  352. align-items: center;
  353. justify-content: center;
  354. .logo-image {
  355. width: 106px;
  356. height: auto;
  357. }
  358. }
  359. }
  360. .user-top-menu {
  361. padding-top: 30px;
  362. margin-right: 100px;
  363. margin-left: 100px;
  364. margin-bottom: 22px;
  365. @media only screen and (max-width: 1500px) {
  366. margin-right: 10px;
  367. margin-left: 10px;
  368. }
  369. @media only screen and (max-width: 1023px) {
  370. padding-top: 0;
  371. margin-bottom: 0;
  372. }
  373. display: flex;
  374. flex-flow: row;
  375. justify-content: space-between;
  376. .q-btn {
  377. height: 40px;
  378. svg {
  379. margin-right: 10px;
  380. margin-left: 10px;
  381. }
  382. }
  383. .right-side {
  384. display: flex;
  385. flex-flow: row;
  386. align-items: center;
  387. .q-toolbar {
  388. min-height: 68px;
  389. .q-btn {
  390. align-self: center;
  391. }
  392. }
  393. }
  394. .center-logo {
  395. $width: 100px;
  396. $height: 55px;
  397. position: absolute;
  398. width: $width;
  399. height: 100%;
  400. top: 0;
  401. left: calc( 50% - (#{$width} / 2));
  402. }
  403. .left-side {
  404. display: flex;
  405. flex-flow: row;
  406. align-items: center;
  407. padding-right: 50px;
  408. @media only screen and (max-width: 1023px) {
  409. height: 100%;
  410. }
  411. @media only screen and (max-width: 599px) {
  412. padding-right: 0;
  413. }
  414. }
  415. &.isHomePage {
  416. .q-toolbar {
  417. .top-menu-item {
  418. color: white;
  419. }
  420. }
  421. }
  422. }
  423. }
  424. .top-menu-items {
  425. border-radius: 10px;
  426. @media only screen and (max-width: 1439px) {
  427. & {
  428. display: none !important;
  429. }
  430. }
  431. @media only screen and (max-width: 500px) {
  432. .q-btn__content {
  433. margin: 4px;
  434. font-size: 0.7rem;
  435. }
  436. }
  437. @media only screen and (max-width: 400px) {
  438. .q-btn__content {
  439. margin: 3px;
  440. font-size: 0.6rem;
  441. }
  442. }
  443. }
  444. .breadcrumbs {
  445. .q-breadcrumbs__separator {
  446. .q-icon {
  447. font-size: 22px;
  448. }
  449. }
  450. }
  451. .drawer-btn {
  452. .q-btn {
  453. flex-direction: row !important;
  454. &.toolbar-button {
  455. margin-left: 0 !important;
  456. }
  457. }
  458. }
  459. .q-btn {
  460. &.toolbar-button {
  461. margin-left: 12px;
  462. height: 48px;
  463. width: 48px;
  464. box-shadow: -2px -4px 10px rgba(255, 255, 255, 0.6), 2px 4px 10px rgba(112, 108, 162, 0.05);
  465. border-radius: 16px;
  466. border: solid 1px #c5c5c5;
  467. }
  468. }
  469. .left-side {
  470. .q-btn {
  471. &.toolbar-button {
  472. .q-btn__content {
  473. .q-btn-dropdown__arrow {
  474. display: none !important;
  475. }
  476. }
  477. }
  478. }
  479. }
  480. </style>