dashboard.ts
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { QueryForParams, ServiceResponse } from '@/types/global';
import axios, { AxiosRequestConfig } from 'axios';
import FileSaver from 'file-saver';
export default class useDashboardApi {
static userCertify() {
return axios.get('dashboard/user-certify').then((res) => Promise.resolve(res.data));
}
static userTotal() {
return axios.get('dashboard/user-total').then((res) => Promise.resolve(res.data));
}
static userSkill() {
return axios.get('dashboard/user-skill').then((res) => Promise.resolve(res.data));
}
static userStyle() {
return axios.get('dashboard/user-style').then((res) => Promise.resolve(res.data));
}
static activityTotal() {
return axios.get('dashboard/activity-total').then((res) => Promise.resolve(res.data));
}
static activityStyle() {
return axios.get('dashboard/activity-style').then((res) => Promise.resolve(res.data));
}
static activityLike() {
return axios.get('dashboard/activity-like').then((res) => Promise.resolve(res.data));
}
static activityListen() {
return axios.get('dashboard/activity-listen').then((res) => Promise.resolve(res.data));
}
static overview(params?: QueryForParams) {
return axios.get('dashboard/overview', { params }).then((res) => Promise.resolve(res.data));
}
static getOverviewExport(fileName: string, params?: QueryForParams) {
const config = { params: { ...params, fetchType: 'excel' }, timeout: 60000, responseType: 'blob' } as AxiosRequestConfig;
return axios.get('dashboard/overview', config).then(({ data }) => FileSaver.saveAs(data, `${fileName}.xlsx`));
}
static submitWork(params?: QueryForParams): Promise<ServiceResponse> {
return axios.get('dashboard/submit-work', { params });
}
static getSubmitWorkExport(fileName: string, params?: QueryForParams) {
const config = { params: { ...params, fetchType: 'excel' }, timeout: 60000, responseType: 'blob' } as AxiosRequestConfig;
return axios.get('dashboard/submit-work', config).then(({ data }) => FileSaver.saveAs(data, `${fileName}.xlsx`));
}
}