riku
2025-09-19 58c0f11fe2f23a1be2dec768f9ac02107301a634
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
  <el-container class="el-container">
    <el-aside class="el-aside">
      <SiderMenu :collapse="isCollapsed" @nav-page="navPage"></SiderMenu>
    </el-aside>
    <el-container>
      <el-header ref="headerRef" class="el-header">
        <Header
          :navTitles="navTitles"
          :collapse="isCollapsed"
          @collapsed-sider="collapsedSider"
        ></Header
      ></el-header>
      <el-main class="el-main">
        <el-scrollbar>
          <div
            class="el-main__content"
            :style="{
              maxHeight: contentMaxHeight + 'px',
              padding: mainPadding + 'px'
            }"
          >
            <Content></Content>
            <!-- <el-backtop
                target=".el-main .el-scrollbar__wrap"
                :right="10"
                :bottom="100"
                style="z-index: 1000;"
              >
                <div class="back-top">
                  <el-icon><ArrowUpBold /></el-icon>
                  <span style="">返回顶部</span>
                </div>
              </el-backtop> -->
          </div>
        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>
 
<script>
import { computed } from 'vue';
 
export default {
  data() {
    return {
      isCollapsed: false,
      navTitles: [],
      headerHeight: 60,
      mainPadding: 10,
      contentMaxHeight: NaN
    };
  },
  methods: {
    collapsedSider(b) {
      this.isCollapsed = b;
    },
    navPage(titles) {
      this.navTitles = titles;
    }
  },
  mounted() {
    this.headerHeight = this.$refs.headerRef.$el.offsetHeight;
    this.contentMaxHeight =
      window.innerHeight - this.headerHeight - this.mainPadding * 2;
  },
  provide() {
    return {
      headerHeight: computed(() => this.headerHeight),
      mainPadding: computed(() => this.mainPadding),
      contentMaxHeight: computed(() => this.contentMaxHeight)
    };
  }
};
</script>
 
<style scoped>
.el-container {
  /* min-height: 820px; */
}
.el-aside {
  width: initial;
}
 
.el-header {
  /* background-color: rgb(216, 201, 201); */
  border-bottom: 1px solid var(--el-color-info-light-7);
}
 
.el-main {
  position: relative;
  /* background-color: bisque; */
  padding: initial;
  /* max-height: calc(100vh - 60px); */
  /* overflow: hidden; */
}
 
.el-main__content {
  /* --main-padding: 10px; */
  /* padding: var(--main-padding) calc(var(--main-padding) / 2); */
  /* padding: var(--main-padding); */
  /* max-height: calc(100vh - 60px - var(--main-padding) * 2); */
  /* background-color: aqua; */
  /* overflow: auto; */
}
.back-top {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  width: 100%;
  background-color: var(--el-bg-color-overlay);
  box-shadow: var(--el-box-shadow-lighter);
  text-align: center;
  /* line-height: 40px; */
  color: var(--el-color-info);
  border: var(--el-border);
  font-size: var(--el-font-size-medium);
  border-radius: var(--el-border-radius-base);
}
</style>