Files
d8d-admin-mobile-starter-pu…/client/mobile/api/system.ts
yourname ba64ad96ed 修改范围覆盖mobile/api目录下所有API文件(共9个,包括auth.ts)
统一使用index.ts中的全局axios配置
移除了所有重复的API_BASE_URL定义
简化了所有API调用路径格式
提高了代码一致性和可维护性
确保所有API功能保持正常
2025-05-13 09:31:30 +00:00

48 lines
1.2 KiB
TypeScript

import axios from 'axios';
import type {
SystemSetting, SystemSettingGroupData,
} from '../../share/types.ts';
// 系统设置API
export const SystemAPI = {
// 获取所有系统设置
getSettings: async (): Promise<SystemSettingGroupData[]> => {
try {
const response = await axios.get('/settings');
return response.data.data;
} catch (error) {
throw error;
}
},
// 获取指定分组的系统设置
getSettingsByGroup: async (group: string): Promise<SystemSetting[]> => {
try {
const response = await axios.get(`/settings/group/${group}`);
return response.data.data;
} catch (error) {
throw error;
}
},
// 更新系统设置
updateSettings: async (settings: Partial<SystemSetting>[]): Promise<SystemSetting[]> => {
try {
const response = await axios.put('/settings', settings);
return response.data.data;
} catch (error) {
throw error;
}
},
// 重置系统设置
resetSettings: async (): Promise<SystemSetting[]> => {
try {
const response = await axios.post('/settings/reset');
return response.data.data;
} catch (error) {
throw error;
}
}
};