From e3a54b874d072ed6913cf72cf422289d5a40a991 Mon Sep 17 00:00:00 2001 From: bruce Date: Thu, 4 Jun 2026 03:19:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E7=9F=A5=E8=AF=86?= =?UTF-8?q?=E5=BA=93=E6=B2=BB=E7=90=86=E5=8F=B0=E5=8A=A8=E4=BD=9C=E6=80=BB?= =?UTF-8?q?=E8=A7=88=E4=B8=8E=E9=80=9A=E7=9F=A5=E7=AD=96=E7=95=A5=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/platform_ui/services.py | 32 ++++++++++++++ templates/platform_ui/knowledge_base.html | 51 +++++++++++++++++++++++ tests/test_platform_ui.py | 17 ++++++++ 3 files changed, 100 insertions(+) diff --git a/apps/platform_ui/services.py b/apps/platform_ui/services.py index 79a9fda..29e780b 100644 --- a/apps/platform_ui/services.py +++ b/apps/platform_ui/services.py @@ -424,6 +424,7 @@ def build_knowledge_base_context(selected_view: str) -> dict: { "governance_objects": governance_objects, "active_governance_object": active_object, + "governance_action_hub": _build_governance_action_hub(active_object, context), } ) return context @@ -495,3 +496,34 @@ def _build_governance_objects() -> list[dict]: "admin_url": reverse("admin:platform_ui_feishunotifyconfig_changelist"), }, ] + + +def _build_governance_action_hub(active_object: dict, context: dict) -> dict: + """ + 为治理台提供当前对象聚焦信息与跨入口动作。 + + 目标是把知识库从“静态配置展示页”收口为“治理入口”: + - 明确当前治理对象 + - 提供固定通知策略口径 + - 提供跳转到审核智能体 / 资料包 / 处理历史的快速入口 + """ + owner_count = len(context.get("owner_mappings") or []) + template_count = len(context.get("template_mappings") or []) + feishu_count = len(context.get("feishu_configs") or []) + return { + "title": "治理动作总览", + "current_object": active_object["title"], + "current_summary": active_object["summary"], + "status_items": [ + {"label": "责任人映射", "value": f"{owner_count} 条"}, + {"label": "Word 模板版本", "value": f"{template_count} 个"}, + {"label": "通知配置", "value": f"{feishu_count} 条"}, + ], + "quick_actions": [ + {"label": "进入审核智能体", "url": reverse("chat:index")}, + {"label": "查看资料包", "url": reverse("documents:list")}, + {"label": "查看处理历史", "url": reverse("audit:list")}, + {"label": "进入后台维护", "url": active_object["admin_url"]}, + ], + "notify_reasons": ["task_completed", "task_failed"], + } diff --git a/templates/platform_ui/knowledge_base.html b/templates/platform_ui/knowledge_base.html index d051d18..8f95f8e 100644 --- a/templates/platform_ui/knowledge_base.html +++ b/templates/platform_ui/knowledge_base.html @@ -63,6 +63,57 @@ +
+
+
+
+

{{ governance_action_hub.title }}

+

用当前治理对象作为焦点,快速进入审核、资料包和处理历史入口。

+
+
+
    +
  • + 当前治理对象 +
    {{ governance_action_hub.current_object }}
    +
    {{ governance_action_hub.current_summary }}
    +
  • +
+
+ {% for item in governance_action_hub.status_items %} + {{ item.label }}:{{ item.value }} + {% endfor %} +
+
+ {% for action in governance_action_hub.quick_actions %} + {{ action.label }} + {% endfor %} +
+
+ +
+
+
+

固定通知策略

+

Demo 首版固定仅支持执行完成或执行异常两类飞书通知口径。

+
+
+
    + {% for reason in governance_action_hub.notify_reasons %} +
  • + {{ reason }} +
    + {% if reason == "task_completed" %} + 审核执行完成后直接通知处理人。 + {% else %} + 审核执行异常后直接通知处理人。 + {% endif %} +
    +
  • + {% endfor %} +
+
+
+
{% for section in governance_sections %}
diff --git a/tests/test_platform_ui.py b/tests/test_platform_ui.py index 73d7367..23079fe 100644 --- a/tests/test_platform_ui.py +++ b/tests/test_platform_ui.py @@ -171,3 +171,20 @@ def test_knowledge_base_page_exposes_governance_crud_entry_links(client): assert "编辑占位符映射" in content assert "预览模板" in content assert reverse("admin:platform_ui_wordtemplatemapping_changelist") in content + + +def test_knowledge_base_page_shows_governance_action_hub_and_fixed_notify_policy(client): + response = client.get(reverse("platform_ui:knowledge-base"), {"view": "feishu_configs"}) + + content = response.content.decode("utf-8") + assert response.status_code == 200 + assert "治理动作总览" in content + assert "当前治理对象" in content + assert "进入审核智能体" in content + assert "查看资料包" in content + assert "查看处理历史" in content + assert "固定通知策略" in content + assert "task_completed" in content + assert "task_failed" in content + assert reverse("audit:list") in content + assert reverse("documents:list") in content