app.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 handleResize = () => {
  30. const width = window.innerWidth
  31. if (width >= 768 && width <= 1440) {
  32. // @ts-ignore
  33. document.documentElement.style.zoom = width / 1440
  34. } else {
  35. // @ts-ignore
  36. document.documentElement.style.zoom = 1
  37. }
  38. }
  39. onMounted(() => {
  40. window.addEventListener('resize', handleResize)
  41. handleResize()
  42. })
  43. onUnmounted(() => {
  44. window.removeEventListener('resize', handleResize)
  45. })
  46. }
  47. </script>
  48. <style lang="scss">
  49. html {
  50. /**
  51. 一般浏览器的默认字体大小为 16px,以10px 为基数计算rem,font-size: 1.4rem = 14px;
  52. 注意:此设置在媒体查询中无效,媒体查询中,基数还是16px
  53. */
  54. font-size: 62.5%;
  55. }
  56. html,
  57. body,
  58. #__nuxt {
  59. padding: 0;
  60. margin: 0;
  61. height: 100%;
  62. }
  63. </style>