Commit d390dcfe by liimin

refactor(ui): 重构入口组件和样式系统以支持响应式设计

- 将Entrance组件改为scroll-view实现垂直滚动
- 添加横竖屏自适应图标尺寸计算功能
- 移除硬编码样式改为CSS变量驱动
- 删除废弃的横屏tabbar相关props传递
- 更新HomeFrame组件样式为现代化玻璃态设计
- 移除动态样式计算逻辑改用纯CSS变量方案
- 新增完整的响应式样式配置文档和变量系统
- 优化卡片交互效果和整体视觉层次
1 parent feca21ab
<template> <template>
<view class="entrance-box"> <view class="entrance-box">
<view class="entrance-list"> <scroll-view class="entrance-list"
<view v-for="(item, index) in entranceList" direction="vertical"
:key="index" :show-scrollbar="false"
:class="['entrance-item', compactMode ? 'entrance-item-compact' : '']" :bounces="false"
@click="handleClick(item)"> :scroll-with-animation="false"
<!-- uView Next 图片图标:name 传图片路径(包含 /) --> scroll-y>
<un-icon class="entrance-icon" <view class="entrance-content">
:class="[compactMode ? 'entrance-icon-compact' : '']" <view v-for="(item, index) in entranceList"
:name="getIconUrl(item.icon)" :key="index"
size="48" /> :class="['entrance-item', compactMode ? 'entrance-item-compact' : '']"
<text :class="['entrance-name', compactMode ? 'entrance-name-compact' : '']">{{ item.label }}</text> hover-class="entrance-item-hover"
@click="handleClick(item)">
<!-- 图标容器 -->
<view class="entrance-icon-wrapper">
<un-icon class="entrance-icon"
:class="[compactMode ? 'entrance-icon-compact' : '']"
:name="getIconUrl(item.icon)"
:size="iconSize" />
</view>
<text :class="['entrance-name', compactMode ? 'entrance-name-compact' : '']">{{ item.label }}</text>
</view>
</view> </view>
</view> </scroll-view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed } from "vue"; import { computed } from "vue";
import { layoutService } from "@/services/LayoutService.uts";
type EntranceItem = { type EntranceItem = {
color: string color: string
...@@ -31,6 +42,12 @@ const props = defineProps<{ ...@@ -31,6 +42,12 @@ const props = defineProps<{
defineEmits(["entranceClick"]); defineEmits(["entranceClick"]);
// 根据横竖屏动态计算图标尺寸
const iconSize = computed((): number => {
const isLandscape = !layoutService.isMode("portrait");
return isLandscape ? 56 : 52;
});
const entranceList = computed((): EntranceItem[] => { const entranceList = computed((): EntranceItem[] => {
const sceneType = props.sceneType ?? 1; const sceneType = props.sceneType ?? 1;
if (sceneType === 1) { if (sceneType === 1) {
...@@ -88,50 +105,94 @@ function getIconUrl(icon: string): string { ...@@ -88,50 +105,94 @@ function getIconUrl(icon: string): string {
.entrance-box { .entrance-box {
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden;
} }
.entrance-list { .entrance-list {
width: 100%; width: 100%;
height: 100%;
box-sizing: border-box;
padding: var(--l-spacing-lg);
padding-bottom: var(--l-spacing-2xl);
}
.entrance-content {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
flex-direction: row; flex-direction: row;
overflow-y: auto; // 允许垂直滚动 justify-content: space-between;
overflow-x: hidden; align-content: flex-start;
gap: var(--entrance-item-gap);
min-height: 100%;
} }
.entrance-item { .entrance-item {
width: 30%; // 使用百分比宽度,保证三列布局 width: calc(100% / 3);
min-height: 120px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
margin-right: var(--l-spacing-lg); justify-content: center;
margin-bottom: var(--l-spacing-xl); padding: var(--l-spacing-lg);
border-radius: var(--l-radius-md);
background: rgba(255, 255, 255, 0.6);
transition-property: transform, background, box-shadow;
transition-duration: 0.3s;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
cursor: pointer;
}
.entrance-item-hover {
transform: translateY(-4px);
background: rgba(255, 255, 255, 0.9);
box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
}
.entrance-icon-wrapper {
width: var(--entrance-icon-size);
height: var(--entrance-icon-size);
border-radius: var(--l-radius-md);
background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf5 100%);
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
margin-bottom: var(--l-spacing-sm);
}
.entrance-item:hover .entrance-icon-wrapper {
box-shadow: 0 6px 16px rgba(102, 126, 234, 0.2);
transform: scale(1.05);
} }
.entrance-icon { .entrance-icon {
width: 48px; width: calc(var(--entrance-icon-size) - 16px);
height: 48px; height: calc(var(--entrance-icon-size) - 16px);
border-radius: var(--l-radius-lg);
} }
.entrance-name { .entrance-name {
font-size: 12px; font-size: var(--l-font-xs);
color: #333; color: #4a4a4a;
margin-top: 6px; font-weight: 500;
text-align: center;
letter-spacing: 0.3px;
line-height: 1.4;
} }
.entrance-item-compact { .entrance-item-compact {
width: 30%; // compact 模式也使用百分比 width: calc(100% / 3);
margin-bottom: 16px; min-height: 100px;
padding: var(--l-spacing-md);
} }
.entrance-icon-compact { .entrance-icon-compact {
width: 44px; width: calc(var(--entrance-icon-size) - 20px);
height: 44px; height: calc(var(--entrance-icon-size) - 20px);
} }
.entrance-name-compact { .entrance-name-compact {
font-size: 11px; font-size: 11px;
margin-top: 4px; margin-top: 2px;
} }
</style> </style>
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
<view class="main-tab-shell-body main-tab-shell-body-landscape"> <view class="main-tab-shell-body main-tab-shell-body-landscape">
<HomeFrameTabbarLandscape :adapter-class-name="adapterClassName" <HomeFrameTabbarLandscape :adapter-class-name="adapterClassName"
:user-name="userName" :user-name="userName"
:landscape-tabbar-root-style="landscapeTabbarRootStyle"
:landscape-tabbar-inner-height="landscapeTabbarInnerHeight"
:landscape-tabbar-icon-size="landscapeTabbarIconSize"
:current-tab-index="currentTabIndex" :current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList" :scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup" :show-scene-popup="showScenePopup"
...@@ -55,9 +52,6 @@ const tabbarSource: HomeFrameTabbarSource = { ...@@ -55,9 +52,6 @@ const tabbarSource: HomeFrameTabbarSource = {
const _tabbar = useHomeFrameTabbar(tabbarSource); const _tabbar = useHomeFrameTabbar(tabbarSource);
const adapterClassName = _tabbar.adapterClassName; const adapterClassName = _tabbar.adapterClassName;
const userName = _tabbar.userName; const userName = _tabbar.userName;
const landscapeTabbarRootStyle = _tabbar.landscapeTabbarRootStyle;
const landscapeTabbarInnerHeight = _tabbar.landscapeTabbarInnerHeight;
const landscapeTabbarIconSize = _tabbar.landscapeTabbarIconSize;
const currentTabIndex = _tabbar.currentTabIndex; const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList; const sceneTypeList = _tabbar.sceneTypeList;
const showScenePopup = _tabbar.showScenePopup; const showScenePopup = _tabbar.showScenePopup;
......
...@@ -156,7 +156,7 @@ function onSlideTapFromEvent(idx: any): void { ...@@ -156,7 +156,7 @@ function onSlideTapFromEvent(idx: any): void {
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
border-radius: 16px; border-radius: 0;
background: rgba(255, 255, 255, 0.86); background: rgba(255, 255, 255, 0.86);
box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10); box-shadow: 0 12px 32px rgba(15, 23, 42, 0.10);
overflow: hidden; overflow: hidden;
......
...@@ -2,9 +2,6 @@ ...@@ -2,9 +2,6 @@
<HomeFrameTabbarLandscape v-if="!isPortraitMode" <HomeFrameTabbarLandscape v-if="!isPortraitMode"
:adapter-class-name="adapterClassName" :adapter-class-name="adapterClassName"
:user-name="userName" :user-name="userName"
:landscape-tabbar-root-style="landscapeTabbarRootStyle"
:landscape-tabbar-inner-height="landscapeTabbarInnerHeight"
:landscape-tabbar-icon-size="landscapeTabbarIconSize"
:current-tab-index="currentTabIndex" :current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList" :scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup" :show-scene-popup="showScenePopup"
......
...@@ -17,18 +17,15 @@ ...@@ -17,18 +17,15 @@
</view> </view>
</view> </view>
<view class="landscape-tabbar-wrap"> <view class="landscape-tabbar-wrap">
<view class="landscape-un-tabbar landscape-vertical-tabs" <view class="landscape-un-tabbar landscape-vertical-tabs">
:style="landscapeTabbarRootStyle">
<view v-for="(item, index) in tabs" <view v-for="(item, index) in tabs"
:key="index" :key="index"
class="landscape-vertical-tabs__item" class="landscape-vertical-tabs__item"
:class="index === currentTabIndex ? 'landscape-vertical-tabs__item--active' : ''" :class="index === currentTabIndex ? 'landscape-vertical-tabs__item--active' : ''"
:style="tabRowStyle"
@click="onTabItemClick(index)"> @click="onTabItemClick(index)">
<view class="landscape-vertical-tabs__inner"> <view class="landscape-vertical-tabs__inner">
<image class="landscape-vertical-tabs__icon" <image class="landscape-vertical-tabs__icon"
mode="aspectFit" mode="aspectFit"
:style="iconImageStyle"
:src="index === currentTabIndex ? item.iconSrcActive : item.iconSrcInactive" /> :src="index === currentTabIndex ? item.iconSrcActive : item.iconSrcInactive" />
<text class="landscape-vertical-tabs__label">{{ item.label }}</text> <text class="landscape-vertical-tabs__label">{{ item.label }}</text>
</view> </view>
...@@ -70,9 +67,6 @@ import { HOME_FRAME_TABS } from "./tabbarShared.uts"; ...@@ -70,9 +67,6 @@ import { HOME_FRAME_TABS } from "./tabbarShared.uts";
const props = defineProps<{ const props = defineProps<{
adapterClassName: string adapterClassName: string
userName: string userName: string
landscapeTabbarRootStyle: string
landscapeTabbarInnerHeight: number
landscapeTabbarIconSize: number
currentTabIndex: number currentTabIndex: number
sceneTypeList: UTSJSONObject[] sceneTypeList: UTSJSONObject[]
showScenePopup: boolean showScenePopup: boolean
...@@ -104,22 +98,6 @@ const avatarText = computed((): string => { ...@@ -104,22 +98,6 @@ const avatarText = computed((): string => {
return s.substring(0, 1); return s.substring(0, 1);
}); });
const iconImageStyle = computed((): any => {
const s = props.landscapeTabbarIconSize;
return {
width: `${s}px`,
height: `${s}px`
};
});
/** 与原 un-tabbar :height 一致,保证每项可点区域高度 */
const tabRowStyle = computed((): any => {
const h = props.landscapeTabbarInnerHeight;
return {
minHeight: `${h}px`
};
});
function onTabItemClick(index: number): void { function onTabItemClick(index: number): void {
emit("tabChange", index); emit("tabChange", index);
} }
...@@ -186,8 +164,14 @@ function onTabItemClick(index: number): void { ...@@ -186,8 +164,14 @@ function onTabItemClick(index: number): void {
flex-shrink: 0; flex-shrink: 0;
} }
/* 与原先 .landscape-un-tabbar 占位一致,内部强制纵向排列 item */ /* 横屏侧栏 Tab 区域 */
.landscape-vertical-tabs { .landscape-vertical-tabs {
width: 100%;
height: var(--tabbar-height, 540px);
padding-left: var(--tabbar-padding, 16px);
padding-right: var(--tabbar-padding, 16px);
padding-top: 8px;
padding-bottom: 8px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
...@@ -217,6 +201,8 @@ function onTabItemClick(index: number): void { ...@@ -217,6 +201,8 @@ function onTabItemClick(index: number): void {
} }
.landscape-vertical-tabs__icon { .landscape-vertical-tabs__icon {
width: var(--tabbar-icon-size, 28px);
height: var(--tabbar-icon-size, 28px);
flex-shrink: 0; flex-shrink: 0;
} }
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
class="start" class="start"
hover-class="start-hover" hover-class="start-hover"
@click="onStartClick"> @click="onStartClick">
<view class="start-glow"></view>
<view class="start-shine"></view>
<view class="start-inner"> <view class="start-inner">
<view class="start-icon-wrap"> <view class="start-icon-wrap">
<un-icon name="play-right-fill" size="14" color="#1677ff"></un-icon> <un-icon name="play-right-fill" size="14" color="#1677ff"></un-icon>
...@@ -22,7 +20,7 @@ ...@@ -22,7 +20,7 @@
</view> </view>
<view class="right-content-box flex-row"> <view class="right-content-box flex-row">
<view class="content-left"> <view class="content-left">
<view class="module-box box-class" :style="dynamicModuleBoxStyle"> <view class="module-box box-class">
<view class="common-title"> <view class="common-title">
<text class="title-text">产品介绍</text> <text class="title-text">产品介绍</text>
</view> </view>
...@@ -42,7 +40,7 @@ ...@@ -42,7 +40,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="tool-box box-class" :style="dynamicToolBoxStyle"> <view class="tool-box box-class">
<view class="common-title"> <view class="common-title">
<text class="title-text">{{ resolvedToolBoxTitle }}</text> <text class="title-text">{{ resolvedToolBoxTitle }}</text>
</view> </view>
...@@ -80,9 +78,6 @@ import { storage } from "@/utils/storage.uts"; ...@@ -80,9 +78,6 @@ import { storage } from "@/utils/storage.uts";
import HomeFrameMessageIndex from "./MessageIndex.uvue"; import HomeFrameMessageIndex from "./MessageIndex.uvue";
import ProductIntroSwiper from "./ProductIntroSwiper.uvue"; import ProductIntroSwiper from "./ProductIntroSwiper.uvue";
// 导入样式变量
import { getLandscapeConfig } from "./styles/landscape.uts";
import { getPortraitConfig } from "./styles/portrait.uts";
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
showFooter?: boolean showFooter?: boolean
...@@ -200,56 +195,13 @@ const resolutionClass = computed((): string => { ...@@ -200,56 +195,13 @@ const resolutionClass = computed((): string => {
return `res-${bucket}`; return `res-${bucket}`;
}); });
// 动态样式 - 根据分辨率返回不同的样式 // 动态样式 - 根据分辨率返回不同的样式(使用 CSS 变量)
const dynamicModuleBoxStyle = computed((): any => { const dynamicModuleBoxStyle = computed((): any => {
const adapterCls = cssClassRef.value; return {};
let height = 'var(--l-module-box-height)';
let flex = '1';
const landscapeConfig = getLandscapeConfig(adapterCls);
if (landscapeConfig != null) {
height = landscapeConfig.moduleBoxHeight as string;
flex = 'none';
}
const portraitConfig = getPortraitConfig(adapterCls);
if (portraitConfig != null) {
height = portraitConfig.moduleBoxHeight as string;
flex = 'none';
}
console.log('[HomeFrame] dynamicModuleBoxStyle:', { height: height, flex: flex });
return { height: height, flex: flex };
}); });
const dynamicToolBoxStyle = computed((): any => { const dynamicToolBoxStyle = computed((): any => {
const adapterCls = cssClassRef.value; return {};
let height = '';
let flex = '1';
let minHeight = 'var(--l-tool-box-min-height)';
let marginBottom = '';
const landscapeConfig = getLandscapeConfig(adapterCls);
if (landscapeConfig != null) {
height = landscapeConfig.toolBoxHeight as string;
flex = 'none';
minHeight = '';
}
const portraitConfig = getPortraitConfig(adapterCls);
if (portraitConfig != null) {
flex = '1';
minHeight = portraitConfig.toolBoxMinHeight as string;
marginBottom = portraitConfig.toolBoxMarginBottom as string;
}
const style: any = {
flex: flex,
height: height !== '' ? height : null,
minHeight: minHeight !== '' ? minHeight : null,
marginBottom: marginBottom !== '' ? marginBottom : null
};
console.log('[HomeFrame] dynamicToolBoxStyle:', style, 'adapterCls:', adapterCls);
return style;
}); });
const userInfo = ref<UTSJSONObject>({}); const userInfo = ref<UTSJSONObject>({});
......
# HomeFrame 响应式样式配置
## 🎨 企业级设计系统
HomeFrame 采用现代化的企业级设计语言,融合以下核心设计理念:
### 设计原则
- **视觉层次**:通过阴影、渐变、圆角建立清晰的层级关系
- **微交互**:悬停效果、过渡动画提升用户体验
- **响应式适配**:横竖屏自动切换,多分辨率精确适配
- **一致性**:统一的设计令牌(Design Tokens)确保视觉一致性
### 核心特性
✨ **玻璃态卡片** - `backdrop-filter: blur(10px)` 营造现代感
🌈 **渐变色彩** - 企业级渐变色方案(primary/secondary/success)
💫 **流畅动画** - cubic-bezier 缓动函数实现自然过渡
📐 **精确间距** - 8px 网格系统保证布局规整
🎯 **响应式图标** - Entrance 组件图标尺寸随屏幕自适应
---
## 架构说明
HomeFrame 组件采用 **CSS 变量 + layout-root** 的响应式方案,无需手动处理横竖屏切换。
### 核心原理
1. **配置文件** - `index.vars.uts` 定义所有响应式变量
2. **自动注入** - `layout-root` 组件根据屏幕状态自动应用对应的 CSS 变量
3. **样式引用** - SCSS 中使用 `var(--xxx)` 引用变量,自动响应变化
## 配置文件结构
```typescript
// styles/index.vars.uts
export default {
common: {
// 所有场景通用
'--common-title-height': '48px',
// 设计系统变量
'--l-spacing-sm': '8px',
'--l-radius-lg': '16px',
'--l-shadow-md': '0 4px 16px rgba(0, 0, 0, 0.08)',
'--l-bg-card': 'rgba(255, 255, 255, 0.85)',
'--l-gradient-primary': 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
},
portrait: {
// 竖屏专用
'--module-box-height': 'auto',
'--tool-box-min-height': '280px',
'--entrance-icon-size': '52px',
},
landscape: {
// 横屏专用
'--module-box-height': '320px',
'--tool-box-height': '280px',
'--entrance-icon-size': '56px',
},
resolutions: {
// 精确分辨率适配(优先级最高)
'landscape-1024x768': {
'--module-box-height': '360px',
'--entrance-icon-size': '60px',
},
}
}
```
## 使用方式
### 1. 在组件中导入配置
```typescript
import pageVars from "./styles/index.vars"
```
### 2. 在 SCSS 中使用 CSS 变量
```scss
.module-box {
height: var(--module-box-height);
min-height: var(--tool-box-min-height);
}
```
### 3. 无需任何 JavaScript 逻辑
❌ **不需要**:
- 监听屏幕旋转事件
- 手动计算样式
- 条件判断横竖屏
- 动态绑定 `:style`
✅ **只需要**:
- 定义 CSS 变量
- 在 SCSS 中引用
## 变量命名规范
HomeFrame 布局相关变量简洁命名,间距和字体保留 `l-` 前缀:
### 基础变量
| 变量名 | 说明 | 示例值 |
|--------|------|--------|
| `--module-box-height` | 产品介绍模块高度 | `320px` / `auto` |
| `--tool-box-height` | 展业工具模块高度(横屏) | `280px` |
| `--tool-box-min-height` | 展业工具最小高度(竖屏) | `280px` |
| `--tool-box-margin-bottom` | 展业工具底部间距 | `16px` / `0` |
| `--common-title-height` | 通用标题高度 | `48px` |
| `--tabbar-height` | TabBar 高度 | `60px` / `540px` |
| `--tabbar-icon-size` | TabBar 图标大小 | `24px` / `28px` |
| `--tabbar-width` | TabBar 宽度(横屏) | `120px` |
| `--tabbar-padding` | TabBar 内边距(横屏) | `16px` |
| `--entrance-icon-size` | Entrance 图标尺寸 | `52px` / `56px` |
| `--entrance-item-gap` | Entrance 项目间距 | `20px` / `24px` |
### 设计系统变量
| 变量名 | 说明 | 示例值 |
|--------|------|--------|
| `--l-spacing-*` | 间距变量 (xs/sm/md/lg/xl/2xl/3xl) | `4px` ~ `32px` |
| `--l-font-*` | 字体变量 (xs/sm/md/lg) | `12px` ~ `18px` |
| `--l-radius-*` | 圆角变量 (sm/md/lg/xl) | `8px` ~ `20px` |
| `--l-shadow-*` | 阴影变量 (sm/md/lg) | 多层次阴影 |
| `--l-bg-card` | 卡片背景色 | `rgba(255, 255, 255, 0.85)` |
| `--l-gradient-*` | 渐变色 (primary/secondary/success) | 企业级渐变 |
## 配置层级与优先级
```
resolutions[方向-分辨率] > portrait/landscape > common
(最高) (中) (最低)
```
**合并规则**:后合并的配置覆盖前面的同名属性
## 调试方法
1. 打开控制台,查看 `[useScreenVars]` 日志
2. 确认当前应用的 CSS 变量值
3. 旋转屏幕,观察变量是否自动更新
## 注意事项
⚠️ **重要**:
- 变量名必须与 `index.vars.uts` 中定义的完全一致
- 分辨率 key 格式:`{方向}-{宽}x{高}`,如 `portrait-393x816`
- UTS 对象属性间必须用逗号分隔
- 不要在组件中使用 `:style` 动态绑定,让 CSS 变量自动生效
## 扩展新分辨率
在 `resolutions` 中添加新的配置即可:
```typescript
resolutions: {
// 新增 iPad Pro 横屏
'landscape-1366x1024': {
'--module-box-height': '400px',
'--tool-box-height': '320px',
}
}
```
系统会自动识别并应用,无需修改其他代码。
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative; position: relative;
background: linear-gradient(to bottom, #e8f0fe, #f5f7fa); background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf5 50%, #e4e9f2 100%);
} }
/* 嵌入 index tab 槽(SceneShell 右侧):在 flex 列/行里占满剩余空间,避免仅依赖 height:100% 横竖屏一侧失效 */ /* 嵌入 index tab 槽(SceneShell 右侧):在 flex 列/行里占满剩余空间,避免仅依赖 height:100% 横竖屏一侧失效 */
...@@ -115,88 +115,68 @@ ...@@ -115,88 +115,68 @@
} }
.right-content { .right-content {
padding: 0 var(--l-spacing-xl) 0 var(--l-spacing-md); padding: var(--l-spacing-lg) 8px var(--l-spacing-2xl);
} }
// ===== Start 按钮 ===== // ===== Start 按钮 =====
.start { .start {
height: 96px; height: 80px;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
z-index: 100;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
overflow: hidden; overflow: visible;
flex-shrink: 0; flex-shrink: 0;
min-width: 140px; min-width: 100px;
border-radius: 24px; margin: var(--l-spacing-sm) 0;
background-image: linear-gradient(to right bottom, #1677ff, #469cff); padding: 0;
box-shadow: 0 8px 24px rgba(22, 119, 255, 0.25); border-radius: var(--l-radius-xl);
background-color: #667eea;
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
transition-property: transform, box-shadow, opacity; transition-property: transform, box-shadow, opacity;
transition-duration: 0.15s; transition-duration: 0.2s;
transition-timing-function: ease-out; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
.start-glow {
position: absolute;
left: 18px;
top: 18px;
right: 18px;
bottom: 18px;
border-radius: 18px;
background: rgba(255, 255, 255, 0.16);
animation: startGlowPulse 1.8s ease-in-out infinite;
}
.start-shine {
position: absolute;
top: -30%;
bottom: -30%;
width: 42px;
left: -52px;
background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0));
transform: rotate(14deg);
animation: startShineSweep 2.6s ease-in-out infinite;
} }
.start-hover { .start-hover {
transform: scale(0.92); transform: scale(0.96);
box-shadow: 0 2px 8px rgba(22, 119, 255, 0.1); box-shadow: 0 4px 16px rgba(102, 126, 234, 0.2);
opacity: 0.8; opacity: 0.9;
} }
.start-inner { .start-inner {
position: relative; position: relative;
z-index: 1; z-index: 10;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 0; padding: 0 var(--l-spacing-lg);
background-color: transparent; background-color: transparent;
} }
.start-icon-wrap { .start-icon-wrap {
width: 28px; width: 32px;
height: 28px; height: 32px;
border-radius: 14px; border-radius: 16px;
background: rgba(255, 255, 255, 0.92); background: rgba(255, 255, 255, 0.95);
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-right: 10px; margin-right: 10px;
box-shadow: 0 3px 8px rgba(22, 119, 255, 0.22); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
animation: startIconBreath 1.6s ease-in-out infinite;
} }
.start-text { .start-text {
font-size: 22px; font-size: var(--l-font-lg);
font-weight: bold; font-weight: 600;
color: #ffffff; color: #ffffff;
text-align: center; text-align: center;
letter-spacing: 2px; letter-spacing: 1px;
} }
@keyframes startGlowPulse { @keyframes startGlowPulse {
...@@ -246,16 +226,25 @@ ...@@ -246,16 +226,25 @@
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: var(--l-spacing-md) 0 var(--l-spacing-2xl); gap: var(--l-spacing-lg);
padding: var(--l-spacing-md) 0 var(--l-spacing-3xl);
overflow: hidden; overflow: hidden;
} }
.box-class { .box-class {
background: rgba(255, 255, 255, 0.6); background: var(--l-bg-card);
border-radius: var(--l-spacing-lg); backdrop-filter: blur(10px);
border-radius: var(--l-radius-lg);
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
box-shadow: var(--l-shadow-md);
transition: all 0.3s ease;
}
.box-class:hover {
box-shadow: var(--l-shadow-lg);
background: var(--l-bg-card-hover);
} }
.content-left { .content-left {
...@@ -263,7 +252,6 @@ ...@@ -263,7 +252,6 @@
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-right: var(--l-spacing-lg);
} }
.content-right { .content-right {
...@@ -273,35 +261,59 @@ ...@@ -273,35 +261,59 @@
flex-direction: column; flex-direction: column;
} }
// ===== 模块盒子(使用 CSS 变量作为默认值)===== // ===== 模块盒子(使用 CSS 变量)=====
.module-box { .module-box {
height: var(--l-module-box-height); height: var(--module-box-height);
margin-bottom: var(--l-spacing-lg); margin-bottom: var(--l-spacing-xl);
} }
.tool-box { .tool-box {
flex: 1; flex: 1;
min-height: var(--l-tool-box-min-height); min-height: var(--tool-box-min-height);
margin-bottom: var(--tool-box-margin-bottom);
display: flex;
flex-direction: column;
overflow: hidden;
}
.tool-box.box-class {
overflow: hidden !important;
} }
// ===== 通用标题和内容 ===== // ===== 通用标题和内容 =====
.common-title { .common-title {
height: var(--l-common-title-height); height: var(--common-title-height);
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
padding-left: var(--l-spacing-lg); padding-left: var(--l-spacing-lg);
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
background: linear-gradient(to right, rgba(255, 255, 255, 0.5), transparent);
} }
.title-text { .title-text {
font-size: 16px; font-size: var(--l-font-md);
font-weight: 500; font-weight: 600;
color: #333; color: #1a1a1a;
letter-spacing: 0.5px;
position: relative;
}
.title-text::before {
content: '';
position: absolute;
left: -12px;
top: 50%;
transform: translateY(-50%);
width: 3px;
height: 16px;
background: var(--l-gradient-primary);
border-radius: 2px;
} }
.content-box { .content-box {
flex: 1; flex: 1;
padding: 0 var(--l-spacing-lg) var(--l-spacing-lg); padding: 0;
overflow: hidden; overflow: hidden;
} }
......
// ========================================================================
// HomeFrame 公共样式变量 - UTS 定义
// ========================================================================
/**
* 模块盒子高度(默认值)
*/
export const MODULE_BOX_HEIGHT = 'var(--l-module-box-height)';
/**
* ToolBox 最小高度(默认值)
*/
export const TOOL_BOX_MIN_HEIGHT = 'var(--l-tool-box-min-height)';
/**
* Common Title 高度(默认值)
*/
export const COMMON_TITLE_HEIGHT = 'var(--l-common-title-height)';
/**
* Left Tabs 高度(默认)
*/
export const LEFT_TABS_HEIGHT = '540px';
/**
* Icon Box 尺寸(默认)
*/
export const ICON_BOX_SIZE = '52px';
export const ICON_BOX_RADIUS = '26px';
/**
* Tab Label 字体大小(默认)
*/
export const TAB_LABEL_FONTSIZE = '13px';
/**
* TabBar 高度(默认竖屏)
*/
export const TABBAR_HEIGHT_DEFAULT = 56;
/**
* TabBar 图标尺寸(默认竖屏)
*/
export const TABBAR_ICON_SIZE_DEFAULT = 24;
// HomeFrame 响应式样式配置 - 横竖屏与分辨率适配
export default {
common: {
// 通用标题高度
'--common-title-height': '48px',
// 间距变量
'--l-spacing-xs': '4px',
'--l-spacing-sm': '8px',
'--l-spacing-md': '12px',
'--l-spacing-lg': '16px',
'--l-spacing-xl': '20px',
'--l-spacing-2xl': '24px',
'--l-spacing-3xl': '32px',
// 字体大小
'--l-font-xs': '12px',
'--l-font-sm': '14px',
'--l-font-md': '16px',
'--l-font-lg': '18px',
// 圆角
'--l-radius-sm': '8px',
'--l-radius-md': '12px',
'--l-radius-lg': '16px',
'--l-radius-xl': '20px',
// 阴影
'--l-shadow-sm': '0 2px 8px rgba(0, 0, 0, 0.04)',
'--l-shadow-md': '0 4px 16px rgba(0, 0, 0, 0.08)',
'--l-shadow-lg': '0 8px 24px rgba(0, 0, 0, 0.12)',
// 背景色
'--l-bg-card': 'rgba(255, 255, 255, 0.85)',
'--l-bg-card-hover': 'rgba(255, 255, 255, 0.95)',
// 渐变色
'--l-gradient-primary': 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
'--l-gradient-secondary': 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
'--l-gradient-success': 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
},
portrait: {
// 竖屏布局
'--module-box-height': 'auto',
'--tool-box-min-height': '400px',
'--tool-box-margin-bottom': 'var(--l-spacing-lg)',
// Entrance 图标尺寸(竖屏)
'--entrance-icon-size': '52px',
'--entrance-item-gap': 'var(--l-spacing-xl)',
// TabBar 相关(竖屏底部)
'--tabbar-height': '60px',
'--tabbar-icon-size': '24px',
},
landscape: {
// 横屏布局
'--module-box-height': '320px',
'--tool-box-height': '280px',
'--tool-box-min-height': 'auto',
'--tool-box-margin-bottom': '0',
// Entrance 图标尺寸(横屏)
'--entrance-icon-size': '56px',
'--entrance-item-gap': 'var(--l-spacing-2xl)',
// TabBar 相关(横屏左侧)
'--tabbar-width': '120px',
'--tabbar-height': '540px',
'--tabbar-padding': '16px',
'--tabbar-icon-size': '28px',
},
resolutions: {
// iPad 横屏优化 (1024x768)
'landscape-1024x768': {
'--module-box-height': '360px',
'--tool-box-height': '320px',
'--common-title-height': '52px',
'--entrance-icon-size': '60px',
'--tabbar-height': '600px',
'--tabbar-icon-size': '32px',
},
// 小屏 Pad 横屏 (816x393)
'landscape-816x393': {
'--module-box-height': '280px',
'--tool-box-height': '240px',
'--common-title-height': '44px',
'--entrance-icon-size': '52px',
'--tabbar-height': '480px',
'--tabbar-icon-size': '26px',
},
// 大屏手机竖屏 (414x896)
'portrait-414x896': {
'--tool-box-min-height': '180px',
'--common-title-height': '44px',
},
// iPhone 14 Pro 竖屏 (393x816)
'portrait-393x816': {
'--tool-box-min-height': '160px',
'--common-title-height': '42px',
},
}
}
// ========================================================================
// HomeFrame 横屏样式变量 - UTS 定义(按分辨率)
// ========================================================================
/**
* 横屏配置类型
*/
export type LandscapeConfig = {
// index.uvue 布局
rightContentBoxPadding?: string
moduleBoxHeight: string
toolBoxHeight: string
toolBoxContentPaddingBottom?: string
// HomeFrame Tabbar(横屏)
leftTabsHeight: string
leftTabsPaddingLeft: string
iconBoxSize: string
iconBoxRadius: string
tabLabelFontSize: string
}
/**
* 1174x768 横屏配置
*/
export const LANDSCAPE_1174x768: LandscapeConfig = {
// index.uvue 布局
rightContentBoxPadding: '6px 0 10px',
moduleBoxHeight: '340px',
toolBoxHeight: '152px',
toolBoxContentPaddingBottom: '14px',
// HomeFrame Tabbar(横屏)
leftTabsHeight: '560px',
leftTabsPaddingLeft: '18px',
iconBoxSize: '56px',
iconBoxRadius: '28px',
tabLabelFontSize: '14px'
};
/**
* 1920x1080 横屏配置
*/
export const LANDSCAPE_1920x1080: LandscapeConfig = {
// index.uvue 布局
moduleBoxHeight: '320px',
toolBoxHeight: '480px',
// HomeFrame Tabbar(横屏)
leftTabsHeight: '620px',
leftTabsPaddingLeft: '22px',
iconBoxSize: '64px',
iconBoxRadius: '32px',
tabLabelFontSize: '16px'
};
/**
* 根据分辨率获取横屏配置
*/
export function getLandscapeConfig(resolutionKey: string): null | LandscapeConfig {
// UTS 中字符串比较可能有问题,使用 indexOf 替代
if (resolutionKey.indexOf('layout-landscape-1174x768') >= 0) {
return LANDSCAPE_1174x768;
}
if (resolutionKey.indexOf('layout-landscape-1920x1080') >= 0) {
return LANDSCAPE_1920x1080;
}
return null;
}
// ========================================================================
// HomeFrame 竖屏样式变量 - UTS 定义(按分辨率)
// ========================================================================
/**
* 竖屏配置类型
*/
export type PortraitConfig = {
// index.uvue 布局
rightContentBoxPadding?: string
moduleBoxHeight?: string
moduleBoxMinHeight?: string
moduleBoxMarginBottom?: string
toolBoxMinHeight?: string
toolBoxMarginBottom?: string
toolBoxHeight?: string
// HomeFrame Tabbar(竖屏)
leftSidePortraitPaddingBottom?: string
tabbarHeight: number
tabbarIconSize: number
}
/**
* 768x1174 竖屏配置(Pad 竖屏)
*/
export const PORTRAIT_768x1174: PortraitConfig = {
// index.uvue 布局
rightContentBoxPadding: '10px 0 0',
moduleBoxHeight: '55%',
moduleBoxMinHeight: '400px',
moduleBoxMarginBottom: '12px',
toolBoxMinHeight: '452px',
toolBoxHeight: '552px',
toolBoxMarginBottom: '60px',
// HomeFrame Tabbar(竖屏)
leftSidePortraitPaddingBottom: '8px',
tabbarHeight: 106,
tabbarIconSize: 60
};
/**
* 其他竖屏分辨率(默认)
*/
export const PORTRAIT_COMMON: PortraitConfig = {
// HomeFrame Tabbar(竖屏)
tabbarHeight: 56,
tabbarIconSize: 24
};
/**
* 根据分辨率获取竖屏配置
*/
export function getPortraitConfig(resolutionKey: string): null | PortraitConfig {
// UTS 中字符串比较可能有问题,使用 indexOf 替代
if (resolutionKey.indexOf('layout-portrait-768x1174') >= 0) {
return PORTRAIT_768x1174;
}
return null;
}
...@@ -5,9 +5,6 @@ import { storage } from "@/utils/storage.uts"; ...@@ -5,9 +5,6 @@ import { storage } from "@/utils/storage.uts";
import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts"; import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts"; import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import { getLandscapeConfig } from "./styles/landscape.uts";
import { getPortraitConfig, PORTRAIT_COMMON } from "./styles/portrait.uts";
export type HomeFrameTabbarSource = { export type HomeFrameTabbarSource = {
getAdapterClass: () => null | string getAdapterClass: () => null | string
getTabIndex: () => number getTabIndex: () => number
...@@ -115,53 +112,6 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) { ...@@ -115,53 +112,6 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
return cls.indexOf("layout-portrait-768x1174") >= 0; return cls.indexOf("layout-portrait-768x1174") >= 0;
}); });
const tabbarHeight = computed((): number => {
const adapterCls = cssClassRef.value;
const portraitConfig = getPortraitConfig(adapterCls);
if (portraitConfig != null) {
return portraitConfig.tabbarHeight as number;
}
return PORTRAIT_COMMON.tabbarHeight as number;
});
const tabbarIconSize = computed((): number => {
const adapterCls = cssClassRef.value;
const portraitConfig = getPortraitConfig(adapterCls);
if (portraitConfig != null) {
return portraitConfig.tabbarIconSize as number;
}
return PORTRAIT_COMMON.tabbarIconSize as number;
});
const landscapeTabbarRootStyle = computed((): string => {
const adapterCls = cssClassRef.value;
const lc = getLandscapeConfig(adapterCls);
const h = lc != null ? lc.leftTabsHeight : "540px";
const padX = lc != null ? lc.leftTabsPaddingLeft : "16px";
/* 左右对称,与用户区、底栏在同一中轴上对齐 */
return `display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:${h};padding-left:${padX};padding-right:${padX};padding-top:8px;padding-bottom:8px;box-sizing:border-box;`;
});
const landscapeTabbarInnerHeight = computed((): number => {
const adapterCls = cssClassRef.value;
const lc = getLandscapeConfig(adapterCls);
if (lc != null && adapterCls.indexOf("1920") >= 0) {
return 64;
}
if (lc != null) {
return 58;
}
return 56;
});
const landscapeTabbarIconSize = computed((): number => {
const adapterCls = cssClassRef.value;
if (adapterCls.indexOf("1920") >= 0) {
return 32;
}
return 28;
});
const currentTabIndex = computed((): number => { const currentTabIndex = computed((): number => {
return source.getTabIndex(); return source.getTabIndex();
}); });
...@@ -316,11 +266,6 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) { ...@@ -316,11 +266,6 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
showSetting, showSetting,
adapterClassName, adapterClassName,
isPadPortraitMode, isPadPortraitMode,
tabbarHeight,
tabbarIconSize,
landscapeTabbarRootStyle,
landscapeTabbarInnerHeight,
landscapeTabbarIconSize,
currentTabIndex, currentTabIndex,
sceneTypeList, sceneTypeList,
sceneTypeIdList, sceneTypeIdList,
......
<template> <template>
<!-- 唯一物理「首页」tab:SceneShell(导航壳)+ HomeMainTab(三场景);场景内各自 Panel + HomeFrame(embedInTabSlot) --> <!-- 唯一物理「首页」tab:SceneShell(导航壳)+ HomeMainTab(三场景);场景内各自 Panel + HomeFrame(embedInTabSlot) -->
<layout-root> <layout-root :page-vars="pageVars">
<view class="index-shell-page"> <view class="index-shell-page">
<!-- 可拉伸层:单列 flex 下单个子项须 flex:1+min-height:0 才吃满高度;接待/我的等同层无 flex 故无此问题 --> <!-- 可拉伸层:单列 flex 下单个子项须 flex:1+min-height:0 才吃满高度;接待/我的等同层无 flex 故无此问题 -->
<view class="index-shell-scene-stretch"> <view class="index-shell-scene-stretch">
...@@ -27,7 +27,7 @@ import HomeMainTab from "@/components/HomeFrame/presets/HomeMainTab.uvue"; ...@@ -27,7 +27,7 @@ import HomeMainTab from "@/components/HomeFrame/presets/HomeMainTab.uvue";
import { useBoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts"; import { useBoutiqueLogic } from "@/pages/boutique/useBoutiqueLogic.uts";
import { storage } from "@/utils/storage.uts"; import { storage } from "@/utils/storage.uts";
import { USER_SCENE_TYPE_CHANGED } from "@/utils/userSceneEvents.uts"; import { USER_SCENE_TYPE_CHANGED } from "@/utils/userSceneEvents.uts";
import pageVars from "@/components/HomeFrame/styles/index.vars"
const shellRef = ref(null); const shellRef = ref(null);
const logic = useBoutiqueLogic(); const logic = useBoutiqueLogic();
/** 场景切换后强制重建 HomeMainTab,避免 userInfo 引用未变导致子树不更新 */ /** 场景切换后强制重建 HomeMainTab,避免 userInfo 引用未变导致子树不更新 */
...@@ -55,7 +55,8 @@ async function syncHomeAfterSceneChange(_sceneType: number): Promise<void> { ...@@ -55,7 +55,8 @@ async function syncHomeAfterSceneChange(_sceneType: number): Promise<void> {
} }
function onUserSceneTypeChanged(sceneType: number): void { function onUserSceneTypeChanged(sceneType: number): void {
void syncHomeAfterSceneChange(sceneType); // void syncHomeAfterSceneChange(sceneType);
} }
onMounted((): void => { onMounted((): void => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!