feat(frontend): 启用工作流快捷提示按钮
This commit is contained in:
@@ -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) {
|
async function streamChat(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (!composer || !promptInput || !sendButton || !chatStage) {
|
if (!composer || !promptInput || !sendButton || !chatStage) {
|
||||||
@@ -1126,6 +1146,7 @@
|
|||||||
bindWorkflowBatchCarouselControls();
|
bindWorkflowBatchCarouselControls();
|
||||||
bindConditionConfirmForms();
|
bindConditionConfirmForms();
|
||||||
bindRectificationActionButtons();
|
bindRectificationActionButtons();
|
||||||
|
bindPromptTemplateButtons();
|
||||||
refreshRunningWorkflowCards();
|
refreshRunningWorkflowCards();
|
||||||
|
|
||||||
if (chatScroll) {
|
if (chatScroll) {
|
||||||
|
|||||||
@@ -198,9 +198,21 @@
|
|||||||
<textarea id="prompt" name="prompt" rows="1" placeholder="输入审核问题、法规条款、说明书疑点或上传需求"></textarea>
|
<textarea id="prompt" name="prompt" rows="1" placeholder="输入审核问题、法规条款、说明书疑点或上传需求"></textarea>
|
||||||
<div class="composer-actions">
|
<div class="composer-actions">
|
||||||
<div class="composer-tools">
|
<div class="composer-tools">
|
||||||
<span class="tool-chip passive-chip">法规核查</span>
|
<button
|
||||||
<span class="tool-chip passive-chip">说明书审核</span>
|
class="tool-chip"
|
||||||
<span class="tool-chip passive-chip">风险识别</span>
|
type="button"
|
||||||
|
data-prompt-template="请对当前对话已上传的文件或压缩包自动汇总文件目录、文件类型和页数,并生成可下载的汇总报告。"
|
||||||
|
>目录自动汇总</button>
|
||||||
|
<button
|
||||||
|
class="tool-chip"
|
||||||
|
type="button"
|
||||||
|
data-prompt-template="请对当前对话最近成功汇总的注册资料发起 NMPA 法规核查与风险预警,检查完整性、章节结构、一致性、高风险问题、阻断项、证据来源和整改建议。"
|
||||||
|
>法规核查与风险预警</button>
|
||||||
|
<button
|
||||||
|
class="tool-chip"
|
||||||
|
type="button"
|
||||||
|
data-prompt-template="请基于当前对话最近成功汇总的产品资料,自动提取产品关键信息并填入申报文件模板,优先生成注册证 Word 和字段来源追溯清单。"
|
||||||
|
>申报文件填表</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="send-button" type="submit" id="sendButton">发送</button>
|
<button class="send-button" type="submit" id="sendButton">发送</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -233,3 +233,24 @@ def test_frontend_renders_workflow_batches_as_carousel():
|
|||||||
assert "workflow-batch-carousel" in script
|
assert "workflow-batch-carousel" in script
|
||||||
assert ".workflow-batch-controls" in css
|
assert ".workflow-batch-controls" in css
|
||||||
assert ".workflow-card.active" 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 ">风险预警</button>" 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
|
||||||
|
|||||||
Reference in New Issue
Block a user