创建了api目录并拆分为10个功能模块文件

建立了index.ts统一导出
精简了原api.ts文件
This commit is contained in:
yourname
2025-05-13 09:00:58 +00:00
parent 175596d0ee
commit 1df9f7fea2
17 changed files with 824 additions and 9 deletions

View File

@@ -0,0 +1,39 @@
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;
}
}
};