139 lines
3.0 KiB
Vue
139 lines
3.0 KiB
Vue
<template>
|
|
<div class="demo">
|
|
<div class="bar">
|
|
<button
|
|
v-for="item in modeList"
|
|
:key="item.value"
|
|
type="button"
|
|
class="chip"
|
|
:class="{ on: mode === item.value }"
|
|
@click="mode = item.value"
|
|
>
|
|
<span v-text="item.text" />
|
|
</button>
|
|
</div>
|
|
<div class="frame">
|
|
<app-shell
|
|
v-model="active"
|
|
:items="tabList"
|
|
:mode="mode"
|
|
logo-text="糕"
|
|
>
|
|
<div class="page">
|
|
<header class="navbar">
|
|
<span v-text="activeText" />
|
|
</header>
|
|
<main class="content">
|
|
<p class="mode" v-text="`当前形态:${mode}`" />
|
|
<p class="desc" v-text="descText" />
|
|
</main>
|
|
</div>
|
|
</app-shell>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, ref } from "vue";
|
|
import { AppShell, type AppShellMode } from "timi-tdesign-mobile";
|
|
|
|
const modeList: Array<{ value: AppShellMode; text: string }> = [
|
|
{ value: "phone", text: "手机" },
|
|
{ value: "tablet", text: "竖屏平板" },
|
|
{ value: "wide", text: "横屏平板" }
|
|
];
|
|
|
|
const tabList = [
|
|
{ value: "/customers", icon: "usergroup", text: "客户", badge: 12 },
|
|
{ value: "/product", icon: "layers", text: "产品" },
|
|
{ value: "/store", icon: "shop-3", text: "门店" },
|
|
{ value: "/management", icon: "setting-1", text: "管理" }
|
|
];
|
|
|
|
const mode = ref<AppShellMode>("wide");
|
|
const active = ref("/customers");
|
|
|
|
const activeText = computed(() => tabList.find(item => item.value === active.value)?.text || "");
|
|
|
|
const descText = computed(() => (mode.value === "wide"
|
|
? "横屏平板使用左侧导航栏,一级导航始终可见。"
|
|
: "手机与竖屏平板保留底部标签栏,把纵向空间留给内容。"));
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.demo {
|
|
.bar {
|
|
gap: .5rem;
|
|
display: flex;
|
|
margin-bottom: .75rem;
|
|
}
|
|
|
|
.chip {
|
|
padding: .375rem .875rem;
|
|
color: var(--td-text-color-secondary);
|
|
font-size: .8125rem;
|
|
background: var(--td-bg-color-container);
|
|
border-radius: 99rem;
|
|
border: 1px solid var(--td-component-border);
|
|
cursor: pointer;
|
|
|
|
&.on {
|
|
color: var(--td-brand-color);
|
|
border-color: var(--td-brand-color);
|
|
background: var(--td-brand-color-1);
|
|
}
|
|
}
|
|
|
|
.frame {
|
|
height: 340px;
|
|
overflow: hidden;
|
|
border-radius: .75rem;
|
|
border: 1px solid var(--td-component-border);
|
|
|
|
:deep(.tui-app-shell) {
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
.page {
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
background: var(--td-bg-color-page);
|
|
|
|
.navbar {
|
|
height: 3rem;
|
|
flex: none;
|
|
display: grid;
|
|
color: var(--td-text-color-primary);
|
|
font-size: .9375rem;
|
|
font-weight: 600;
|
|
place-items: center;
|
|
background: var(--td-bg-color-container);
|
|
border-bottom: 1px solid var(--td-component-border);
|
|
}
|
|
|
|
.content {
|
|
flex: 1;
|
|
padding: 1rem;
|
|
min-height: 0;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.mode {
|
|
margin: 0 0 .5rem;
|
|
color: var(--td-text-color-primary);
|
|
font-size: .875rem;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.desc {
|
|
margin: 0;
|
|
color: var(--td-text-color-secondary);
|
|
font-size: .8125rem;
|
|
line-height: 1.7;
|
|
}
|
|
}
|
|
}
|
|
</style>
|