export type Level = 0 | 1 | 2 | 3 export const LEVEL_META: Record = { 0: { name: '静默记录', color: '#607563', bg: '#edf1e9', desc: '更新状态,留在时间线' }, 1: { name: '轻提醒', color: '#476a8b', bg: '#eaf0f6', desc: '值得知道的变化' }, 2: { name: '需要关注', color: '#b56a37', bg: '#fcf0df', desc: '请查看现场证据' }, 3: { name: '紧急提醒', color: '#b24c43', bg: '#f9e9e6', desc: '保持提醒,直到确认' }, } export interface Template { id: string; name: string; desc: string; itemName: string; camera: string; groundClip: string; groundQuestion: string; groundYes: string; question: string; choices: Record; labels: Record; levels: Record; normal: string[]; hint: string; keywords: string[]; icon: string; confirmation: string[]; } const unclear = '画面被遮挡、过暗或质量不足,无法可靠判断' const base = { groundYes: 'clear', groundQuestion: '只根据当前画面判断:目标活动区域是否清晰可见?', confirmation: [] as string[] } export const TEMPLATES: Template[] = [ { ...base, id: 'package', name: '门口包裹', desc: '到货即知,留意物品变化', itemName: '门口的包裹', camera: '门口', groundClip: '/media/pkg-arrive.mp4', icon: 'package', question: '只根据当前画面判断:门口地面上是否能看见包裹或快递?', choices: { visible: '地面上能看见包裹或快递', absent: '门口地面清晰可见,没有包裹', unclear }, labels: { visible: '包裹在门口', absent: '门口未见包裹', unclear: '等待清晰画面' }, levels: { visible: 1, absent: 2, unclear: 0 }, normal: ['visible', 'absent'], confirmation: ['absent'], hint: '包裹从在场变为不在场时提醒;连续两帧确认变化。', keywords: ['包裹', '快递', '门口', '物品'] }, { ...base, id: 'pet', name: '宠物近况', desc: '看看小家伙在哪里', itemName: '猫咪的近况', camera: '客厅', groundClip: '/media/cat-active.mp4', icon: 'cat', question: '只根据当前画面判断:是否能看见猫或狗?', choices: { visible: '画面中能看见猫或狗', not_visible: '画面中看不见猫或狗', unclear }, labels: { visible: '小家伙在画面里', not_visible: '暂时没出现在画面里', unclear: '等待清晰画面' }, levels: { visible: 0, not_visible: 0, unclear: 0 }, normal: ['visible'], hint: '记录可见的宠物活动,随时回看近况。', keywords: ['猫', '宠物', '狗', '猫咪', '近况'] }, { ...base, id: 'destroy', name: '宠物拆家', desc: '持续抓咬、破坏时提醒', itemName: '宠物有没有拆家', camera: '客厅', groundClip: '/media/cat-destroy.mp4', icon: 'sofa', question: '是否可见猫或狗正在撕咬、抓挠或破坏纸巾、沙发、家具等物品?', choices: { destroying: '可见宠物正在撕咬或破坏物品', calm: '宠物在画面中,没有破坏行为', absent: '没有宠物', unclear }, labels: { destroying: '发现持续破坏迹象', calm: '小家伙安安静静', absent: '宠物不在画面中', unclear: '等待清晰画面' }, levels: { destroying: 2, calm: 0, absent: 0, unclear: 0 }, normal: ['calm', 'absent'], confirmation: ['destroying'], hint: '两帧一致后提醒,日常活动静默记录。', keywords: ['拆家', '撕咬', '破坏', '沙发', '啃'] }, { ...base, id: 'night_yard', name: '庭院守望', desc: '留意夜间庭院的人影', itemName: '庭院夜间动静', camera: '庭院', groundClip: '/media/yard-night.mp4', icon: 'moon', question: '只根据当前画面判断:庭院内是否能看见有人?', choices: { person: '庭院内能看见有人', none: '庭院内没有看见人', unclear }, labels: { person: '庭院有人活动', none: '庭院未见人影', unclear: '等待清晰画面' }, levels: { person: 2, none: 0, unclear: 0 }, normal: ['none'], confirmation: ['person'], hint: '连续两帧确认人影,只判断是否有人。', keywords: ['庭院', '院子', '陌生人', '夜间', '有人'] }, { ...base, id: 'feeding', groundQuestion: '画面中是否清晰可见宠物的食盆及其周围活动区域?', name: '按时吃饭', desc: '留意宠物的进食迹象', itemName: '今天好好吃饭了吗', camera: '客厅', groundClip: '/media/cat-active.mp4', icon: 'bowl', question: '画面里是否可见宠物在食盆处低头进食的迹象?', choices: { eating: '可见宠物低头进食的迹象', nearby: '宠物在附近但未进食', absent: '未见宠物进食', unclear }, labels: { eating: '观察到进食迹象', nearby: '在附近活动', absent: '暂未观察到进食', unclear: '等待清晰画面' }, levels: { eating: 1, nearby: 0, absent: 0, unclear: 0 }, normal: ['eating'], confirmation: ['eating'], hint: '对准食盆区域,在你设定的时间窗内观察。', keywords: ['吃饭', '进食', '食盆', '饭盆', '喂食'] }, { ...base, id: 'cats', name: '猫咪集合', desc: '三只小家伙到齐时告诉你', itemName: '三只猫咪都到齐', camera: '客厅', groundClip: '/media/cat-active.mp4', icon: 'cat', question: '画面中清晰可见几只猫?只计入清晰可分辨的猫。', choices: { all: '正好三只猫', less: '少于三只猫', more: '多于三只猫', unclear }, labels: { all: '三只小家伙到齐了', less: '小家伙还没到齐', more: '看见三只以上的猫', unclear: '等待清晰画面' }, levels: { all: 1, less: 0, more: 0, unclear: 0 }, normal: ['all'], confirmation: ['all'], hint: '连续两帧看到三只猫,即可生成集合提醒。', keywords: ['三只', '到齐', '集合', '几只'] }, { ...base, id: 'window', groundQuestion: '画面中是否有窗户清晰可见,能分辨开关状态?', name: '窗户状态', desc: '留意窗户是否关好', itemName: '阳台窗户关好了吗', camera: '阳台', groundClip: '/media/porch-empty.mp4', icon: 'window', question: '画面中的窗户是否处于开启状态?如果没有窗户可见,请弃权。', choices: { opened: '窗户明显开启', closed: '窗户清晰可见且关闭', unclear }, labels: { opened: '窗户处于开启状态', closed: '窗户已关闭', unclear: '等待清晰画面' }, levels: { opened: 2, closed: 0, unclear: 0 }, normal: ['closed'], confirmation: ['opened'], hint: '上传能看清窗户的画面后启用观察。', keywords: ['窗户', '阳台', '下雨', '关窗'] }, ] export const GROUND_CHOICES = { clear: '目标区域清晰可见,可以可靠观察', blocked: '目标区域被遮挡、过暗或不在视野里' } export function parseIntent(text: string): Template | null { if (!text.trim()) return null const matches = TEMPLATES.map(t => ({ t, score: t.keywords.reduce((s,k) => s + (text.includes(k) ? k.length : 0), 0) })).sort((a,b) => b.score-a.score) return matches[0]?.score ? matches[0].t : null } export const SCENES = [ { id: 'e-cat', name: '客厅里的小家伙', camera: '客厅', trigger: '宠物活动', media: '/media/cat-active.mp4', poster: '/media/posters/cat-active.jpg', templateId: 'pet', color: '#8b9775' }, { id: 'e-arrive', name: '门廊有访客', camera: '门口', trigger: '运动事件', media: '/media/pkg-arrive.mp4', poster: '/media/posters/pkg-arrive.jpg', templateId: 'package', color: '#bb9c70' }, { id: 'e-destroy', name: '宠物与纸巾', camera: '客厅', trigger: '宠物活动', media: '/media/cat-destroy.mp4', poster: '/media/posters/cat-destroy.jpg', templateId: 'destroy', color: '#ba8867' }, { id: 'e-taken', name: '门口的片刻停留', camera: '门口', trigger: '运动事件', media: '/media/pkg-taken.mp4', poster: '/media/posters/pkg-taken.jpg', templateId: 'package', color: '#8b9775' }, { id: 'e-porch', name: '傍晚的门廊', camera: '门口', trigger: '定时巡看', media: '/media/porch-empty.mp4', poster: '/media/posters/porch-empty.jpg', templateId: 'package', color: '#bb9c70' }, { id: 'e-yard', name: '夜幕下的庭院', camera: '庭院', trigger: '夜间事件', media: '/media/yard-night.mp4', poster: '/media/posters/yard-night.jpg', templateId: 'night_yard', color: '#647b8b' }, ]