Commit 6cbac4b7ece60a1a7c1fda931cfffce42dfe3e51
1 parent
81cf4413
feat(avatar-cropper): add action tooltip
为头像剪裁组件的操作按钮添加工具提示
Showing
3 changed files
with
84 additions
and
47 deletions
src/components/Cropper/src/CopperModal.vue
@@ -23,57 +23,80 @@ | @@ -23,57 +23,80 @@ | ||
23 | 23 | ||
24 | <div :class="`${prefixCls}-toolbar`"> | 24 | <div :class="`${prefixCls}-toolbar`"> |
25 | <Upload :fileList="[]" accept="image/*" :beforeUpload="handleBeforeUpload"> | 25 | <Upload :fileList="[]" accept="image/*" :beforeUpload="handleBeforeUpload"> |
26 | - <a-button size="small" preIcon="ant-design:upload-outlined" type="primary" /> | 26 | + <Tooltip :title="t('component.cropper.selectImage')" placement="bottom"> |
27 | + <a-button size="small" preIcon="ant-design:upload-outlined" type="primary" /> | ||
28 | + </Tooltip> | ||
27 | </Upload> | 29 | </Upload> |
28 | <Space> | 30 | <Space> |
29 | - <a-button | ||
30 | - type="primary" | ||
31 | - preIcon="ant-design:reload-outlined" | ||
32 | - size="small" | ||
33 | - @click="handlerToolbar('reset')" | ||
34 | - /> | ||
35 | - <a-button | ||
36 | - type="primary" | ||
37 | - preIcon="ant-design:rotate-left-outlined" | ||
38 | - size="small" | ||
39 | - @click="handlerToolbar('rotate', -45)" | ||
40 | - /> | ||
41 | - <a-button | ||
42 | - type="primary" | ||
43 | - preIcon="ant-design:rotate-right-outlined" | ||
44 | - size="small" | ||
45 | - @click="handlerToolbar('rotate', 45)" | ||
46 | - /> | ||
47 | - <a-button | ||
48 | - type="primary" | ||
49 | - preIcon="vaadin:arrows-long-h" | ||
50 | - size="small" | ||
51 | - @click="handlerToolbar('scaleX')" | ||
52 | - /> | ||
53 | - <a-button | ||
54 | - type="primary" | ||
55 | - preIcon="vaadin:arrows-long-v" | ||
56 | - size="small" | ||
57 | - @click="handlerToolbar('scaleY')" | ||
58 | - /> | ||
59 | - <a-button | ||
60 | - type="primary" | ||
61 | - preIcon="ant-design:zoom-in-outlined" | ||
62 | - size="small" | ||
63 | - @click="handlerToolbar('zoom', 0.1)" | ||
64 | - /> | ||
65 | - <a-button | ||
66 | - type="primary" | ||
67 | - preIcon="ant-design:zoom-out-outlined" | ||
68 | - size="small" | ||
69 | - @click="handlerToolbar('zoom', -0.1)" | ||
70 | - /> | 31 | + <Tooltip :title="t('component.cropper.btn_reset')" placement="bottom"> |
32 | + <a-button | ||
33 | + type="primary" | ||
34 | + preIcon="ant-design:reload-outlined" | ||
35 | + size="small" | ||
36 | + :disabled="!src" | ||
37 | + @click="handlerToolbar('reset')" | ||
38 | + /> | ||
39 | + </Tooltip> | ||
40 | + <Tooltip :title="t('component.cropper.btn_rotate_left')" placement="bottom"> | ||
41 | + <a-button | ||
42 | + type="primary" | ||
43 | + preIcon="ant-design:rotate-left-outlined" | ||
44 | + size="small" | ||
45 | + :disabled="!src" | ||
46 | + @click="handlerToolbar('rotate', -45)" | ||
47 | + /> | ||
48 | + </Tooltip> | ||
49 | + <Tooltip :title="t('component.cropper.btn_rotate_right')" placement="bottom"> | ||
50 | + <a-button | ||
51 | + type="primary" | ||
52 | + preIcon="ant-design:rotate-right-outlined" | ||
53 | + size="small" | ||
54 | + :disabled="!src" | ||
55 | + @click="handlerToolbar('rotate', 45)" | ||
56 | + /> | ||
57 | + </Tooltip> | ||
58 | + <Tooltip :title="t('component.cropper.btn_scale_x')" placement="bottom"> | ||
59 | + <a-button | ||
60 | + type="primary" | ||
61 | + preIcon="vaadin:arrows-long-h" | ||
62 | + size="small" | ||
63 | + :disabled="!src" | ||
64 | + @click="handlerToolbar('scaleX')" | ||
65 | + /> | ||
66 | + </Tooltip> | ||
67 | + <Tooltip :title="t('component.cropper.btn_scale_y')" placement="bottom"> | ||
68 | + <a-button | ||
69 | + type="primary" | ||
70 | + preIcon="vaadin:arrows-long-v" | ||
71 | + size="small" | ||
72 | + :disabled="!src" | ||
73 | + @click="handlerToolbar('scaleY')" | ||
74 | + /> | ||
75 | + </Tooltip> | ||
76 | + <Tooltip :title="t('component.cropper.btn_zoom_in')" placement="bottom"> | ||
77 | + <a-button | ||
78 | + type="primary" | ||
79 | + preIcon="ant-design:zoom-in-outlined" | ||
80 | + size="small" | ||
81 | + :disabled="!src" | ||
82 | + @click="handlerToolbar('zoom', 0.1)" | ||
83 | + /> | ||
84 | + </Tooltip> | ||
85 | + <Tooltip :title="t('component.cropper.btn_zoom_out')" placement="bottom"> | ||
86 | + <a-button | ||
87 | + type="primary" | ||
88 | + preIcon="ant-design:zoom-out-outlined" | ||
89 | + size="small" | ||
90 | + :disabled="!src" | ||
91 | + @click="handlerToolbar('zoom', -0.1)" | ||
92 | + /> | ||
93 | + </Tooltip> | ||
71 | </Space> | 94 | </Space> |
72 | </div> | 95 | </div> |
73 | </div> | 96 | </div> |
74 | <div :class="`${prefixCls}-right`"> | 97 | <div :class="`${prefixCls}-right`"> |
75 | <div :class="`${prefixCls}-preview`"> | 98 | <div :class="`${prefixCls}-preview`"> |
76 | - <img :src="previewSource" v-if="previewSource" /> | 99 | + <img :src="previewSource" v-if="previewSource" :alt="t('component.cropper.preview')" /> |
77 | </div> | 100 | </div> |
78 | <template v-if="previewSource"> | 101 | <template v-if="previewSource"> |
79 | <div :class="`${prefixCls}-group`"> | 102 | <div :class="`${prefixCls}-group`"> |
@@ -92,7 +115,7 @@ | @@ -92,7 +115,7 @@ | ||
92 | 115 | ||
93 | import { defineComponent, ref } from 'vue'; | 116 | import { defineComponent, ref } from 'vue'; |
94 | import CropperImage from './Cropper.vue'; | 117 | import CropperImage from './Cropper.vue'; |
95 | - import { Space, Upload, Avatar } from 'ant-design-vue'; | 118 | + import { Space, Upload, Avatar, Tooltip } from 'ant-design-vue'; |
96 | import { useDesign } from '/@/hooks/web/useDesign'; | 119 | import { useDesign } from '/@/hooks/web/useDesign'; |
97 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 120 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
98 | import { dataURLtoBlob } from '/@/utils/file/base64Conver'; | 121 | import { dataURLtoBlob } from '/@/utils/file/base64Conver'; |
@@ -102,13 +125,13 @@ | @@ -102,13 +125,13 @@ | ||
102 | const props = { | 125 | const props = { |
103 | circled: { type: Boolean, default: true }, | 126 | circled: { type: Boolean, default: true }, |
104 | uploadApi: { | 127 | uploadApi: { |
105 | - type: Function as PropType<({ file: Blob, name: stirng, filename: string }) => Promise<any>>, | 128 | + type: Function as PropType<({ file: Blob, name: string, filename: string }) => Promise<any>>, |
106 | }, | 129 | }, |
107 | }; | 130 | }; |
108 | 131 | ||
109 | export default defineComponent({ | 132 | export default defineComponent({ |
110 | name: 'CropperAvatar', | 133 | name: 'CropperAvatar', |
111 | - components: { BasicModal, Space, CropperImage, Upload, Avatar }, | 134 | + components: { BasicModal, Space, CropperImage, Upload, Avatar, Tooltip }, |
112 | props, | 135 | props, |
113 | emits: ['uploadSuccess', 'register'], | 136 | emits: ['uploadSuccess', 'register'], |
114 | setup(props, { emit }) { | 137 | setup(props, { emit }) { |
src/locales/lang/en/component.ts
@@ -13,6 +13,13 @@ export default { | @@ -13,6 +13,13 @@ export default { | ||
13 | uploadSuccess: 'Uploaded success!', | 13 | uploadSuccess: 'Uploaded success!', |
14 | modalTitle: 'Avatar upload', | 14 | modalTitle: 'Avatar upload', |
15 | okText: 'Confirm and upload', | 15 | okText: 'Confirm and upload', |
16 | + btn_reset: 'Reset', | ||
17 | + btn_rotate_left: 'Counterclockwise rotation', | ||
18 | + btn_rotate_right: 'Clockwise rotation', | ||
19 | + btn_scale_x: 'Flip horizontal', | ||
20 | + btn_scale_y: 'Flip vertical', | ||
21 | + btn_zoom_in: 'Zoom in', | ||
22 | + btn_zoom_out: 'Zoom out', | ||
16 | }, | 23 | }, |
17 | drawer: { | 24 | drawer: { |
18 | loadingText: 'Loading...', | 25 | loadingText: 'Loading...', |
src/locales/lang/zh_CN/component.ts
@@ -13,6 +13,13 @@ export default { | @@ -13,6 +13,13 @@ export default { | ||
13 | uploadSuccess: '上传成功', | 13 | uploadSuccess: '上传成功', |
14 | modalTitle: '头像上传', | 14 | modalTitle: '头像上传', |
15 | okText: '确认并上传', | 15 | okText: '确认并上传', |
16 | + btn_reset: '重置', | ||
17 | + btn_rotate_left: '逆时针旋转', | ||
18 | + btn_rotate_right: '顺时针旋转', | ||
19 | + btn_scale_x: '水平翻转', | ||
20 | + btn_scale_y: '垂直翻转', | ||
21 | + btn_zoom_in: '放大', | ||
22 | + btn_zoom_out: '缩小', | ||
16 | }, | 23 | }, |
17 | drawer: { | 24 | drawer: { |
18 | loadingText: '加载中...', | 25 | loadingText: '加载中...', |