import browser from "@/utils/browser";
import Vue from "vue";

import { $showOrientationtip, $hideOrientationtip } from "@/components/verticaltip/build.js";



Vue.prototype.$bus = new Vue();

Vue.mixin({
  data() {
    return {
      isMobile: browser.mobile,
      g_isLandscape: window.orientation === 90 || window.orientation === -90,
    };
  },
  methods:{
    $showOrientationtip,
    $hideOrientationtip
  },
  computed: {
    theme() {
      return this.$route.params.type;
    },
  },
  mounted() {
    if (this.isMobile || this.isiPad) {
      // window.orientation：获取屏幕旋转方向
      window.addEventListener(
        "onorientationchange" in window ? "orientationchange" : "resize",
        () => {
          // 正常方向或屏幕旋转180度
          if (window.orientation === 180 || window.orientation === 0) {
            this.g_isLandscape = false;
          }

          // 屏幕顺时钟旋转90度或屏幕逆时针旋转90度
          if (window.orientation === 90 || window.orientation === -90) {
            this.g_isLandscape = true;
            this.$bus.$emit("isShowHuDong", false);
          }
        }
      );
    }
  },
});
