已从10个API模块文件中移除重复的API_BASE_URL定义
所有API调用现在统一使用client/admin/api/index.ts中的全局axios配置 保持原有功能不变的同时简化了代码结构
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// 基础配置
|
||||
export const API_BASE_URL = '/api';
|
||||
// 全局axios配置
|
||||
axios.defaults.baseURL = API_BASE_URL;
|
||||
|
||||
// 获取OSS完整URL
|
||||
export const getOssUrl = (path: string): string => {
|
||||
// 获取全局配置中的OSS_HOST,如果不存在使用默认值
|
||||
const ossHost = (window.CONFIG?.OSS_BASE_URL) || '';
|
||||
// 确保path不以/开头
|
||||
const ossPath = path.startsWith('/') ? path.substring(1) : path;
|
||||
return `${ossHost}/${ossPath}`;
|
||||
};
|
||||
|
||||
export * from './auth.ts';
|
||||
export * from './users.ts';
|
||||
export * from './files.ts';
|
||||
|
||||
Reference in New Issue
Block a user