|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="mobile-layout">
|
|
|
+ <div class="mobile-layout" :class="{ 'is-tablet': isTablet }">
|
|
|
<Header />
|
|
|
<main class="mobile-layout-main">
|
|
|
<slot />
|
|
|
@@ -12,26 +12,21 @@
|
|
|
import Header from '~/components/mobile/Header.vue'
|
|
|
import Footer from '~/components/mobile/Footer.vue'
|
|
|
|
|
|
-// const { width } = useWindowSize()
|
|
|
-
|
|
|
-// const updateRootFontSize = (value) => {
|
|
|
-// const baseWidth = 375
|
|
|
-// const baseFont = 37.5
|
|
|
-// const minFont = 32
|
|
|
-// const maxFont = 46
|
|
|
-// const nextFont = (value / baseWidth) * baseFont
|
|
|
-// const finalFont = Math.min(Math.max(nextFont, minFont), maxFont)
|
|
|
-
|
|
|
-// if (typeof document !== 'undefined') {
|
|
|
-// document.documentElement.style.fontSize = `${finalFont}px`
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// watchEffect(() => {
|
|
|
-// if (width.value > 0) {
|
|
|
-// updateRootFontSize(width.value)
|
|
|
-// }
|
|
|
-// })
|
|
|
+const { width } = useWindowSize()
|
|
|
+
|
|
|
+// 平板断点: 768px - 1024px
|
|
|
+const isTablet = computed(() => width.value >= 768 && width.value <= 1024)
|
|
|
+
|
|
|
+// 平板模式下增加内边距 (与 header 高度匹配)
|
|
|
+const mainPadding = computed(() => {
|
|
|
+ const topPadding = isTablet.value ? '70px' : '54px' // header + gap
|
|
|
+ return `${topPadding} ${isTablet.value ? '32px' : '16px'} ${isTablet.value ? '32px' : '16px'}`
|
|
|
+})
|
|
|
+
|
|
|
+// 平板模式下 Header 高度
|
|
|
+const headerHeight = computed(() => isTablet.value ? '60px' : '44px')
|
|
|
+
|
|
|
+provide('headerHeight', headerHeight)
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
@@ -47,6 +42,15 @@ import Footer from '~/components/mobile/Footer.vue'
|
|
|
.mobile-layout-main {
|
|
|
flex: 1;
|
|
|
width: 100%;
|
|
|
- padding: 60px 16px 16px;
|
|
|
+ padding: v-bind(mainPadding);
|
|
|
+ box-sizing: border-box;
|
|
|
+}
|
|
|
+
|
|
|
+// 平板模式样式
|
|
|
+.mobile-layout.is-tablet {
|
|
|
+ .mobile-layout-main {
|
|
|
+ max-width: 1024px;
|
|
|
+ margin: 0 auto;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|