dashboard.ts 1.3 KB
Newer Older
1 2
import axios from 'axios';

3 4
const BASE_URL = '/dashboard';

5 6 7 8 9 10 11
export interface DashboardTotalRecord {
  pvCount: number;
  ipCount: number;
  todayPvCount: number;
  newPvFromYesterday: number;
}

12 13 14 15 16 17
export interface DashboardAccessTrendRecord {
  date: string;
  pvCount: number;
  ipCount: number;
}

18 19 20 21 22 23
export interface DashboardPopularModuleRecord {
  module: string;
  pvCount: number;
  newPvFromYesterday: number;
}

24 25 26 27 28
export interface DashboardGeoDistributionRecord {
  locations: string[];
  locationIpStatistics: [];
}

29
export interface DashboardAnnouncementRecord {
30 31 32 33 34
  id: string;
  title: string;
  type: number;
}

35 36 37 38 39 40
export interface DashboardRecentlyVisitedRecord {
  title?: string;
  path: string;
  icon?: string;
}

41 42 43 44
export function getTotal() {
  return axios.get<DashboardTotalRecord>(`${BASE_URL}/total`);
}

45 46 47 48 49 50
export function listAccessTrend(days: number) {
  return axios.get<DashboardAccessTrendRecord[]>(
    `${BASE_URL}/access/trend/${days}`
  );
}

51 52 53 54 55 56
export function listPopularModule() {
  return axios.get<DashboardPopularModuleRecord[]>(
    `${BASE_URL}/popular/module`
  );
}

57 58 59 60 61 62
export function getGeoDistribution() {
  return axios.get<DashboardGeoDistributionRecord>(
    `${BASE_URL}/geo/distribution`
  );
}

63
export function listAnnouncement() {
64
  return axios.get<DashboardAnnouncementRecord[]>(`${BASE_URL}/announcement`);
65
}