App.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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);
  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. /* 让整个项目文字都能选中 */
  67. * {
  68. -webkit-user-select: text !important;
  69. user-select: text !important;
  70. }
  71. /* 修复滚动层无法选中 */
  72. view,
  73. text,
  74. div,
  75. span {
  76. -webkit-user-select: text !important;
  77. user-select: text !important;
  78. }
  79. /* 强制修复 uni-datetime-picker 重复渲染双日历 */
  80. // .uni-calendar+.uni-calendar {
  81. // display: none !important;
  82. // }
  83. :deep(.u-toolbar__wrapper__confirm) {
  84. font-size: 20px !important;
  85. }
  86. :deep(.u-toolbar__wrapper__cancel) {
  87. font-size: 20px !important;
  88. }
  89. .page {
  90. /* padding: 31px 31px 110px 31px; */
  91. box-sizing: border-box;
  92. /* background: var(--main-bg); */
  93. }
  94. html {
  95. font-size: 32px !important;
  96. }
  97. uni-page-body {
  98. height: 100%;
  99. }
  100. </style>