Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
lls_program
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-09-19 23:24:28 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f8724775839e3d160492a6840a9f39bf4ebea148
f8724775
1 parent
13d7f076
feat(Dashboard): 根据设备类型动态调整首页高度
添加系统信息获取功能,检测是否为平板设备 根据设备类型动态调整首页 hero 区域高度
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
2 deletions
src/pages/Dashboard/index.vue
src/pages/Dashboard/index.vue
View file @
f872477
<!--
* @Date: 2025-08-27 17:43:45
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-09-1
7 14:28:08
* @LastEditTime: 2025-09-1
9 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>
...
...
Please
register
or
login
to post a comment