DragBar.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div :class="getClass" :style="getDragBarStyle"></div>
  3. </template>
  4. <script lang="ts" setup>
  5. import { computed, unref } from 'vue';
  6. import { useDesign } from '@/hooks/web/useDesign';
  7. import { useMenuSetting } from '@/hooks/setting/useMenuSetting';
  8. defineOptions({ name: 'DargBar' });
  9. const props = defineProps({
  10. mobile: Boolean,
  11. });
  12. const { getMiniWidthNumber, getCollapsed, getCanDrag } = useMenuSetting();
  13. const { prefixCls } = useDesign('darg-bar');
  14. const getDragBarStyle = computed(() => {
  15. if (unref(getCollapsed)) {
  16. return { left: `${unref(getMiniWidthNumber)}px` };
  17. }
  18. return {};
  19. });
  20. const getClass = computed(() => {
  21. return [
  22. prefixCls,
  23. {
  24. [`${prefixCls}--hide`]: !unref(getCanDrag) || props.mobile,
  25. },
  26. ];
  27. });
  28. </script>
  29. <style lang="less" scoped>
  30. @prefix-cls: ~'@{namespace}-darg-bar';
  31. .@{prefix-cls} {
  32. position: absolute;
  33. z-index: @side-drag-z-index;
  34. top: 0;
  35. right: -2px;
  36. width: 2px;
  37. height: 100%;
  38. border-top: none;
  39. border-bottom: none;
  40. cursor: col-resize;
  41. &--hide {
  42. display: none;
  43. }
  44. &:hover {
  45. background-color: @primary-color;
  46. box-shadow: 0 0 4px 0 rgb(28 36 56 / 15%);
  47. }
  48. }
  49. </style>