app.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!--
  2. * @Author: wjc
  3. * @Date: 2023-11-15 09:54:21
  4. * @LastEditors: LiZhiWei
  5. * @LastEditTime: 2026-01-15 14:50:45
  6. * @Description:
  7. -->
  8. <template>
  9. <NuxtLayout>
  10. <el-config-provider :size="elConfig.size" :z-index="elConfig.zIndex" :locale="zhCn">
  11. <NuxtPage />
  12. </el-config-provider>
  13. </NuxtLayout>
  14. </template>
  15. <script setup lang="ts">
  16. import zhCn from 'element-plus/es/locale/lang/zh-cn'
  17. import { appName } from '~/constants'
  18. useHead({
  19. title: appName,
  20. })
  21. const elConfig = ref<{
  22. size: 'default' | 'small' | 'large'
  23. zIndex: number
  24. }>({
  25. size: 'default',
  26. zIndex: 300,
  27. })
  28. if (import.meta.client) {
  29. const setDocumentZoom = (zoom: number) => {
  30. ;(document.documentElement.style as unknown as { zoom: number }).zoom = zoom
  31. }
  32. const handleResize = () => {
  33. const width = window.innerWidth
  34. if (width >= 768 && width < 1440) {
  35. setDocumentZoom(width / 1920)
  36. } else {
  37. setDocumentZoom(1)
  38. }
  39. }
  40. onMounted(() => {
  41. window.addEventListener('resize', handleResize)
  42. handleResize()
  43. })
  44. onUnmounted(() => {
  45. window.removeEventListener('resize', handleResize)
  46. })
  47. }
  48. </script>
  49. <style lang="scss">
  50. html {
  51. /**
  52. 一般浏览器的默认字体大小为 16px,以10px 为基数计算rem,font-size: 1.4rem = 14px;
  53. 注意:此设置在媒体查询中无效,媒体查询中,基数还是16px
  54. */
  55. font-size: 62.5%;
  56. }
  57. html,
  58. body,
  59. #__nuxt {
  60. padding: 0;
  61. margin: 0;
  62. height: 100%;
  63. }
  64. </style>