feat: 添加拍药盒功能和语音直达入口

- 实现拍药盒扫描流程,支持本地OCR识别药品信息
- 在日记页面添加拍药盒和记症状的三选一入口
- 优化按钮点击区域,确保符合苹果HIG最小命中区标准
- 添加用药记录到时间线的独立分类显示
- 实现长按+号语音直达功能,支持语音意图分类跳转
- 更新项目配置文件,启用代码分析和死代码剥离选项
- 增加多项本地化字符串支持新功能
```
This commit is contained in:
link2026
2026-06-13 09:16:25 +08:00
parent f58d6064ba
commit 6c6a950140
30 changed files with 1856 additions and 64 deletions

View File

@@ -0,0 +1,53 @@
import Testing
import Foundation
@testable import
/// :LLM + 退
struct VoiceIntentServiceTests {
// MARK: - parseIntent(LLM )
@Test func parsesStandardJSON() {
#expect(VoiceIntentService.parseIntent(from: #"{"intent":"indicator"}"#) == .indicator)
}
@Test func parsesFencedAndThinkWrapped() {
let raw = """
<think>用户想记血压</think>
```json
{"intent": "Indicator"}
```
"""
#expect(VoiceIntentService.parseIntent(from: raw) == .indicator)
}
@Test func parsesBareWord() {
#expect(VoiceIntentService.parseIntent(from: "symptom") == .symptom)
#expect(VoiceIntentService.parseIntent(from: "\"diary\"") == .diary)
}
@Test func unknownReturnsNil() {
#expect(VoiceIntentService.parseIntent(from: #"{"intent":"unknown"}"#) == nil)
#expect(VoiceIntentService.parseIntent(from: "我不知道") == nil)
}
// MARK: - keywordMatch(退)
@Test func reminderBeatsMedication() {
// , reminder
#expect(VoiceIntentService.keywordMatch("每天八点提醒我吃药") == .reminder)
}
@Test func commonUtterances() {
#expect(VoiceIntentService.keywordMatch("记一下血压,高压128") == .indicator)
#expect(VoiceIntentService.keywordMatch("我有点头疼") == .symptom)
#expect(VoiceIntentService.keywordMatch("拍个药盒") == .medication)
#expect(VoiceIntentService.keywordMatch("把体检报告存进去") == .archive)
#expect(VoiceIntentService.keywordMatch("整理一份给医生看的") == .export)
#expect(VoiceIntentService.keywordMatch("写个日记") == .diary)
}
@Test func gibberishReturnsNil() {
#expect(VoiceIntentService.keywordMatch("啦啦啦啦") == nil)
}
}