完整API模块结构:
client/admin/api/ ├── auth.ts (认证API) ├── users.ts (用户API) ├── files.ts (文件API) ├── theme.ts (主题API) ├── charts.ts (图表API) ├── messages.ts (消息API) ├── sys.ts (系统API) ├── know_info.ts (知识库API) ├── maps.ts (地图API) └── index.ts (统一入口)
This commit is contained in:
49
client/admin/api/sys.ts
Normal file
49
client/admin/api/sys.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import axios from 'axios';
|
||||
|
||||
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`);
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user