App.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="home">
  3. <Header
  4. v-if="route.meta && !route.meta.hideHeader"
  5. :color="route.meta.color"
  6. :metaObj="route.meta"
  7. />
  8. <div
  9. :class="!route.meta.hideHeader ? 'ptheader' : ''"
  10. :style="{ background: route.meta.color }"
  11. />
  12. <router-view :key="route.fullPath" />
  13. </div>
  14. </template>
  15. <script lang="ts">
  16. import { defineComponent, nextTick, onMounted, reactive, toRefs } from "vue";
  17. import Header from "@/components/header/Comheader.vue";
  18. import { useRoute, onBeforeRouteUpdate } from "vue-router";
  19. import axios from "axios";
  20. export default defineComponent({
  21. components: {
  22. Header,
  23. },
  24. setup() {
  25. const route: any = useRoute();
  26. const proxyData = reactive({
  27. route: route,
  28. transitionName: "slide-right",
  29. showHeader: false,
  30. getPadVersion() {
  31. axios.get(`/sgipad/pad_mtime`).then((res: any) => {
  32. let data: any = res.data || {};
  33. let pad_mtime: any = data.pad_mtime;
  34. let oldTime: any = localStorage.getItem("pad_mtime");
  35. if (oldTime && oldTime !== pad_mtime) {
  36. localStorage.setItem("pad_mtime", pad_mtime);
  37. window.location.reload();
  38. } else {
  39. localStorage.setItem("pad_mtime", pad_mtime);
  40. }
  41. });
  42. },
  43. timerPadVersion() {
  44. setInterval(() => {
  45. proxyData.getPadVersion();
  46. }, 5000);
  47. },
  48. });
  49. nextTick(() => {
  50. const document: any = window.document;
  51. document.addEventListener("touchstart", function (event: any) {
  52. if (event.touches.length > 1) {
  53. event.preventDefault();
  54. }
  55. });
  56. document.addEventListener("gesturestart", function (event: any) {
  57. event.preventDefault();
  58. });
  59. });
  60. onMounted(() => {
  61. proxyData.timerPadVersion();
  62. });
  63. return {
  64. ...toRefs(proxyData),
  65. };
  66. },
  67. });
  68. </script>
  69. <style lang="scss" scoped>
  70. .home {
  71. .child-view {
  72. position: absolute;
  73. width: 100%;
  74. transition: all 0.8s cubic-bezier(0.55, 0, 0.1, 1);
  75. }
  76. .slide-left-enter,
  77. .slide-right-leave-active {
  78. opacity: 0;
  79. -webkit-transform: translate(50px, 0);
  80. transform: translate(50px, 0);
  81. }
  82. .slide-left-leave-active,
  83. .slide-right-enter {
  84. opacity: 0;
  85. -webkit-transform: translate(-50px, 0);
  86. transform: translate(-50px, 0);
  87. }
  88. }
  89. </style>
  90. function getVersionTime() {
  91. throw new Error("Function not implemented.");
  92. }