mirror of
https://github.com/patdelphi/suanming.git
synced 2026-02-28 05:33:11 +08:00
feat: refactor AI interpretation system and fix recordId issues
- Refactored AI interpretation table to use proper 1-to-1 relationship with reading records - Fixed recordId parameter passing in AnalysisResultDisplay component - Updated database schema to use reading_id instead of analysis_id - Removed complex string ID generation logic - Fixed TypeScript type definitions for all ID fields - Added database migration scripts for AI interpretation refactoring - Improved error handling and debugging capabilities
This commit is contained in:
@@ -90,15 +90,11 @@ const HistoryPage: React.FC = () => {
|
||||
|
||||
setReadings(processedData);
|
||||
|
||||
// 检查每个记录的AI解读状态
|
||||
// 从后端返回的数据中提取AI解读状态
|
||||
const aiStatus: {[key: number]: boolean} = {};
|
||||
for (const reading of processedData) {
|
||||
try {
|
||||
const aiResponse = await localApi.aiInterpretation.get(reading.id);
|
||||
aiStatus[reading.id] = !aiResponse.error && !!aiResponse.data;
|
||||
} catch {
|
||||
aiStatus[reading.id] = false;
|
||||
}
|
||||
// 使用后端返回的has_ai_interpretation字段
|
||||
aiStatus[reading.id] = !!(reading as any).has_ai_interpretation;
|
||||
}
|
||||
setAiInterpretations(aiStatus);
|
||||
} catch (error: any) {
|
||||
@@ -124,8 +120,8 @@ const HistoryPage: React.FC = () => {
|
||||
throw new Error(response.error.message);
|
||||
}
|
||||
|
||||
setReadings(prev => prev.filter(r => r.id !== readingId));
|
||||
if (selectedReading?.id === readingId) {
|
||||
setReadings(prev => prev.filter(r => r.id !== parseInt(readingId)));
|
||||
if (selectedReading?.id === parseInt(readingId)) {
|
||||
setSelectedReading(null);
|
||||
setViewingResult(false);
|
||||
}
|
||||
@@ -227,7 +223,7 @@ const HistoryPage: React.FC = () => {
|
||||
divinationMethod={selectedReading.reading_type === 'yijing' ?
|
||||
getInputDataValue(selectedReading.input_data, 'divination_method', 'time') : undefined}
|
||||
preAnalysisData={selectedReading.analysis}
|
||||
recordId={parseInt(selectedReading.id)}
|
||||
recordId={selectedReading.id}
|
||||
/>
|
||||
|
||||
</div>
|
||||
@@ -345,7 +341,7 @@ const HistoryPage: React.FC = () => {
|
||||
<ChineseButton
|
||||
variant="ghost"
|
||||
size="md"
|
||||
onClick={() => handleDeleteReading(reading.id)}
|
||||
onClick={() => handleDeleteReading(reading.id.toString())}
|
||||
className="min-h-[40px] text-red-600 hover:text-red-700 hover:bg-red-50 px-2 sm:px-3 flex-shrink-0"
|
||||
>
|
||||
<Trash2 className="h-3 w-3 sm:h-4 sm:w-4" />
|
||||
|
||||
Reference in New Issue
Block a user