杨磊
11 小时以前 5967652081d92180adbc78da809c26cff5cf730a
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
<template>
  <div class="layoutBox">
    <Header class="header"></Header>
    <div class="layoutContentBox" id="layout">
      <RouterView />
      <Footer class="footer"></Footer>
    </div>
    <login ref="loginRef"></login>
  </div>
</template>
 
<script setup lang="ts">
import Header from './components/headerPage.vue'
import Footer from './components/footerPage.vue'
import login from './components/login.vue'
import { provide, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
 
watch(
  () => router.currentRoute.value.path,
  (toPath) => {
    const layout = document.getElementById('layout')
    if (layout) layout.scrollTo(0, 0)
  },
  { immediate: true, deep: true },
)
const logIn = () => {
  loginRef.value.logIn()
}
const loginRef = ref()
provide('logIn', logIn)
</script>
 
<style lang="less" scoped>
.layoutBox {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #fff;
 
  .layoutContentBox {
    flex: 1;
    height: auto;
  }
 
  .header {
    flex-shrink: 0;
    width: 100%;
  }
}
 
@media screen and (min-width: 1200px) {
  .layoutContentBox {
    flex: 1;
    overflow: auto;
  }
}
</style>