feat: add message count

pull/90/head
moonrailgun 2 years ago
parent 54a73403d7
commit db52b3d5d5

@ -1,4 +1,4 @@
import { IconFile, IconUser, IconUserGroup } from 'tushan/icon'; import { IconFile, IconMessage, IconUser, IconUserGroup } from 'tushan/icon';
import React from 'react'; import React from 'react';
import { import {
XAxis, XAxis,
@ -30,16 +30,6 @@ export const Dashboard: React.FC = React.memo(() => {
const { userIdentity } = useUserStore(createSelector('userIdentity')); const { userIdentity } = useUserStore(createSelector('userIdentity'));
const { t } = useTranslation(); const { t } = useTranslation();
const { total: usersNum } = useGetList('users', {
pagination: { page: 1, perPage: 1 },
});
const { total: groupNum } = useGetList('groups', {
pagination: { page: 1, perPage: 1 },
});
const { total: fileNum } = useGetList('file', {
pagination: { page: 1, perPage: 1 },
});
return ( return (
<div> <div>
<div> <div>
@ -53,35 +43,7 @@ export const Dashboard: React.FC = React.memo(() => {
<Divider /> <Divider />
<Grid.Row justify="center"> <DashboardSummary />
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconUser />}
title={t('tushan.dashboard.user')}
count={usersNum}
/>
</Grid.Col>
<Divider type="vertical" style={{ height: 40 }} />
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconUserGroup />}
title={t('tushan.dashboard.group')}
count={groupNum}
/>
</Grid.Col>
<Divider type="vertical" style={{ height: 40 }} />
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconFile />}
title={t('custom.dashboard.file')}
count={fileNum}
/>
</Grid.Col>
</Grid.Row>
<Divider /> <Divider />
@ -128,6 +90,66 @@ export const Dashboard: React.FC = React.memo(() => {
}); });
Dashboard.displayName = 'Dashboard'; Dashboard.displayName = 'Dashboard';
const DashboardSummary: React.FC = React.memo(() => {
const { t } = useTranslation();
const { total: usersNum } = useGetList('users', {
pagination: { page: 1, perPage: 1 },
});
const { total: groupNum } = useGetList('groups', {
pagination: { page: 1, perPage: 1 },
});
const { total: fileNum } = useGetList('file', {
pagination: { page: 1, perPage: 1 },
});
const { total: messagesNum } = useGetList('messages', {
pagination: { page: 1, perPage: 1 },
});
return (
<Grid.Row justify="center">
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconUser />}
title={t('tushan.dashboard.user')}
count={usersNum}
/>
</Grid.Col>
<Divider type="vertical" style={{ height: 40 }} />
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconUserGroup />}
title={t('tushan.dashboard.group')}
count={groupNum}
/>
</Grid.Col>
<Divider type="vertical" style={{ height: 40 }} />
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconFile />}
title={t('custom.dashboard.file')}
count={fileNum}
/>
</Grid.Col>
<Divider type="vertical" style={{ height: 40 }} />
<Grid.Col flex={1} style={{ paddingLeft: '1rem' }}>
<DataItem
icon={<IconMessage />}
title={t('custom.dashboard.messages')}
count={messagesNum}
/>
</Grid.Col>
</Grid.Row>
);
});
DashboardSummary.displayName = 'DashboardSummary';
const DashboardItem: React.FC< const DashboardItem: React.FC<
React.PropsWithChildren<{ React.PropsWithChildren<{
title: string; title: string;

@ -15,6 +15,7 @@ export const i18n: TushanContextProps['i18n'] = {
}, },
dashboard: { dashboard: {
file: 'File', file: 'File',
messages: 'Messages',
newUserCount: 'New User Count', newUserCount: 'New User Count',
messageCount: 'Message Count', messageCount: 'Message Count',
tip: { tip: {
@ -138,6 +139,7 @@ export const i18n: TushanContextProps['i18n'] = {
}, },
dashboard: { dashboard: {
file: '文件', file: '文件',
messages: '消息数',
newUserCount: '用户新增', newUserCount: '用户新增',
messageCount: '消息数', messageCount: '消息数',
tip: { tip: {

Loading…
Cancel
Save