DragBar.vue 1.4 KB

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