@@ -105,15 +105,17 @@ async fn launch_new_program(
105105/// 统一记录一次“用户使用该程序/命令”的意图:
106106/// - 由 ProgramManager 统一记录 ranker 与查询关联
107107/// - 并保存配置
108- async fn record_full_launch ( state : & tauri:: State < ' _ , Arc < AppState > > , program_guid : u64 ) {
108+ async fn record_full_launch (
109+ state : & tauri:: State < ' _ , Arc < AppState > > ,
110+ program_guid : u64 ,
111+ query_text : String ,
112+ ) {
109113 let program_manager = state. get_program_manager ( ) ;
110-
111- let last_query = state. get_last_search_query ( ) ;
112114 debug ! (
113115 "📝 记录使用: query='{}' -> GUID={}" ,
114- last_query , program_guid
116+ query_text , program_guid
115117 ) ;
116- program_manager. record_query_launch ( & last_query , program_guid) ;
118+ program_manager. record_query_launch ( & query_text , program_guid) ;
117119
118120 debug ! ( "💾 保存配置文件" ) ;
119121 save_config_to_file ( false ) . await ;
@@ -126,6 +128,7 @@ async fn launch_program_internal(
126128 program_guid : u64 ,
127129 ctrl : bool ,
128130 shift : bool ,
131+ query_text : String ,
129132 override_method : Option < LaunchMethod > ,
130133) -> Result < ( ) , String > {
131134 info ! (
@@ -154,7 +157,7 @@ async fn launch_program_internal(
154157 if let LaunchMethod :: BuiltinCommand ( ref cmd_str) = program. launch_method {
155158 let result = execute_builtin_command ( cmd_str) . await ;
156159 // 无论命令执行是否成功,都记录一次用户意图
157- record_full_launch ( & state, program_guid) . await ;
160+ record_full_launch ( & state, program_guid, query_text ) . await ;
158161 return result;
159162 }
160163
@@ -203,7 +206,7 @@ async fn launch_program_internal(
203206
204207 // 6. 统一记录本次用户意图
205208 // 无论是成功唤醒、启动新实例,还是唤醒失败但不启动,都代表了一次用户意图的完成。
206- record_full_launch ( & state, program_guid) . await ;
209+ record_full_launch ( & state, program_guid, query_text ) . await ;
207210
208211 Ok ( ( ) )
209212}
@@ -243,14 +246,13 @@ pub async fn get_program_count<R: Runtime>(
243246/// - `ctrl`: 是否按下 Ctrl 键(请求管理员权限)
244247/// - `shift`: 是否按下 Shift 键(唤醒已存在窗口)
245248/// - `args`: 用户参数数组,无参数时传递空数组 []
246- pub async fn launch_program < R : Runtime > (
247- _app : tauri:: AppHandle < R > ,
248- _window : tauri:: Window < R > ,
249+ pub async fn launch_program (
249250 state : tauri:: State < ' _ , Arc < AppState > > ,
250251 program_guid : u64 ,
251252 ctrl : bool ,
252253 shift : bool ,
253254 args : Vec < String > ,
255+ query_text : String ,
254256) -> Result < ( ) , String > {
255257 use crate :: modules:: parameter_resolver:: SystemParameterSnapshot ;
256258
@@ -265,7 +267,15 @@ pub async fn launch_program<R: Runtime>(
265267 . await
266268 . map_err ( |e| format ! ( "Failed to build launch method: {}" , e) ) ?;
267269
268- launch_program_internal ( state, program_guid, ctrl, shift, Some ( override_method) ) . await
270+ launch_program_internal (
271+ state,
272+ program_guid,
273+ ctrl,
274+ shift,
275+ query_text,
276+ Some ( override_method) ,
277+ )
278+ . await
269279}
270280
271281#[ tauri:: command]
@@ -333,9 +343,6 @@ pub async fn handle_search_text<R: Runtime>(
333343
334344 debug ! ( "🔍 处理搜索请求: '{}'" , search_text) ;
335345
336- // 保存当前搜索查询
337- state. set_last_search_query ( search_text. clone ( ) ) ;
338-
339346 let runtime_config = state. get_runtime_config ( ) ;
340347
341348 let result_count = runtime_config. get_app_config ( ) . get_search_result_count ( ) ;
0 commit comments