feat:【ele】cropper todo 优化,对齐 antd
This commit is contained in:
@@ -6,6 +6,7 @@ import type { CropperAvatarProps } from './typing';
|
|||||||
import { computed, ref, unref, watch, watchEffect } from 'vue';
|
import { computed, ref, unref, watch, watchEffect } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
|
|
||||||
import { ElButton, ElMessage } from 'element-plus';
|
import { ElButton, ElMessage } from 'element-plus';
|
||||||
@@ -83,16 +84,16 @@ defineExpose({
|
|||||||
class="duration-400 absolute inset-0 flex cursor-pointer items-center justify-center rounded-full bg-black bg-opacity-40 opacity-0 transition-opacity group-hover:opacity-100"
|
class="duration-400 absolute inset-0 flex cursor-pointer items-center justify-center rounded-full bg-black bg-opacity-40 opacity-0 transition-opacity group-hover:opacity-100"
|
||||||
:style="getImageWrapperStyle"
|
:style="getImageWrapperStyle"
|
||||||
>
|
>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-avatar.vue 里的 Icon 么? -->
|
<IconifyIcon
|
||||||
<span
|
icon="lucide:cloud-upload"
|
||||||
|
class="m-auto text-gray-400"
|
||||||
:style="{
|
:style="{
|
||||||
...getImageWrapperStyle,
|
...getImageWrapperStyle,
|
||||||
width: getIconWidth,
|
width: getIconWidth,
|
||||||
height: getIconWidth,
|
height: getIconWidth,
|
||||||
lineHeight: getIconWidth,
|
lineHeight: getIconWidth,
|
||||||
}"
|
}"
|
||||||
class="icon-[ant-design--cloud-upload-outlined] text-gray-400"
|
/>
|
||||||
></span>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- 头像图片 -->
|
<!-- 头像图片 -->
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { CropendResult, CropperModalProps, CropperType } from './typing';
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
import { IconifyIcon } from '@vben/icons';
|
||||||
import { $t } from '@vben/locales';
|
import { $t } from '@vben/locales';
|
||||||
import { dataURLtoBlob, isFunction } from '@vben/utils';
|
import { dataURLtoBlob, isFunction } from '@vben/utils';
|
||||||
|
|
||||||
@@ -112,44 +113,19 @@ async function handleOk() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- TODO @puhui999:antd 版本里是 2/3 宽度,两边要对齐么? -->
|
|
||||||
<Modal
|
<Modal
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:confirm-text="$t('ui.cropper.okText')"
|
:confirm-text="$t('ui.cropper.okText')"
|
||||||
:fullscreen-button="false"
|
:fullscreen-button="false"
|
||||||
:title="$t('ui.cropper.modalTitle')"
|
:title="$t('ui.cropper.modalTitle')"
|
||||||
class="w-[800px]"
|
class="w-2/3"
|
||||||
>
|
>
|
||||||
<!-- TODO @puhui999:antd 版本有个 h-96,两边要对齐么? -->
|
<div class="flex h-96">
|
||||||
<div class="flex">
|
|
||||||
<!-- 左侧区域 -->
|
<!-- 左侧区域 -->
|
||||||
<!-- TODO @puhui999:antd 版本是 h-full w-3/5 两边要对齐么? -->
|
<div class="h-full w-3/5">
|
||||||
<div class="h-[340px] w-[55%]">
|
|
||||||
<!-- 裁剪器容器 -->
|
<!-- 裁剪器容器 -->
|
||||||
<!-- TODO @puhui999:antd class 简单一点,看看要不要对齐 -->
|
|
||||||
<div
|
<div
|
||||||
class="h-[300px] bg-[#eee]"
|
class="relative h-[300px] bg-gradient-to-b from-neutral-50 to-neutral-200"
|
||||||
style="
|
|
||||||
background-image:
|
|
||||||
linear-gradient(
|
|
||||||
45deg,
|
|
||||||
rgb(0 0 0 / 25%) 25%,
|
|
||||||
transparent 0,
|
|
||||||
transparent 75%,
|
|
||||||
rgb(0 0 0 / 25%) 0
|
|
||||||
),
|
|
||||||
linear-gradient(
|
|
||||||
45deg,
|
|
||||||
rgb(0 0 0 / 25%) 25%,
|
|
||||||
transparent 0,
|
|
||||||
transparent 75%,
|
|
||||||
rgb(0 0 0 / 25%) 0
|
|
||||||
);
|
|
||||||
background-position:
|
|
||||||
0 0,
|
|
||||||
12px 12px;
|
|
||||||
background-size: 24px 24px;
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<CropperImage
|
<CropperImage
|
||||||
v-if="src"
|
v-if="src"
|
||||||
@@ -162,8 +138,7 @@ async function handleOk() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 工具栏 -->
|
<!-- 工具栏 -->
|
||||||
<!-- TODO @puhui999:antd 是 mt-4,看看两边要不要对齐 -->
|
<div class="mt-4 flex items-center justify-between">
|
||||||
<div class="mt-2.5 flex items-center justify-between">
|
|
||||||
<ElUpload
|
<ElUpload
|
||||||
:before-upload="handleBeforeUpload"
|
:before-upload="handleBeforeUpload"
|
||||||
:file-list="[]"
|
:file-list="[]"
|
||||||
@@ -174,10 +149,9 @@ async function handleOk() {
|
|||||||
placement="bottom"
|
placement="bottom"
|
||||||
>
|
>
|
||||||
<ElButton size="small" type="primary">
|
<ElButton size="small" type="primary">
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span class="icon-[ant-design--upload-outlined]"></span>
|
<IconifyIcon icon="lucide:upload" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -192,9 +166,8 @@ async function handleOk() {
|
|||||||
@click="handlerToolbar('reset')"
|
@click="handlerToolbar('reset')"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span class="icon-[ant-design--reload-outlined]"></span>
|
<IconifyIcon icon="lucide:rotate-ccw" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -211,10 +184,7 @@ async function handleOk() {
|
|||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
<IconifyIcon icon="ant-design:rotate-left-outlined" />
|
||||||
<span
|
|
||||||
class="icon-[ant-design--rotate-left-outlined]"
|
|
||||||
></span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -230,11 +200,8 @@ async function handleOk() {
|
|||||||
@click="handlerToolbar('rotate', 45)"
|
@click="handlerToolbar('rotate', 45)"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span
|
<IconifyIcon icon="ant-design:rotate-right-outlined" />
|
||||||
class="icon-[ant-design--rotate-right-outlined]"
|
|
||||||
></span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -250,9 +217,8 @@ async function handleOk() {
|
|||||||
@click="handlerToolbar('scaleX')"
|
@click="handlerToolbar('scaleX')"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span class="icon-[vaadin--arrows-long-h]"></span>
|
<IconifyIcon icon="vaadin:arrows-long-h" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -268,9 +234,8 @@ async function handleOk() {
|
|||||||
@click="handlerToolbar('scaleY')"
|
@click="handlerToolbar('scaleY')"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span class="icon-[vaadin--arrows-long-v]"></span>
|
<IconifyIcon icon="vaadin:arrows-long-v" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -286,9 +251,8 @@ async function handleOk() {
|
|||||||
@click="handlerToolbar('zoom', 0.1)"
|
@click="handlerToolbar('zoom', 0.1)"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span class="icon-[ant-design--zoom-in-outlined]"></span>
|
<IconifyIcon icon="lucide:zoom-in" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -304,9 +268,8 @@ async function handleOk() {
|
|||||||
@click="handlerToolbar('zoom', -0.1)"
|
@click="handlerToolbar('zoom', -0.1)"
|
||||||
>
|
>
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<!-- TODO @puhui999:可以改成类似 /Users/yunai/Java/yudao-ui-admin-vben-v5/apps/web-antd/src/components/cropper/cropper-modal.vue 里的 Icon 么? -->
|
|
||||||
<div class="flex items-center justify-center">
|
<div class="flex items-center justify-center">
|
||||||
<span class="icon-[ant-design--zoom-out-outlined]"></span>
|
<IconifyIcon icon="lucide:zoom-out" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElButton>
|
</ElButton>
|
||||||
@@ -316,16 +279,16 @@ async function handleOk() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 右侧区域 -->
|
<!-- 右侧区域 -->
|
||||||
<div class="h-[340px] w-[45%]">
|
<div class="h-full w-2/5">
|
||||||
<!-- 预览区域 -->
|
<!-- 预览区域 -->
|
||||||
<div
|
<div
|
||||||
class="mx-auto h-[220px] w-[220px] overflow-hidden rounded-full border border-gray-200"
|
class="mx-auto h-56 w-56 overflow-hidden rounded-full border border-gray-200"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
v-if="previewSource"
|
v-if="previewSource"
|
||||||
:alt="$t('ui.cropper.preview')"
|
:alt="$t('ui.cropper.preview')"
|
||||||
:src="previewSource"
|
:src="previewSource"
|
||||||
class="h-full w-full"
|
class="h-full w-full object-cover"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<!-- 头像组合预览 -->
|
<!-- 头像组合预览 -->
|
||||||
|
|||||||
Reference in New Issue
Block a user