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 (统一入口)
38 lines
942 B
TypeScript
38 lines
942 B
TypeScript
import axios from 'axios';
|
|
import type { ThemeSettings } from '../../share/types.ts';
|
|
|
|
const API_BASE_URL = '/api';
|
|
|
|
export interface ThemeSettingsResponse {
|
|
message: string;
|
|
data: ThemeSettings;
|
|
}
|
|
|
|
export const ThemeAPI = {
|
|
getThemeSettings: async (): Promise<ThemeSettings> => {
|
|
try {
|
|
const response = await axios.get(`${API_BASE_URL}/theme`);
|
|
return response.data.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
updateThemeSettings: async (themeData: Partial<ThemeSettings>): Promise<ThemeSettings> => {
|
|
try {
|
|
const response = await axios.put(`${API_BASE_URL}/theme`, themeData);
|
|
return response.data.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
},
|
|
|
|
resetThemeSettings: async (): Promise<ThemeSettings> => {
|
|
try {
|
|
const response = await axios.post(`${API_BASE_URL}/theme/reset`);
|
|
return response.data.data;
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
}; |