Commit 2106012f authored by 张烨's avatar 张烨

style: 优化样式

parent 96d89c11
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
.avatarUploader { .avatarUploader {
display: inline-block; display: inline-block;
text-align: left; text-align: left;
.ant-upload-list-item-thumbnail>img{
background: #aaa;
background-image: linear-gradient(white 0px, transparent 0), linear-gradient(hsla(0,0%,100%,.3) 1px, transparent 0), linear-gradient(90deg, hsla(0,0%,100%,.3) 1px, transparent 0);
background-size: 75px 75px, 75px 75px, 15px 15px, 15px 15px;
}
} }
.wallBtn { .wallBtn {
...@@ -23,6 +28,12 @@ ...@@ -23,6 +28,12 @@
border-bottom: 1px solid #2f54eb; border-bottom: 1px solid #2f54eb;
} }
.svgBg{
background: #aaa;
background-image: linear-gradient(white 0px, transparent 0), linear-gradient(hsla(0,0%,100%,.3) 1px, transparent 0), linear-gradient(90deg, hsla(0,0%,100%,.3) 1px, transparent 0);
background-size: 75px 75px, 75px 75px, 15px 15px, 15px 15px;
}
.imgBox { .imgBox {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
......
...@@ -85,6 +85,7 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -85,6 +85,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
}; };
handleModalOk = () => { handleModalOk = () => {
const { maxLen = 1 } = this.props;
const fileList = [ const fileList = [
{ {
uid: uuid(8, 16), uid: uuid(8, 16),
...@@ -93,11 +94,12 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -93,11 +94,12 @@ class PicturesWall extends React.Component<PicturesWallType> {
url: this.state.curSelectedImg, url: this.state.curSelectedImg,
}, },
]; ];
this.props.onChange && this.props.onChange(this.props.maxLen === 1 ? fileList[0].url : fileList.map(f => f.url)); this.props.onChange && this.props.onChange( maxLen === 1 ? fileList[0].url : fileList.map(f => f.url));
this.setState({ fileList, wallModalVisible: false }); this.setState({ fileList, wallModalVisible: false });
}; };
handleChange = ({ file, fileList }: UploadChangeParam<UploadFile<any>>) => { handleChange = ({ file, fileList }: UploadChangeParam<UploadFile<any>>) => {
const { maxLen = 1 } = this.props;
this.setState({ fileList }); this.setState({ fileList });
if (file.status === 'done') { if (file.status === 'done') {
const files = fileList.map(item => { const files = fileList.map(item => {
...@@ -105,7 +107,7 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -105,7 +107,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
const url = thumbUrl || this.getImageUrl(data); const url = thumbUrl || this.getImageUrl(data);
return { uid: uuid(8, 16), name, status, url }; return { uid: uuid(8, 16), name, status, url };
}); });
this.props.onChange && this.props.onChange( this.props.maxLen === 1 ? files[0].url : files.map(f => f.url)); this.props.onChange && this.props.onChange( maxLen === 1 ? files[0].url : files.map(f => f.url));
} }
}; };
...@@ -178,7 +180,7 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -178,7 +180,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
aspect={cropRate as number} aspect={cropRate as number}
> >
<Upload <Upload
fileList={fileList} fileList={fileList.map(f => ({...f, url: this.getImageUrl(f.url) }))}
onPreview={this.handlePreview} onPreview={this.handlePreview}
onChange={this.handleChange} onChange={this.handleChange}
name="singleFile" name="singleFile"
...@@ -187,8 +189,8 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -187,8 +189,8 @@ class PicturesWall extends React.Component<PicturesWallType> {
action={action} action={action}
withCredentials={withCredentials} withCredentials={withCredentials}
headers={{ headers={{
'x-requested-with': localStorage.getItem('user') || '', // 'x-requested-with': localStorage.getItem('user') || '',
token: localStorage.getItem('token') || '', Authorization: 'Bearer ' + localStorage.getItem('token') || '',
...headers, ...headers,
}} }}
beforeUpload={this.handleBeforeUpload} beforeUpload={this.handleBeforeUpload}
...@@ -198,7 +200,7 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -198,7 +200,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
</ImgCrop> </ImgCrop>
) : ( ) : (
<Upload <Upload
fileList={fileList} fileList={fileList.map(f => ({...f, url: this.getImageUrl(f.url) }))}
onPreview={this.handlePreview} onPreview={this.handlePreview}
onChange={this.handleChange} onChange={this.handleChange}
name="singleFile" name="singleFile"
...@@ -207,8 +209,8 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -207,8 +209,8 @@ class PicturesWall extends React.Component<PicturesWallType> {
action={action} action={action}
withCredentials={withCredentials} withCredentials={withCredentials}
headers={{ headers={{
'x-requested-with': localStorage.getItem('user') || '', // 'x-requested-with': localStorage.getItem('user') || '',
token: localStorage.getItem('token') || '', Authorization: 'Bearer ' + localStorage.getItem('token') || '',
...headers, ...headers,
}} }}
beforeUpload={this.handleBeforeUpload} beforeUpload={this.handleBeforeUpload}
...@@ -225,7 +227,7 @@ class PicturesWall extends React.Component<PicturesWallType> { ...@@ -225,7 +227,7 @@ class PicturesWall extends React.Component<PicturesWallType> {
footer={null} footer={null}
onCancel={this.handleCancel} onCancel={this.handleCancel}
> >
<img alt="预览图片" style={{ width: '100%' }} src={this.getImageUrl(previewImage)} /> <img alt="预览图片" className={styles.svgBg} style={{ width: '100%' }} src={this.getImageUrl(previewImage)} />
</Modal> </Modal>
<Modal <Modal
visible={wallModalVisible} visible={wallModalVisible}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment