Layout.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <script lang="tsx">
  2. import { computed, defineComponent, unref } from 'vue'
  3. import { useAppStore } from '@/store/modules/app'
  4. import { Backtop } from '@/components/Backtop'
  5. import { Setting } from '@/components/Setting'
  6. import { useRenderLayout } from './components/useRenderLayout'
  7. import { useDesign } from '@/hooks/web/useDesign'
  8. const { getPrefixCls } = useDesign()
  9. const prefixCls = getPrefixCls('layout')
  10. const appStore = useAppStore()
  11. // 是否是移动端
  12. const mobile = computed(() => appStore.getMobile)
  13. // 菜单折叠
  14. const collapse = computed(() => appStore.getCollapse)
  15. const layout = computed(() => appStore.getLayout)
  16. const handleClickOutside = () => {
  17. appStore.setCollapse(true)
  18. }
  19. const renderLayout = () => {
  20. switch (unref(layout)) {
  21. case 'classic':
  22. const { renderClassic } = useRenderLayout()
  23. return renderClassic()
  24. case 'topLeft':
  25. const { renderTopLeft } = useRenderLayout()
  26. return renderTopLeft()
  27. case 'top':
  28. const { renderTop } = useRenderLayout()
  29. return renderTop()
  30. case 'cutMenu':
  31. const { renderCutMenu } = useRenderLayout()
  32. return renderCutMenu()
  33. default:
  34. break
  35. }
  36. }
  37. export default defineComponent({
  38. name: 'Layout',
  39. setup() {
  40. return () => (
  41. <section class={[prefixCls, `${prefixCls}__${layout.value}`, 'w-[100%] h-[100%] relative']}>
  42. {mobile.value && !collapse.value ? (
  43. <div
  44. class="absolute top-0 left-0 w-full h-full opacity-30 z-99 bg-[var(--el-color-black)]"
  45. onClick={handleClickOutside}
  46. ></div>
  47. ) : undefined}
  48. {renderLayout()}
  49. <Backtop></Backtop>
  50. <Setting></Setting>
  51. </section>
  52. )
  53. }
  54. })
  55. </script>
  56. <style lang="less" scoped>
  57. @prefix-cls: ~'@{namespace}-layout';
  58. .@{prefix-cls} {
  59. background-color: var(--app-contnet-bg-color);
  60. :deep(.@{elNamespace}-scrollbar__view) {
  61. height: 100% !important;
  62. }
  63. }
  64. </style>