App.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <script setup>
  2. import { ref, onMounted, nextTick, watch, onBeforeUnmount, getCurrentInstance } from 'vue';
  3. import { useI18n } from "vue-i18n";
  4. const { locale } = useI18n();
  5. import {
  6. onLoad,
  7. onShow,
  8. onLaunch
  9. } from '@dcloudio/uni-app'
  10. import {
  11. updateRoute
  12. } from "@/hooks/useRoute";
  13. import useGlobalStore from "@/stores/use-global-store";
  14. // import { useAppUpdate } from '@/hooks/useAppUpdate'
  15. // const { checkUpdate } = useAppUpdate()
  16. const globalStore = useGlobalStore()
  17. onLoad((options) => {
  18. updateRoute();
  19. // checkUpdate()
  20. })
  21. onShow((options) => {
  22. updateRoute();
  23. // checkUpdate()
  24. })
  25. onLaunch((options) => {
  26. // updateRoute();
  27. // checkUpdate()
  28. })
  29. watch(locale, () => {
  30. const currentPath = route.path;
  31. menu.value.forEach((item, index) => {
  32. if (item.children) {
  33. const isActive = item.children.some(child => child.path.includes(currentPath));
  34. menu.value[index].isOpenMenu = isActive;
  35. if (isActive) {
  36. nextTick(() => {
  37. updateSubmenuHeight(index);
  38. });
  39. }
  40. }
  41. });
  42. }, { immediate: true })
  43. onMounted(() => {
  44. const sysInfo = uni.getSystemInfoSync();
  45. globalStore.setBarHeight(sysInfo.statusBarHeight || 60);
  46. // ---------- 新增 H5 端专属初始化 ----------
  47. // 仅在 H5 端执行(通过环境判断)
  48. // #ifdef H5
  49. if (typeof window !== 'undefined') {
  50. const instance = getCurrentInstance()
  51. if (instance) {
  52. window.vm = instance.proxy
  53. }
  54. }
  55. // #endif
  56. });
  57. </script>
  58. <style>
  59. /*每个页面公共css */
  60. </style>
  61. <style lang="scss">
  62. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  63. @import "uview-plus/index.scss";
  64. @import "@/static/scss/global/global.scss";
  65. @import "/static/scss/style.scss";
  66. @font-face {
  67. font-family: 'Google Sans';
  68. src: url('/static/Google_Sans/GoogleSans-VariableFont_GRAD,opsz,wght.ttf') format('truetype-variations');
  69. font-weight: 100 900;
  70. font-style: normal;
  71. font-display: swap;
  72. }
  73. /* 全局字体,不破坏 uni-icons 图标 */
  74. view,
  75. text,
  76. button,
  77. input,
  78. textarea,
  79. label {
  80. font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  81. font-weight: 400;
  82. }
  83. /* 专门保护 uni-icons 不被覆盖 */
  84. .uni-icon,
  85. [class*="uni-icons-"],
  86. .uni-icons {
  87. font-family: uniicons !important;
  88. }
  89. /* 让整个项目文字都能选中 */
  90. * {
  91. -webkit-user-select: text !important;
  92. user-select: text !important;
  93. }
  94. /* 修复滚动层无法选中 */
  95. view,
  96. text,
  97. div,
  98. span {
  99. -webkit-user-select: text !important;
  100. user-select: text !important;
  101. }
  102. /* 强制修复 uni-datetime-picker 重复渲染双日历 */
  103. // .uni-calendar+.uni-calendar {
  104. // display: none !important;
  105. // }
  106. :deep(.u-toolbar__wrapper__confirm) {
  107. font-size: 20px !important;
  108. }
  109. :deep(.u-toolbar__wrapper__cancel) {
  110. font-size: 20px !important;
  111. }
  112. .page {
  113. /* padding: 31px 31px 110px 31px; */
  114. box-sizing: border-box;
  115. /* background: var(--main-bg); */
  116. }
  117. html {
  118. font-size: 32px !important;
  119. }
  120. uni-page-body {
  121. height: 100%;
  122. }
  123. </style>