fix:修复角色管理页面获取职业信息问题

This commit is contained in:
xiamuceer
2026-01-06 19:39:01 +08:00
parent 731913faaf
commit 609426fd7d
+5 -7
View File
@@ -9,11 +9,10 @@ import { SSELoadingOverlay } from '../components/SSELoadingOverlay';
import type { Character } from '../types';
import { characterApi } from '../services/api';
import { SSEPostClient } from '../utils/sseClient';
import axios from 'axios';
import api from '../services/api';
const { Title } = Typography;
const { TextArea } = Input;
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000';
interface Career {
id: string;
@@ -59,12 +58,11 @@ export default function Characters() {
const fetchCareers = async () => {
if (!currentProject?.id) return;
try {
const response = await axios.get(`${API_BASE_URL}/api/careers`, {
params: { project_id: currentProject.id },
headers: { Authorization: `Bearer ${localStorage.getItem('token')}` }
const response = await api.get<unknown, { main_careers: Career[]; sub_careers: Career[] }>('/careers', {
params: { project_id: currentProject.id }
});
setMainCareers(response.data.main_careers || []);
setSubCareers(response.data.sub_careers || []);
setMainCareers(response.main_careers || []);
setSubCareers(response.sub_careers || []);
} catch (error) {
console.error('获取职业列表失败:', error);
}