gohttpdUi/src/layout/Layout.vue

143 lines
4.0 KiB
Vue
Raw Normal View History

2022-01-12 16:44:57 +08:00
<script lang="tsx">
import { computed, defineComponent } from 'vue'
2022-01-12 16:44:57 +08:00
import { useAppStore } from '@/store/modules/app'
import { Menu } from '@/components/Menu'
2022-01-13 17:26:06 +08:00
import { Collapse } from '@/components/Collapse'
import { LocaleDropdown } from '@/components/LocaleDropdown'
import { SizeDropdown } from '@/components/SizeDropdown'
import { UserInfo } from '@/components/UserInfo'
import { Screenfull } from '@/components/Screenfull'
import { Breadcrumb } from '@/components/Breadcrumb'
import { TagsView } from '@/components/TagsView'
2022-01-16 19:35:39 +08:00
import { Backtop } from '@/components/Backtop'
import { Setting } from '@/components/Setting'
import AppView from './components/AppView.vue'
2022-01-12 16:44:57 +08:00
const appStore = useAppStore()
2022-01-12 17:25:35 +08:00
2022-01-18 16:22:47 +08:00
// 是否是移动端
const mobile = computed(() => appStore.getMobile)
2022-01-18 16:22:47 +08:00
// 面包屑
const breadcrumb = computed(() => appStore.getBreadcrumb)
// 菜单折叠
const collapse = computed(() => appStore.getCollapse)
2022-01-18 16:22:47 +08:00
// 折叠图标
const hamburger = computed(() => appStore.getHamburger)
// 全屏图标
const screenfull = computed(() => appStore.getScreenfull)
// 尺寸图标
const size = computed(() => appStore.getSize)
// 多语言图标
const locale = computed(() => appStore.getLocale)
// 标签页
const tagsView = computed(() => appStore.getTagsView)
const classSuffix = computed(() => appStore.getLayout)
2022-01-12 16:44:57 +08:00
const handleClickOutside = () => {
appStore.setCollapse(true)
}
2022-01-12 16:44:57 +08:00
export default defineComponent({
name: 'Layout',
setup() {
return () => (
<section class={['v-app', `v-app__${classSuffix.value}`, 'w-[100%] h-[100%] relative']}>
{mobile.value && !collapse.value ? (
<div
class="absolute top-0 left-0 w-full h-full opacity-30 z-99 bg-[var(--el-color-black)]"
onClick={handleClickOutside}
></div>
) : undefined}
2022-01-12 17:25:35 +08:00
<Menu class="absolute top-0 left-0"></Menu>
<div
class={[
'v-app-right',
2022-01-12 17:25:35 +08:00
'absolute top-0 h-[100%]',
collapse.value
2022-01-12 17:25:35 +08:00
? 'w-[calc(100%-var(--left-menu-min-width))]'
: 'w-[calc(100%-var(--left-menu-max-width))]',
collapse.value
2022-01-12 17:25:35 +08:00
? 'left-[var(--left-menu-min-width)]'
: 'left-[var(--left-menu-max-width)]',
'<md:(!left-0 !w-[100%])'
2022-01-12 17:25:35 +08:00
]}
>
<div
class={[
'v-app-right__tool',
2022-01-13 17:26:06 +08:00
'h-[var(--top-tool-height)] relative px-[var(--top-tool-p-x)] flex items-center justify-between'
2022-01-12 17:25:35 +08:00
]}
>
2022-01-13 17:26:06 +08:00
<div class="h-full flex items-center">
2022-01-18 16:22:47 +08:00
{hamburger.value ? <Collapse class="header__tigger"></Collapse> : undefined}
{breadcrumb.value ? <Breadcrumb class="<md:hidden"></Breadcrumb> : undefined}
2022-01-13 17:26:06 +08:00
</div>
<div class="h-full flex items-center">
2022-01-18 16:22:47 +08:00
{screenfull.value ? <Screenfull class="header__tigger"></Screenfull> : undefined}
{size.value ? <SizeDropdown class="header__tigger"></SizeDropdown> : undefined}
{locale.value ? <LocaleDropdown class="header__tigger"></LocaleDropdown> : undefined}
2022-01-13 17:26:06 +08:00
<UserInfo class="header__tigger"></UserInfo>
</div>
2022-01-12 17:25:35 +08:00
</div>
2022-01-18 16:22:47 +08:00
{tagsView.value ? (
<div class="v-app-right__tags-view relative">
<TagsView></TagsView>
</div>
) : undefined}
<AppView></AppView>
2022-01-12 17:25:35 +08:00
</div>
2022-01-16 19:35:39 +08:00
<Backtop></Backtop>
<Setting></Setting>
2022-01-12 16:44:57 +08:00
</section>
)
}
})
</script>
2022-01-12 17:25:35 +08:00
<style lang="less" scoped>
@prefix-cls: ~'@{namespace}-app';
2022-01-13 17:26:06 +08:00
.header__tigger {
display: flex;
height: 100%;
padding: 1px 10px 0;
cursor: pointer;
align-items: center;
transition: background var(--transition-time-02);
&:hover {
background-color: #f6f6f6;
}
}
2022-01-12 17:25:35 +08:00
.@{prefix-cls} {
&-right {
2022-01-13 17:26:06 +08:00
transition: left var(--transition-time-02);
&__tool,
&__tags-view {
2022-01-12 17:25:35 +08:00
&::after {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 1px;
border-top: 1px solid var(--top-tool-border-color);
content: '';
}
}
}
}
</style>