feat: add user avatar

This commit is contained in:
jialin
2025-08-14 16:39:25 +08:00
parent d6dce4021d
commit 5bd5c7d2c5
12 changed files with 149 additions and 16 deletions
+47 -3
View File
@@ -1,8 +1,8 @@
@font-face {
font-family: iconfont; /* Project id 4613488 */
src: url('iconfont.woff2?t=1752112673765') format('woff2'),
url('iconfont.woff?t=1752112673765') format('woff'),
url('iconfont.ttf?t=1752112673765') format('truetype');
src: url('iconfont.woff2?t=1755160439217') format('woff2'),
url('iconfont.woff?t=1755160439217') format('woff'),
url('iconfont.ttf?t=1755160439217') format('truetype');
}
.iconfont {
@@ -13,6 +13,50 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-admin-user::before {
content: "\e69d";
}
.icon-user::before {
content: "\e69e";
}
.icon-quick_reference_24dp_1F1F1F_FILL0_wght300_GRAD0_op::before {
content: "\e69b";
}
.icon-docker::before {
content: "\e69c";
}
.icon-digitalocean::before {
content: "\eb79";
}
.icon-rocket-launch1::before {
content: "\e699";
}
.icon-rocket-launch-fill::before {
content: "\e69a";
}
.icon-credential-filled::before {
content: "\e697";
}
.icon-credential-outline::before {
content: "\e698";
}
.icon-k8s-filled::before {
content: "\e63e";
}
.icon-k8s-outline::before {
content: "\e64b";
}
.icon-huggingface1::before {
content: "\e605";
}
File diff suppressed because one or more lines are too long
@@ -5,6 +5,83 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "45240470",
"name": "admin-user",
"font_class": "admin-user",
"unicode": "e69d",
"unicode_decimal": 59037
},
{
"icon_id": "45240469",
"name": "user",
"font_class": "user",
"unicode": "e69e",
"unicode_decimal": 59038
},
{
"icon_id": "45221182",
"name": "quick_reference_24dp_1F1F1F_FILL0_wght300_GRAD0_op",
"font_class": "quick_reference_24dp_1F1F1F_FILL0_wght300_GRAD0_op",
"unicode": "e69b",
"unicode_decimal": 59035
},
{
"icon_id": "45102077",
"name": "Docker",
"font_class": "docker",
"unicode": "e69c",
"unicode_decimal": 59036
},
{
"icon_id": "15378290",
"name": "digitalocean",
"font_class": "digitalocean",
"unicode": "eb79",
"unicode_decimal": 60281
},
{
"icon_id": "45040302",
"name": "rocket-launch",
"font_class": "rocket-launch1",
"unicode": "e699",
"unicode_decimal": 59033
},
{
"icon_id": "45040301",
"name": "rocket-launch-fill",
"font_class": "rocket-launch-fill",
"unicode": "e69a",
"unicode_decimal": 59034
},
{
"icon_id": "45028316",
"name": "credential",
"font_class": "credential-filled",
"unicode": "e697",
"unicode_decimal": 59031
},
{
"icon_id": "45028315",
"name": "credential",
"font_class": "credential-outline",
"unicode": "e698",
"unicode_decimal": 59032
},
{
"icon_id": "37601405",
"name": "k8s",
"font_class": "k8s-filled",
"unicode": "e63e",
"unicode_decimal": 58942
},
{
"icon_id": "41673174",
"name": "k8s",
"font_class": "k8s-outline",
"unicode": "e64b",
"unicode_decimal": 58955
},
{
"icon_id": "40865292",
"name": "huggingface",
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -21,6 +21,7 @@ declare namespace Global {
require_password_change: boolean;
id: number;
source: string;
avatar_url?: string;
}
interface BaseListItem<T> {
+1
View File
@@ -267,6 +267,7 @@ export const getRightRenderContent = (opts: {
<span className="avatar-container">
<Avatar
size={28}
src={opts.initialState?.currentUser?.avatar_url}
style={{
color: 'var(--ant-color-text)',
fontSize: 16
+3 -3
View File
@@ -192,7 +192,7 @@ const LoginForm = () => {
<ButtonText>
{intl.formatMessage(
{ id: 'common.external.login' },
{ type: 'OIDC' }
{ type: 'SSO' }
)}
</ButtonText>
</ButtonWrapper>
@@ -202,7 +202,7 @@ const LoginForm = () => {
<ButtonText>
{intl.formatMessage(
{ id: 'common.external.login' },
{ type: 'SAML' }
{ type: 'SSO' }
)}
</ButtonText>
</ButtonWrapper>
@@ -239,7 +239,7 @@ const LoginForm = () => {
<BackButton onClick={handleLoginWithThirdParty}>
{intl.formatMessage(
{ id: 'common.external.login' },
{ type: SSOAuth.options.oidc ? 'OIDC' : 'SAML' }
{ type: 'SSO' }
)}
</BackButton>
)}
+2
View File
@@ -3,6 +3,8 @@ export interface ListItem {
is_admin: boolean;
full_name: string;
id: number;
source: string;
avatar_url: string;
username: string;
created_at: string;
updated_at: string;
+16 -8
View File
@@ -1,6 +1,7 @@
import AutoTooltip from '@/components/auto-tooltip';
import DeleteModal from '@/components/delete-modal';
import DropdownButtons from '@/components/drop-down-buttons';
import IconFont from '@/components/icon-font';
import PageTools from '@/components/page-tools';
import { PageAction } from '@/config';
import HotKeys from '@/config/hotkeys';
@@ -10,13 +11,12 @@ import {
DeleteOutlined,
EditOutlined,
PlusOutlined,
SyncOutlined,
UserOutlined,
UserSwitchOutlined
SyncOutlined
} from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components';
import { useIntl } from '@umijs/max';
import {
Avatar,
Button,
ConfigProvider,
Empty,
@@ -231,9 +231,14 @@ const Users: React.FC = () => {
}}
render={(text, record) => {
return (
<AutoTooltip ghost minWidth={20}>
{text}
</AutoTooltip>
<span className="flex flex-center gap-8">
{record.avatar_url && (
<Avatar src={record.avatar_url} alt={text} size="small" />
)}
<AutoTooltip ghost minWidth={20}>
{text}
</AutoTooltip>
</span>
);
}}
/>
@@ -247,14 +252,17 @@ const Users: React.FC = () => {
render={(text, record: ListItem) => {
return record.is_admin ? (
<AutoTooltip ghost minWidth={50}>
<UserSwitchOutlined className="size-16" />
<IconFont
type="icon-admin-user"
className="size-16"
></IconFont>
<span className="m-l-5">
{intl.formatMessage({ id: 'users.form.admin' })}
</span>
</AutoTooltip>
) : (
<AutoTooltip ghost minWidth={50}>
<UserOutlined className="size-16" />
<IconFont type="icon-user" className="size-16"></IconFont>
<span className="m-l-5">
{intl.formatMessage({ id: 'users.form.user' })}
</span>
+1 -1
View File
@@ -1,7 +1,7 @@
import { request } from '@umijs/max';
export async function queryCurrentUserState(opts?: Record<string, any>) {
return request(`/users/me`, {
return request<Global.UserInfo>(`/users/me`, {
method: 'GET',
...opts
});