Files
vf_react/src/services/industryService.js
2025-10-23 14:24:26 +08:00

29 lines
901 B
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { getApiBase } from '../utils/apiConfig';
// src/services/industryService.js
import axios from 'axios';
// 判断当前是否是生产环境
const isProduction = process.env.NODE_ENV === 'production';
const API_BASE_URL = getApiBase();
// 配置 axios 默认包含 credentials
axios.defaults.withCredentials = true;
export const industryService = {
/**
* 获取行业分类完整树形结构
* @param {string} classification - 可选,指定分类体系名称,不传则返回所有
* @returns {Promise} 返回树形结构数据
*/
async getClassifications(classification) {
let url = `${API_BASE_URL}/api/classifications`;
if (classification) {
url += `?classification=${encodeURIComponent(classification)}`;
}
const res = await axios.get(url);
return res.data;
}
// 注意getLevels 接口已废弃,使用 getClassifications 替代
};