Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 058eb04b
authored
Apr 13, 2026
by
岑成威
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: tabbar调整
1 parent
862b896a
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
97 additions
and
148 deletions
apps/uniappX/uniapp-x-tape/.hbuilderx/launch.json
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellLandscape.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellPortrait.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/SceneShell.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/Tabbar.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarLandscape.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarPortrait.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/index.uvue
apps/uniappX/uniapp-x-tape/components/HomeFrame/styles/common.scss
apps/uniappX/uniapp-x-tape/components/HomeFrame/styles/index.vars.uts
apps/uniappX/uniapp-x-tape/components/HomeFrame/tabbarShared.uts
apps/uniappX/uniapp-x-tape/pages.json
apps/uniappX/uniapp-x-tape/.hbuilderx/launch.json
View file @
058eb04
...
...
@@ -3,7 +3,7 @@
"configurations"
:
[
{
"customPlaygroundType"
:
"local"
,
"playground"
:
"
custom
"
,
"playground"
:
"
standard
"
,
"type"
:
"uni-app:app-android"
}
]
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellLandscape.uvue
View file @
058eb04
<template>
<view class="main-tab-shell-root">
<view class="main-tab-shell-body main-tab-shell-body-landscape">
<HomeFrameTabbarLandscape :adapter-class-name="adapterClassName"
:user-name="userName"
<HomeFrameTabbarLandscape :user-name="userName"
:current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup"
...
...
@@ -22,11 +21,12 @@
</template>
<script setup lang="uts">
import { computed } from "vue";
import { computed
, inject, type Ref
} from "vue";
import HomeFrameTabbarLandscape from "./TabbarLandscape.uvue";
import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";
import { SCENE_SHELL_USER_INFO_INJECT_KEY, useHomeFrameTabbar } from "./tabbarShared.uts";
import { storage } from "@/utils/storage.uts";
type MainTabShellSlotProps = {
userInfo: UTSJSONObject
...
...
@@ -40,17 +40,22 @@ defineSlots<MainTabShellSlots>();
const props = defineProps<{
activeTabIndex: number
userInfo?: null | UTSJSONObject
}>();
const shellUserInfoRef = inject(SCENE_SHELL_USER_INFO_INJECT_KEY, null) as Ref<UTSJSONObject> | null;
const tabbarSource: HomeFrameTabbarSource = {
getAdapterClass: (): null | string => null,
getTabIndex: (): number => props.activeTabIndex,
getUserInfo: (): null | UTSJSONObject => props.userInfo as null | UTSJSONObject
getUserInfo: (): null | UTSJSONObject => {
const r = shellUserInfoRef;
if (r != null) {
return r.value as UTSJSONObject;
}
return storage.get("userInfo") as null | UTSJSONObject;
}
};
const _tabbar = useHomeFrameTabbar(tabbarSource);
const adapterClassName = _tabbar.adapterClassName;
const userName = _tabbar.userName;
const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList;
...
...
@@ -65,8 +70,12 @@ const onChooseScene = _tabbar.onChooseScene;
const jumpPersonCenter = _tabbar.jumpPersonCenter;
const slotUserInfo = computed((): UTSJSONObject => {
const u = props.userInfo;
return u != null ? u : ({} as UTSJSONObject);
const r = shellUserInfoRef;
if (r != null) {
return r.value as UTSJSONObject;
}
const raw = storage.get("userInfo");
return raw != null ? raw as UTSJSONObject : ({} as UTSJSONObject);
});
</script>
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/MainTabShellPortrait.uvue
View file @
058eb04
...
...
@@ -4,11 +4,7 @@
<view class="main-tab-shell-slot main-tab-shell-slot-portrait">
<slot :user-info="slotUserInfo"></slot>
</view>
<HomeFrameTabbarPortrait :adapter-class-name="adapterClassName"
:is-pad-portrait-mode="isPadPortraitMode"
:tabbar-height="tabbarHeight"
:tabbar-icon-size="tabbarIconSize"
:current-tab-index="currentTabIndex"
<HomeFrameTabbarPortrait :current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup"
:show-setting="showSetting"
...
...
@@ -21,11 +17,12 @@
</template>
<script setup lang="uts">
import { computed } from "vue";
import { computed
, inject, type Ref
} from "vue";
import HomeFrameTabbarPortrait from "./TabbarPortrait.uvue";
import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";
import { SCENE_SHELL_USER_INFO_INJECT_KEY, useHomeFrameTabbar } from "./tabbarShared.uts";
import { storage } from "@/utils/storage.uts";
type MainTabShellSlotProps = {
userInfo: UTSJSONObject
...
...
@@ -39,20 +36,22 @@ defineSlots<MainTabShellSlots>();
const props = defineProps<{
activeTabIndex: number
userInfo?: null | UTSJSONObject
}>();
const shellUserInfoRef = inject(SCENE_SHELL_USER_INFO_INJECT_KEY, null) as Ref<UTSJSONObject> | null;
const tabbarSource: HomeFrameTabbarSource = {
getAdapterClass: (): null | string => null,
getTabIndex: (): number => props.activeTabIndex,
getUserInfo: (): null | UTSJSONObject => props.userInfo as null | UTSJSONObject
getUserInfo: (): null | UTSJSONObject => {
const r = shellUserInfoRef;
if (r != null) {
return r.value as UTSJSONObject;
}
return storage.get("userInfo") as null | UTSJSONObject;
}
};
const _tabbar = useHomeFrameTabbar(tabbarSource);
const adapterClassName = _tabbar.adapterClassName;
const isPadPortraitMode = _tabbar.isPadPortraitMode;
const tabbarHeight = _tabbar.tabbarHeight;
const tabbarIconSize = _tabbar.tabbarIconSize;
const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList;
const showScenePopup = _tabbar.showScenePopup;
...
...
@@ -63,8 +62,12 @@ const onSettingVisible = _tabbar.onSettingVisible;
const onChooseScene = _tabbar.onChooseScene;
const slotUserInfo = computed((): UTSJSONObject => {
const u = props.userInfo;
return u != null ? u : ({} as UTSJSONObject);
const r = shellUserInfoRef;
if (r != null) {
return r.value as UTSJSONObject;
}
const raw = storage.get("userInfo");
return raw != null ? raw as UTSJSONObject : ({} as UTSJSONObject);
});
</script>
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/SceneShell.uvue
View file @
058eb04
<template>
<!-- 物理 tab 三页共用:横/竖两套壳 + 默认槽;方向由 updateOrientation + useOrientation 驱动 -->
<MainTabShellPortrait v-if="shellIsPortrait"
:active-tab-index="props.activeTabIndex"
:user-info="userInfo">
:active-tab-index="props.activeTabIndex">
<template #default="{ userInfo: u }">
<slot :user-info="u"></slot>
</template>
</MainTabShellPortrait>
<MainTabShellLandscape v-else
:active-tab-index="props.activeTabIndex"
:user-info="userInfo">
:active-tab-index="props.activeTabIndex">
<template #default="{ userInfo: u }">
<slot :user-info="u"></slot>
</template>
...
...
@@ -17,7 +15,7 @@
</template>
<script setup lang="uts">
import { computed, defineExpose, onMounted, onResize, ref, type Ref } from "vue";
import { computed, defineExpose, onMounted, onResize,
provide,
ref, type Ref } from "vue";
import { updateOrientation, useOrientation } from "@/services/adapter/hooks/index.uts";
import { requestRecordPermission } from "@/utils/permission.uts";
...
...
@@ -26,6 +24,7 @@ import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
import MainTabShellLandscape from "./MainTabShellLandscape.uvue";
import MainTabShellPortrait from "./MainTabShellPortrait.uvue";
import { SCENE_SHELL_USER_INFO_INJECT_KEY } from "./tabbarShared.uts";
type SceneShellSlotProps = {
userInfo: UTSJSONObject
...
...
@@ -51,6 +50,8 @@ const shellIsPortrait = computed((): boolean => {
});
onMounted((): void => {
requestRecordPermission();
hideNativeTabBar();
updateOrientation();
});
...
...
@@ -59,6 +60,7 @@ onResize((_res: any): void => {
});
const userInfo = ref<UTSJSONObject>({});
provide(SCENE_SHELL_USER_INFO_INJECT_KEY, userInfo);
function updateApp(): void {
const info = storage.get("userInfo");
...
...
@@ -67,12 +69,6 @@ function updateApp(): void {
}
}
onLoad((_options) => {
requestRecordPermission();
hideNativeTabBar();
updateOrientation();
});
onShow(() => {
hideNativeTabBar();
});
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/Tabbar.uvue
View file @
058eb04
<template>
<HomeFrameTabbarLandscape v-if="!isPortraitMode"
:adapter-class-name="adapterClassName"
:user-name="userName"
:current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList"
...
...
@@ -14,10 +13,6 @@
@choose-scene="onChooseScene"
@jump-person-center="jumpPersonCenter" />
<HomeFrameTabbarPortrait v-else
:adapter-class-name="adapterClassName"
:is-pad-portrait-mode="isPadPortraitMode"
:tabbar-height="tabbarHeight"
:tabbar-icon-size="tabbarIconSize"
:current-tab-index="currentTabIndex"
:scene-type-list="sceneTypeList"
:show-scene-popup="showScenePopup"
...
...
@@ -39,7 +34,6 @@ import type { HomeFrameTabbarSource } from "./tabbarShared.uts";
import { useHomeFrameTabbar } from "./tabbarShared.uts";
const props = defineProps<{
adapterClass?: string
tabIndex?: number
userInfo?: null | UTSJSONObject
}>();
...
...
@@ -51,19 +45,11 @@ const isPortraitMode = computed((): boolean => {
});
const tabbarSource: HomeFrameTabbarSource = {
getAdapterClass: (): null | string => props.adapterClass as null | string,
getTabIndex: (): number => props.tabIndex != null ? (props.tabIndex as number) : 0,
getUserInfo: (): null | UTSJSONObject => props.userInfo as null | UTSJSONObject
};
const _tabbar = useHomeFrameTabbar(tabbarSource);
const adapterClassName = _tabbar.adapterClassName;
const isPadPortraitMode = _tabbar.isPadPortraitMode;
const tabbarHeight = _tabbar.tabbarHeight;
const tabbarIconSize = _tabbar.tabbarIconSize;
const landscapeTabbarRootStyle = _tabbar.landscapeTabbarRootStyle;
const landscapeTabbarInnerHeight = _tabbar.landscapeTabbarInnerHeight;
const landscapeTabbarIconSize = _tabbar.landscapeTabbarIconSize;
const currentTabIndex = _tabbar.currentTabIndex;
const sceneTypeList = _tabbar.sceneTypeList;
const userName = _tabbar.userName;
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarLandscape.uvue
View file @
058eb04
<template>
<view class="home-tabbar home-tabbar-landscape"
:class="[adapterClassName]">
<image class="home-tabbar-bg-img"
<view class="home-tabbar home-tabbar-landscape">
<!-- <image class="home-tabbar-bg-img"
mode="aspectFill"
src="/static/images/home/left-bg.png" />
src="/static/images/home/left-bg.png" />
-->
<view class="hf-landscape-column">
<view class="user-box user-box-clickable hf-landscape-user"
@click="emit('jumpPersonCenter')">
<view class="hf-landscape-profile">
<un-avatar :text="avatarText"
shape="circle"
size="
5
2"
size="
4
2"
bgColor="#2f6af7"
color="#ffffff"
fontSize="20" />
...
...
@@ -33,19 +32,19 @@
</view>
</view>
</view>
<view class="home-tabbar-footer flex-col hf-landscape-footer"
>
<view class="hf-landscape-footer-btn"
@tap="emit('sceneChange')">
<image class="hf-landscape-footer-icon"
mode="aspectFit
"
src="/static/images/home/scene-change.png" />
</view
>
<view class="hf-landscape-footer-btn hf-landscape-footer-btn--after"
@tap="emit('setting')">
<image class="hf-landscape-footer-icon"
mode="aspectFit
"
src="/static/images/home/setting.png" />
</view
>
</view
>
<view class="home-tabbar-footer flex-col hf-landscape-footer">
<view class="hf-landscape-footer-btn"
@tap="emit('sceneChange')">
<image class="hf-landscape-footer-icon
"
mode="aspectFit"
src="/static/images/home/scene-change.png" /
>
</view>
<view class="hf-landscape-footer-btn hf-landscape-footer-btn--after"
@tap="emit('setting')">
<image class="hf-landscape-footer-icon
"
mode="aspectFit"
src="/static/images/home/setting.png" /
>
</view>
</view>
<CenterPopup :list="sceneTypeList"
...
...
@@ -67,7 +66,6 @@ import SettingBox from "@/pages/person/SettingBox.uvue";
import { HOME_FRAME_TABS } from "./tabbarShared.uts";
const props = defineProps<{
adapterClassName: string
userName: string
currentTabIndex: number
sceneTypeList: UTSJSONObject[]
...
...
@@ -108,16 +106,15 @@ function onTabItemClick(index: number): void {
<style scoped lang="scss">
@import "./styles/common.scss";
/*
横屏侧栏主列:顶/左右/底对称留白,子块共一条竖直中轴
*/
/*
顶部用户区:仅内容高度,不把中间 Tab 区挤没
*/
.hf-landscape-column {
flex: 1;
min-height: 0;
flex-shrink: 0;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
padding: 14px 10px
20px
;
padding: 14px 10px
0
;
position: relative;
z-index: 1;
}
...
...
@@ -143,7 +140,7 @@ function onTabItemClick(index: number): void {
/* 与 MyCenterMain .name 一致;与 Tab 文案同宽便于视觉对齐 */
.hf-landscape-name {
margin-top: 10px;
font-size: 1
9
px;
font-size: 1
4
px;
font-weight: 600;
color: #1a2433;
line-height: 24px;
...
...
@@ -155,15 +152,6 @@ function onTabItemClick(index: number): void {
white-space: nowrap;
}
.hf-landscape-tab-wrap {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 0;
}
.hf-landscape-footer {
width: 100%;
display: flex;
...
...
@@ -171,8 +159,8 @@ function onTabItemClick(index: number): void {
align-items: center;
box-sizing: border-box;
flex-shrink: 0;
margin-top: auto
;
padding-
bottom: 0
;
padding-left: 10px
;
padding-
right: 10px
;
}
.hf-landscape-footer-btn {
...
...
@@ -194,10 +182,11 @@ function onTabItemClick(index: number): void {
flex-shrink: 0;
}
/* 横屏侧栏 Tab
区域
*/
/* 横屏侧栏 Tab
:占满中间 landscape-tabbar-wrap,条目在剩余高度内垂直居中
*/
.landscape-vertical-tabs {
flex: 1;
min-height: 0;
width: 100%;
height: var(--tabbar-height, 540px);
padding-left: var(--tabbar-padding, 16px);
padding-right: var(--tabbar-padding, 16px);
padding-top: 8px;
...
...
@@ -231,8 +220,8 @@ function onTabItemClick(index: number): void {
}
.landscape-vertical-tabs__icon {
width: var(--tabbar-icon-size
, 28px
);
height: var(--tabbar-icon-size
, 28px
);
width: var(--tabbar-icon-size);
height: var(--tabbar-icon-size);
flex-shrink: 0;
}
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/TabbarPortrait.uvue
View file @
058eb04
<template>
<view class="home-tabbar home-tabbar-portrait"
:class="[adapterClassName, isPadPortraitMode ? 'home-tabbar-portrait-pad' : '']">
<view class="home-tabbar home-tabbar-portrait home-tabbar-portrait-pad">
<un-tabbar :model-value="currentTabIndex"
class="portrait-un-tabbar"
:fixed="true"
...
...
@@ -9,13 +8,12 @@
active-color="#3773f8"
inactive-color="#8a98b5"
bg-color="#ffffff"
:height="tabbarHeight"
@change="emit('tabChange', ($event as string | number))">
<un-tabbar-item v-for="(item, index) in tabs"
:key="index"
:name="index"
:text="item.label"
:icon-size="tabbarIconSize">
:text="item.label">
<template #icon="{ active }">
<image v-if="active === true"
class="tabbar-icon-img"
...
...
@@ -45,10 +43,6 @@ import SettingBox from "@/pages/person/SettingBox.uvue";
import { HOME_FRAME_TABS } from "./tabbarShared.uts";
defineProps<{
adapterClassName: string
isPadPortraitMode: boolean
tabbarHeight: number
tabbarIconSize: number
currentTabIndex: number
sceneTypeList: UTSJSONObject[]
showScenePopup: boolean
...
...
@@ -67,4 +61,10 @@ const tabs = HOME_FRAME_TABS;
<style scoped lang="scss">
@import "./styles/common.scss";
/* 与 layout-root 注入的 index.vars.uts 中 --tabbar-icon-size 一致;横屏侧栏见 TabbarLandscape .landscape-vertical-tabs__icon */
.tabbar-icon-img {
width: var(--tabbar-icon-size);
height: var(--tabbar-icon-size);
}
</style>
apps/uniappX/uniapp-x-tape/components/HomeFrame/index.uvue
View file @
058eb04
...
...
@@ -65,7 +65,7 @@
</template>
<script setup lang="uts">
import { computed, defineExpose, ref } from "vue";
import { computed, defineExpose,
onMounted,
ref } from "vue";
import type { UnSwiperItem } from "@/uni_modules/uview-unix";
...
...
@@ -235,7 +235,8 @@ function onStartClick(): void {
emit("start");
}
onLoad((options) => {
onMounted((): void => {
requestRecordPermission();
});
defineExpose({
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/styles/common.scss
View file @
058eb04
...
...
@@ -454,6 +454,7 @@
pointer-events
:
none
;
}
.hf-landscape-column
,
.user-box
,
.landscape-tabbar-wrap
,
.home-tabbar-footer
{
...
...
@@ -464,6 +465,8 @@
.home-tabbar-landscape
{
min-height
:
0
;
height
:
100%
;
align-self
:
stretch
;
}
.home-tabbar-portrait
{
...
...
@@ -577,8 +580,9 @@
min-height
:
0
;
}
/* 横屏:footer 为侧栏第三段,由父级 flex 贴底;竖屏若复用此类名再按需加 margin */
.home-tabbar-footer
{
margin-top
:
auto
;
flex-shrink
:
0
;
padding-bottom
:
40px
;
}
...
...
apps/uniappX/uniapp-x-tape/components/HomeFrame/styles/index.vars.uts
View file @
058eb04
...
...
@@ -85,8 +85,8 @@ export default {
'--common-title-height': '54px',
'--entrance-icon-size': '64px',
'--entrance-item-gap': 'var(--l-spacing-3xl)',
'--tabbar-height': '
64
0px',
'--tabbar-icon-size': '
34
px',
'--tabbar-height': '
7
0px',
'--tabbar-icon-size': '
46
px',
'--tabbar-width': '140px',
},
...
...
@@ -126,7 +126,7 @@ export default {
'--entrance-icon-size': '64px',
'--entrance-item-gap': 'var(--l-spacing-3xl)',
'--tabbar-height': '70px',
'--tabbar-icon-size': '3
4
px',
'--tabbar-icon-size': '3
2
px',
},
}
}
apps/uniappX/uniapp-x-tape/components/HomeFrame/tabbarShared.uts
View file @
058eb04
import { computed, ref } from "vue";
import { cssClassRef } from "@/services/adapter";
import { storage } from "@/utils/storage.uts";
import { notifyUserSceneTypeChanged } from "@/utils/userSceneEvents.uts";
import { hideNativeTabBar } from "@/utils/tabBarShell.uts";
export type HomeFrameTabbarSource = {
getAdapterClass: () => null | string
getTabIndex: () => number
getUserInfo: () => null | UTSJSONObject
}
/** SceneShell `provide`:`Ref<UTSJSONObject>`;MainTabShell `inject`,与插槽同源 */
export const SCENE_SHELL_USER_INFO_INJECT_KEY = "homeFrame.sceneShellUserInfo"
export type TabItem = {
label: string;
icon: string;
...
...
@@ -98,20 +99,6 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
const showScenePopup = ref(false);
const showSetting = ref(false);
const adapterClassName = computed((): string => {
const cls = source.getAdapterClass();
if (cls != null && cls !== "") {
return cls as string;
}
const fromRef = cssClassRef.value;
return fromRef != null ? (fromRef as string) : "";
});
const isPadPortraitMode = computed((): boolean => {
const cls = adapterClassName.value;
return cls.indexOf("layout-portrait-768x1174") >= 0;
});
const currentTabIndex = computed((): number => {
return source.getTabIndex();
});
...
...
@@ -264,8 +251,6 @@ export function useHomeFrameTabbar(source: HomeFrameTabbarSource) {
return {
showScenePopup,
showSetting,
adapterClassName,
isPadPortraitMode,
currentTabIndex,
sceneTypeList,
sceneTypeIdList,
...
...
apps/uniappX/uniapp-x-tape/pages.json
View file @
058eb04
...
...
@@ -13,24 +13,6 @@
}
},
{
"path"
:
"pages/usedCar/index"
,
"style"
:
{
"navigationStyle"
:
"custom"
}
},
{
"path"
:
"pages/equity/index"
,
"style"
:
{
"navigationStyle"
:
"custom"
}
},
{
"path"
:
"pages/boutique/index"
,
"style"
:
{
"navigationStyle"
:
"custom"
}
},
{
"path"
:
"pages/receptionCenter/center"
,
"style"
:
{
"navigationStyle"
:
"custom"
...
...
@@ -43,12 +25,6 @@
}
},
{
"path"
:
"pages/test/index"
,
"style"
:
{
"navigationStyle"
:
"custom"
}
},
{
"path"
:
"pages/index/index"
,
"style"
:
{
"navigationStyle"
:
"custom"
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment