feat: #62 add title section in website

This commit is contained in:
moonrailgun 2024-05-08 00:26:04 +08:00
parent ab03eddfa1
commit d5895dc4a9
4 changed files with 28 additions and 11 deletions

View File

@ -16,6 +16,7 @@ interface MetricsTableProps {
| 'url'
| 'language'
| 'referrer'
| 'title'
| 'browser'
| 'os'
| 'device'

View File

@ -128,7 +128,16 @@ function WebsiteDetailComponent() {
endAt={endAt}
/>
</Card.Grid>
<Card.Grid hoverable={false} className="min-h-[470px] !w-1/2">
<Card.Grid hoverable={false} className="min-h-[470px] !w-1/3">
<WebsiteMetricsTable
websiteId={websiteId}
type="title"
title={[t('Title'), t('Views')]}
startAt={startAt}
endAt={endAt}
/>
</Card.Grid>
<Card.Grid hoverable={false} className="min-h-[470px] !w-1/3">
<WebsiteMetricsTable
websiteId={websiteId}
type="country"
@ -141,7 +150,7 @@ function WebsiteDetailComponent() {
<WebsiteVisitorMapBtn websiteId={websiteId} />
</div>
</Card.Grid>
<Card.Grid hoverable={false} className="min-h-[470px] !w-1/2">
<Card.Grid hoverable={false} className="min-h-[470px] !w-1/3">
<WebsiteMetricsTable
websiteId={websiteId}
type="event"

View File

@ -36,6 +36,9 @@ export default defineConfig({
'/api/workspace': {
target: 'http://localhost:12345',
},
'/api/website/send': {
target: 'http://localhost:12345',
},
},
},
});

View File

@ -184,7 +184,8 @@ export const websiteRouter = router({
}),
]);
const stats = Object.keys(metrics[0]).reduce((obj, key) => {
const stats = Object.keys(metrics[0]).reduce(
(obj, key) => {
const current = Number(metrics[0][key]) || 0;
const prev = Number(prevPeriod[0][key]) || 0;
obj[key] = {
@ -192,7 +193,9 @@ export const websiteRouter = router({
prev,
};
return obj;
}, {} as Record<string, { value: number; prev: number }>);
},
{} as Record<string, { value: number; prev: number }>
);
return websiteStatsSchema.parse(stats);
}),
@ -330,6 +333,7 @@ export const websiteRouter = router({
'url',
'language',
'referrer',
'title',
'browser',
'os',
'device',