PageView.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="content">
  3. <div class="page-header-index-wide">
  4. <!-- keep-alive -->
  5. <keep-alive v-if="multiTab">
  6. <router-view ref="content" />
  7. </keep-alive>
  8. <router-view v-else ref="content" />
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import { mapState } from 'vuex'
  14. export default {
  15. name: 'PageView',
  16. props: {
  17. avatar: {
  18. type: String,
  19. default: null
  20. },
  21. title: {
  22. type: [String, Boolean],
  23. default: true
  24. },
  25. logo: {
  26. type: String,
  27. default: null
  28. },
  29. directTabs: {
  30. type: Object,
  31. default: null
  32. }
  33. },
  34. data () {
  35. return {
  36. pageTitle: null,
  37. description: null,
  38. linkList: [],
  39. extraImage: '',
  40. search: false,
  41. tabs: {}
  42. }
  43. },
  44. computed: {
  45. ...mapState({
  46. multiTab: state => state.app.multiTab
  47. })
  48. },
  49. mounted () {
  50. this.tabs = this.directTabs
  51. this.getPageMeta()
  52. },
  53. updated () {
  54. this.getPageMeta()
  55. },
  56. methods: {
  57. getPageMeta () {
  58. // eslint-disable-next-line
  59. this.pageTitle = (typeof (this.title) === 'string' || !this.title) ? this.title : this.$route.meta.title
  60. const content = this.$refs.content
  61. if (content) {
  62. if (content.pageMeta) {
  63. Object.assign(this, content.pageMeta)
  64. } else {
  65. this.description = content.description
  66. this.linkList = content.linkList
  67. this.extraImage = content.extraImage
  68. this.search = content.search === true
  69. this.tabs = content.tabs
  70. }
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="less" scoped>
  77. .content {
  78. margin: 24px 0 0 24px;
  79. .link {
  80. margin-top: 16px;
  81. &:not(:empty) {
  82. margin-bottom: 16px;
  83. }
  84. a {
  85. margin-right: 32px;
  86. height: 24px;
  87. line-height: 24px;
  88. display: inline-block;
  89. i {
  90. font-size: 24px;
  91. margin-right: 8px;
  92. vertical-align: middle;
  93. }
  94. span {
  95. height: 24px;
  96. line-height: 24px;
  97. display: inline-block;
  98. vertical-align: middle;
  99. }
  100. }
  101. }
  102. }
  103. .page-menu-search {
  104. text-align: center;
  105. margin-bottom: 16px;
  106. }
  107. .page-menu-tabs {
  108. margin-top: 48px;
  109. }
  110. .extra-img {
  111. margin-top: -60px;
  112. text-align: center;
  113. width: 195px;
  114. img {
  115. width: 100%;
  116. }
  117. }
  118. .mobile {
  119. .extra-img {
  120. margin-top: 0;
  121. text-align: center;
  122. width: 96px;
  123. img {
  124. width: 100%;
  125. }
  126. }
  127. }
  128. </style>