gohttpdUi/src/layout/Layout.vue

85 lines
2.0 KiB
Vue
Raw Normal View History

2022-01-12 16:44:57 +08:00
<script lang="tsx">
2022-01-19 16:29:35 +08:00
import { computed, defineComponent, unref } from 'vue'
2022-01-12 16:44:57 +08:00
import { useAppStore } from '@/store/modules/app'
import { Backtop } from '@/components/Backtop'
2022-01-16 19:35:39 +08:00
import { Setting } from '@/components/Setting'
2022-01-19 16:29:35 +08:00
import { useRenderLayout } from './components/useRenderLayout'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('layout')
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 collapse = computed(() => appStore.getCollapse)
2022-01-19 16:29:35 +08:00
const layout = computed(() => appStore.getLayout)
2022-01-12 16:44:57 +08:00
const handleClickOutside = () => {
appStore.setCollapse(true)
}
2022-01-12 16:44:57 +08:00
2022-01-19 16:29:35 +08:00
const renderLayout = () => {
switch (unref(layout)) {
case 'classic':
const { renderClassic } = useRenderLayout()
return renderClassic()
case 'topLeft':
const { renderTopLeft } = useRenderLayout()
return renderTopLeft()
2022-01-21 16:17:40 +08:00
case 'top':
const { renderTop } = useRenderLayout()
return renderTop()
case 'cutMenu':
const { renderCutMenu } = useRenderLayout()
return renderCutMenu()
2022-01-19 16:29:35 +08:00
default:
break
}
}
2022-01-12 16:44:57 +08:00
export default defineComponent({
name: 'Layout',
setup() {
return () => (
<section class={[prefixCls, `${prefixCls}__${layout.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-18 16:22:47 +08:00
2022-01-19 16:29:35 +08:00
{renderLayout()}
2022-01-16 19:35:39 +08:00
<Backtop></Backtop>
2022-01-16 19:35:39 +08:00
<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: ~'@{adminNamespace}-layout';
2022-04-14 09:33:27 +08:00
.@{prefix-cls} {
2022-08-13 08:32:12 +08:00
background-color: var(--app-content-bg-color);
.@{prefix-cls}-content-scrollbar {
& > :deep(.el-scrollbar__wrap) {
& > .@{elNamespace}-scrollbar__view {
display: flex;
height: 100% !important;
flex-direction: column;
}
}
2022-04-14 09:33:27 +08:00
}
2022-01-22 10:54:28 +08:00
}
2022-01-12 17:25:35 +08:00
</style>