Skip to content

Commit 30a5157

Browse files
committed
feat: avater
1 parent deeb4a9 commit 30a5157

File tree

11 files changed

+53
-24
lines changed

11 files changed

+53
-24
lines changed

src/api/caravan/Login.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,13 @@ export const updateUserAvatarUrl = payload => {
104104
export const findAccountLogs = (payload: any) => {
105105
return request(`${BASE_URL}Accountlog/findAccountLogs`, "GET", payload);
106106
};
107+
108+
/**
109+
* 使用免费图床
110+
* */
111+
export const saveUserAvatarUrl = payload => {
112+
return request(`https://freeimg.cn/api/v1/upload`, "POST", payload, {
113+
processData: false,
114+
"Content-Type":"multipart/form-data"
115+
});
116+
};

src/assets/login/1login.jpg

71.6 KB
Loading

src/assets/login/login.jpg

-534 KB
Loading

src/components/Footer/LoginCopyright/index.module.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
right: 0;
55
height: 20px;
66
padding-right: 12px;
7+
a{
8+
color: #000;
9+
}
710
}

src/components/Forms/LoginForm/index.module.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
left: 50%;
88
margin-top: -183px;
99
margin-left: -162px;
10-
background: #fff;
10+
background: rgba(164,203,200,.3);
11+
&:hover{
12+
box-shadow: -4px 4px 16px 1px rgba(0, 0, 0, 0.15);
13+
background: rgba(164,203,200,1);
14+
transition: box-shadow 1s,background 1s, transform 2s;
15+
}
1116
}
1217

1318
.title {

src/components/Modals/UserEditModal/index.tsx

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { UserOutlined } from "@ant-design/icons";
22
import { Avatar, Col, Form, Input, message, Modal, Radio, Row, Upload } from "antd";
33
import type { FC } from "react";
44
import React, { useEffect, useState } from "react";
5-
import { addOneUser, editOneUser, updateUserAvatarUrl } from "@/api/caravan/Login";
5+
import { addOneUser, editOneUser, saveUserAvatarUrl, updateUserAvatarUrl } from "@/api/caravan/Login";
66
import { trim } from "lodash";
77

88
import styles from "./index.module.scss";
9+
import axios from "axios";
910

1011
const layout = {
1112
labelCol: { span: 8 },
@@ -28,7 +29,7 @@ const UserEditModal: FC<any> = (props: any) => {
2829
reader.addEventListener("load", () => callback(reader.result));
2930
reader.readAsDataURL(img);
3031
};
31-
const handleUpload = (uid: string) => {
32+
const handleUpload = async (uid: string) => {
3233
if (fileList.length <= 0 || !uid) {
3334
return;
3435
}
@@ -41,19 +42,28 @@ const UserEditModal: FC<any> = (props: any) => {
4142
}
4243
formData.append("userUid", uid);
4344
setuploading(true);
44-
updateUserAvatarUrl(formData)
45-
.then(result => {
46-
setAvatarUrl("");
47-
if (result.data.code === 200) {
48-
message.info("头像修改成功");
49-
return;
50-
}
51-
message.info("头像修改失败");
52-
})
53-
.catch(() => {
54-
setAvatarUrl("");
55-
message.info("头像修改失败");
56-
});
45+
const avatar = await axios.post('https://freeimg.cn/api/v1/upload',{
46+
file:fileList[0],
47+
album_id:145
48+
},{
49+
headers:{
50+
"Authorization": "Bearer 134|dfgG6kRMsd3SP6E0ZJvieEq98mOOhdaATYQRZruZ",
51+
"Content-Type": "multipart/form-data"
52+
}
53+
}).then(result => {
54+
setAvatarUrl("");
55+
message.info(`头像上传${result?.data?.status?"成功":"失败"}`);
56+
return result?.data?.data?.links?.url;
57+
})
58+
.catch(() => {
59+
setAvatarUrl("");
60+
message.info("头像修改失败");
61+
return ''
62+
});
63+
updateUserAvatarUrl({
64+
uid,
65+
avatar
66+
}).finally(()=>onOk(true))
5767
};
5868

5969
const UpLoadProps = {
@@ -101,7 +111,6 @@ const UserEditModal: FC<any> = (props: any) => {
101111
message.info("操作成功");
102112
setuploading(false);
103113
handleUpload(initUser.uid || result.data.data.uid);
104-
onOk(true);
105114
};
106115

107116
const setInputType = () => {

src/components/Tables/LoginLog/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const LoginLog = () => {
1515
dataIndex: "bowser"
1616
},
1717
{
18-
title: "IP地址",
19-
dataIndex: "ip"
18+
title: "来源",
19+
dataIndex: "host"
2020
},
2121
{
2222
title: "登录设备",

src/pages/Login/index.module.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$base-url: "@/assets/login/login.jpg";
1+
// $base-url: "@/assets/login/login.jpg";
2+
// 134|dfgG6kRMsd3SP6E0ZJvieEq98mOOhdaATYQRZruZ
3+
$base-url:'https://www.freeimg.cn/i/2024/01/13/65a28bad6be9e.jpg';
24
.container {
35
width: 100vw;
46
height: 100vh;

src/pages/RoleAdmin/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const RoleList: FC = () => {
3737
findalluser({})
3838
.then(res => setUserDatasource(res.data.data || []))
3939
.catch(() => setUserDatasource([]));
40-
findAllMenu({ isdeleted: 0 })
40+
findAllMenu({ isdeleted: 0, version: 2 })
4141
.then((res: any) => setMenuDataSource(res.data.data || []))
4242
.catch(() => setMenuDataSource([]));
4343
}, []);

src/pages/WsOnlineList/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const WsOnlineList: React.FC = () => {
5959
renderItem={(item: any) => (
6060
<List.Item>
6161
<List.Item.Meta title={<b>{item.name}</b>} description={webSocketManager.MySocketID === item.id ? "当前用户" : item.id} />
62-
<div className="listinfo">
62+
{webSocketManager.MySocketID === item.id ?null:<div className="listinfo">
6363
<Button
6464
danger
6565
type="primary"
@@ -69,7 +69,7 @@ const WsOnlineList: React.FC = () => {
6969
>
7070
强制下线
7171
</Button>
72-
</div>
72+
</div>}
7373
</List.Item>
7474
)}
7575
/>

0 commit comments

Comments
 (0)