diff --git a/cwd-admin/src/api/admin.ts b/cwd-admin/src/api/admin.ts index 247844e..86b8234 100644 --- a/cwd-admin/src/api/admin.ts +++ b/cwd-admin/src/api/admin.ts @@ -83,6 +83,23 @@ export type CommentStatsResponse = { }[]; }; +export type VisitOverviewResponse = { + totalPv: number; + totalPages: number; +}; + +export type VisitPageItem = { + postSlug: string; + postTitle: string | null; + postUrl: string | null; + pv: number; + lastVisitAt: string | null; +}; + +export type VisitPagesResponse = { + items: VisitPageItem[]; +}; + export async function loginAdmin(name: string, password: string): Promise { const res = await post('/admin/login', { name, password }); const key = res.data.key; @@ -212,3 +229,11 @@ export function importComments(data: any[]): Promise<{ message: string }> { export function fetchCommentStats(): Promise { return get('/admin/stats/comments'); } + +export function fetchVisitOverview(): Promise { + return get('/admin/analytics/overview'); +} + +export function fetchVisitPages(): Promise { + return get('/admin/analytics/pages'); +} diff --git a/cwd-admin/src/router/index.ts b/cwd-admin/src/router/index.ts index 52dc22e..155a8d1 100644 --- a/cwd-admin/src/router/index.ts +++ b/cwd-admin/src/router/index.ts @@ -5,6 +5,7 @@ import CommentsView from '../views/CommentsView.vue'; import SettingsView from '../views/SettingsView.vue'; import DataView from '../views/DataView.vue'; import StatsView from '../views/StatsView.vue'; +import AnalyticsVisitView from '../views/AnalyticsVisitView.vue'; const routes: RouteRecordRaw[] = [ { @@ -30,6 +31,11 @@ const routes: RouteRecordRaw[] = [ name: 'stats', component: StatsView }, + { + path: 'analytics', + name: 'analytics', + component: AnalyticsVisitView + }, { path: 'settings', name: 'settings', diff --git a/cwd-admin/src/views/AnalyticsVisitView.vue b/cwd-admin/src/views/AnalyticsVisitView.vue new file mode 100644 index 0000000..fb7178c --- /dev/null +++ b/cwd-admin/src/views/AnalyticsVisitView.vue @@ -0,0 +1,266 @@ + + + + + + diff --git a/cwd-admin/src/views/LayoutView.vue b/cwd-admin/src/views/LayoutView.vue index 7e87697..0b63bd4 100644 --- a/cwd-admin/src/views/LayoutView.vue +++ b/cwd-admin/src/views/LayoutView.vue @@ -75,6 +75,13 @@ > 数据看板 +