docs: add lineloss target_url fix design spec

🤖 Generated with [Qoder][https://qoder.com]
This commit is contained in:
木炎
2026-04-13 14:59:51 +08:00
parent 733aee1e9a
commit 695a888840

View File

@@ -0,0 +1,36 @@
# 台区线损 Skill - target_url 缺失修复方案
## 问题背景
`browser_script_skill_tool.rs` 调用 `Action::Eval` 时只传了 `script` 参数,没有传 `target_url``callback_backend.rs``target_url` 方法需要从 params 或 `current_target_url` 获取值,两者都没有时报错。
知乎热榜正常工作是因为先执行了 `Action::Navigate`,设置了 `current_target_url`
## 设计方案
**方案:在 `browser_script_skill_tool.rs` 的 params 中添加 `target_url`**
### 修改位置
`src/compat/browser_script_skill_tool.rs` - `execute_browser_script_impl` 函数
### 修改内容
在调用 `browser_tool.invoke(Action::Eval, ...)` 时,从 `expected_domain` 构造完整 URL 并添加到 params
```rust
let target_url = format!("http://{}", expected_domain);
let result = match browser_tool.invoke(
Action::Eval,
json!({
"script": wrapped_script,
"target_url": target_url,
}),
&expected_domain,
) {
```
### 约束条件
- 使用 `http://` 协议前缀
- `expected_domain` 可能包含端口号(如 `20.76.57.61:18080`),直接拼接即可