|
@@ -1,32 +1,7 @@
|
|
|
// api.ts
|
|
// api.ts
|
|
|
-import axios from 'axios'
|
|
|
|
|
import type { Category, Source, NewsItem, Report } from '@/types'
|
|
import type { Category, Source, NewsItem, Report } from '@/types'
|
|
|
|
|
|
|
|
-const API_BASE_URL = '/api'
|
|
|
|
|
-
|
|
|
|
|
-// Create an axios instance
|
|
|
|
|
-const apiClient = axios.create({
|
|
|
|
|
- baseURL: API_BASE_URL,
|
|
|
|
|
- timeout: 10000,
|
|
|
|
|
- headers: {
|
|
|
|
|
- 'Content-Type': 'application/json',
|
|
|
|
|
- },
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-// Response interceptor to handle errors
|
|
|
|
|
-apiClient.interceptors.response.use(
|
|
|
|
|
- (response) => response.data,
|
|
|
|
|
- (error) => {
|
|
|
|
|
- console.error('API Error:', error)
|
|
|
|
|
- return Promise.reject(error)
|
|
|
|
|
- },
|
|
|
|
|
-)
|
|
|
|
|
-
|
|
|
|
|
-interface ApiResponse<T> {
|
|
|
|
|
- data: T
|
|
|
|
|
- message: string
|
|
|
|
|
- code: boolean
|
|
|
|
|
-}
|
|
|
|
|
|
|
+import apiClient from './axios'
|
|
|
|
|
|
|
|
// Categories API
|
|
// Categories API
|
|
|
export const categoryApi = {
|
|
export const categoryApi = {
|
|
@@ -74,23 +49,22 @@ export const configApi = {
|
|
|
getConfigurations: async (params: Record<string, any>): Promise<unknown> => {
|
|
getConfigurations: async (params: Record<string, any>): Promise<unknown> => {
|
|
|
try {
|
|
try {
|
|
|
const url = `/xiaoshi/ppa/sourceInfo/selectConfigurationList`
|
|
const url = `/xiaoshi/ppa/sourceInfo/selectConfigurationList`
|
|
|
- const response = await apiClient.get<unknown>(url, {params})
|
|
|
|
|
|
|
+ const response = await apiClient.get<unknown>(url, { params })
|
|
|
return response
|
|
return response
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(`Error from export report:`, error)
|
|
console.error(`Error from export report:`, error)
|
|
|
throw error
|
|
throw error
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Sources API
|
|
// Sources API
|
|
|
export const sourceApi = {
|
|
export const sourceApi = {
|
|
|
//获取来源列表
|
|
//获取来源列表
|
|
|
- getSources: async (params?: Record<string,any>): Promise<unknown> => {
|
|
|
|
|
|
|
+ getSources: async (params?: Record<string, any>): Promise<unknown> => {
|
|
|
try {
|
|
try {
|
|
|
const url = `/xiaoshi/ppa/sourceInfo/selectSourceInfoList`
|
|
const url = `/xiaoshi/ppa/sourceInfo/selectSourceInfoList`
|
|
|
- const response = await apiClient.post<unknown>(url,params)
|
|
|
|
|
|
|
+ const response = await apiClient.post<unknown>(url, params)
|
|
|
return response
|
|
return response
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('Error fetching sources:', error)
|
|
console.error('Error fetching sources:', error)
|
|
@@ -99,10 +73,10 @@ export const sourceApi = {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
//获取来源详情
|
|
//获取来源详情
|
|
|
- getSource: async (params?: Record<string,any>): Promise<unknown> => {
|
|
|
|
|
|
|
+ getSource: async (params?: Record<string, any>): Promise<unknown> => {
|
|
|
try {
|
|
try {
|
|
|
const url = `/xiaoshi/ppa/sourceInfo/selectSourceInfoDetail`
|
|
const url = `/xiaoshi/ppa/sourceInfo/selectSourceInfoDetail`
|
|
|
- const response = await apiClient.post<unknown>(url,params)
|
|
|
|
|
|
|
+ const response = await apiClient.post<unknown>(url, params)
|
|
|
return response
|
|
return response
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(`Error fetching source:`, error)
|
|
console.error(`Error fetching source:`, error)
|
|
@@ -111,10 +85,10 @@ export const sourceApi = {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// Create source
|
|
// Create source
|
|
|
- createSource: async (params?: Record<string,any>): Promise<unknown> => {
|
|
|
|
|
|
|
+ createSource: async (params?: Record<string, any>): Promise<unknown> => {
|
|
|
try {
|
|
try {
|
|
|
const url = `/xiaoshi/ppa/sourceInfo/addOrEditSourceInfo`
|
|
const url = `/xiaoshi/ppa/sourceInfo/addOrEditSourceInfo`
|
|
|
- const response = await apiClient.post<unknown>(url,params)
|
|
|
|
|
|
|
+ const response = await apiClient.post<unknown>(url, params)
|
|
|
return response
|
|
return response
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('Error creating source:', error)
|
|
console.error('Error creating source:', error)
|
|
@@ -122,8 +96,7 @@ export const sourceApi = {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- // 删除来源
|
|
|
|
|
|
|
+ // 删除来源
|
|
|
deleteSource: async (params: Record<string, any>): Promise<unknown> => {
|
|
deleteSource: async (params: Record<string, any>): Promise<unknown> => {
|
|
|
try {
|
|
try {
|
|
|
const url = `/xiaoshi/ppa/sourceInfo/deleteSourceInfo`
|
|
const url = `/xiaoshi/ppa/sourceInfo/deleteSourceInfo`
|
|
@@ -281,14 +254,14 @@ export const reportApi = {
|
|
|
exportReportInfo: async (params: Record<string, any>): Promise<unknown> => {
|
|
exportReportInfo: async (params: Record<string, any>): Promise<unknown> => {
|
|
|
try {
|
|
try {
|
|
|
const url = `/xiaoshi/ppa/report/exportReport`
|
|
const url = `/xiaoshi/ppa/report/exportReport`
|
|
|
- const response = await apiClient.get<unknown>(url, {params})
|
|
|
|
|
|
|
+ const response = await apiClient.get<unknown>(url, { params })
|
|
|
return response
|
|
return response
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error(`Error from export report:`, error)
|
|
console.error(`Error from export report:`, error)
|
|
|
throw error
|
|
throw error
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//一键导出上月资讯报告
|
|
//一键导出上月资讯报告
|
|
|
oneClickExportReport: async (): Promise<unknown> => {
|
|
oneClickExportReport: async (): Promise<unknown> => {
|
|
|
try {
|
|
try {
|