39 lines
951 B
TypeScript
39 lines
951 B
TypeScript
import axios from 'axios';
|
|
import type {
|
|
ThemeSettings
|
|
} from '../../share/types.ts';
|
|
|
|
const API_BASE_URL = '/api';
|
|
|
|
// Theme API 定义
|
|
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;
|
|
}
|
|
}
|
|
}; |