Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f1b7c341c |
@@ -1584,6 +1584,8 @@ def capture():
|
|||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
"action": "screenshot" | "html" | "text" | "smart",
|
"action": "screenshot" | "html" | "text" | "smart",
|
||||||
"refresh": false, // 可选:true=强制实时提取(绕过网址缓存)
|
"refresh": false, // 可选:true=强制实时提取(绕过网址缓存)
|
||||||
|
"cache": true, // 可选:false=本次请求禁用缓存
|
||||||
|
"cache_ttl_seconds": 3600, // 可选:本次请求的缓存时效(秒),覆盖全局设置;命中判定也用它
|
||||||
"scroll_times": 0,
|
"scroll_times": 0,
|
||||||
"scroll_delay": 1000,
|
"scroll_delay": 1000,
|
||||||
"full_page": false,
|
"full_page": false,
|
||||||
@@ -1637,9 +1639,15 @@ def capture():
|
|||||||
cache_cfg = settings.get("cache", DEFAULT_CACHE_CONFIG)
|
cache_cfg = settings.get("cache", DEFAULT_CACHE_CONFIG)
|
||||||
retry_cfg = settings.get("retry", DEFAULT_RETRY_CONFIG)
|
retry_cfg = settings.get("retry", DEFAULT_RETRY_CONFIG)
|
||||||
force_refresh = bool(data.get("refresh") or data.get("force"))
|
force_refresh = bool(data.get("refresh") or data.get("force"))
|
||||||
|
# per-request 缓存参数:cache_ttl_seconds=本次缓存时效(覆盖全局),cache=false / no_cache=true=本次禁用缓存
|
||||||
|
no_cache = data.get("cache") is False or str(data.get("no_cache")).lower() in ("true", "1", "yes")
|
||||||
|
try:
|
||||||
|
cache_ttl_override = max(1, int(data.get("cache_ttl_seconds"))) if data.get("cache_ttl_seconds") is not None else None
|
||||||
|
except Exception:
|
||||||
|
cache_ttl_override = None
|
||||||
|
|
||||||
if cache_cfg.get("enabled") and not force_refresh:
|
if cache_cfg.get("enabled") and not force_refresh and not no_cache:
|
||||||
ttl = int(cache_cfg.get("ttl_seconds", 3600))
|
ttl = cache_ttl_override or int(cache_cfg.get("ttl_seconds", 3600))
|
||||||
hit = find_cache_hit(url, action, ttl)
|
hit = find_cache_hit(url, action, ttl)
|
||||||
if hit:
|
if hit:
|
||||||
hit["from_cache"] = True
|
hit["from_cache"] = True
|
||||||
|
|||||||
+20
-4
@@ -627,8 +627,10 @@
|
|||||||
🔄 强制刷新(绕过网址缓存,重新提取)
|
🔄 强制刷新(绕过网址缓存,重新提取)
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<small style="color: #666; display: block; margin-top: 4px;">
|
<small style="color: #666; display: block; margin-top: 6px; line-height: 1.8;">
|
||||||
📦 网址缓存已<span id="cacheStateBadge">…</span>(有效期 <span id="cacheTtlBadge">…</span>),同网址命中缓存直接返回历史结果,不会重复提取。
|
📦 网址缓存:<span id="cacheStateBadge">…</span> | 有效期 <span id="cacheTtlBadge">…</span>
|
||||||
|
<button type="button" class="btn-small" onclick="openCaptureCfg()" style="margin-left:8px;padding:3px 10px;font-size:12px;vertical-align:middle;" title="打开缓存/重试设置">⚙️ 设置时效与开关</button><br>
|
||||||
|
<span style="color:#999;">同网址命中缓存直接返回历史结果,不重复提取;勾选上方「强制刷新」可绕过。</span>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -761,7 +763,6 @@
|
|||||||
{
|
{
|
||||||
"url": "https://example.com",
|
"url": "https://example.com",
|
||||||
"action": "smart", // "screenshot" | "html" | "text" | "smart"
|
"action": "smart", // "screenshot" | "html" | "text" | "smart"
|
||||||
"refresh": false, // 可选:true=强制实时提取(绕过网址缓存)
|
|
||||||
"wait_time": 15000, // 重要!验证网站需设置较长等待
|
"wait_time": 15000, // 重要!验证网站需设置较长等待
|
||||||
"scroll_times": 3, // 可选:加载动态内容
|
"scroll_times": 3, // 可选:加载动态内容
|
||||||
"scroll_delay": 1000, // 可选:滚动间隔
|
"scroll_delay": 1000, // 可选:滚动间隔
|
||||||
@@ -770,6 +771,10 @@
|
|||||||
"caller": "news-tracker", // 可选:调用者标识(历史记录里显示,默认游客)
|
"caller": "news-tracker", // 可选:调用者标识(历史记录里显示,默认游客)
|
||||||
"call_method": "api", // 可选:调用方式 web/api(缺省自动判定)
|
"call_method": "api", // 可选:调用方式 web/api(缺省自动判定)
|
||||||
"viewport": {"width":1280,"height":700},
|
"viewport": {"width":1280,"height":700},
|
||||||
|
// ---- 📦 网址缓存(默认开启,全局配置在 /api/capture/settings)----
|
||||||
|
"refresh": false, // 可选:true=强制实时提取(绕过缓存)
|
||||||
|
"cache": true, // 可选:false=本次请求禁用缓存
|
||||||
|
"cache_ttl_seconds": 3600, // 可选:本次缓存时效(秒),覆盖全局有效期,命中判定也用它
|
||||||
"smart_config": { // 可选:临时覆盖按需截图配置(接口列表按顺序=优先级,失败自动降级)
|
"smart_config": { // 可选:临时覆盖按需截图配置(接口列表按顺序=优先级,失败自动降级)
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
{"name":"本地Qwen", "base_url":"http://121.40.164.32:18008/v1", "api_key":"xxxx", "model":"unsloth/Qwen3.8-27B-NVFP4", "enabled":true},
|
{"name":"本地Qwen", "base_url":"http://121.40.164.32:18008/v1", "api_key":"xxxx", "model":"unsloth/Qwen3.8-27B-NVFP4", "enabled":true},
|
||||||
@@ -779,11 +784,22 @@
|
|||||||
"scroll_ratio": 0.85
|
"scroll_ratio": 0.85
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 缓存命中响应(text/html/smart 为 JSON;screenshot 直接返回历史图片文件):
|
||||||
|
// {success:true, from_cache:true, history_id:123, cached_at:"2026-09-11 22:49:41", cache_ttl_seconds:3600, ...}
|
||||||
|
|
||||||
|
📦 缓存/🔁 重试全局配置(页面「⚙️ 缓存/重试」按钮或以下接口):
|
||||||
|
GET /api/capture/settings
|
||||||
|
POST /api/capture/settings
|
||||||
|
{
|
||||||
|
"settings": {
|
||||||
|
"cache": {"enabled": true, "ttl_seconds": 3600}, // enabled=缓存开关, ttl_seconds=有效期(秒)
|
||||||
|
"retry": {"max_retries": 2, "delay_seconds": 2} // max_retries=失败重试次数(默认2), delay_seconds=重试间隔(秒)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GET /api/smart/config // 获取智能截图配置(含 endpoints 多接口列表)
|
GET /api/smart/config // 获取智能截图配置(含 endpoints 多接口列表)
|
||||||
POST /api/smart/config // 保存配置(body: {config:{endpoints:[...], prompt, max_scrolls,...}})
|
POST /api/smart/config // 保存配置(body: {config:{endpoints:[...], prompt, max_scrolls,...}})
|
||||||
POST /api/smart/test // 测试指定接口(body: {endpoint_id} 或 {endpoint:{...}} 或旧版 {config:{...}})
|
POST /api/smart/test // 测试指定接口(body: {endpoint_id} 或 {endpoint:{...}} 或旧版 {config:{...}})
|
||||||
GET /api/capture/settings // 网址缓存+失败重试 配置({cache:{enabled,ttl_seconds}, retry:{max_retries,delay_seconds}})
|
|
||||||
GET /api/history?page=1&page_size=15&action=all&search=关键词 // 历史分页
|
GET /api/history?page=1&page_size=15&action=all&search=关键词 // 历史分页
|
||||||
GET /api/history/stats?dimension=day&days=30 // 历史统计(dimension: day/action/backend/status/caller/method)
|
GET /api/history/stats?dimension=day&days=30 // 历史统计(dimension: day/action/backend/status/caller/method)
|
||||||
GET /api/history/<id> // 历史详情
|
GET /api/history/<id> // 历史详情
|
||||||
|
|||||||
Reference in New Issue
Block a user