Blame view

apps/app.vue 2.43 KB
陈峰 authored
1 2 3 4
<template>
  <div id="app">
    <transition
      :name="`route-view-${yoho.direction}`">
陈峰 authored
5
      <keep-alive>
陈峰 authored
6
        <router-view v-if="$route.meta.keepAlive"></router-view>
陈峰 authored
7 8 9 10 11
      </keep-alive>
    </transition>
    <transition
      :name="`route-view-${yoho.direction}`">
      <router-view v-if="!$route.meta.keepAlive"></router-view>
陈峰 authored
12
    </transition>
陈峰 authored
13 14 15
    <div class="fps" v-if="showFps">
      {{fps}}
    </div>
陈峰 authored
16 17 18 19 20 21 22 23
  </div>
</template>

<script>
import {mapState} from 'vuex';

export default {
  name: 'App',
陈峰 authored
24 25 26 27 28 29 30
  data() {
    return {
      showFps: false,
      fpsTick: 0,
      fps: 0
    };
  },
陈峰 authored
31 32 33 34
  computed: {
    ...mapState(['yoho'])
  },
  mounted() {
陈峰 authored
35 36 37 38
    if (process.env.NODE_ENV === 'development') {
      this.showFps = true;
      this.frameCallback();
    }
陈峰 authored
39 40 41 42 43 44
    if (this.yoho.context.needLogin) {
      this.$yoho.ready(() => {
        this.$sdk.goLogin();
      });
    }
  },
陈峰 authored
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
  methods: {
    frameCallback() {
      window.requestAnimationFrame(() => {
        const now = Date.now();

        if (!this.time) {
          this.time = now;
        }
        if (now - this.time >= 1000) {
          this.time = now;
          this.fps = this.fpsTick;
          this.fpsTick = 0;
        }
        this.fpsTick++;
        this.frameCallback();
      });
    }
  },
陈峰 authored
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
  watch: {
    'yoho.context.needLogin': function(newVal) {
      if (newVal) {
        this.$sdk.goLogin();
      }
    },
  }
};
</script>

<style lang="scss">
.route-view-forword-enter-active,
.route-view-forword-leave-active,
.route-view-back-enter-active,
.route-view-back-leave-active {
  will-change: true;
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  perspective: 1000;
}

.route-view-forword-leave-active,
.route-view-back-leave-active {
  transition: all 200ms;
}

.route-view-forword-enter-active,
.route-view-back-enter-active {
  transition: all 200ms cubic-bezier(0.165, 0.84, 0.44, 1);
}

.route-view-forword-enter {
  transform: translate3d(100%, 0, 0);
}
yyq authored
100 101 102 103
.route-view-forword-enter-active {
  z-index: 2;
}
陈峰 authored
104
.route-view-forword-leave-active {
yyq authored
105
  z-index: 1;
陈峰 authored
106 107 108 109 110 111 112
  transform: translate3d(-30%, 0, 0);
}

.route-view-back-enter {
  transform: translate3d(-30%, 0, 0);
}
yyq authored
113 114 115 116
.route-view-back-enter-active {
  z-index: 1;
}
陈峰 authored
117 118 119 120
.route-view-back-leave-active {
  transform: translate3d(100%, 0, 0);
  z-index: 2;
}
陈峰 authored
121 122 123 124 125 126 127 128 129 130 131

.fps {
  position: absolute;
  z-index: 99;
  left: 0;
  top: 0;
  width: 20PX;
  height: 20PX;
  background-color: white;
  color: black;
}
陈峰 authored
132
</style>