已从10个API模块文件中移除重复的API_BASE_URL定义
所有API调用现在统一使用client/admin/api/index.ts中的全局axios配置 保持原有功能不变的同时简化了代码结构
This commit is contained in:
@@ -32,9 +32,6 @@ interface KnowInfoDeleteResponse {
|
||||
}
|
||||
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
|
||||
// 知识库API
|
||||
export const KnowInfoAPI = {
|
||||
// 获取知识库列表
|
||||
@@ -46,7 +43,7 @@ export const KnowInfoAPI = {
|
||||
tags?: string;
|
||||
}): Promise<KnowInfoListResponse> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/know-infos`, { params });
|
||||
const response = await axios.get('/know-infos', { params });
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -56,7 +53,7 @@ export const KnowInfoAPI = {
|
||||
// 获取单个知识详情
|
||||
getKnowInfo: async (id: number): Promise<KnowInfoResponse> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/know-infos/${id}`);
|
||||
const response = await axios.get(`/know-infos/${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -66,7 +63,7 @@ export const KnowInfoAPI = {
|
||||
// 创建知识
|
||||
createKnowInfo: async (data: Partial<KnowInfo>): Promise<KnowInfoCreateResponse> => {
|
||||
try {
|
||||
const response = await axios.post(`${API_BASE_URL}/know-infos`, data);
|
||||
const response = await axios.post('/know-infos', data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -76,7 +73,7 @@ export const KnowInfoAPI = {
|
||||
// 更新知识
|
||||
updateKnowInfo: async (id: number, data: Partial<KnowInfo>): Promise<KnowInfoUpdateResponse> => {
|
||||
try {
|
||||
const response = await axios.put(`${API_BASE_URL}/know-infos/${id}`, data);
|
||||
const response = await axios.put(`/know-infos/${id}`, data);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -86,7 +83,7 @@ export const KnowInfoAPI = {
|
||||
// 删除知识
|
||||
deleteKnowInfo: async (id: number): Promise<KnowInfoDeleteResponse> => {
|
||||
try {
|
||||
const response = await axios.delete(`${API_BASE_URL}/know-infos/${id}`);
|
||||
const response = await axios.delete(`/know-infos/${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user