feat(rohs-check): 新增 RoHS 检核工具进度查询功能及相关接口

This commit is contained in:
hugo committed 2026-06-11 10:05:29 +08:00
1 parent fee33f69d9
commit a18a07ef1a
19 files changed
+654 -58

No files matched your search

+48 -12
View File
@@ -12,9 +12,11 @@ import LocaleToggleButton from '@/components/LocaleToggleButton.vue';
import FilePreviewModal from '@/components/FilePreviewModal.vue';
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog.vue';
import GeneralFeedbackDialog from '@/components/GeneralFeedbackDialog.vue';
import ToolRunProgressCard from '@/features/chat/components/ToolRunProgressCard.vue';
import ChatShell from '@/layouts/ChatShell.vue';
import { useChat } from '@/features/chat/composables/useChat';
import { useChatSourceFiles } from '@/features/chat/composables/useChatSourceFiles';
import { useToolRunProgress, type ToolRunProgressConfig } from '@/features/chat/composables/useToolRunProgress';
import { config } from '@/config';
import {
listChatSessions,
@@ -439,7 +441,7 @@ const handleVoiceFeatureClick = () => {
msg.info(t('chat.devComingSoon'));
return;
}
if (isThinking.value || isVoiceTranscribing.value) return;
if (isThinking.value || isVoiceTranscribing.value || toolRunShouldLockInput.value) return;
const unavailable = getVoiceUnavailableErrorKey();
if (unavailable) {
msg.warning(t(unavailable));
@@ -458,6 +460,22 @@ const showGeneralFeedbackDialog = ref(false);
const LEAVE_FEATURE_AGENT_NAMES = new Set(['通用入口', '人事规章']);
const canUseLeaveFeature = computed(() => LEAVE_FEATURE_AGENT_NAMES.has(String(currentAgent.value?.name || '').trim()));
const toolRunProgressConfig = computed<ToolRunProgressConfig | null>(() => {
const extra = currentAgent.value?.extra_config || {};
const capabilities = Array.isArray(extra.capabilities) ? extra.capabilities.map((item: unknown) => String(item)) : [];
if (!capabilities.includes('tool_run_progress')) return null;
const raw = extra.tool_run_progress;
if (!raw || typeof raw !== 'object') return null;
return raw as ToolRunProgressConfig;
});
const {
run: toolRunProgress,
loading: toolRunProgressLoading,
error: toolRunProgressError,
shouldLockInput: toolRunShouldLockInput,
lockMessage: toolRunLockMessage,
} = useToolRunProgress(toolRunProgressConfig);
type AgentSuggestedQuestionItem = {
question: string;
group: string;
@@ -674,7 +692,7 @@ const showAttachmentMenu = ref(false);
const showAttachmentUrlPanel = ref(false);
const canSendMessage = computed(() => {
if (isThinking.value || isUploadingAttachments.value) return false;
if (isThinking.value || isUploadingAttachments.value || toolRunShouldLockInput.value) return false;
if (input.value.trim()) return true;
if (isShippingNoticeAgent.value && attachments.value.length > 0) return true;
return false;
@@ -687,7 +705,7 @@ const closeAttachmentMenu = () => {
};
const toggleAttachmentMenu = async () => {
if (isThinking.value || isUploadingAttachments.value) return;
if (isThinking.value || isUploadingAttachments.value || toolRunShouldLockInput.value) return;
showAttachmentMenu.value = !showAttachmentMenu.value;
if (!showAttachmentMenu.value) {
showAttachmentUrlPanel.value = false;
@@ -696,13 +714,13 @@ const toggleAttachmentMenu = async () => {
};
const selectAttachmentLocal = () => {
if (!attachmentPolicy.value.canLocal) return;
if (!attachmentPolicy.value.canLocal || toolRunShouldLockInput.value) return;
closeAttachmentMenu();
filePickerRef.value?.click();
};
const selectAttachmentUrl = async () => {
if (!attachmentPolicy.value.canRemote) return;
if (!attachmentPolicy.value.canRemote || toolRunShouldLockInput.value) return;
showAttachmentMenu.value = true;
showAttachmentUrlPanel.value = true;
await nextTick();
@@ -3107,6 +3125,10 @@ const reuploadShippingInventoryFromMappingForm = (msgObj: any) => {
*/
const handleSend = async (textOrEvent?: string | Event) => {
if (toolRunShouldLockInput.value) {
msg.info(toolRunLockMessage.value);
return;
}
const content = (typeof textOrEvent === 'string' ? textOrEvent : null) || input.value;
const trimmed = content.trim();
if ((shippingAutoFlowRequested.value || !trimmed) && isShippingNoticeAgent.value && attachments.value.length > 0 && !isThinking.value && !isUploadingAttachments.value) {
@@ -4063,6 +4085,12 @@ const showChatRating = ref(false);
<div
:class="messages.length === 0 ? 'h-full' : 'flex min-h-full flex-col justify-end'"
>
<ToolRunProgressCard
:run="toolRunProgress"
:loading="toolRunProgressLoading"
:error="toolRunProgressError"
:fallback-title="toolRunProgressConfig?.title"
/>
<div v-if="messages.length === 0" class="flex h-full min-h-0 w-full flex-col items-center px-4 pt-2 pb-2 md:pb-3">
<template v-if="suggestedQuestionsStyle === 'styled' && styledSuggestedQuestionSections.length > 0">
<div class="mb-6 mt-2 flex h-16 w-16 shrink-0 items-center justify-center rounded-2xl bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-2xl font-bold text-white shadow-lg shadow-brand-500/20">
@@ -4640,10 +4668,10 @@ const showChatRating = ref(false);
v-model="input"
@keydown.enter.prevent="handleSend"
rows="1"
:placeholder="isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : $t('chat.askAnything')"
:placeholder="toolRunShouldLockInput ? toolRunLockMessage : isVoiceTranscribing ? $t('chat.voiceTranscribing') : isVoiceRecording ? $t('chat.voiceListening') : $t('chat.askAnything')"
class="w-full resize-none border-none bg-transparent px-3 py-2 text-[15px] leading-relaxed text-primary placeholder-slate-400 focus:outline-none focus:ring-0 focus:border-transparent"
style="min-height: 44px; max-height: 220px;"
:disabled="isThinking || isVoiceTranscribing"
:disabled="isThinking || isVoiceTranscribing || toolRunShouldLockInput"
spellcheck="false"
autocorrect="off"
autocapitalize="off"
@@ -4654,6 +4682,7 @@ const showChatRating = ref(false);
type="file"
class="hidden"
accept=".xlsx,.xls,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,text/csv"
:disabled="toolRunShouldLockInput"
@change="handleShippingInventorySelected"
/>
@@ -4663,6 +4692,7 @@ const showChatRating = ref(false);
multiple
class="hidden"
:accept="attachmentPolicy.accept || undefined"
:disabled="toolRunShouldLockInput"
@change="handleLocalFilesSelected"
/>
@@ -4694,13 +4724,19 @@ const showChatRating = ref(false);
</button>
<span>点发送开始处理</span>
</div>
<div
v-if="toolRunShouldLockInput"
class="px-3 pb-1 text-xs font-medium text-amber-700"
>
{{ toolRunLockMessage }}
</div>
<div class="mt-2 flex items-center justify-between px-2 pb-1">
<div class="flex items-center gap-3">
<button
@click="handleVoiceFeatureClick"
type="button"
:disabled="isThinking || isVoiceTranscribing"
:disabled="isThinking || isVoiceTranscribing || toolRunShouldLockInput"
:title="isVoiceRecording ? $t('chat.voiceStop') : isVoiceTranscribing ? $t('chat.voiceTranscribing') : $t('chat.voiceFeature')"
class="transition-colors disabled:cursor-not-allowed disabled:opacity-50"
:class="isVoiceRecording ? 'text-red-500 animate-pulse' : isVoiceTranscribing ? 'text-brand-500' : 'text-muted hover:text-brand-600'"
@@ -4712,7 +4748,7 @@ const showChatRating = ref(false);
<button
@click="toggleAttachmentMenu"
type="button"
:disabled="isThinking || isUploadingAttachments"
:disabled="isThinking || isUploadingAttachments || toolRunShouldLockInput"
title="附件"
class="flex h-9 w-9 items-center justify-center rounded-lg text-muted transition-colors hover:text-brand-600 disabled:cursor-not-allowed disabled:opacity-50"
>
@@ -4745,14 +4781,14 @@ const showChatRating = ref(false);
<input
ref="attachmentUrlInputRef"
v-model="attachmentUrlInput"
:disabled="isThinking || isUploadingAttachments"
:disabled="isThinking || isUploadingAttachments || toolRunShouldLockInput"
placeholder="粘贴附件 URL(http/https)"
class="flex-1 rounded-lg border border-default bg-surface-soft px-3 py-2 text-xs text-secondary placeholder-slate-400 focus:outline-none focus:ring-0"
@keydown.enter.prevent="addRemoteUrlAttachment"
/>
<button
type="button"
:disabled="isThinking || isUploadingAttachments"
:disabled="isThinking || isUploadingAttachments || toolRunShouldLockInput"
@click="addRemoteUrlAttachment"
class="flex h-9 w-9 items-center justify-center rounded-lg border border-default text-muted transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
title="添加"
@@ -4761,7 +4797,7 @@ const showChatRating = ref(false);
</button>
<button
type="button"
:disabled="isThinking || isUploadingAttachments"
:disabled="isThinking || isUploadingAttachments || toolRunShouldLockInput"
@click="closeAttachmentMenu"
class="flex h-9 w-9 items-center justify-center rounded-lg border border-default text-muted transition-colors hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
title="取消"