hookehuyr

feat(Dashboard): 根据设备类型动态调整首页高度

添加系统信息获取功能,检测是否为平板设备
根据设备类型动态调整首页 hero 区域高度
<!--
* @Date: 2025-08-27 17:43:45
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-17 14:28:08
* @LastEditTime: 2025-09-19 23:23:33
* @FilePath: /lls_program/src/pages/Dashboard/index.vue
* @Description: 首页
-->
<template>
<view class="min-h-screen flex flex-col bg-white pb-16" style="background-color: #F9FAFB;">
<!-- Hero section with family name and background image -->
<view class=" bg-white rounded-xl shadow-md mx-4 mt-4 relative" style="height: 30vh;">
<view class=" bg-white rounded-xl shadow-md mx-4 mt-4 relative" :style="{ height: isTabletDevice ? '40vh' : '30vh' }">
<image :src="familyCover" mode="aspectFill" alt="Family background" class="w-full h-full object-cover rounded-xl" />
<view class="absolute inset-0 flex flex-col justify-end rounded-xl bg-black bg-opacity-10">
<view class="m-5">
......@@ -383,6 +383,9 @@ useLoad(async () => {
});
useDidShow(async () => {
// 获取系统信息
getSystemInfo();
// 刷新页面数据
await refreshDashboardData();
......@@ -466,4 +469,35 @@ const onShareAppMessage = (res) => {
Taro.useShareAppMessage((res) => {
return onShareAppMessage(res);
});
// 系统信息
const systemInfo = ref({});
/**
* 获取系统信息
*/
const getSystemInfo = () => {
try {
const info = Taro.getSystemInfoSync();
systemInfo.value = info;
} catch (error) {
console.error('获取系统信息失败:', error);
}
};
/**
* 检测是否为 iPad 类型设备
*/
const isTabletDevice = computed(() => {
if (!systemInfo.value.screenWidth) {
return false;
}
const { screenWidth, screenHeight } = systemInfo.value;
const screenRatio = screenWidth / screenHeight;
// iPad 类型设备通常屏幕比例在 0.7-0.8 之间(4:3 约为 0.75)
// 普通手机设备比例通常在 0.4-0.6 之间
return screenRatio > 0.65;
});
</script>
......