feat(样式): 添加iPad设备的内容自适应样式
为iPad及类似平板设备添加内容自适应样式,包括字体大小、行高和内边距的适配
Showing
1 changed file
with
50 additions
and
6 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-15 22:08:49 | 2 | * @Date: 2024-09-15 22:08:49 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-09-19 18:31:34 | 4 | + * @LastEditTime: 2025-09-21 01:42:38 |
| 5 | * @FilePath: /map-demo/src/views/checkin/info.vue | 5 | * @FilePath: /map-demo/src/views/checkin/info.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -96,7 +96,7 @@ import AMapLoader from '@amap/amap-jsapi-loader' | ... | @@ -96,7 +96,7 @@ import AMapLoader from '@amap/amap-jsapi-loader' |
| 96 | 96 | ||
| 97 | import { mapAPI, mapAudioAPI } from '@/api/map.js' | 97 | import { mapAPI, mapAudioAPI } from '@/api/map.js' |
| 98 | import { isCheckedAPI, checkinAPI } from '@/api/checkin.js' | 98 | import { isCheckedAPI, checkinAPI } from '@/api/checkin.js' |
| 99 | -import { getAdaptiveFontSize, getAdaptivePadding } from '@/utils/tools.js' | 99 | +import { getAdaptiveFontSize, getAdaptivePadding, getDeviceInfo } from '@/utils/tools.js' |
| 100 | 100 | ||
| 101 | const store = mainStore(); | 101 | const store = mainStore(); |
| 102 | const { audio_status, audio_entity, audio_list_status, audio_list_entity } = storeToRefs(store); | 102 | const { audio_status, audio_entity, audio_list_status, audio_list_entity } = storeToRefs(store); |
| ... | @@ -115,6 +115,29 @@ const adaptiveButtonWidth = computed(() => getAdaptiveFontSize(3)); // 基础宽 | ... | @@ -115,6 +115,29 @@ const adaptiveButtonWidth = computed(() => getAdaptiveFontSize(3)); // 基础宽 |
| 115 | const adaptiveButtonHeight = computed(() => getAdaptiveFontSize(1.5)); // 基础高度1.5rem | 115 | const adaptiveButtonHeight = computed(() => getAdaptiveFontSize(1.5)); // 基础高度1.5rem |
| 116 | const adaptiveButtonPadding = computed(() => getAdaptivePadding(0.5)); // 基础内边距0.5rem | 116 | const adaptiveButtonPadding = computed(() => getAdaptivePadding(0.5)); // 基础内边距0.5rem |
| 117 | 117 | ||
| 118 | +// 动态文章内容适配计算属性 - 仅适配iPad类似设备 | ||
| 119 | +const adaptiveContentFontSize = computed(() => { | ||
| 120 | + const deviceInfo = getDeviceInfo(); | ||
| 121 | + if (deviceInfo.isiPad || deviceInfo.isTablet) { | ||
| 122 | + return getAdaptiveFontSize(0.9); // iPad设备适配字体大小 | ||
| 123 | + } | ||
| 124 | + return '0.9rem'; // 普通屏幕保持原始大小 | ||
| 125 | +}); | ||
| 126 | +const adaptiveContentLineHeight = computed(() => { | ||
| 127 | + const deviceInfo = getDeviceInfo(); | ||
| 128 | + if (deviceInfo.isiPad || deviceInfo.isTablet) { | ||
| 129 | + return '1.8'; // iPad设备行高更大 | ||
| 130 | + } | ||
| 131 | + return '1.75'; // 普通屏幕默认行高 | ||
| 132 | +}); | ||
| 133 | +const adaptiveContentPadding = computed(() => { | ||
| 134 | + const deviceInfo = getDeviceInfo(); | ||
| 135 | + if (deviceInfo.isiPad || deviceInfo.isTablet) { | ||
| 136 | + return getAdaptivePadding('1rem'); // iPad设备适配内边距 | ||
| 137 | + } | ||
| 138 | + return '1rem'; // 普通屏幕保持原始内边距 | ||
| 139 | +}); | ||
| 140 | + | ||
| 118 | const themeVars = ref({ | 141 | const themeVars = ref({ |
| 119 | swipeIndicatorInactiveBackground: '#fff', | 142 | swipeIndicatorInactiveBackground: '#fff', |
| 120 | swipeIndicatorMargin: '1.5rem', | 143 | swipeIndicatorMargin: '1.5rem', |
| ... | @@ -688,14 +711,35 @@ const checkIn = async () => { // 打卡 | ... | @@ -688,14 +711,35 @@ const checkIn = async () => { // 打卡 |
| 688 | } | 711 | } |
| 689 | .info-content { | 712 | .info-content { |
| 690 | color: #47525F; | 713 | color: #47525F; |
| 691 | - padding: 1rem; | 714 | + padding: v-bind(adaptiveContentPadding); |
| 692 | - line-height: 1.75; | 715 | + line-height: v-bind(adaptiveContentLineHeight); |
| 716 | + font-size: v-bind(adaptiveContentFontSize); | ||
| 717 | + | ||
| 718 | + // 仅对iPad类似设备的HTML元素进行适配 | ||
| 693 | p { | 719 | p { |
| 694 | - line-height: 1.75; | 720 | + line-height: v-bind(adaptiveContentLineHeight); |
| 695 | - // padding: 0 0.85rem; | ||
| 696 | text-align: justify; | 721 | text-align: justify; |
| 722 | + // margin-bottom: v-bind(adaptiveContentPadding); | ||
| 723 | + font-size: v-bind(adaptiveContentFontSize); | ||
| 697 | img { | 724 | img { |
| 698 | width: 100%; | 725 | width: 100%; |
| 726 | + height: auto; | ||
| 727 | + max-width: 100%; | ||
| 728 | + } | ||
| 729 | + } | ||
| 730 | + | ||
| 731 | + h1, h2, h3, h4, h5, h6 { | ||
| 732 | + margin: v-bind(adaptiveContentPadding) 0; | ||
| 733 | + font-size: calc(v-bind(adaptiveContentFontSize) * 1.2); | ||
| 734 | + } | ||
| 735 | + | ||
| 736 | + ul, ol { | ||
| 737 | + margin: v-bind(adaptiveContentPadding) 0; | ||
| 738 | + padding-left: calc(v-bind(adaptiveContentPadding) * 2); | ||
| 739 | + | ||
| 740 | + li { | ||
| 741 | + margin-bottom: calc(v-bind(adaptiveContentPadding) * 0.5); | ||
| 742 | + font-size: v-bind(adaptiveContentFontSize); | ||
| 699 | } | 743 | } |
| 700 | } | 744 | } |
| 701 | } | 745 | } | ... | ... |
-
Please register or login to post a comment