ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<script lang="ts">
import { computed, defineComponent } from 'vue';
 
import { $t } from '@vben/locales';
 
import { useNamespace } from '@vben-core/composables';
 
import { CloseOutlined, FullscreenExitOutlined, FullscreenOutlined } from '@ant-design/icons-vue';
import { Tooltip } from 'ant-design-vue';
 
export default defineComponent({
  components: { CloseOutlined, FullscreenExitOutlined, FullscreenOutlined, Tooltip },
  emits: ['cancel', 'fullscreen'],
  name: 'ModalClose',
  props: {
    canFullscreen: { default: true, type: Boolean },
    fullScreen: { type: Boolean },
  },
  setup(props, { emit }) {
    const { b } = useNamespace('basic-modal-close');
    const prefixCls = b();
 
    const getClass = computed(() => {
      return [
        prefixCls,
        `${prefixCls}--custom`,
        {
          [`${prefixCls}--can-full`]: props.canFullscreen,
        },
      ];
    });
 
    function handleCancel(e: Event) {
      emit('cancel', e);
    }
 
    function handleFullScreen(e: Event) {
      e?.stopPropagation();
      e?.preventDefault();
      emit('fullscreen');
    }
 
    return {
      getClass,
      handleCancel,
      handleFullScreen,
      prefixCls,
      t: $t,
    };
  },
});
</script>
<template>
  <div :class="getClass">
    <template v-if="canFullscreen">
      <Tooltip v-if="fullScreen" :title="t('component.modal.restore')" placement="bottom">
        <FullscreenExitOutlined role="full" @click="handleFullScreen" />
      </Tooltip>
      <Tooltip v-else :title="t('component.modal.maximize')" placement="bottom">
        <FullscreenOutlined role="close" @click="handleFullScreen" />
      </Tooltip>
    </template>
    <Tooltip :title="t('component.modal.close')" placement="bottom">
      <CloseOutlined @click="handleCancel" />
    </Tooltip>
  </div>
</template>
<style lang="scss">
.jnpf-basic-modal-close {
  display: flex;
  align-items: center;
  height: 100%;
 
  > span {
    margin-left: 48px;
    font-size: 16px;
  }
 
  &--can-full {
    > span {
      margin-left: 12px;
    }
  }
 
  &:not(&--can-full) {
    > span:nth-child(1) {
      &:hover {
        font-weight: 700;
      }
    }
  }
 
  & span:nth-child(1) {
    display: inline-block;
    padding: 10px;
 
    &:hover {
      color: var(--primary-color);
    }
  }
 
  & span:last-child {
    &:hover {
      color: var(--error-color);
    }
  }
}
</style>