已从10个API模块文件中移除重复的API_BASE_URL定义
所有API调用现在统一使用client/admin/api/index.ts中的全局axios配置 保持原有功能不变的同时简化了代码结构
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
import axios from 'axios';
|
||||
|
||||
import type {
|
||||
SystemSetting, SystemSettingGroupData,
|
||||
import type {
|
||||
SystemSetting, SystemSettingGroupData,
|
||||
} from '../../share/types.ts';
|
||||
|
||||
const API_BASE_URL = '/api';
|
||||
|
||||
export const SystemAPI = {
|
||||
// 获取所有系统设置
|
||||
getSettings: async (): Promise<SystemSettingGroupData[]> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/settings`);
|
||||
const response = await axios.get('/settings');
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -20,7 +18,7 @@ export const SystemAPI = {
|
||||
// 获取指定分组的系统设置
|
||||
getSettingsByGroup: async (group: string): Promise<SystemSetting[]> => {
|
||||
try {
|
||||
const response = await axios.get(`${API_BASE_URL}/settings/group/${group}`);
|
||||
const response = await axios.get(`/settings/group/${group}`);
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -30,7 +28,7 @@ export const SystemAPI = {
|
||||
// 更新系统设置
|
||||
updateSettings: async (settings: Partial<SystemSetting>[]): Promise<SystemSetting[]> => {
|
||||
try {
|
||||
const response = await axios.put(`${API_BASE_URL}/settings`, settings);
|
||||
const response = await axios.put('/settings', settings);
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -40,7 +38,7 @@ export const SystemAPI = {
|
||||
// 重置系统设置
|
||||
resetSettings: async (): Promise<SystemSetting[]> => {
|
||||
try {
|
||||
const response = await axios.post(`${API_BASE_URL}/settings/reset`);
|
||||
const response = await axios.post('/settings/reset');
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user