diff --git a/static/js/app.js b/static/js/app.js
index ef6bd75..a1f4a99 100644
--- a/static/js/app.js
+++ b/static/js/app.js
@@ -965,6 +965,26 @@
});
}
+ function bindPromptTemplateButtons() {
+ document.querySelectorAll("[data-prompt-template]").forEach(function (button) {
+ if (button.dataset.bound === "true") {
+ return;
+ }
+ button.dataset.bound = "true";
+ button.addEventListener("click", function () {
+ if (!promptInput) {
+ return;
+ }
+ var template = button.getAttribute("data-prompt-template") || "";
+ promptInput.value = template;
+ promptInput.focus();
+ if (typeof promptInput.setSelectionRange === "function") {
+ promptInput.setSelectionRange(promptInput.value.length, promptInput.value.length);
+ }
+ });
+ });
+ }
+
async function streamChat(event) {
event.preventDefault();
if (!composer || !promptInput || !sendButton || !chatStage) {
@@ -1126,6 +1146,7 @@
bindWorkflowBatchCarouselControls();
bindConditionConfirmForms();
bindRectificationActionButtons();
+ bindPromptTemplateButtons();
refreshRunningWorkflowCards();
if (chatScroll) {
diff --git a/templates/home.html b/templates/home.html
index f6f49a1..38fa136 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -198,9 +198,21 @@
- 法规核查
- 说明书审核
- 风险识别
+
+
+
diff --git a/tests/test_file_summary_frontend.py b/tests/test_file_summary_frontend.py
index cd5473d..5481f5b 100644
--- a/tests/test_file_summary_frontend.py
+++ b/tests/test_file_summary_frontend.py
@@ -233,3 +233,24 @@ def test_frontend_renders_workflow_batches_as_carousel():
assert "workflow-batch-carousel" in script
assert ".workflow-batch-controls" in css
assert ".workflow-card.active" in css
+
+
+def test_workspace_tool_buttons_fill_default_prompts(client, django_user_model):
+ user = django_user_model.objects.create_user(username="owner", password="pass")
+ conversation = Conversation.objects.create(user=user, title="会话")
+ client.force_login(user)
+
+ response = client.get(f"{reverse('home')}?conversation={conversation.pk}")
+
+ content = response.content.decode("utf-8")
+ script = open("static/js/app.js", encoding="utf-8").read()
+ assert "目录自动汇总" in content
+ assert "法规核查与风险预警" in content
+ assert "申报文件填表" in content
+ assert "说明书审查" not in content
+ assert ">风险预警" not in content
+ assert 'data-prompt-template="请对当前对话已上传的文件或压缩包自动汇总文件目录' in content
+ assert 'data-prompt-template="请对当前对话最近成功汇总的注册资料发起 NMPA 法规核查与风险预警' in content
+ assert 'data-prompt-template="请基于当前对话最近成功汇总的产品资料,自动提取产品关键信息并填入申报文件模板' in content
+ assert "bindPromptTemplateButtons" in script
+ assert "promptInput.value = template" in script