parent
a15d777afb
commit
bdaeb75ccc
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="user-info-head" @click="open()">
|
<div class="user-info-head" @click="open()">
|
||||||
<img :src="sourceValue" class="img-circle img-lg" />
|
<img v-if="sourceValue" :src="sourceValue" alt="avatar" class="img-circle img-lg" />
|
||||||
|
<img v-if="!sourceValue" :src="avatar" alt="avatar" class="img-circle img-lg" />
|
||||||
<el-button v-if="showBtn" :class="`${prefixCls}-upload-btn`" @click="open()">
|
<el-button v-if="showBtn" :class="`${prefixCls}-upload-btn`" @click="open()">
|
||||||
{{ btnText ? btnText : t('cropper.selectImage') }}
|
{{ btnText ? btnText : t('cropper.selectImage') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -17,6 +18,7 @@ import { useDesign } from '@/hooks/web/useDesign'
|
|||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import CopperModal from './CopperModal.vue'
|
import CopperModal from './CopperModal.vue'
|
||||||
|
import avatar from '@/assets/imgs/avatar.jpg'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
width: propTypes.string.def('200px'),
|
width: propTypes.string.def('200px'),
|
||||||
@ -83,14 +85,14 @@ $prefix-cls: #{$namespace}--cropper-avatar;
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-image-mask {
|
&-image-mask {
|
||||||
opacity: 0%;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: inherit;
|
width: inherit;
|
||||||
height: inherit;
|
height: inherit;
|
||||||
border-radius: inherit;
|
|
||||||
border: inherit;
|
|
||||||
background: rgb(0 0 0 / 40%);
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
background: rgb(0 0 0 / 40%);
|
||||||
|
border: inherit;
|
||||||
|
border-radius: inherit;
|
||||||
|
opacity: 0;
|
||||||
transition: opacity 0.4s;
|
transition: opacity 0.4s;
|
||||||
|
|
||||||
::v-deep(svg) {
|
::v-deep(svg) {
|
||||||
@ -99,7 +101,7 @@ $prefix-cls: #{$namespace}--cropper-avatar;
|
|||||||
}
|
}
|
||||||
|
|
||||||
&-image-mask:hover {
|
&-image-mask:hover {
|
||||||
opacity: 4000%;
|
opacity: 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-upload-btn {
|
&-upload-btn {
|
||||||
@ -121,21 +123,18 @@ $prefix-cls: #{$namespace}--cropper-avatar;
|
|||||||
height: 120px;
|
height: 120px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-info-head:hover:after {
|
.user-info-head:hover::after {
|
||||||
content: '+';
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
inset: 0;
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
color: #eee;
|
|
||||||
background: rgba(0, 0, 0, 0.5);
|
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-style: normal;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
cursor: pointer;
|
font-style: normal;
|
||||||
line-height: 110px;
|
line-height: 110px;
|
||||||
|
color: #eee;
|
||||||
|
cursor: pointer;
|
||||||
|
background: rgb(0 0 0 / 50%);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
content: '+';
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
ref="cropperRef"
|
ref="cropperRef"
|
||||||
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
|
:btnProps="{ preIcon: 'ant-design:cloud-upload-outlined' }"
|
||||||
:showBtn="false"
|
:showBtn="false"
|
||||||
:value="avatar"
|
:value="img"
|
||||||
width="120px"
|
width="120px"
|
||||||
@change="handelUpload"
|
@change="handelUpload"
|
||||||
/>
|
/>
|
||||||
@ -14,12 +14,11 @@
|
|||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { uploadAvatarApi } from '@/api/system/user/profile'
|
import { uploadAvatarApi } from '@/api/system/user/profile'
|
||||||
|
|
||||||
const props = defineProps({
|
defineOptions({ name: 'UserAvatar' })
|
||||||
|
|
||||||
|
defineProps({
|
||||||
img: propTypes.string.def('')
|
img: propTypes.string.def('')
|
||||||
})
|
})
|
||||||
const avatar = computed(() => {
|
|
||||||
return props.img
|
|
||||||
})
|
|
||||||
|
|
||||||
const cropperRef = ref()
|
const cropperRef = ref()
|
||||||
const handelUpload = async ({ data }) => {
|
const handelUpload = async ({ data }) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user