fix(knowdge-base): 修复google浏览器不兼容问题

This commit is contained in:
sophie committed 2026-07-02 15:23:10 +08:00
1 parent 60dd0c0f58
commit 09cd6fc3c7
2 files changed
+44 -13

No files matched your search

@@ -11,6 +11,7 @@ from app.services.shipping_notice.state_machine import (
ALL_ACTION_IDS, ALL_ACTION_IDS,
ALL_CHECKPOINT_IDS, ALL_CHECKPOINT_IDS,
CHECKPOINT_REGISTRY, CHECKPOINT_REGISTRY,
CP_INVENTORY_SOURCE_REVIEW,
TaskTransition, TaskTransition,
TaskUiState, TaskUiState,
action_buttons_for_checkpoint, action_buttons_for_checkpoint,
@@ -21,6 +22,7 @@ from app.services.shipping_notice.state_machine import (
human_options_for_checkpoint, human_options_for_checkpoint,
human_options_for_task, human_options_for_task,
human_options_for_task_or_checkpoint, human_options_for_task_or_checkpoint,
inventory_source_action_buttons,
resolve_task_ui_state, resolve_task_ui_state,
ui_state_for_checkpoint, ui_state_for_checkpoint,
upload_req_options_for_task, upload_req_options_for_task,
@@ -30,6 +32,34 @@ from app.services.shipping_notice.state_machine import (
# Legacy alias # Legacy alias
CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY
def build_chat_actions_payload(task):
"""
Build the legacy chat-actions API payload for one shipping task.
AI trigger: use this when the workspace chat panel needs the current checkpoint
and clickable action buttons for an existing ShippingTask. The payload keeps the
historical `task_id` field as `task.task_no` so older frontend code can consume it.
"""
ui_state = resolve_task_ui_state(task)
action_buttons = (
inventory_source_action_buttons(task)
if ui_state.checkpoint == CP_INVENTORY_SOURCE_REVIEW
else ui_state.action_buttons
)
return {
"task_id": task.task_no,
"task_no": task.task_no,
"checkpoint": ui_state.checkpoint,
"human_options": ui_state.human_options or [],
"action_buttons": action_buttons,
"process_status": task.process_status,
"review_status": task.review_status,
"pending_human_reason": task.pending_human_reason,
"match_status": task.match_status,
"updated_at": task.updated_at.isoformat() if task.updated_at else None,
}
__all__ = [ __all__ = [
"ACTION_SPECS", "ACTION_SPECS",
"ALL_ACTION_IDS", "ALL_ACTION_IDS",
@@ -41,6 +71,7 @@ __all__ = [
"action_buttons_for_checkpoint", "action_buttons_for_checkpoint",
"apply_task_transition", "apply_task_transition",
"build_action_buttons", "build_action_buttons",
"build_chat_actions_payload",
"build_checkpoint_catalog", "build_checkpoint_catalog",
"checkpoint_for_task", "checkpoint_for_task",
"human_options_for_checkpoint", "human_options_for_checkpoint",
@@ -403,7 +403,7 @@ const kb = useKbWorkspace({ embedded: props.embedded });
? 'border-brand-200 bg-brand-50/50 border-brand-200' ? 'border-brand-200 bg-brand-50/50 border-brand-200'
: 'border-default'" : 'border-default'"
> >
<div class="grid gap-3 xl:grid-cols-[minmax(0,1.3fr)_minmax(360px,0.9fr)_auto] xl:items-center"> <div class="grid gap-3 2xl:grid-cols-[minmax(420px,1fr)_minmax(280px,auto)_minmax(320px,auto)] 2xl:items-center">
<div class="flex min-w-0 gap-3"> <div class="flex min-w-0 gap-3">
<label class="mt-1 inline-flex shrink-0 cursor-pointer items-center"> <label class="mt-1 inline-flex shrink-0 cursor-pointer items-center">
<input <input
@@ -427,18 +427,18 @@ const kb = useKbWorkspace({ embedded: props.embedded });
> >
{{ kb.getDocumentDisplayDescription(doc) }} {{ kb.getDocumentDisplayDescription(doc) }}
</button> </button>
<div class="mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted"> <div class="mt-2 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted">
<span>{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span> <span class="shrink-0">{{ kb.t('kbWorkspace.documents.versionCount', { count: doc.version_count ?? 0 }) }}</span>
<span v-if="doc.latest_version">{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span> <span v-if="doc.latest_version" class="shrink-0">{{ kb.t('kbWorkspace.documents.currentVersion', { version: doc.latest_version.version_no }) }}</span>
<button <button
v-if="doc.latest_version" v-if="doc.latest_version"
type="button" type="button"
@click="kb.openSourceInfo(doc)" @click="kb.openSourceInfo(doc)"
class="max-w-full truncate text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600" class="min-w-0 max-w-full truncate text-xs text-muted underline-offset-2 transition-colors hover:text-brand-600 hover:underline hover:text-brand-600"
> >
{{ doc.latest_version.source_file_name }} {{ doc.latest_version.source_file_name }}
</button> </button>
<span>{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}</span> <span class="shrink-0">{{ kb.t('kbWorkspace.documents.updatedAt', { time: kb.formatDateTime(doc.updated_at) }) }}</span>
</div> </div>
<div <div
v-if="kb.getDocumentWorkflowState(doc).primaryError" v-if="kb.getDocumentWorkflowState(doc).primaryError"
@@ -449,28 +449,28 @@ const kb = useKbWorkspace({ embedded: props.embedded });
</div> </div>
</div> </div>
<div class="flex flex-wrap items-center gap-2 xl:justify-end"> <div class="flex min-w-0 flex-wrap items-center gap-2 2xl:justify-end">
<div <div
v-for="badge in kb.getWorkflowBadges(doc)" v-for="badge in kb.getWorkflowBadges(doc)"
:key="`${doc.id}-${badge.label}`" :key="`${doc.id}-${badge.label}`"
class="inline-flex items-center rounded-full border px-3 py-1 text-xs font-semibold" class="inline-flex shrink-0 items-center rounded-full border px-3 py-1 text-xs font-semibold"
:class="badge.className" :class="badge.className"
> >
{{ badge.label }}:{{ badge.value }} {{ badge.label }}:{{ badge.value }}
</div> </div>
</div> </div>
<div class="flex flex-wrap items-center gap-2 xl:justify-end"> <div class="flex min-w-0 flex-wrap items-center gap-2 2xl:justify-end">
<button <button
@click="kb.openDocumentDetail(doc.id)" @click="kb.openDocumentDetail(doc.id)"
class="inline-flex items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50" class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
> >
<FileText class="h-3.5 w-3.5" /> <FileText class="h-3.5 w-3.5" />
{{ kb.t('kbWorkspace.documents.viewRecord') }} {{ kb.t('kbWorkspace.documents.viewRecord') }}
</button> </button>
<button <button
@click="kb.triggerUploadForDocument(doc.id)" @click="kb.triggerUploadForDocument(doc.id)"
class="inline-flex items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50" class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-brand-200 px-3 py-2 text-xs font-medium text-brand-700 transition-colors hover:bg-brand-50 border-brand-200 hover:bg-brand-50"
> >
<Upload class="h-3.5 w-3.5" /> <Upload class="h-3.5 w-3.5" />
{{ kb.t('kbWorkspace.documents.uploadVersion') }} {{ kb.t('kbWorkspace.documents.uploadVersion') }}
@@ -479,14 +479,14 @@ const kb = useKbWorkspace({ embedded: props.embedded });
v-if="kb.isKbAdmin" v-if="kb.isKbAdmin"
@click="kb.handleSyncDocument(doc.id)" @click="kb.handleSyncDocument(doc.id)"
:disabled="kb.syncingDocumentId === doc.id || !doc.latest_version" :disabled="kb.syncingDocumentId === doc.id || !doc.latest_version"
class="inline-flex items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200" class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50 disabled:cursor-not-allowed disabled:opacity-60 border-emerald-200"
> >
<RefreshCw class="h-3.5 w-3.5" /> <RefreshCw class="h-3.5 w-3.5" />
{{ kb.syncingDocumentId === doc.id ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }} {{ kb.syncingDocumentId === doc.id ? kb.t('kbWorkspace.documents.syncingDify') : kb.t('kbWorkspace.documents.syncDify') }}
</button> </button>
<button <button
@click="kb.handleDeleteDocument(doc)" @click="kb.handleDeleteDocument(doc)"
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 border-rose-200 hover:bg-rose-50" class="inline-flex shrink-0 items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50 border-rose-200 hover:bg-rose-50"
> >
<Trash2 class="h-3.5 w-3.5" /> <Trash2 class="h-3.5 w-3.5" />
{{ kb.t('kbWorkspace.common.delete') }} {{ kb.t('kbWorkspace.common.delete') }}