已从10个API模块文件中移除重复的API_BASE_URL定义

所有API调用现在统一使用client/admin/api/index.ts中的全局axios配置
保持原有功能不变的同时简化了代码结构
This commit is contained in:
yourname
2025-05-13 11:44:28 +00:00
parent d0d88ab950
commit e4f45ed952
10 changed files with 64 additions and 66 deletions

View File

@@ -1,8 +1,6 @@
import axios from 'axios';
import type { ThemeSettings } from '../../share/types.ts';
const API_BASE_URL = '/api';
export interface ThemeSettingsResponse {
message: string;
data: ThemeSettings;
@@ -11,7 +9,7 @@ export interface ThemeSettingsResponse {
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;
@@ -29,7 +27,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;