support tablet

This commit is contained in:
Timi
2026-11-02 23:12:05 +08:00
parent c48b19bed5
commit d3879c9c77
123 changed files with 4153 additions and 2673 deletions
+33 -73
View File
@@ -1,45 +1,26 @@
<template>
<div class="main-layout diselect">
<div class="content">
<page-transition
:keep-alive="shouldKeepAlive"
:page-background="globalUIStore.bodyBackground"
:page-class="pageClass"
:respect-reduced-motion="false"
/>
</div>
<t-tab-bar
v-model="tabVal"
:class="{ 'is-hidden': !tabBarStore.isShowing }"
class="tab-bar glass-white"
shape="round"
theme="tag"
:split="false"
:z-index="999"
:bordered="false"
:disabled="!tabBarStore.isShowing"
@change="onChangeTab"
>
<t-tab-bar-item
v-for="item in list"
:key="item.value"
class="item bg-transparent"
:value="item.value"
>
<span v-text="item.text"></span>
<template #icon>
<t-icon :name="item.icon" />
</template>
</t-tab-bar-item>
</t-tab-bar>
</div>
<app-shell
v-model="tabVal"
class="diselect"
:items="navList"
logo-text="糕"
tab-bar-float
:hide-nav="!tabBarStore.isShowing"
@change="onChangeTab"
>
<page-transition
:keep-alive="shouldKeepAlive"
:page-background="globalUIStore.bodyBackground"
:page-class="pageClass"
/>
</app-shell>
</template>
<script setup lang="ts">
import { AppShell, PageTransition, useLayout } from "timi-tdesign-mobile";
import { useGlobalUIStore } from "@/store/globalUI";
import { useTabBarStore } from "@/store/tabBarStore";
import { permissionCodes } from "@/utils/permission";
import { PageTransition } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api/store";
import type { RouteLocationNormalizedLoaded } from "vue-router";
@@ -49,6 +30,9 @@ const globalUIStore = useGlobalUIStore();
const tabBarStore = useTabBarStore();
const userStore = useUserStore();
/** 与 AppShell 内部的断点参数保持一致,用于判断页面是否需要底部留白。 */
const { railVisible } = useLayout({ tablet: true });
const cachedRouteNames = new Set(["EventRecordRank", "SalesOrderList", "ProductList", "ProductStockList", "ProductStockBatchSelect", "ProductStockBatchConfigure"]);
function shouldKeepAlive(sourceRoute: RouteLocationNormalizedLoaded): boolean {
@@ -99,6 +83,12 @@ const list = computed(() => tabList.filter(item => (
&& (!item.role || userStore.hasRoles(item.role, item.roleMode))
)));
const navList = computed(() => list.value.map(item => ({
value: item.value,
text: item.text,
icon: item.icon
})));
watch(() => route.path, (newPath: string) => {
tabVal.value = resolveTabValue(newPath);
}, { immediate: true });
@@ -161,48 +151,18 @@ const isTabBarPaddingNeeded = computed(() => {
return false;
}
// 左侧导航栏出现后底部不再有标签栏,页面不需要为它留白
if (railVisible.value) {
return false;
}
return route.meta.tabBarPadding !== false;
});
const pageClass = computed(() => ({
"page-layout": true,
navbar: true,
tabbar: isTabBarPaddingNeeded.value
"tui-page-layout": true,
"tui-navbar": true,
"tui-tabbar": isTabBarPaddingNeeded.value
}));
</script>
<style scoped lang="less">
.main-layout {
height: 100vh;
overflow: hidden;
position: relative;
.content {
height: 100%;
}
.tab-bar {
--td-tab-bar-height: 52px;
--td-tab-bar-active-bg: var(--td-brand-color-2);
bottom: 1rem;
opacity: 1;
transform: translateY(0);
transition: opacity 520ms, transform 520ms var(--tui-bezier);
pointer-events: auto;
backdrop-filter: blur(10px);
&.is-hidden {
opacity: 0;
pointer-events: none;
transform: translateY(calc(100% + 1rem));
}
.item {
margin: 4px 0;
padding: 0 4px;
}
}
}
</style>