App.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div id="app">
  3. <div class="w-full h-full flex">
  4. <router-view />
  5. </div>
  6. <loginPopup />
  7. </div>
  8. </template>
  9. <script>
  10. import NavMenu from '@/views/components/NavMenu'
  11. import loginPopup from '@/views/homeComponents/loginPopup'
  12. export default {
  13. name: 'App',
  14. components: {
  15. loginPopup,
  16. NavMenu
  17. },
  18. metaInfo() {
  19. return {
  20. title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
  21. titleTemplate: title => {
  22. return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
  23. }
  24. }
  25. },
  26. mounted() {
  27. //首先我们获得视口高度并将其乘以1%以获得1vh单位的值
  28. let vh = window.innerHeight * 0.01
  29. // 然后,我们将——vh自定义属性中的值设置为文档的根
  30. document.documentElement.style.setProperty('--vh', `${vh}px`)
  31. // 我们监听resize事件 视图大小发生变化就重新计算1vh的值
  32. window.addEventListener('resize', () => {
  33. // 我们执行与前面相同的脚本
  34. let vh = window.innerHeight * 0.01
  35. console.log(vh);
  36. document.documentElement.style.setProperty('--vh', `${vh}px`)
  37. })
  38. this.pdIsMobile()
  39. let _this = this
  40. window.onresize = () => {
  41. setTimeout(() => {
  42. _this.pdIsMobile()
  43. }, 100)
  44. }
  45. },
  46. methods: {
  47. pdIsMobile() {
  48. if (this.fIsMobile()) {
  49. this.$store.commit('app/TOGGLE_MOBILE', true)
  50. // this.isMobile = true
  51. } else {
  52. this.$store.commit('app/TOGGLE_MOBILE', false)
  53. // this.isMobile = false
  54. }
  55. },
  56. fIsMobile() {
  57. return /Android|iPhone|iPad|iPod|BlackBerry|webOS|Windows Phone|SymbianOS|IEMobile|Opera Mini/i.test(navigator.userAgent);
  58. }
  59. }
  60. }
  61. </script>
  62. <style lang="scss" scoped>
  63. #app {
  64. // padding-bottom: 50px;
  65. }
  66. .pageContent {
  67. width: calc(100% - 72px);
  68. height: 100%;
  69. overflow: visible;
  70. // overflow-y: auto;
  71. }
  72. </style>