Files
d8d-admin-mobile-starter-pu…/client/mobile/api/system.ts
yourname 1df9f7fea2 创建了api目录并拆分为10个功能模块文件
建立了index.ts统一导出
精简了原api.ts文件
2025-05-13 09:00:58 +00:00

50 lines
1.3 KiB
TypeScript

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