Commit c3b907656a5fad7a9b241562179f7a0f6fe0e6f0

Authored by 无木
1 parent b96ea075

feat(modal): add `tooltip` for action buttons

为最大化、全屏、还原等操作按钮添加工具提示
CHANGELOG.zh_CN.md
... ... @@ -12,6 +12,7 @@
12 12 - 新增`onChange`用于接受头像剪裁并上传成功事件
13 13 - 新增`btnText`、`btnProps` 用于自定义上传按钮文案和属性
14 14 - 为剪裁`Modal`内的操作按钮添加工具提示
  15 +- **Modal** 为右上角的操作按钮添加工具提示
15 16  
16 17 ### 🐛 Bug Fixes
17 18  
... ...
src/components/Modal/src/components/ModalClose.vue
1 1 <template>
2 2 <div :class="getClass">
3 3 <template v-if="canFullscreen">
4   - <FullscreenExitOutlined role="full" @click="handleFullScreen" v-if="fullScreen" />
5   - <FullscreenOutlined role="close" @click="handleFullScreen" v-else />
  4 + <Tooltip :title="t('component.modal.restore')" placement="bottom" v-if="fullScreen">
  5 + <FullscreenExitOutlined role="full" @click="handleFullScreen" />
  6 + </Tooltip>
  7 + <Tooltip :title="t('component.modal.maximize')" placement="bottom" v-else>
  8 + <FullscreenOutlined role="close" @click="handleFullScreen" />
  9 + </Tooltip>
6 10 </template>
7   - <CloseOutlined @click="handleCancel" />
  11 + <Tooltip :title="t('component.modal.close')" placement="bottom">
  12 + <CloseOutlined @click="handleCancel" />
  13 + </Tooltip>
8 14 </div>
9 15 </template>
10 16 <script lang="ts">
11 17 import { defineComponent, computed } from 'vue';
12 18 import { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined } from '@ant-design/icons-vue';
13 19 import { useDesign } from '/@/hooks/web/useDesign';
  20 + import { Tooltip } from 'ant-design-vue';
  21 + import { useI18n } from '/@/hooks/web/useI18n';
14 22  
15 23 export default defineComponent({
16 24 name: 'ModalClose',
17   - components: { FullscreenExitOutlined, FullscreenOutlined, CloseOutlined },
  25 + components: { Tooltip, FullscreenExitOutlined, FullscreenOutlined, CloseOutlined },
18 26 props: {
19 27 canFullscreen: { type: Boolean, default: true },
20 28 fullScreen: { type: Boolean },
... ... @@ -22,6 +30,7 @@
22 30 emits: ['cancel', 'fullscreen'],
23 31 setup(props, { emit }) {
24 32 const { prefixCls } = useDesign('basic-modal-close');
  33 + const { t } = useI18n();
25 34  
26 35 const getClass = computed(() => {
27 36 return [
... ... @@ -44,6 +53,7 @@
44 53 }
45 54  
46 55 return {
  56 + t,
47 57 getClass,
48 58 prefixCls,
49 59 handleCancel,
... ...
src/locales/lang/en/component.ts
... ... @@ -48,6 +48,9 @@ export default {
48 48 modal: {
49 49 cancelText: 'Close',
50 50 okText: 'Confirm',
  51 + close: 'Close',
  52 + maximize: 'Maximize',
  53 + restore: 'Restore',
51 54 },
52 55 table: {
53 56 settingDens: 'Density',
... ...
src/locales/lang/zh_CN/component.ts
... ... @@ -50,6 +50,9 @@ export default {
50 50 modal: {
51 51 cancelText: '关闭',
52 52 okText: '确认',
  53 + close: '关闭',
  54 + maximize: '最大化',
  55 + restore: '还原',
53 56 },
54 57 table: {
55 58 settingDens: '密度',
... ...