fix: 修复前端AiClassificationService方法调用错误

- 将getAllAiClassifications()调用修正为getAllClassifications()
- 修复导入路径从ai-classification改为aiClassification
- 更新所有相关组件和测试文件
- 解决'AiClassificationService.getAllAiClassifications is not a function'错误
This commit is contained in:
imeepos 2025-07-25 17:09:09 +08:00
parent 30ecaf56ec
commit 7a5859e424
4 changed files with 9 additions and 9 deletions

View File

@ -119,7 +119,7 @@ describe('Template Weight Configuration E2E Tests', () => {
jest.clearAllMocks(); jest.clearAllMocks();
// Setup default mock implementations // Setup default mock implementations
mockAiClassificationService.getAllAiClassifications.mockResolvedValue(mockAiClassifications); mockAiClassificationService.getAllClassifications.mockResolvedValue(mockAiClassifications);
mockTemplateSegmentWeightService.getSegmentWeightsWithDefaults.mockResolvedValue({ mockTemplateSegmentWeightService.getSegmentWeightsWithDefaults.mockResolvedValue({
classification_1: 80, classification_1: 80,
classification_2: 60, classification_2: 60,

View File

@ -6,7 +6,7 @@ import {
CheckIcon, CheckIcon,
ExclamationTriangleIcon, ExclamationTriangleIcon,
} from '@heroicons/react/24/outline'; } from '@heroicons/react/24/outline';
import { AiClassification } from '../../types/ai-classification'; import { AiClassification } from '../../types/aiClassification';
import { TemplateSegmentWeightHelper } from '../../types/template'; import { TemplateSegmentWeightHelper } from '../../types/template';
import { TemplateSegmentWeightService } from '../../services/templateSegmentWeightService'; import { TemplateSegmentWeightService } from '../../services/templateSegmentWeightService';
import { AiClassificationService } from '../../services/aiClassificationService'; import { AiClassificationService } from '../../services/aiClassificationService';
@ -60,7 +60,7 @@ export const BatchWeightConfigModal: React.FC<BatchWeightConfigModalProps> = ({
const loadAiClassifications = async () => { const loadAiClassifications = async () => {
try { try {
const classifications = await AiClassificationService.getAllAiClassifications(); const classifications = await AiClassificationService.getAllClassifications();
const activeClassifications = classifications.filter(c => c.is_active); const activeClassifications = classifications.filter(c => c.is_active);
setAiClassifications(activeClassifications); setAiClassifications(activeClassifications);

View File

@ -6,8 +6,8 @@ import {
XMarkIcon, XMarkIcon,
InformationCircleIcon InformationCircleIcon
} from '@heroicons/react/24/outline'; } from '@heroicons/react/24/outline';
import { AiClassification } from '../../types/ai-classification'; import { AiClassification } from '../../types/aiClassification';
import { TemplateSegmentWeight, TemplateSegmentWeightHelper } from '../../types/template'; import { TemplateSegmentWeightHelper } from '../../types/template';
import { TemplateSegmentWeightService } from '../../services/templateSegmentWeightService'; import { TemplateSegmentWeightService } from '../../services/templateSegmentWeightService';
import { AiClassificationService } from '../../services/aiClassificationService'; import { AiClassificationService } from '../../services/aiClassificationService';
@ -57,7 +57,7 @@ export const TemplateSegmentWeightEditor: React.FC<TemplateSegmentWeightEditorPr
setError(null); setError(null);
const [classifications, weights, hasCustom] = await Promise.all([ const [classifications, weights, hasCustom] = await Promise.all([
AiClassificationService.getAllAiClassifications(), AiClassificationService.getAllClassifications(),
TemplateSegmentWeightService.getSegmentWeightsWithDefaults(templateId, trackSegmentId), TemplateSegmentWeightService.getSegmentWeightsWithDefaults(templateId, trackSegmentId),
TemplateSegmentWeightService.hasCustomSegmentWeights(templateId, trackSegmentId), TemplateSegmentWeightService.hasCustomSegmentWeights(templateId, trackSegmentId),
]); ]);

View File

@ -63,7 +63,7 @@ describe('TemplateSegmentWeightEditor', () => {
jest.clearAllMocks(); jest.clearAllMocks();
// Setup default mock implementations // Setup default mock implementations
mockAiClassificationService.getAllAiClassifications.mockResolvedValue(mockAiClassifications); mockAiClassificationService.getAllClassifications.mockResolvedValue(mockAiClassifications);
mockTemplateSegmentWeightService.getSegmentWeightsWithDefaults.mockResolvedValue(mockCurrentWeights); mockTemplateSegmentWeightService.getSegmentWeightsWithDefaults.mockResolvedValue(mockCurrentWeights);
mockTemplateSegmentWeightService.hasCustomSegmentWeights.mockResolvedValue(false); mockTemplateSegmentWeightService.hasCustomSegmentWeights.mockResolvedValue(false);
}); });
@ -264,7 +264,7 @@ describe('TemplateSegmentWeightEditor', () => {
it('handles loading state', () => { it('handles loading state', () => {
// Mock loading state // Mock loading state
mockAiClassificationService.getAllAiClassifications.mockImplementation( mockAiClassificationService.getAllClassifications.mockImplementation(
() => new Promise(() => {}) // Never resolves () => new Promise(() => {}) // Never resolves
); );
@ -274,7 +274,7 @@ describe('TemplateSegmentWeightEditor', () => {
}); });
it('handles error state', async () => { it('handles error state', async () => {
mockAiClassificationService.getAllAiClassifications.mockRejectedValue( mockAiClassificationService.getAllClassifications.mockRejectedValue(
new Error('Failed to load classifications') new Error('Failed to load classifications')
); );