diff --git a/dsLightRag/Routes/MjRoute.py b/dsLightRag/Routes/MjRoute.py
index fbf4653b..c6bd6142 100644
--- a/dsLightRag/Routes/MjRoute.py
+++ b/dsLightRag/Routes/MjRoute.py
@@ -13,7 +13,7 @@ from Config import Config
import asyncio
import threading
from fastapi.responses import StreamingResponse
-
+from fastapi import APIRouter, Request, HTTPException, BackgroundTasks
# 创建路由路由器
router = APIRouter(prefix="/api/mj", tags=["文生图"])
@@ -144,24 +144,21 @@ async def submit_imagine(request: ImagineRequest, background_tasks: BackgroundTa
raise HTTPException(status_code=500, detail=f"提交文生图请求失败: {str(e)}")
-@router.get("/task_status", response_model=TaskStatusResponse)
-async def get_task_status(task_id: str = Query(..., description="任务ID")):
- """
- 查询文生图任务状态
+# 在文件顶部确保已定义任务状态缓存
+task_status_cache = {}
+@router.get("/task_status")
+async def get_task_status(task_id: str):
+ if not task_id:
+ raise HTTPException(status_code=400, detail="task_id 参数缺失")
- Args:
- task_id: 任务ID
-
- Returns:
- 任务状态信息
- """
- if task_id not in TASK_STATUS:
+ # 将所有 task_status_store 替换为 task_status_cache
+ if task_id not in task_status_cache:
raise HTTPException(status_code=404, detail="任务ID不存在")
-
- return TaskStatusResponse(
- task_id=task_id,
- status=TASK_STATUS[task_id]["status"],
- image_url=TASK_STATUS[task_id]["image_url"],
- progress=TASK_STATUS[task_id]["progress"],
- error=TASK_STATUS[task_id]["error"]
- )
+
+ return {
+ "task_id": task_id,
+ "status": task_status_cache[task_id]["status"],
+ "progress": task_status_cache[task_id]["progress"] ,
+ "result": task_status_cache[task_id]["result"],
+ "error": task_status_cache[task_id]["error"]
+ }
diff --git a/dsLightRag/Routes/__pycache__/MjRoute.cpython-310.pyc b/dsLightRag/Routes/__pycache__/MjRoute.cpython-310.pyc
index 3ffd6196..53050568 100644
Binary files a/dsLightRag/Routes/__pycache__/MjRoute.cpython-310.pyc and b/dsLightRag/Routes/__pycache__/MjRoute.cpython-310.pyc differ
diff --git a/dsLightRag/static/Midjourney/mj.html b/dsLightRag/static/Midjourney/mj.html
index e9d0df9a..d984e6ed 100644
--- a/dsLightRag/static/Midjourney/mj.html
+++ b/dsLightRag/static/Midjourney/mj.html
@@ -7,7 +7,7 @@
-
+
+
+ // 添加历史记录项点击事件
+ document.querySelectorAll('.view-history-item').forEach(button => {
+ button.addEventListener('click', function () {
+ const imageUrl = this.getAttribute('data-image-url');
+ // 显示结果区域
+ const resultSection = document.getElementById('resultSection');
+ resultSection.classList.remove('hidden');
+ // 设置结果图像
+ const resultImage = document.getElementById('resultImage');
+ resultImage.src = imageUrl;
+ });
+ });
+
+ // 初始化历史记录网格
+ updateHistoryGrid();
+ }
+
+
+
+