@@ -10,8 +10,8 @@ use tauri::State;
1010
1111use crate :: commands:: AppState ;
1212use crate :: video_profile:: {
13- apply_profile_memory, builtin_profiles, profile_by_kind , vote_detect, DetectResult ,
14- ObservedSignals , ProfileKind , ProfileMemory , VideoProfile ,
13+ apply_profile_memory, builtin_profiles, vote_detect, DetectResult , ObservedSignals ,
14+ ProfileMemory , VideoProfile ,
1515} ;
1616use crate :: video_profile_spec:: { ContentForm , ProfileSpec } ;
1717
@@ -128,50 +128,6 @@ pub fn detect_video_profile(
128128 result
129129}
130130
131- /// 领域标签检测(REQ-190:平台分区 > 用户确认 > 标题词 > 术语频率)。
132- ///
133- /// @param title - 窗口标题(来源②标题领域词)
134- /// @param platformTags - 平台分区标签(来源①——B站分区/本地目录名)
135- /// @param userConfirmed - 用户已确认领域(来源③——检测卡下拉;kebab-case)
136- /// @param termFreq - 会话中术语频率词(来源④——自动补全)
137- /// @param ocrTags - 画面内 OCR 标签(REQ-191 通用化通道——任何平台画面标签
138- /// 都算;与 platformTags 合并入平台来源)
139- #[ tauri:: command]
140- pub fn detect_video_domain (
141- title : Option < String > ,
142- platform_tags : Option < Vec < String > > ,
143- user_confirmed : Option < String > ,
144- term_freq : Option < Vec < String > > ,
145- ocr_tags : Option < Vec < String > > ,
146- ) -> crate :: video_profile_domain:: DomainDetection {
147- let user = user_confirmed. and_then ( |s| {
148- crate :: video_profile_domain:: DomainKind :: parse ( & s. chars ( ) . take ( 30 ) . collect :: < String > ( ) )
149- } ) ;
150- // OCR 标签通用化(REQ-191):画面内标签与平台标签同为强信号来源——
151- // 经 platform_adapter 通用通道合并(词表映射扩展,不依赖平台枚举)
152- let mut platform = platform_tags. unwrap_or_default ( ) ;
153- for t in ocr_tags. unwrap_or_default ( ) {
154- if !platform. contains ( & t) {
155- platform. push ( t) ;
156- }
157- }
158- // 平台标签 → 领域(通用通道);无平台信号 → 其余来源(标题/用户/术语)
159- let from_ocr = crate :: platform_adapter:: ocr_tags_to_domain ( & platform) ;
160- if from_ocr. kind . is_some ( ) {
161- return from_ocr;
162- }
163- crate :: video_profile_domain:: detect_domain ( & crate :: video_profile_domain:: DomainSignals {
164- title : title. map ( |t| t. chars ( ) . take ( 200 ) . collect ( ) ) ,
165- platform_tags : Vec :: new ( ) ,
166- user_confirmed : user,
167- term_freq : term_freq. unwrap_or_default ( )
168- . into_iter ( )
169- . map ( |t| t. chars ( ) . take ( 50 ) . collect ( ) )
170- . collect ( ) ,
171- asr_opening : None ,
172- } )
173- }
174-
175131/// 领域 → hotwords 预热(REQ-190 作用链:VocabManager 通道——注入共享词表,
176132/// ASR 术语命中率↑;幂等去重)。
177133///
@@ -284,37 +240,6 @@ pub fn list_domain_fine() -> Vec<(String, Vec<crate::video_profile_domain_fine::
284240 . collect ( )
285241}
286242
287- /// 记录用户确认/修改:窗口标题 → 档案(记忆偏好,下次同标题直接生效)。
288- ///
289- /// @param title - 窗口标题(记忆匹配键,完整标题入库)
290- /// @param kind - 档案标识(kebab-case;非法值回退 Lecture)
291- #[ tauri:: command]
292- pub fn remember_video_profile (
293- state : State < ' _ , AppState > ,
294- title : String ,
295- kind : String ,
296- ) -> Result < ( ) , String > {
297- let title = title. trim ( ) . to_string ( ) ;
298- if title. is_empty ( ) {
299- return Err ( "窗口标题为空,无法记忆档案偏好" . to_string ( ) ) ;
300- }
301- let title = title. chars ( ) . take ( 200 ) . collect :: < String > ( ) ;
302- let kind = ProfileKind :: parse ( & kind. chars ( ) . take ( KIND_MAX_CHARS ) . collect :: < String > ( ) ) ;
303- let path = state. profile_memory_path . clone ( ) ;
304- let memory = state. profile_memory . clone ( ) ;
305- // 锁内 read-modify-write(与词表同模式,防 TOCTOU 文件竞争)
306- {
307- let mut guard = memory
308- . lock ( )
309- . map_err ( |e| format ! ( "档案记忆锁中毒: {}" , e) ) ?;
310- guard. remember ( & title, kind) ;
311- guard
312- . save ( & path)
313- . map_err ( |e| format ! ( "保存档案记忆失败: {}" , e) ) ?;
314- }
315- Ok ( ( ) )
316- }
317-
318243/// 读取当前档案记忆(诊断/展示用)。
319244#[ tauri:: command]
320245pub fn video_profile_memory ( state : State < ' _ , AppState > ) -> ProfileMemory {
@@ -325,12 +250,6 @@ pub fn video_profile_memory(state: State<'_, AppState>) -> ProfileMemory {
325250 . unwrap_or_default ( )
326251}
327252
328- /// 按标识查单档案(前端"检测为:网课(可改)"下拉用;非法值回退 Lecture)。
329- #[ tauri:: command]
330- pub fn video_profile_by_kind ( kind : String ) -> VideoProfile {
331- profile_by_kind ( ProfileKind :: parse ( & kind. chars ( ) . take ( KIND_MAX_CHARS ) . collect :: < String > ( ) ) )
332- }
333-
334253// ── v0.9.0 M1(REQ-188):四维解耦 command(检测卡 v2 消费端;旧命令零改动)──
335254
336255/// 按四维规格查参数矩阵(形态 × 画面档 → 采样/OCR/存储/模板)。
@@ -353,13 +272,6 @@ pub fn video_profile_for_spec(form: Option<String>, tier: Option<String>) -> Vid
353272 crate :: video_profile_spec:: profile_for_spec ( & spec)
354273}
355274
356- /// 旧档案 → 四维规格(记忆库 kind 映射迁移/旧会话解读;检测卡 v2 展示用)。
357- #[ tauri:: command]
358- pub fn video_profile_spec_by_kind ( kind : String ) -> ProfileSpec {
359- let kind = ProfileKind :: parse ( & kind. chars ( ) . take ( KIND_MAX_CHARS ) . collect :: < String > ( ) ) ;
360- crate :: video_profile_spec:: spec_from_kind ( kind)
361- }
362-
363275/// 记录用户确认/修改(四维形态版,REQ-188):记忆偏好存新形态(form 字段),
364276/// kind 兼容字段存代表旧类——消费端 v1/v2 双通道读取均有效。
365277///
0 commit comments