From bf86ff98ba4ef4ae43a4e9cca91b2074c0a64454 Mon Sep 17 00:00:00 2001 From: XianYuDaXian Date: Fri, 13 Mar 2026 21:24:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=A4=9A=E5=9B=BE=E8=AF=B7=E6=B1=82=E4=B8=8E=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/grok/services/image_edit.py | 3 ++- app/services/grok/services/video.py | 7 +++--- app/static/public/js/video.js | 31 +++++++++++++++++++++--- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/app/services/grok/services/image_edit.py b/app/services/grok/services/image_edit.py index 84d534a..fd5631b 100644 --- a/app/services/grok/services/image_edit.py +++ b/app/services/grok/services/image_edit.py @@ -59,7 +59,6 @@ def _extract_image_post_id(value: str) -> str: matches = re.findall(r"([0-9a-fA-F-]{32,36})", text) return matches[-1] if matches else "" - async def _try_log_image_share_link( token: str, post_id: str, @@ -793,6 +792,8 @@ class ImageEditService: request_url = raw_source mention_id = original_id attachment_id = "" + resolved_url = "" + resolved_id = "" should_upload_for_attachment = _needs_image_edit_reference_upload( item, raw_source ) diff --git a/app/services/grok/services/video.py b/app/services/grok/services/video.py index 37cfa64..ea16c67 100644 --- a/app/services/grok/services/video.py +++ b/app/services/grok/services/video.py @@ -39,7 +39,6 @@ from app.services.grok.utils.upload import UploadService _VIDEO_SEMAPHORE = None _VIDEO_SEM_VALUE = 0 - def _get_video_semaphore() -> asyncio.Semaphore: """Reverse 接口并发控制(video 服务)。""" global _VIDEO_SEMAPHORE, _VIDEO_SEM_VALUE @@ -110,7 +109,6 @@ def _normalize_assets_url(value: str) -> str: return f"https://assets.grok.com{raw}" return f"https://assets.grok.com/{raw}" - def _log_final_video_payload( *, message: str, @@ -425,7 +423,10 @@ class VideoService: source_url = await self._resolve_reference_source_url(token, item) if not source_url: raise ValidationException(f"第 {index + 1} 张参考图缺少可用来源") - file_id, file_uri = await upload_service.upload_file(source_url, token) + uploaded_file_id, file_uri = await upload_service.upload_file( + source_url, token + ) + file_id = str(uploaded_file_id or "").strip() asset_url = _normalize_assets_url(file_uri) uploaded.append( { diff --git a/app/static/public/js/video.js b/app/static/public/js/video.js index 7545473..78db8e5 100644 --- a/app/static/public/js/video.js +++ b/app/static/public/js/video.js @@ -1120,6 +1120,9 @@ const title = document.createElement('div'); title.className = 'video-item-title'; title.textContent = `视频 ${previewCount}`; + + const prompt = document.createElement('div'); + prompt.className = 'video-item-prompt hidden'; const actions = document.createElement('div'); actions.className = 'video-item-actions video-item-actions-overlay'; @@ -1146,6 +1149,7 @@ actions.appendChild(downloadBtn); actions.appendChild(editBtn); header.appendChild(title); + header.appendChild(prompt); const body = document.createElement('div'); body.className = 'video-item-body'; @@ -1387,7 +1391,8 @@ mention_alias: String(item && item.mentionLabel ? item.mentionLabel : getReferenceMentionLabel(index)).trim() })).filter((item) => item.parent_post_id || item.image_url || item.source_image_url); - const primaryRef = referenceItems[0] || null; + const hasReferenceItems = referenceItems.length > 0; + const primaryRef = hasReferenceItems ? null : (referenceItems[0] || null); const parentPostId = primaryRef ? String(primaryRef.parent_post_id || '').trim() : ''; const imageUrl = primaryRef ? String(primaryRef.image_url || primaryRef.source_image_url || '').trim() : ''; const sourceImageUrl = primaryRef ? String(primaryRef.source_image_url || primaryRef.image_url || '').trim() : ''; @@ -1400,9 +1405,9 @@ }, body: JSON.stringify({ prompt, - image_url: parentPostId ? null : (imageUrl || null), - parent_post_id: parentPostId || null, - source_image_url: parentPostId ? (sourceImageUrl || null) : null, + image_url: hasReferenceItems ? null : (parentPostId ? null : (imageUrl || null)), + parent_post_id: hasReferenceItems ? null : (parentPostId || null), + source_image_url: hasReferenceItems ? null : (parentPostId ? (sourceImageUrl || null) : null), reference_items: referenceItems, reasoning_effort: DEFAULT_REASONING_EFFORT, aspect_ratio: ratioSelect ? ratioSelect.value : '3:2', @@ -1533,6 +1538,21 @@ } } + function setPreviewPrompt(item, text) { + if (!item) return; + const promptEl = item.querySelector('.video-item-prompt'); + const promptText = String(text || '').trim(); + item.dataset.prompt = promptText; + if (!promptEl) return; + if (promptText) { + promptEl.textContent = promptText; + promptEl.classList.remove('hidden'); + return; + } + promptEl.textContent = ''; + promptEl.classList.add('hidden'); + } + function getSelectedVideoItem() { if (!selectedVideoItemId || !videoStage) return null; return videoStage.querySelector(`.video-item[data-index="${selectedVideoItemId}"]`); @@ -1942,6 +1962,7 @@ updateMeta(); resetOutput(true); setStatus('connecting', '连接中'); + const promptText = promptInput ? String(promptInput.value || '').trim() : ''; let taskIds = []; try { @@ -1965,6 +1986,7 @@ for (const taskId of taskIds) { const previewItem = initPreviewSlot(); setPreviewTitle(previewItem, buildHistoryTitle('generated', previewItem && previewItem.dataset ? previewItem.dataset.index : previewCount)); + setPreviewPrompt(previewItem, promptText); taskStates.set(taskId, { taskId, source: null, @@ -2279,6 +2301,7 @@ for (const tid of taskIds) { const placeholder = initPreviewSlot(); setPreviewTitle(placeholder, buildHistoryTitle('splice', serial)); + setPreviewPrompt(placeholder, prompt); if (placeholder) placeholder.dataset.taskId = tid; spliceRun.placeholders.set(tid, placeholder); }