mirror of
https://github.com/patdelphi/suanming.git
synced 2026-02-28 05:33:11 +08:00
Fix TypeScript build errors for Koyeb deployment
- Replace private localApi.request() calls with public methods - Add aiInterpretation public methods to LocalApiClient - Fix type mismatches in AnalysisPage and HistoryPage - Convert string IDs to numbers where required - Ensure all API calls use proper public interfaces
This commit is contained in:
728
dist/assets/index-B67iqrfZ.js
vendored
728
dist/assets/index-B67iqrfZ.js
vendored
File diff suppressed because one or more lines are too long
1
dist/assets/index-BXLzG-9P.css
vendored
1
dist/assets/index-BXLzG-9P.css
vendored
File diff suppressed because one or more lines are too long
805
dist/assets/index-DuhglRqS.js
vendored
Normal file
805
dist/assets/index-DuhglRqS.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/assets/index-e9aiQwGl.css
vendored
Normal file
1
dist/assets/index-e9aiQwGl.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
dist/index.html
vendored
4
dist/index.html
vendored
@@ -4,8 +4,8 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script type="module" crossorigin src="/assets/index-B67iqrfZ.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-BXLzG-9P.css">
|
||||
<script type="module" crossorigin src="/assets/index-DuhglRqS.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-e9aiQwGl.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -351,6 +351,40 @@ class LocalApiClient {
|
||||
},
|
||||
};
|
||||
|
||||
// AI解读相关方法
|
||||
aiInterpretation = {
|
||||
// 获取AI解读状态
|
||||
get: async (analysisId: number): Promise<ApiResponse<any>> => {
|
||||
return this.request<any>(`/ai-interpretation/get/${analysisId}`);
|
||||
},
|
||||
|
||||
// 保存AI解读结果
|
||||
save: async (analysisId: number, content: string, analysisType: string, model?: string, tokensUsed?: number): Promise<ApiResponse<any>> => {
|
||||
return this.request<any>('/ai-interpretation/save', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
analysis_id: analysisId,
|
||||
analysis_type: analysisType,
|
||||
content,
|
||||
model,
|
||||
tokens_used: tokensUsed,
|
||||
success: true
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
// 获取用户的所有AI解读记录
|
||||
list: async (params?: { page?: number; limit?: number; analysis_type?: string }): Promise<ApiResponse<any[]>> => {
|
||||
const queryParams = new URLSearchParams();
|
||||
if (params?.page) queryParams.append('page', params.page.toString());
|
||||
if (params?.limit) queryParams.append('limit', params.limit.toString());
|
||||
if (params?.analysis_type) queryParams.append('analysis_type', params.analysis_type);
|
||||
|
||||
const endpoint = `/ai-interpretation/list${queryParams.toString() ? '?' + queryParams.toString() : ''}`;
|
||||
return this.request<any[]>(endpoint);
|
||||
},
|
||||
};
|
||||
|
||||
// 兼容Supabase的functions.invoke方法
|
||||
functions = {
|
||||
invoke: async (functionName: string, options: { body: any }): Promise<ApiResponse<any>> => {
|
||||
|
||||
@@ -142,14 +142,11 @@ const AnalysisPage: React.FC = () => {
|
||||
|
||||
// 保存历史记录
|
||||
try {
|
||||
const saveResponse = await localApi.request('/analysis/save-history', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
analysis_type: analysisType,
|
||||
analysis_data: analysisData,
|
||||
input_data: analysisType === 'yijing' ? { question: formData.question } : birthData
|
||||
})
|
||||
});
|
||||
const saveResponse = await localApi.analysis.saveHistory(
|
||||
analysisType,
|
||||
analysisData,
|
||||
analysisType === 'yijing' ? { question: formData.question } : birthData
|
||||
);
|
||||
|
||||
if (saveResponse.data?.record_id) {
|
||||
// 将record_id添加到分析结果中,用于AI解读
|
||||
|
||||
@@ -94,10 +94,8 @@ const HistoryPage: React.FC = () => {
|
||||
const aiStatus: {[key: number]: boolean} = {};
|
||||
for (const reading of processedData) {
|
||||
try {
|
||||
const aiResponse = await localApi.request(`/ai-interpretation/get/${reading.id}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
aiStatus[reading.id] = aiResponse.success && aiResponse.data;
|
||||
const aiResponse = await localApi.aiInterpretation.get(reading.id);
|
||||
aiStatus[reading.id] = !aiResponse.error && !!aiResponse.data;
|
||||
} catch {
|
||||
aiStatus[reading.id] = false;
|
||||
}
|
||||
@@ -229,7 +227,7 @@ const HistoryPage: React.FC = () => {
|
||||
divinationMethod={selectedReading.reading_type === 'yijing' ?
|
||||
getInputDataValue(selectedReading.input_data, 'divination_method', 'time') : undefined}
|
||||
preAnalysisData={selectedReading.analysis}
|
||||
recordId={selectedReading.id}
|
||||
recordId={parseInt(selectedReading.id)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Sparkles, Star, Compass, Heart, BarChart3, BookOpen, Shield, Zap, Users, Award, Brain, TrendingUp, Github } from 'lucide-react';
|
||||
import { Sparkles, Star, Compass, Heart, BarChart3, BookOpen, Shield, Zap, Users, Award, Brain, TrendingUp } from 'lucide-react';
|
||||
import { ChineseButton } from '../components/ui/ChineseButton';
|
||||
import { ChineseCard, ChineseCardContent, ChineseCardHeader, ChineseCardTitle } from '../components/ui/ChineseCard';
|
||||
import { useAuth } from '../contexts/AuthContext';
|
||||
@@ -333,24 +333,7 @@ const HomePage: React.FC = () => {
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* GitHub链接 */}
|
||||
<div className="mt-8 pt-6 border-t border-red-200">
|
||||
<div className="flex justify-center">
|
||||
<a
|
||||
href="https://github.com/patdelphi/suanming"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center space-x-2 px-4 py-2 rounded-lg bg-gray-800 hover:bg-gray-700 text-white transition-colors duration-200 shadow-md hover:shadow-lg"
|
||||
>
|
||||
<Github className="h-5 w-5" />
|
||||
<span className="font-medium">查看GitHub源码</span>
|
||||
</a>
|
||||
</div>
|
||||
<p className="text-center text-sm text-gray-600 mt-3 font-chinese">
|
||||
开源项目,欢迎贡献代码和建议
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</ChineseCardContent>
|
||||
</ChineseCard>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user