App.vue 2.0 KB
Newer Older
Z
zhuzhida 已提交
1
<template>
richard_1015's avatar
richard_1015 已提交
2
  <div v-if="title != '/'" id="nav">{{ title }}</div>
Z
zhuzhida 已提交
3 4 5
  <router-view />
</template>
<script lang="ts">
richard_1015's avatar
richard_1015 已提交
6 7
import { defineComponent, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
Z
zy19940510 已提交
8
import { isMobile } from '@/sites/assets/util';
Z
zhuzhida 已提交
9
export default defineComponent({
Z
zy19940510 已提交
10
  name: 'app',
Z
zhuzhida 已提交
11
  components: {},
richard_1015's avatar
richard_1015 已提交
12 13 14 15
  setup() {
    const title = ref('NutUI');
    // 获取当前路由
    const route = useRoute();
richard_1015's avatar
richard_1015 已提交
16 17 18 19
    // 当当前路由发生变化时,调用回调函数
    watch(
      () => route,
      () => {
richard_1015's avatar
richard_1015 已提交
20 21
        // const { origin, hash, pathname } = window.top.location;
        const { hash } = window.top.location;
richard_1015's avatar
richard_1015 已提交
22
        if (!isMobile && route.hash != hash) {
23
          // window.top.location.replace(`${origin}${pathname}#/${route.hash}`);
richard_1015's avatar
richard_1015 已提交
24 25 26 27 28 29 30 31 32 33
          title.value = route.name as string;
        } else {
          title.value = route.name as string;
        }
      },
      {
        immediate: true,
        deep: true
      }
    );
richard_1015's avatar
richard_1015 已提交
34

richard_1015's avatar
richard_1015 已提交
35
    return { title };
Z
zhuzhida 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  }
});
</script>

<style lang="scss">
#app {
  font-family: PingFangSC-Regular;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: none;
  -ms-text-size-adjust: 100%;
  background: #fff;
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;

  #nav {
    position: fixed;
richard_1015's avatar
richard_1015 已提交
55
    z-index: 10;
Z
zhuzhida 已提交
56 57 58 59 60
    left: 0;
    right: 0;
    height: 57px;
    line-height: 57px;
    text-align: center;
richard_1015's avatar
richard_1015 已提交
61 62
    background: $white;
    font-weight: bold;
Z
zhuzhida 已提交
63 64
    font-size: 20px;
    color: rgba(51, 51, 51, 1);
richard_1015's avatar
richard_1015 已提交
65
    box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.07);
Z
zhuzhida 已提交
66 67 68 69 70 71
  }

  .demo {
    height: 100%;
    background: #f7f8fa;
    overflow-y: auto;
Z
zy19940510 已提交
72 73 74 75 76 77
    padding: 0 25px;
    padding-top: 57px;
    &::-webkit-scrollbar {
      width: 0;
      background: transparent;
    }
richard_1015's avatar
richard_1015 已提交
78
    > h2 {
Z
zhuzhida 已提交
79 80 81 82 83 84 85 86 87 88 89 90 91
      height: 56px;
      line-height: 56px;
      font-size: 14px;
      color: rgba(144, 156, 164, 1);
    }

    .card {
      padding: 25px 18px;
      background: rgba(255, 255, 255, 1);
    }
  }
}
</style>