AppMain.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <section class="app-main" :style="{ paddingTop: show ? '140px' : '80px' }">
  3. <div class="app-main-view">
  4. <keep-alive>
  5. <router-view v-if="$route.meta.isCache == 1 && nameKey.indexOf($route.name) == 0" :key="nameKey" />
  6. </keep-alive>
  7. <router-view v-if="$route.meta.isCache != 1 && nameKey.indexOf($route.name) == 0" :key="nameKey" />
  8. <zj-watermark color="rgba(200,200,200,.3)" position="absolute" :str="str" zIndex="99" />
  9. </div>
  10. </section>
  11. </template>
  12. <script>
  13. import { mapGetters } from 'vuex'
  14. export default {
  15. name: 'AppMain',
  16. data() {
  17. return {
  18. key: 0,
  19. nameKey: ""
  20. }
  21. },
  22. computed: {
  23. ...mapGetters(['show']),
  24. str() {
  25. return this.$store.state?.user?.name
  26. },
  27. },
  28. watch: {
  29. $route(val, oval) {
  30. this.setNameKey()
  31. },
  32. },
  33. created() {
  34. this.setNameKey()
  35. },
  36. methods: {
  37. setNameKey() {
  38. var { name, params } = this.$route
  39. var { pageType, pageCode, pagePam } = params
  40. var item = this.$store.state.tagsView.visitedViews.find(item => {
  41. return item?.nameKey.indexOf(`${name}_${pageType}_${pageCode}_${pagePam}`) === 0
  42. })
  43. if (!item) {
  44. setTimeout(() => {
  45. this.setNameKey()
  46. }, 50)
  47. } else {
  48. this.nameKey = item.nameKey
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped>
  55. .app-main {
  56. /*50 = navbar */
  57. height: 100vh;
  58. width: 100%;
  59. position: relative;
  60. overflow: hidden;
  61. }
  62. .fixed-header+.app-main {
  63. /* padding-top: 50px; */
  64. /* padding-top: 80px; */
  65. }
  66. .app-main-view {
  67. width: 100%;
  68. height: 100%;
  69. position: relative;
  70. overflow-x: hidden;
  71. overflow-y: auto;
  72. }
  73. </style>