sync update from LAN repo (source dhk-1 @ 3b1ec5b4)

This commit is contained in:
gozeros committed 2026-11-05 10:56:34 +08:00
1 parent da6521b6cb
commit 264e2200d6
995 files changed
+148105 -13399

No files matched your search

@@ -0,0 +1,130 @@
"""Browser-reachable addresses written into generated HTML pages.
The settings dialog is the source of truth. A value saved in
``system_settings.json`` wins over ``config.yaml`` and the built-in default,
so a deployment can point new pages at a domain users can actually open
without editing or restarting from a config file.
"""
from __future__ import annotations
import logging
from urllib.parse import urlparse
from deerflow.config.html_runtime_config import (
DEFAULT_HTML_MAP_TILE_URL,
DEFAULT_HTML_RUNTIME_BASE_URL,
)
logger = logging.getLogger(__name__)
_HTML_RUNTIME_SUFFIX = "/api/public/html-runtime"
def normalize_html_runtime_base_url(value: str) -> str:
"""Return an absolute runtime base, appending the public asset path when omitted."""
raw = str(value or "").strip()
if not raw:
raise ValueError("请填写用户浏览器能够访问的 HTML 运行库地址")
if any(character.isspace() for character in raw):
raise ValueError("HTML 运行库地址不能包含空格")
parsed = urlparse(raw)
if parsed.scheme not in {"http", "https"} or not parsed.netloc:
raise ValueError("HTML 运行库地址需要以 http:// 或 https:// 开头,并包含域名或 IP")
if parsed.username or parsed.password:
raise ValueError("HTML 运行库地址不能包含账号或密码")
if parsed.query or parsed.fragment:
raise ValueError("HTML 运行库地址不需要查询参数")
path = parsed.path.rstrip("/")
if path in {"", "/"}:
path = _HTML_RUNTIME_SUFFIX
return f"{parsed.scheme}://{parsed.netloc}{path}"
def normalize_html_map_tile_url(value: str) -> str:
"""Return a Leaflet tile template containing the x/y/z placeholders."""
raw = str(value or "").strip()
if not raw:
raise ValueError("请填写地图瓦片地址")
if any(character.isspace() for character in raw):
raise ValueError("地图瓦片地址不能包含空格")
parsed = urlparse(raw)
if parsed.scheme not in {"http", "https"} or not parsed.netloc:
raise ValueError("地图瓦片地址需要以 http:// 或 https:// 开头,并包含域名或 IP")
if parsed.username or parsed.password:
raise ValueError("地图瓦片地址不能包含账号或密码")
lowered = raw.lower()
missing = [token for token in ("{z}", "{x}", "{y}") if token not in lowered]
if missing:
raise ValueError("地图瓦片地址需要包含 {z}、{x}、{y} 三个占位符")
return raw
def html_runtime_base_url(fallback: str | None = None) -> str:
"""Return the runtime base used when writing or serving generated HTML."""
saved = _saved("base_url")
if saved:
try:
return normalize_html_runtime_base_url(saved)
except ValueError:
logger.warning("Ignoring invalid saved HTML runtime base URL")
return _first_valid_base(fallback, _config_value("base_url"), DEFAULT_HTML_RUNTIME_BASE_URL)
def html_map_tile_url(fallback: str | None = None) -> str:
"""Return the Leaflet tile template injected into deerflow-runtime.js."""
saved = _saved("map_tile_url")
if saved:
try:
return normalize_html_map_tile_url(saved)
except ValueError:
logger.warning("Ignoring invalid saved HTML map tile URL")
return _first_valid_tile(fallback, _config_value("map_tile_url"), DEFAULT_HTML_MAP_TILE_URL)
def _saved(field: str) -> str:
try:
from deerflow.config.system_settings import load_system_settings
block = load_system_settings().html_runtime
return str(getattr(block, field, "") or "").strip()
except Exception:
logger.debug("HTML runtime settings are unavailable", exc_info=True)
return ""
def _config_value(field: str) -> str:
try:
from deerflow.config import get_app_config
runtime = get_app_config().html_runtime
return str(getattr(runtime, field, "") or "").strip()
except Exception:
logger.debug("HTML runtime config fallback is unavailable", exc_info=True)
return ""
def _first_valid_base(*candidates: str | None) -> str:
for candidate in candidates:
if not candidate or not str(candidate).strip():
continue
try:
return normalize_html_runtime_base_url(str(candidate))
except ValueError:
continue
return DEFAULT_HTML_RUNTIME_BASE_URL
def _first_valid_tile(*candidates: str | None) -> str:
for candidate in candidates:
if not candidate or not str(candidate).strip():
continue
try:
return normalize_html_map_tile_url(str(candidate))
except ValueError:
continue
return DEFAULT_HTML_MAP_TILE_URL
@@ -0,0 +1,26 @@
BSD 2-Clause License
Copyright (c) 2010-2023, Volodymyr Agafonkin
Copyright (c) 2010-2011, CloudMade
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,5 +1,17 @@
/* 认知态势图渲染引擎 v2.4 — 超宽简报画布 2560×720 缩放适配 + 普通视口文档流自适应 */
const DESIGN_W = 2560, DESIGN_H = 720;
/* 认知态势图渲染引擎 v2.7 — 16:9(1920×1080,默认)与 32:9(2560×720)锁定画布,等比缩放适配视口 */
const ASPECTS = {
"16:9": { id: "16-9", w: 1920, h: 1080 },
"32:9": { id: "32-9", w: 2560, h: 720 }
};
const LEGACY_DESIGN = { w: 2560, h: 720 };
function resolveAspect(value) {
const raw = String(value ?? "").trim().toLowerCase().replace(/\s+/g, "").replace(/比/g, ":");
if (!raw) return null;
if (/^(16[:x×/]9|1920[x×*]1080|standard|widescreen|普通屏?|标准屏?)$/.test(raw)) return "16:9";
if (/^(32[:x×/]9|2560[x×*]720|ultrawide|ultra-wide|超宽屏?)$/.test(raw)) return "32:9";
return null;
}
/* 运行时依赖(样式/脚本/底图/国旗)由 Gateway 静态提供:页面里注入
window.__DF_SKILL_BASE__ = <gateway>/api/public/html-runtime/cognitive-situation-map
后,所有相对资源统一加该前缀;未注入时保持相对路径(本地整包部署仍可用)。 */
@@ -14,6 +26,7 @@ const MAPS = {
"first-island-chain": { label: "第一岛链", asset: "assets/maps/first-island-chain.png", heading: "第一岛链 · 西太平洋联动态势" },
"us-pacific": { label: "美国—太平洋", asset: "assets/maps/us-pacific.png", heading: "美国—太平洋 · 跨洋战略联动态势" },
"south-china-sea": { label: "南海", asset: "assets/maps/south-china-sea.png", heading: "南海 · 多方海上行动" },
"taiwan": { label: "台湾", asset: "assets/maps/taiwan.png", heading: "台湾 · 岛内及周边近景态势" },
"taiwan-strait": { label: "台海", asset: "assets/maps/taiwan-strait.png", heading: "台海 · 多域联动态势" },
"middle-east": { label: "中东", asset: "assets/maps/middle-east.png", heading: "中东 · 海湾安全态势" },
"kuril-islands": { label: "北方四岛", asset: "assets/maps/kuril-islands.png", heading: "北方四岛 · 海空博弈态势" },
@@ -428,6 +441,8 @@ function normalize(input) {
function render(next) {
state = normalize(next);
const { meta, template } = state;
applyAspect(template);
fitStage();
$("#appShell").dataset.theme = state.theme;
$("#scenarioKicker").textContent = meta.kicker || "认知态势研判";
$("#scenarioTitle").textContent = meta.title || "未命名态势图";
@@ -464,6 +479,42 @@ function renderTimeline() {
</article>`).join("")}</div>`;
}
$("#timelineRoot").innerHTML = `${timelineLegend(events)}<div class="tl-canvas">${content}</div>`;
scheduleTimelineDetailFit();
}
let timelineDetailFitFrame = 0;
function scheduleTimelineDetailFit() {
cancelAnimationFrame(timelineDetailFitFrame);
timelineDetailFitFrame = requestAnimationFrame(fitTimelineDetails);
}
function elementOuterHeight(element) {
const styles = getComputedStyle(element);
return element.offsetHeight
+ (Number.parseFloat(styles.marginTop) || 0)
+ (Number.parseFloat(styles.marginBottom) || 0);
}
function fitTimelineDetails() {
timelineDetailFitFrame = 0;
document.querySelectorAll("#timelineRoot .ev-card > p, #timelineRoot .tl-dual-card > p").forEach(paragraph => {
const card = paragraph.parentElement;
if (!card || card.clientHeight <= 0) return;
const cardStyles = getComputedStyle(card);
const paragraphStyles = getComputedStyle(paragraph);
const lineHeight = Number.parseFloat(paragraphStyles.lineHeight);
if (!Number.isFinite(lineHeight) || lineHeight <= 0) return;
const contentHeight = card.clientHeight
- (Number.parseFloat(cardStyles.paddingTop) || 0)
- (Number.parseFloat(cardStyles.paddingBottom) || 0);
const fixedHeight = Array.from(card.children)
.filter(child => child !== paragraph)
.reduce((height, child) => height + elementOuterHeight(child), 0);
const paragraphMargins = (Number.parseFloat(paragraphStyles.marginTop) || 0)
+ (Number.parseFloat(paragraphStyles.marginBottom) || 0);
const availableHeight = Math.max(0, contentHeight - fixedHeight - paragraphMargins);
const lines = Math.max(1, Math.floor((availableHeight + 0.5) / lineHeight));
paragraph.style.setProperty("--timeline-detail-lines", String(lines));
});
}
function dualCard(e, adverse = false, index = -1) {
if (!e) return "";
@@ -920,15 +971,28 @@ function fillSelect(el, source, labelKey) { el.innerHTML = Object.entries(source
function setupStudio() {
fillSelect($("#regionSelect"), MAPS, "label"); fillSelect($("#timelineSelect"), TIMELINES); fillSelect($("#infoSelect"), INFO_TYPES); fillSelect($("#themeSelect"), THEMES);
$("#variantSelect").innerHTML = VARIANTS.map(v => `<option value="${v.id}">${v.label}</option>`).join("");
$("#templateCatalog").innerHTML = `<div class="catalog-card"><b>地图底图 28</b>7 个地区 × 4 种底图</div><div class="catalog-card"><b>标注类别 4</b>人物 / 事件 / 舆情 / 认知</div><div class="catalog-card"><b>箭头线型 5</b>突击 / 推进 / 补给 / 影响 / 阻拦</div><div class="catalog-card"><b>配色主题 4</b>全局 CSS 变量驱动</div>`;
["regionSelect", "variantSelect", "timelineSelect", "infoSelect", "themeSelect"].forEach(id => $("#" + id).addEventListener("change", e => {
let draft; try { draft = JSON.parse($("#jsonEditor").value); } catch { return; }
const key = { regionSelect: "region", variantSelect: "mapVariant", timelineSelect: "timeline", infoSelect: "info" }[id];
if (id === "themeSelect") draft.theme = e.target.value; else { draft.template ||= {}; draft.template[key] = e.target.value; }
$("#jsonEditor").value = JSON.stringify(draft, null, 2); validateEditor();
}));
$("#templateCatalog").innerHTML = `<div class="catalog-card"><b>画面比例 2</b>16:9 标准 / 32:9 超宽</div><div class="catalog-card"><b>地图底图 28</b>7 个地区 × 4 种底图</div><div class="catalog-card"><b>标注类别 4</b>人物 / 事件 / 舆情 / 认知</div><div class="catalog-card"><b>箭头线型 5</b>突击 / 推进 / 补给 / 影响 / 阻拦</div>`;
["regionSelect", "variantSelect", "timelineSelect", "infoSelect", "themeSelect", "aspectSelect"].forEach(id => {
const control = $("#" + id);
if (!control) return;
control.addEventListener("change", e => {
let draft; try { draft = JSON.parse($("#jsonEditor").value); } catch { return; }
const key = { regionSelect: "region", variantSelect: "mapVariant", timelineSelect: "timeline", infoSelect: "info" }[id];
draft.template ||= {};
if (id === "themeSelect") draft.theme = e.target.value;
else if (id === "aspectSelect") {
if (e.target.value) draft.template.aspect = e.target.value;
else delete draft.template.aspect;
} else draft.template[key] = e.target.value;
$("#jsonEditor").value = JSON.stringify(draft, null, 2); validateEditor();
});
});
}
function syncControls() {
$("#regionSelect").value = state.template.region; $("#variantSelect").value = state.template.mapVariant; $("#timelineSelect").value = state.template.timeline; $("#infoSelect").value = state.template.info; $("#themeSelect").value = state.theme;
const aspectSelect = $("#aspectSelect");
if (aspectSelect) aspectSelect.value = resolveAspect(state.template.aspect) || "";
}
function syncControls() { $("#regionSelect").value = state.template.region; $("#variantSelect").value = state.template.mapVariant; $("#timelineSelect").value = state.template.timeline; $("#infoSelect").value = state.template.info; $("#themeSelect").value = state.theme; }
function validateEditor() { try { JSON.parse($("#jsonEditor").value); $("#jsonStatus").textContent = "JSON 有效"; $("#jsonStatus").style.color = "var(--success)"; return true; } catch (e) { $("#jsonStatus").textContent = `第 ${e.message.match(/position (\d+)/)?.[1] || "?"} 位存在错误`; $("#jsonStatus").style.color = "var(--danger)"; return false; } }
function toast(message) { const el = $("#toast"); el.textContent = message; el.classList.add("show"); clearTimeout(toast.timer); toast.timer = setTimeout(() => el.classList.remove("show"), 1800); }
@@ -941,21 +1005,43 @@ $("#downloadJson").addEventListener("click", () => { const blob = new Blob([$("#
function registerModelTools() {
const context = document.modelContext; if (!context?.registerTool) return;
const tool = { name: "render_situation_config", title: "渲染认知态势图", description: "用完整 JSON 配置更新当前认知态势图,组合地图、标注、箭头、时间轴、关键信息与主题。", inputSchema: { type: "object", properties: { config: { type: "object" } }, required: ["config"], additionalProperties: false }, annotations: { readOnlyHint: false, untrustedContentHint: false }, execute({ config }) { if (!config || typeof config !== "object") throw new Error("config 必须是对象"); render(config); return { status: "rendered", title: state.meta.title, region: state.template.region, timeline: state.template.timeline, info: state.template.info, theme: state.theme }; } };
const tool = { name: "render_situation_config", title: "渲染认知态势图", description: "用完整 JSON 配置更新当前认知态势图,组合画面比例、地图、标注、箭头、时间轴、关键信息与主题。template.aspect 取 16:9 或 32:9。", inputSchema: { type: "object", properties: { config: { type: "object" } }, required: ["config"], additionalProperties: false }, annotations: { readOnlyHint: false, untrustedContentHint: false }, execute({ config }) { if (!config || typeof config !== "object") throw new Error("config 必须是对象"); render(config); return { status: "rendered", title: state.meta.title, region: state.template.region, aspect: resolveAspect(state.template.aspect) || "adaptive", timeline: state.template.timeline, info: state.template.info, theme: state.theme }; } };
try { Promise.resolve(context.registerTool(tool)).catch(() => { }); } catch { }
}
/* ============ 缩放适配(双模式) ============
超宽视口(宽高比 >= 2.05,如简报大屏):保留 2560×720 固定画布,整体等比缩放居中;
普通视口(普通浏览器窗口 / 系统内嵌 iframe):切换 flow-mode 文档流布局,
取消固定画布与缩放,地图优先纵向堆叠,页面可滚动。 */
/* ============ 缩放适配 ============
template.aspect 为 16:9 / 32:9 时锁定对应设计画布,整页等比缩放居中。
未写比例的旧页面仍按视口切换:超宽屏走 2560×720,普通窗口走 flow-mode。 */
const WIDE_VIEWPORT_RATIO = 2.05;
function applyAspect(template) {
const key = resolveAspect(template?.aspect);
const root = document.documentElement;
if (!key) {
delete root.dataset.aspect;
return null;
}
root.dataset.aspect = ASPECTS[key].id;
return ASPECTS[key];
}
function fitStage() {
const wide = window.innerWidth / Math.max(window.innerHeight, 1) >= WIDE_VIEWPORT_RATIO;
document.documentElement.classList.toggle("flow-mode", !wide);
const locked = document.documentElement.dataset.aspect === "16-9" ? ASPECTS["16:9"]
: document.documentElement.dataset.aspect === "32-9" ? ASPECTS["32:9"] : null;
const stage = $("#appShell");
const root = document.documentElement;
if (locked) {
root.classList.remove("flow-mode");
stage.style.width = `${locked.w}px`;
stage.style.height = `${locked.h}px`;
const scale = Math.min(window.innerWidth / locked.w, window.innerHeight / locked.h);
stage.style.transform = `translate(-50%,-50%) scale(${scale})`;
return;
}
stage.style.width = "";
stage.style.height = "";
const wide = window.innerWidth / Math.max(window.innerHeight, 1) >= WIDE_VIEWPORT_RATIO;
root.classList.toggle("flow-mode", !wide);
if (wide) {
const scale = Math.min(window.innerWidth / DESIGN_W, window.innerHeight / DESIGN_H);
const scale = Math.min(window.innerWidth / LEGACY_DESIGN.w, window.innerHeight / LEGACY_DESIGN.h);
stage.style.transform = `translate(-50%,-50%) scale(${scale})`;
} else {
stage.style.transform = "";
@@ -965,10 +1051,11 @@ let resizeTimer = null;
window.addEventListener("resize", () => {
fitStage();
clearTimeout(resizeTimer);
resizeTimer = setTimeout(() => { if (state) { renderFlows(); renderMarkers(); updateMapBackgroundSizes(); } }, 120);
resizeTimer = setTimeout(() => { if (state) { renderFlows(); renderMarkers(); updateMapBackgroundSizes(); scheduleTimelineDetailFit(); } }, 120);
});
setupStudio();
fitStage();
render(injectedScenario || SCENARIOS[0]);
if (document.fonts?.ready) document.fonts.ready.then(scheduleTimelineDetailFit);
registerModelTools();
@@ -21,7 +21,8 @@
"type": "object",
"required": ["region", "timeline", "info"],
"properties": {
"region": {"type": "string", "minLength": 1, "description": "Built-ins: middle-east, south-china-sea, taiwan-strait, philippines-surrounding, first-island-chain, us-pacific, kuril-islands, russia-ukraine; custom values require mapAsset."},
"aspect": {"enum": ["16:9", "32:9"], "description": "16:9 (1920x1080) is the default when the user does not specify a ratio. 32:9 (2560x720) is only for an explicit ultra-wide request."},
"region": {"type": "string", "minLength": 1, "description": "Built-ins: middle-east, south-china-sea, taiwan, taiwan-strait, philippines-surrounding, first-island-chain, us-pacific, kuril-islands, russia-ukraine; custom values require mapAsset."},
"mapVariant": {"enum": ["terrain", "maritime", "tactical", "brief"]},
"timeline": {"enum": ["single", "dual", "list"]},
"info": {"enum": ["outline", "text-chart", "text-image", "chart", "image"]},
@@ -4,8 +4,8 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="theme-color" content="#030910">
<meta name="description" content="由 JSON 驱动的 32:9 认知态势图渲染引擎 v2.2:超宽简报画布 2560×720 缩放适配 + 普通视口文档流自适应,四类标注体系与军标式渐变箭头。">
<title>认知态势图引擎 v2.2</title>
<meta name="description" content="由 JSON 驱动的认知态势图渲染引擎 v2.7:16:9(1920×1080,默认)与 32:9(2560×720)锁定画布,等比缩放适配视口。">
<title>认知态势图引擎 v2.7</title>
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%2307111f'/%3E%3Ccircle cx='16' cy='16' r='10' fill='none' stroke='%234bd4ff' stroke-width='2'/%3E%3Cpath d='M6 18c5-5 11-6 20-5M9 24c5-3 9-4 14-3' fill='none' stroke='%23f4b942' stroke-width='2'/%3E%3Ccircle cx='20' cy='12' r='3' fill='%23ff5b55'/%3E%3C/svg%3E">
<link rel="stylesheet" href="styles.css">
</head>
@@ -116,6 +116,11 @@
<label>时间轴模板<select id="timelineSelect"></select></label>
<label>关键信息模板<select id="infoSelect"></select></label>
<label>配色主题<select id="themeSelect"></select></label>
<label>画面比例<select id="aspectSelect">
<option value="">跟随视口</option>
<option value="16:9">16:9 标准</option>
<option value="32:9">32:9 超宽</option>
</select></label>
<div class="template-catalog" id="templateCatalog"></div>
</section>
<section class="json-editor-wrap">
@@ -124,7 +129,7 @@
<span id="jsonStatus">JSON 有效</span>
</div>
<textarea id="jsonEditor" spellcheck="false" aria-describedby="editorHelp"></textarea>
<p id="editorHelp">修改 template、theme、markers、flows、events 等字段后应用。markers 支持 category/icon/anchor,flows 支持 assault/advance/supply/influence/block 五种线型。</p>
<p id="editorHelp">修改 template.aspect(16:9 或 32:9)、theme、markers、flows、events 等字段后应用。未写 aspect 的旧页面仍跟随视口;新生成页面默认 16:9。</p>
</section>
</div>
<footer class="studio-footer">
@@ -1,4 +1,4 @@
/* 认知态势图 v2.2 — 超宽简报画布 2560×720 + 普通视口文档流自适应 */
/* 认知态势图 v2.7 — 16:9(1920×1080)与 32:9(2560×720)锁定画布;未指定比例的旧页面仍按视口自适应 */
:root {
color-scheme: dark;
--bg: #030910;
@@ -118,8 +118,7 @@ h1 { margin: 0; font-size: 36px; line-height: 1.05; letter-spacing: .03em; white
.tl-single .ev-card, .tl-list-item .ev-card { display: flex; flex-direction: column; justify-content: center; }
.tl-list-item .ev-card { padding: 6px 10px; }
.tl-single .ev-card p, .tl-list-item .ev-card p { margin-top: 3px; }
.tl-single.dense .ev-card p, .tl-list.dense .ev-card p { -webkit-line-clamp: 1; }
.ev-card p, .tl-list-item p, .tl-dual-card p { font-size: 14px; line-height: 1.4; color: var(--muted); margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.ev-card p, .tl-list-item p, .tl-dual-card p { font-size: 14px; line-height: 1.4; color: var(--muted); margin: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--timeline-detail-lines, 2); overflow: hidden; }
.identity-badge { flex: 0 0 auto; display: inline-grid; place-items: center; overflow: hidden; border: 1px solid rgba(255, 255, 255, .3); background: #0a1c2d; border-radius: 2px; }
.identity-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.org-badge { color: #eaf7ff; font: 900 10px/1 var(--mono); letter-spacing: .04em; border-color: var(--cat, var(--line-strong)); }
@@ -377,4 +376,16 @@ html.flow-mode body { overflow-y: auto; }
.flow-mode .intel-stack { grid-template-rows: minmax(176px, 1fr) minmax(0, 1.5fr) minmax(150px, 1fr); }
.flow-mode .judgement-strip { min-height: 66px; height: auto; padding: 10px 18px; }
/* 锁定画布:16:9 比 32:9 更窄更高,侧栏收窄,把多出来的高度分给地图和信息栏 */
html[data-aspect="16-9"] .stage { width: 1920px; height: 1080px; }
html[data-aspect="32-9"] .stage { width: 2560px; height: 720px; }
html[data-aspect="16-9"] .topbar { gap: 16px; padding: 0 14px; }
html[data-aspect="16-9"] h1 { font-size: 30px; }
html[data-aspect="16-9"] .scenario-meta > span { padding: 8px 10px; }
html[data-aspect="16-9"] .board { grid-template-columns: 360px minmax(0, 1fr) 420px; }
html[data-aspect="16-9"] .intel-stack { grid-template-rows: minmax(210px, .95fr) minmax(0, 1.35fr) minmax(190px, .9fr); }
html[data-aspect="16-9"] .judgement-strip { gap: 14px; padding: 0 14px; }
html[data-aspect="16-9"] .judgement-strip p { font-size: 16px; }
html[data-aspect="16-9"] .signal { min-width: 76px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
@@ -33,20 +33,35 @@
if (target.clientWidth < 40) target.style.width = "100%";
}
// 多页面门户会用 display:none 隐藏非当前页;此时 ECharts 以 0 宽初始化,
// 多页面门户会用 display:none 隐藏非当前页;此时 G6/ECharts 以 0 宽初始化,
// 即使稍后页面显示也只会在浏览器 resize 时才恢复。等容器真正可见后再
// 创建实例,并把之后的面板/iframe 尺寸变化同步给图表。
// 创建实例,并把之后的面板/iframe 尺寸变化同步给图表和流程图。
function closestLogicalPage(target) {
var node = target;
while (node && node !== document.body) {
if (node.classList && (node.classList.contains("page") || node.classList.contains("view"))) {
return node;
}
node = node.parentNode;
}
return null;
}
function whenVisible(target, callback) {
var observer = null;
var intersection = null;
var attempts = 0;
var timer = null;
var completed = false;
function cleanup() {
if (observer) observer.disconnect();
if (intersection) intersection.disconnect();
if (timer) window.clearTimeout(timer);
observer = null;
intersection = null;
timer = null;
window.removeEventListener("hashchange", check);
}
function check() {
@@ -63,8 +78,19 @@
if (window.ResizeObserver) {
observer = new window.ResizeObserver(check);
observer.observe(target);
return;
var page = closestLogicalPage(target);
if (page) observer.observe(page);
}
if (window.IntersectionObserver) {
intersection = new window.IntersectionObserver(function (entries) {
for (var i = 0; i < entries.length; i += 1) {
if (entries[i].isIntersecting) check();
}
}, { threshold: 0 });
intersection.observe(target);
}
window.addEventListener("hashchange", check);
if (window.ResizeObserver) return;
(function poll() {
if (check() || attempts >= 120) return;
@@ -73,6 +99,26 @@
})();
}
function bindCanvasResize(target, resize) {
var frame = null;
function schedule() {
if (frame !== null) {
window.cancelAnimationFrame(frame);
}
frame = window.requestAnimationFrame(function () {
frame = null;
if (target.clientWidth >= 40 && target.clientHeight >= 40) {
resize();
}
});
}
if (window.ResizeObserver) {
(new window.ResizeObserver(schedule)).observe(target);
}
window.addEventListener("resize", schedule);
window.addEventListener("hashchange", schedule);
}
function bindEChartsResize(target, chart) {
var frame = null;
function resize() {
@@ -86,10 +132,7 @@
}
});
}
if (window.ResizeObserver) {
(new window.ResizeObserver(resize)).observe(target);
}
window.addEventListener("resize", resize);
bindCanvasResize(target, resize);
}
function escapeHtml(value) {
@@ -106,6 +149,11 @@
return [lng, lat];
}
function leafletPoint(value) {
var coordinate = geoPoint(value);
return coordinate ? [coordinate[1], coordinate[0]] : null;
}
function initCharts() {
var items = blocks("data-df-chart");
for (var i = 0; i < items.length; i += 1) {
@@ -369,6 +417,85 @@
}
}
function initMaps() {
var items = blocks("data-df-map");
for (var i = 0; i < items.length; i += 1) {
var block = items[i];
var target = document.getElementById(block.getAttribute("data-df-map"));
if (!target) continue;
var data = parse(block, target);
if (!data) continue;
if (!window.L) {
showError(target, "Leaflet 运行库加载失败");
continue;
}
size(target);
(function (mapTarget, mapData) {
whenVisible(mapTarget, function () {
try {
mapTarget.setAttribute("role", "region");
mapTarget.setAttribute("aria-label", mapData.title || "地图");
var map = window.L.map(mapTarget, { zoomControl: true });
var config = window.DEERFLOW_HTML_RUNTIME_CONFIG || {};
var tileUrl = config.mapTileUrl;
if (tileUrl) {
var tileErrors = 0;
window.L.tileLayer(tileUrl, { maxZoom: 20, attribution: /google/i.test(tileUrl) ? "Google" : "" })
.on("tileerror", function () {
tileErrors += 1;
if (tileErrors === 3) showError(mapTarget, "地图瓦片加载失败;点、线、面数据仍可查看");
})
.addTo(map);
}
var bounds = [];
var markers = mapData.markers || [];
for (var m = 0; m < markers.length; m += 1) {
var marker = markers[m];
var markerPoint = leafletPoint(marker.coordinate);
if (!markerPoint) continue;
bounds.push(markerPoint);
var dot = window.L.circleMarker(markerPoint, {
radius: 7, color: "#1d4ed8", weight: 2, fillColor: "#3b82f6", fillOpacity: 0.9
}).addTo(map);
dot.bindPopup("<strong>" + escapeHtml(marker.name || "地点") + "</strong>" +
(marker.description ? "<br>" + escapeHtml(marker.description) : ""));
dot.bindTooltip(escapeHtml(marker.name || "地点"));
}
var lines = mapData.lines || [];
for (var l = 0; l < lines.length; l += 1) {
var linePoints = [];
var rawLine = lines[l].coordinates || [];
for (var p = 0; p < rawLine.length; p += 1) {
var linePoint = leafletPoint(rawLine[p]);
if (linePoint) { linePoints.push(linePoint); bounds.push(linePoint); }
}
if (linePoints.length > 1) window.L.polyline(linePoints, { color: "#2563eb", weight: 3, opacity: 0.85 }).addTo(map);
}
var polygons = mapData.polygons || [];
for (var g = 0; g < polygons.length; g += 1) {
var polygonPoints = [];
var rawPolygon = polygons[g].coordinates || [];
for (var q = 0; q < rawPolygon.length; q += 1) {
var polygonPoint = leafletPoint(rawPolygon[q]);
if (polygonPoint) { polygonPoints.push(polygonPoint); bounds.push(polygonPoint); }
}
if (polygonPoints.length > 2) window.L.polygon(polygonPoints, {
color: "#7c3aed", weight: 2, fillColor: "#8b5cf6", fillOpacity: 0.2
}).addTo(map);
}
var center = leafletPoint(mapData.center);
if (center) map.setView(center, Number(mapData.zoom) || 6);
else if (bounds.length) map.fitBounds(bounds, { padding: [28, 28], maxZoom: Number(mapData.zoom) || 10 });
else map.setView([35.8617, 104.1954], Number(mapData.zoom) || 4);
bindCanvasResize(mapTarget, function () { map.invalidateSize(); });
} catch (error) {
showError(mapTarget, "地图渲染失败:" + (error && error.message ? error.message : "请检查地图数据"));
}
});
})(target, data);
}
}
function initFlows() {
var items = blocks("data-df-flow");
for (var i = 0; i < items.length; i += 1) {
@@ -381,60 +508,69 @@
showError(target, "AntV G6 运行库加载失败");
continue;
}
try {
size(target);
var nodes = data.nodes || [];
var edges = data.edges || [];
var rankDirection = data.direction === "TB" ? "TB" : "LR";
var colors = {
start: ["#dcfce7", "#22c55e", "#14532d"], end: ["#ede9fe", "#8b5cf6", "#4c1d95"],
decision: ["#fef3c7", "#f59e0b", "#78350f"], risk: ["#fee2e2", "#ef4444", "#7f1d1d"],
process: ["#dbeafe", "#3b82f6", "#1e3a8a"], stage: ["#e0e7ff", "#6366f1", "#312e81"],
task: ["#f1f5f9", "#94a3b8", "#1e293b"]
};
var typeNames = { start: "开始", end: "结束", decision: "判断", risk: "异常", process: "处理", stage: "阶段", task: "任务" };
var graphData = { nodes: [], edges: [] };
for (var n = 0; n < nodes.length; n += 1) {
var node = nodes[n];
var pair = colors[node.type] || colors.task;
graphData.nodes.push({ id: String(node.id), data: {
label: node.label || node.id, description: node.description || "",
typeName: typeNames[node.type] || typeNames.task,
fill: node.color || pair[0], stroke: pair[1], textColor: pair[2], terminal: node.type === "start" || node.type === "end"
}});
}
for (var e = 0; e < edges.length; e += 1) {
graphData.edges.push({ source: String(edges[e].source), target: String(edges[e].target), data: { label: edges[e].label || "" } });
}
var graph = new window.G6.Graph({
container: target, data: graphData, autoFit: "view", padding: 72, zoomRange: [0.1, 2], animation: false,
layout: { type: "dagre", rankdir: rankDirection, nodesep: 44, ranksep: 60 },
node: { type: "rect", style: {
size: function (d) {
var width = Math.max(190, Math.min(260, 118 + String(d.data.label || "").length * 15));
return [width, 68];
},
radius: function (d) { return d.data.terminal ? 38 : 16; },
opacity: 1, fillOpacity: 1, strokeOpacity: 1,
fill: function (d) { return d.data.fill; }, stroke: function (d) { return d.data.stroke; }, lineWidth: 2.5,
shadowColor: "rgba(15,23,42,0.10)", shadowBlur: 12, shadowOffsetY: 4,
labelText: function (d) { return d.data.typeName + " · " + d.data.label; },
labelPlacement: "center", labelFill: function (d) { return d.data.textColor; }, labelOpacity: 1, labelFontSize: 16, labelFontWeight: 700,
labelWordWrap: true, labelMaxWidth: 220, cursor: "grab"
}},
edge: { type: "polyline", style: {
opacity: 1, strokeOpacity: 1, stroke: "#94a3b8", lineWidth: 2.25, radius: 16, endArrow: true,
labelText: function (d) { return d.data.label; }, labelFill: "#334155", labelOpacity: 1, labelFontSize: 12,
labelBackground: true, labelBackgroundFill: "#ffffff", labelBackgroundRadius: 6, labelPadding: [4, 7]
}},
behaviors: ["drag-canvas", "zoom-canvas", "drag-element"]
size(target);
(function (flowTarget, flowData) {
whenVisible(flowTarget, function () {
try {
var nodes = flowData.nodes || [];
var edges = flowData.edges || [];
var rankDirection = flowData.direction === "TB" ? "TB" : "LR";
var colors = {
start: ["#dcfce7", "#22c55e", "#14532d"], end: ["#ede9fe", "#8b5cf6", "#4c1d95"],
decision: ["#fef3c7", "#f59e0b", "#78350f"], risk: ["#fee2e2", "#ef4444", "#7f1d1d"],
process: ["#dbeafe", "#3b82f6", "#1e3a8a"], stage: ["#e0e7ff", "#6366f1", "#312e81"],
task: ["#f1f5f9", "#94a3b8", "#1e293b"]
};
var typeNames = { start: "开始", end: "结束", decision: "判断", risk: "异常", process: "处理", stage: "阶段", task: "任务" };
var graphData = { nodes: [], edges: [] };
for (var n = 0; n < nodes.length; n += 1) {
var node = nodes[n];
var pair = colors[node.type] || colors.task;
graphData.nodes.push({ id: String(node.id), data: {
label: node.label || node.id, description: node.description || "",
typeName: typeNames[node.type] || typeNames.task,
fill: node.color || pair[0], stroke: pair[1], textColor: pair[2], terminal: node.type === "start" || node.type === "end"
}});
}
for (var e = 0; e < edges.length; e += 1) {
graphData.edges.push({ source: String(edges[e].source), target: String(edges[e].target), data: { label: edges[e].label || "" } });
}
flowTarget.setAttribute("role", "img");
flowTarget.setAttribute("aria-label", (flowData.title || "流程图") + ",包含 " + nodes.length + " 个步骤和 " + edges.length + " 条连线");
var graph = new window.G6.Graph({
container: flowTarget, data: graphData, autoFit: "view", padding: 72, zoomRange: [0.1, 2], animation: false,
layout: { type: "dagre", rankdir: rankDirection, nodesep: 44, ranksep: 60 },
node: { type: "rect", style: {
size: function (d) {
var width = Math.max(190, Math.min(260, 118 + String(d.data.label || "").length * 15));
return [width, 68];
},
radius: function (d) { return d.data.terminal ? 38 : 16; },
opacity: 1, fillOpacity: 1, strokeOpacity: 1,
fill: function (d) { return d.data.fill; }, stroke: function (d) { return d.data.stroke; }, lineWidth: 2.5,
shadowColor: "rgba(15,23,42,0.10)", shadowBlur: 12, shadowOffsetY: 4,
labelText: function (d) { return d.data.typeName + " · " + d.data.label; },
labelPlacement: "center", labelFill: function (d) { return d.data.textColor; }, labelOpacity: 1, labelFontSize: 16, labelFontWeight: 700,
labelWordWrap: true, labelMaxWidth: 220, cursor: "grab"
}},
edge: { type: "polyline", style: {
opacity: 1, strokeOpacity: 1, stroke: "#94a3b8", lineWidth: 2.25, radius: 16, endArrow: true,
labelText: function (d) { return d.data.label; }, labelFill: "#334155", labelOpacity: 1, labelFontSize: 12,
labelBackground: true, labelBackgroundFill: "#ffffff", labelBackgroundRadius: 6, labelPadding: [4, 7]
}},
behaviors: ["drag-canvas", "zoom-canvas", "drag-element"]
});
var rendered = graph.render();
if (rendered && rendered.catch) rendered.catch(function (error) { showError(flowTarget, "流程图渲染失败:" + error.message); });
bindCanvasResize(flowTarget, function () {
if (graph.resize) graph.resize();
if (graph.fitView) graph.fitView();
});
} catch (error) {
showError(flowTarget, "流程图渲染失败:" + (error && error.message ? error.message : "请检查流程数据"));
}
});
var rendered = graph.render();
if (rendered && rendered.catch) rendered.catch(function (error) { showError(target, "流程图渲染失败:" + error.message); });
(function (instance) { window.addEventListener("resize", function () { instance.resize(); }); })(graph);
} catch (error) {
showError(target, "流程图渲染失败:" + (error && error.message ? error.message : "请检查流程数据"));
}
})(target, data);
}
}
@@ -442,5 +578,6 @@
initFlows();
initCharts();
initGeoMaps();
initMaps();
});
})();
@@ -0,0 +1,661 @@
/* required styles */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
position: absolute;
left: 0;
top: 0;
}
.leaflet-container {
overflow: hidden;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-user-drag: none;
}
/* Prevents IE11 from highlighting tiles in blue */
.leaflet-tile::selection {
background: transparent;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
image-rendering: -webkit-optimize-contrast;
}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
width: 1600px;
height: 1600px;
-webkit-transform-origin: 0 0;
}
.leaflet-marker-icon,
.leaflet-marker-shadow {
display: block;
}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg {
max-width: none !important;
max-height: none !important;
}
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
max-width: none !important;
max-height: none !important;
width: auto;
padding: 0;
}
.leaflet-container img.leaflet-tile {
/* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */
mix-blend-mode: plus-lighter;
}
.leaflet-container.leaflet-touch-zoom {
-ms-touch-action: pan-x pan-y;
touch-action: pan-x pan-y;
}
.leaflet-container.leaflet-touch-drag {
-ms-touch-action: pinch-zoom;
/* Fallback for FF which doesn't support pinch-zoom */
touch-action: none;
touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom {
-ms-touch-action: none;
touch-action: none;
}
.leaflet-container {
-webkit-tap-highlight-color: transparent;
}
.leaflet-container a {
-webkit-tap-highlight-color: rgba(51, 181, 229, 0.4);
}
.leaflet-tile {
filter: inherit;
visibility: hidden;
}
.leaflet-tile-loaded {
visibility: inherit;
}
.leaflet-zoom-box {
width: 0;
height: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
z-index: 800;
}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
-moz-user-select: none;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-vml-shape {
width: 1px;
height: 1px;
}
.lvml {
behavior: url(#default#VML);
display: inline-block;
position: absolute;
}
/* control positioning */
.leaflet-control {
position: relative;
z-index: 800;
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
position: absolute;
z-index: 1000;
pointer-events: none;
}
.leaflet-top {
top: 0;
}
.leaflet-right {
right: 0;
}
.leaflet-bottom {
bottom: 0;
}
.leaflet-left {
left: 0;
}
.leaflet-control {
float: left;
clear: both;
}
.leaflet-right .leaflet-control {
float: right;
}
.leaflet-top .leaflet-control {
margin-top: 10px;
}
.leaflet-bottom .leaflet-control {
margin-bottom: 10px;
}
.leaflet-left .leaflet-control {
margin-left: 10px;
}
.leaflet-right .leaflet-control {
margin-right: 10px;
}
/* zoom and fade animations */
.leaflet-fade-anim .leaflet-popup {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1;
}
.leaflet-zoom-animated {
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
}
svg.leaflet-zoom-animated {
will-change: transform;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
-webkit-transition: none;
-moz-transition: none;
transition: none;
}
.leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden;
}
/* cursors */
.leaflet-interactive {
cursor: pointer;
}
.leaflet-grab {
cursor: -webkit-grab;
cursor: -moz-grab;
cursor: grab;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
cursor: crosshair;
}
.leaflet-popup-pane,
.leaflet-control {
cursor: auto;
}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
pointer-events: none;
}
.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive,
svg.leaflet-image-layer.leaflet-interactive path {
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
/* visual tweaks */
.leaflet-container {
background: #ddd;
outline-offset: 1px;
}
.leaflet-container a {
color: #0078A8;
}
.leaflet-zoom-box {
border: 2px dotted #38f;
background: rgba(255,255,255,0.5);
}
/* general typography */
.leaflet-container {
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
font-size: 12px;
font-size: 0.75rem;
line-height: 1.5;
}
/* general toolbar styles */
.leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a {
background-color: #fff;
border-bottom: 1px solid #ccc;
width: 26px;
height: 26px;
line-height: 26px;
display: block;
text-align: center;
text-decoration: none;
color: black;
}
.leaflet-bar a,
.leaflet-control-layers-toggle {
background-position: 50% 50%;
background-repeat: no-repeat;
display: block;
}
.leaflet-bar a:hover,
.leaflet-bar a:focus {
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.leaflet-bar a:last-child {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
.leaflet-bar a.leaflet-disabled {
cursor: default;
background-color: #f4f4f4;
color: #bbb;
}
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
line-height: 30px;
}
.leaflet-touch .leaflet-bar a:first-child {
border-top-left-radius: 2px;
border-top-right-radius: 2px;
}
.leaflet-touch .leaflet-bar a:last-child {
border-bottom-left-radius: 2px;
border-bottom-right-radius: 2px;
}
/* zoom control */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out {
font-size: 22px;
}
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
background: #fff;
border-radius: 5px;
}
.leaflet-control-layers-toggle {
background-image: url(images/layers.png);
width: 36px;
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png);
background-size: 26px 26px;
}
.leaflet-touch .leaflet-control-layers-toggle {
width: 44px;
height: 44px;
}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none;
}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block;
position: relative;
}
.leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px;
color: #333;
background: #fff;
}
.leaflet-control-layers-scrollbar {
overflow-y: scroll;
overflow-x: hidden;
padding-right: 5px;
}
.leaflet-control-layers-selector {
margin-top: 2px;
position: relative;
top: 1px;
}
.leaflet-control-layers label {
display: block;
font-size: 13px;
font-size: 1.08333em;
}
.leaflet-control-layers-separator {
height: 0;
border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px;
}
/* Default icon URLs */
.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */
background-image: url(images/marker-icon.png);
}
/* attribution and scale controls */
.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.8);
margin: 0;
}
.leaflet-control-attribution,
.leaflet-control-scale-line {
padding: 0 5px;
color: #333;
line-height: 1.4;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover,
.leaflet-control-attribution a:focus {
text-decoration: underline;
}
.leaflet-attribution-flag {
display: inline !important;
vertical-align: baseline !important;
width: 1em;
height: 0.6669em;
}
.leaflet-left .leaflet-control-scale {
margin-left: 5px;
}
.leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px;
}
.leaflet-control-scale-line {
border: 2px solid #777;
border-top: none;
line-height: 1.1;
padding: 2px 5px 1px;
white-space: nowrap;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: rgba(255, 255, 255, 0.8);
text-shadow: 1px 1px #fff;
}
.leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777;
border-bottom: none;
margin-top: -2px;
}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777;
}
.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
box-shadow: none;
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
/* popup */
.leaflet-popup {
position: absolute;
text-align: center;
margin-bottom: 20px;
}
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 24px 13px 20px;
line-height: 1.3;
font-size: 13px;
font-size: 1.08333em;
min-height: 1px;
}
.leaflet-popup-content p {
margin: 17px 0;
margin: 1.3em 0;
}
.leaflet-popup-tip-container {
width: 40px;
height: 20px;
position: absolute;
left: 50%;
margin-top: -1px;
margin-left: -20px;
overflow: hidden;
pointer-events: none;
}
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0;
pointer-events: auto;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
background: white;
color: #333;
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}
.leaflet-container a.leaflet-popup-close-button {
position: absolute;
top: 0;
right: 0;
border: none;
text-align: center;
width: 24px;
height: 24px;
font: 16px/24px Tahoma, Verdana, sans-serif;
color: #757575;
text-decoration: none;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover,
.leaflet-container a.leaflet-popup-close-button:focus {
color: #585858;
}
.leaflet-popup-scrolled {
overflow: auto;
}
.leaflet-oldie .leaflet-popup-content-wrapper {
-ms-zoom: 1;
}
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}
.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999;
}
/* div icon */
.leaflet-div-icon {
background: #fff;
border: 1px solid #666;
}
/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
position: absolute;
padding: 6px;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
color: #222;
white-space: nowrap;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-tooltip.leaflet-interactive {
cursor: pointer;
pointer-events: auto;
}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
position: absolute;
pointer-events: none;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Directions */
.leaflet-tooltip-bottom {
margin-top: 6px;
}
.leaflet-tooltip-top {
margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
left: 50%;
margin-left: -6px;
}
.leaflet-tooltip-top:before {
bottom: 0;
margin-bottom: -12px;
border-top-color: #fff;
}
.leaflet-tooltip-bottom:before {
top: 0;
margin-top: -12px;
margin-left: -6px;
border-bottom-color: #fff;
}
.leaflet-tooltip-left {
margin-left: -6px;
}
.leaflet-tooltip-right {
margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
top: 50%;
margin-top: -6px;
}
.leaflet-tooltip-left:before {
right: 0;
margin-right: -12px;
border-left-color: #fff;
}
.leaflet-tooltip-right:before {
left: 0;
margin-left: -12px;
border-right-color: #fff;
}
/* Printing */
@media print {
/* Prevent printers from removing background-images of controls. */
.leaflet-control {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
@@ -0,0 +1,6 @@
/* @preserve
* Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var e,i,n=1,o=arguments.length;n<o;n++)for(e in i=arguments[n])t[e]=i[e];return t}var R=Object.create||function(t){return N.prototype=t,new N};function N(){}function a(t,e){var i,n=Array.prototype.slice;return t.bind?t.bind.apply(t,n.call(arguments,1)):(i=n.call(arguments,2),function(){return t.apply(e,i.length?i.concat(n.call(arguments)):arguments)})}var D=0;function h(t){return"_leaflet_id"in t||(t._leaflet_id=++D),t._leaflet_id}function j(t,e,i){var n,o,s=function(){n=!1,o&&(r.apply(i,o),o=!1)},r=function(){n?o=arguments:(t.apply(i,arguments),setTimeout(s,e),n=!0)};return r}function H(t,e,i){var n=e[1],e=e[0],o=n-e;return t===n&&i?t:((t-e)%o+o)%o+e}function u(){return!1}function i(t,e){return!1===e?t:(e=Math.pow(10,void 0===e?6:e),Math.round(t*e)/e)}function W(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function F(t){return W(t).split(/\s+/)}function c(t,e){for(var i in Object.prototype.hasOwnProperty.call(t,"options")||(t.options=t.options?R(t.options):{}),e)t.options[i]=e[i];return t.options}function U(t,e,i){var n,o=[];for(n in t)o.push(encodeURIComponent(i?n.toUpperCase():n)+"="+encodeURIComponent(t[n]));return(e&&-1!==e.indexOf("?")?"&":"?")+o.join("&")}var V=/\{ *([\w_ -]+) *\}/g;function q(t,i){return t.replace(V,function(t,e){e=i[e];if(void 0===e)throw new Error("No value provided for variable "+t);return e="function"==typeof e?e(i):e})}var d=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function G(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return i;return-1}var K="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";function Y(t){return window["webkit"+t]||window["moz"+t]||window["ms"+t]}var X=0;function J(t){var e=+new Date,i=Math.max(0,16-(e-X));return X=e+i,window.setTimeout(t,i)}var $=window.requestAnimationFrame||Y("RequestAnimationFrame")||J,Q=window.cancelAnimationFrame||Y("CancelAnimationFrame")||Y("CancelRequestAnimationFrame")||function(t){window.clearTimeout(t)};function x(t,e,i){if(!i||$!==J)return $.call(window,a(t,e));t.call(e)}function r(t){t&&Q.call(window,t)}var tt={__proto__:null,extend:l,create:R,bind:a,get lastId(){return D},stamp:h,throttle:j,wrapNum:H,falseFn:u,formatNum:i,trim:W,splitWords:F,setOptions:c,getParamString:U,template:q,isArray:d,indexOf:G,emptyImageUrl:K,requestFn:$,cancelFn:Q,requestAnimFrame:x,cancelAnimFrame:r};function et(){}et.extend=function(t){function e(){c(this),this.initialize&&this.initialize.apply(this,arguments),this.callInitHooks()}var i,n=e.__super__=this.prototype,o=R(n);for(i in(o.constructor=e).prototype=o,this)Object.prototype.hasOwnProperty.call(this,i)&&"prototype"!==i&&"__super__"!==i&&(e[i]=this[i]);if(t.statics&&l(e,t.statics),t.includes){var s=t.includes;if("undefined"!=typeof L&&L&&L.Mixin){s=d(s)?s:[s];for(var r=0;r<s.length;r++)s[r]===L.Mixin.Events&&console.warn("Deprecated include of L.Mixin.Events: this property will be removed in future releases, please inherit from L.Evented instead.",(new Error).stack)}l.apply(null,[o].concat(t.includes))}return l(o,t),delete o.statics,delete o.includes,o.options&&(o.options=n.options?R(n.options):{},l(o.options,t.options)),o._initHooks=[],o.callInitHooks=function(){if(!this._initHooksCalled){n.callInitHooks&&n.callInitHooks.call(this),this._initHooksCalled=!0;for(var t=0,e=o._initHooks.length;t<e;t++)o._initHooks[t].call(this)}},e},et.include=function(t){var e=this.prototype.options;return l(this.prototype,t),t.options&&(this.prototype.options=e,this.mergeOptions(t.options)),this},et.mergeOptions=function(t){return l(this.prototype.options,t),this},et.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};return this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i),this};var e={on:function(t,e,i){if("object"==typeof t)for(var n in t)this._on(n,t[n],e);else for(var o=0,s=(t=F(t)).length;o<s;o++)this._on(t[o],e,i);return this},off:function(t,e,i){if(arguments.length)if("object"==typeof t)for(var n in t)this._off(n,t[n],e);else{t=F(t);for(var o=1===arguments.length,s=0,r=t.length;s<r;s++)o?this._off(t[s]):this._off(t[s],e,i)}else delete this._events;return this},_on:function(t,e,i,n){"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1===this._listens(t,e,i)&&(e={fn:e,ctx:i=i===this?void 0:i},n&&(e.once=!0),this._events=this._events||{},this._events[t]=this._events[t]||[],this._events[t].push(e))},_off:function(t,e,i){var n,o,s;if(this._events&&(n=this._events[t]))if(1===arguments.length){if(this._firingCount)for(o=0,s=n.length;o<s;o++)n[o].fn=u;delete this._events[t]}else"function"!=typeof e?console.warn("wrong listener type: "+typeof e):!1!==(e=this._listens(Line truncated
//# sourceMappingURL=leaflet.js.map
@@ -0,0 +1,24 @@
"""Selected map engine for newly generated HTML pages."""
from __future__ import annotations
import logging
from typing import Literal
logger = logging.getLogger(__name__)
HtmlMapEngine = Literal["echarts", "leaflet"]
def html_map_engine() -> HtmlMapEngine:
"""Return the admin-selected HTML map engine, defaulting to ECharts."""
try:
from deerflow.config.system_settings import load_system_settings
engine = load_system_settings().html_map.engine
except Exception:
logger.debug("Failed to read the HTML map engine; using ECharts", exc_info=True)
return "echarts"
if engine == "leaflet":
return "leaflet"
return "echarts"
@@ -17,7 +17,7 @@ import secrets
import stat
from pathlib import Path
from deerflow.config import get_app_config, get_paths
from deerflow.config import get_paths
from deerflow.config.paths import Paths
from deerflow.config.runtime_paths import runtime_home
from deerflow.runtime.thread_paths import remember_thread_owner, resolve_path_user_id
@@ -125,10 +125,14 @@ def verify_html_image_token(token: str) -> tuple[str, str, str]:
def html_images_base_url(runtime_base: str | None = None) -> str:
"""Browser-reachable prefix for signed HTML images.
Derived from ``html_runtime.base_url`` so intranet deployments keep the
same Gateway origin / reverse-proxy prefix as G6/ECharts.
Derived from the HTML runtime address saved in the settings dialog, so
intranet deployments keep the same Gateway origin as G6/ECharts.
"""
base = (runtime_base if runtime_base is not None else get_app_config().html_runtime.base_url).rstrip("/")
if runtime_base is None:
from deerflow.html_runtime.addresses import html_runtime_base_url
runtime_base = html_runtime_base_url()
base = runtime_base.rstrip("/")
if base.endswith("/html-runtime"):
return f"{base[: -len('html-runtime')]}html-images"
parent, _sep, _name = base.rpartition("/")