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' | 'url'
| 'language' | 'language'
| 'referrer' | 'referrer'
| 'title'
| 'browser' | 'browser'
| 'os' | 'os'
| 'device' | 'device'

View File

@ -128,7 +128,16 @@ function WebsiteDetailComponent() {
endAt={endAt} endAt={endAt}
/> />
</Card.Grid> </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 <WebsiteMetricsTable
websiteId={websiteId} websiteId={websiteId}
type="country" type="country"
@ -141,7 +150,7 @@ function WebsiteDetailComponent() {
<WebsiteVisitorMapBtn websiteId={websiteId} /> <WebsiteVisitorMapBtn websiteId={websiteId} />
</div> </div>
</Card.Grid> </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 <WebsiteMetricsTable
websiteId={websiteId} websiteId={websiteId}
type="event" type="event"

View File

@ -36,6 +36,9 @@ export default defineConfig({
'/api/workspace': { '/api/workspace': {
target: 'http://localhost:12345', 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 current = Number(metrics[0][key]) || 0;
const prev = Number(prevPeriod[0][key]) || 0; const prev = Number(prevPeriod[0][key]) || 0;
obj[key] = { obj[key] = {
@ -192,7 +193,9 @@ export const websiteRouter = router({
prev, prev,
}; };
return obj; return obj;
}, {} as Record<string, { value: number; prev: number }>); },
{} as Record<string, { value: number; prev: number }>
);
return websiteStatsSchema.parse(stats); return websiteStatsSchema.parse(stats);
}), }),
@ -330,6 +333,7 @@ export const websiteRouter = router({
'url', 'url',
'language', 'language',
'referrer', 'referrer',
'title',
'browser', 'browser',
'os', 'os',
'device', 'device',