创建了api目录并拆分为10个功能模块文件
建立了index.ts统一导出 精简了原api.ts文件
This commit is contained in:
39
client/mobile/api/theme.ts
Normal file
39
client/mobile/api/theme.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user