修改范围覆盖mobile/api目录下所有API文件(共9个,包括auth.ts)
统一使用index.ts中的全局axios配置 移除了所有重复的API_BASE_URL定义 简化了所有API调用路径格式 提高了代码一致性和可维护性 确保所有API功能保持正常
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
import axios from 'axios';
|
||||
import type {
|
||||
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`);
|
||||
const response = await axios.get('/theme');
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -20,7 +18,7 @@ export const ThemeAPI = {
|
||||
// 更新主题设置
|
||||
updateThemeSettings: async (themeData: Partial<ThemeSettings>): Promise<ThemeSettings> => {
|
||||
try {
|
||||
const response = await axios.put(`${API_BASE_URL}/theme`, themeData);
|
||||
const response = await axios.put('/theme', themeData);
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -30,7 +28,7 @@ export const ThemeAPI = {
|
||||
// 重置主题设置
|
||||
resetThemeSettings: async (): Promise<ThemeSettings> => {
|
||||
try {
|
||||
const response = await axios.post(`${API_BASE_URL}/theme/reset`);
|
||||
const response = await axios.post('/theme/reset');
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user