<script lang="ts" setup>
import { Drawer } from 'ant-design-vue'
import Sider from './LayoutSider.vue'
import MixSider from './MixSider.vue'

import { useAppInject } from '@/hooks/web/useAppInject'
import { useMenuSetting } from '@/hooks/setting/useMenuSetting'
import { useDesign } from '@/hooks/web/useDesign'

import KingdeeSider from '@/layouts/default/sider/KingdeeSider.vue'

defineOptions({ name: 'SiderWrapper' })

const { prefixCls } = useDesign('layout-sider-wrapper')
const { getIsMobile } = useAppInject()
const { setMenuSetting, getCollapsed, getMenuWidth, getIsMixSidebar, getIsKingdeeNew } = useMenuSetting()

function handleClose() {
  setMenuSetting({
    collapsed: true,
  })
}
</script>

<template>
  <Drawer
    v-if="getIsMobile"
    placement="left"
    :class="prefixCls"
    :width="getMenuWidth"
    :get-container="null"
    :open="!getCollapsed"
    @close="handleClose"
  >
    <Sider />
  </Drawer>
  <KingdeeSider v-else-if="getIsKingdeeNew" />
  <MixSider v-else-if="getIsMixSidebar" />
  <Sider v-else />
</template>

<style lang="less">
@prefix-cls: ~'@{namespace}-layout-sider-wrapper';

.@{prefix-cls} {
  .ant-drawer-body {
    height: 100vh;
    padding: 0;
  }

  .ant-drawer-header-no-title {
    display: none;
  }
}
</style>
