feat: AI 场景路由、ASR 服务及前后端全链路同步
- 新增 AI 场景路由控制器和管理接口 - 新增 ASR 语音识别服务及前后端集成 - 同步 AI Runtime 客户端到 Web/小程序/Life-Script - 完善 AI 配置测试修复和管理后台路由配置 - 新增数据库迁移脚本 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { Plus, Wind, Sparkles, Pencil, Trash2 } from 'lucide-react';
|
||||
import { GlassCard, GlassButton, GlassInput, GlassTextarea } from '../components/ui';
|
||||
import Modal from '../components/Modal';
|
||||
import useStore from '../store/useStore';
|
||||
import { analyzeLifeEvent } from '../services/ai';
|
||||
|
||||
/**
|
||||
* 格式化 AI 反馈内容的组件
|
||||
@@ -91,6 +92,7 @@ const TimelineView = () => {
|
||||
// 模态框状态
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [streamFeedback, setStreamFeedback] = useState('');
|
||||
|
||||
// 编辑模式状态:null 表示新增模式,有值表示编辑模式(存储事件 ID)
|
||||
const [editingEventId, setEditingEventId] = useState(null);
|
||||
@@ -111,6 +113,7 @@ const TimelineView = () => {
|
||||
const openAddModal = () => {
|
||||
setEditingEventId(null);
|
||||
setEventForm({ title: '', time: '', content: '' });
|
||||
setStreamFeedback('');
|
||||
setIsModalOpen(true);
|
||||
};
|
||||
|
||||
@@ -125,6 +128,7 @@ const TimelineView = () => {
|
||||
time: event.time || '',
|
||||
content: event.content || ''
|
||||
});
|
||||
setStreamFeedback(event.aiFeedback || '');
|
||||
setIsModalOpen(true);
|
||||
};
|
||||
|
||||
@@ -135,6 +139,7 @@ const TimelineView = () => {
|
||||
setIsModalOpen(false);
|
||||
setEditingEventId(null);
|
||||
setEventForm({ title: '', time: '', content: '' });
|
||||
setStreamFeedback('');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,16 +154,23 @@ const TimelineView = () => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
setStreamFeedback('');
|
||||
const aiFeedback = await analyzeLifeEvent(eventForm, {
|
||||
onDelta: (_delta, output) => setStreamFeedback(output)
|
||||
});
|
||||
|
||||
if (editingEventId) {
|
||||
// 编辑模式:调用更新接口
|
||||
await updateLifeEvent({
|
||||
id: editingEventId,
|
||||
...eventForm
|
||||
...eventForm,
|
||||
aiFeedback
|
||||
});
|
||||
} else {
|
||||
// 新增模式:调用添加接口
|
||||
await addLifeEvent({
|
||||
...eventForm
|
||||
...eventForm,
|
||||
aiFeedback
|
||||
});
|
||||
}
|
||||
|
||||
@@ -311,6 +323,15 @@ const TimelineView = () => {
|
||||
onChange={(v) => setEventForm(prev => ({ ...prev, content: v }))}
|
||||
rows={5}
|
||||
/>
|
||||
{streamFeedback && (
|
||||
<div className="ai-glow-card p-4 rounded-2xl bg-orange-200/[0.02] border border-orange-200/5">
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
<Sparkles className="w-3 h-3 text-orange-200" />
|
||||
<span className="text-[9px] uppercase tracking-[0.2em] text-orange-200/60 font-bold">实时疗愈反馈</span>
|
||||
</div>
|
||||
<p className="text-xs italic text-white/50 leading-loose whitespace-pre-wrap">{streamFeedback}</p>
|
||||
</div>
|
||||
)}
|
||||
<GlassButton
|
||||
variant="primary"
|
||||
onClick={handleSubmit}
|
||||
|
||||
Reference in New Issue
Block a user