Skip to content

Commit

Permalink
Merge pull request #85 from visiky/fix/avatar
Browse files Browse the repository at this point in the history
fix: 修复avatar 上传设置头像问题 & 工作时间展示问题
  • Loading branch information
visiky committed Apr 26, 2023
2 parents f92c2b4 + 263b4eb commit 5e4da0a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 32 deletions.
7 changes: 7 additions & 0 deletions src/components/Avatar/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
display: block !important;
}
}

.avatar-upload-tip {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
}

@media print {
Expand Down
42 changes: 16 additions & 26 deletions src/components/Avatar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,25 @@ import React, { useState } from 'react';
import { Upload, Avatar as AntdAvatar } from 'antd';
import './index.less';

export const Avatar = ({ avatarSrc, className, shape = 'circle', size = 'default' }) => {
const [fileList, setFileList] = useState<any[]>([{ thumbUrl: avatarSrc }]);

const handleChange = ({ file: newFile, fileList: newFileList }) => {
if (newFile.status === 'error') {
console.error('upload avatar error:');
}
setFileList(newFileList);
};

export const Avatar = ({
avatarSrc,
className,
shape = 'circle',
size = 'default',
}) => {
return (
<div className={`avatar ${!fileList.length ? 'avatar-hidden' : ''}`}>
{fileList.length > 0 && (
<div className={`avatar ${!avatarSrc ? 'avatar-hidden' : ''}`}>
{avatarSrc ? (
// @ts-ignore
<AntdAvatar className={className} src={fileList[0]?.thumbUrl} shape={shape} size={size} />
<AntdAvatar
className={className}
src={avatarSrc}
shape={shape as any}
size={size as any}
/>
) : (
<span className="avatar-upload-tip">头像地址为空</span>
)}
<Upload
listType="picture-card"
fileList={fileList}
onChange={handleChange}
className={'btn-upload'}
style={{ display: fileList.length > 0 ? 'none' : 'block' }}
>
{fileList.length <= 0 && (
<div style={{ color: 'rgba(0, 0, 0, 0.45)' }}>
<div className="ant-upload-text">Upload</div>
</div>
)}
</Upload>
</div>
);
};
6 changes: 4 additions & 2 deletions src/components/Resume/Template1/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,10 @@ export const Template1: React.FC<Props> = props => {
})(
<div className="section section-work-exp">
{_.map(workExpList, (work, idx) => {
const start = work.work_time[0];
const end = work.work_time[1] ? work.work_time[1] : null;
const [start = null, end = null] =
typeof work.work_time === 'string'
? `${work.work_time || ''}`.split(',')
: work.work_time;
return work ? (
<div className="section-item" key={idx.toString()}>
<div className="section-info">
Expand Down
6 changes: 4 additions & 2 deletions src/components/Resume/Template2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,10 @@ export const Template2: React.FC<Props> = props => {
>
<div className="section section-work-exp">
{_.map(workExpList, (work, idx) => {
const start = work.work_time[0];
const end = work.work_time[1] ? work.work_time[1] : null;
const [start = null, end = null] =
typeof work.work_time === 'string'
? `${work.work_time || ''}`.split(',')
: work.work_time;
return work ? (
<div className="section-item" key={idx.toString()}>
<div className="section-info">
Expand Down
6 changes: 4 additions & 2 deletions src/components/Resume/Template3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,10 @@ export const Template3: React.FC<Props> = props => {
})(
<div className="section section-work-exp">
{_.map(workExpList, (work, idx) => {
const start = work.work_time[0];
const end = work.work_time[1] ? work.work_time[1] : null;
const [start = null, end = null] =
typeof work.work_time === 'string'
? `${work.work_time || ''}`.split(',')
: work.work_time;
return work ? (
<div className="section-item" key={idx.toString()}>
<div className="section-info">
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/contant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ export const CONTENT_OF_MODULE = ({ intl }) => {
checked: false,
},
},
{
type: 'input',
attributeId: 'src',
displayName: i18n.get('头像地址'),
cfg: {
placeholder: 'https://xxx.png',
},
},
{
type: 'select',
attributeId: 'shape',
Expand Down

0 comments on commit 5e4da0a

Please sign in to comment.