feat: Improve file display, timezone handling, and LOT management

Changes:
- Fix datetime serialization with UTC 'Z' suffix for correct timezone display
- Add PDF upload support with extension fallback for MIME detection
- Fix LOT add/remove by creating new list for SQLAlchemy JSON change detection
- Add file message components (FileMessage, ImageLightbox, UploadPreview)
- Add multi-file upload support with progress tracking
- Link uploaded files to chat messages via message_id
- Include file attachments in AI report generation
- Update specs for file-storage, realtime-messaging, and ai-report-generation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-08 12:39:15 +08:00
parent 599802b818
commit 44822a561a
36 changed files with 2252 additions and 156 deletions

View File

@@ -3,12 +3,37 @@
生產線異常即時反應系統 (Task Reporter)
"""
import os
import json
from pathlib import Path
from datetime import datetime
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from fastapi.responses import FileResponse, JSONResponse
from app.core.config import get_settings
class UTCDateTimeEncoder(json.JSONEncoder):
"""Custom JSON encoder that formats datetime with 'Z' suffix for UTC"""
def default(self, obj):
if isinstance(obj, datetime):
return obj.isoformat() + 'Z'
return super().default(obj)
class UTCJSONResponse(JSONResponse):
"""JSONResponse that uses UTCDateTimeEncoder"""
def render(self, content) -> bytes:
return json.dumps(
content,
ensure_ascii=False,
allow_nan=False,
indent=None,
separators=(",", ":"),
cls=UTCDateTimeEncoder,
).encode("utf-8")
from app.modules.auth import router as auth_router
from app.modules.auth.users_router import router as users_router
from app.modules.auth.middleware import auth_middleware
@@ -26,12 +51,13 @@ settings = get_settings()
# Database tables are managed by Alembic migrations
# Run: alembic upgrade head
# Initialize FastAPI app
# Initialize FastAPI app with custom JSON response for UTC datetime
app = FastAPI(
title="Task Reporter API",
description="Production Line Incident Response System - 生產線異常即時反應系統",
version="1.0.0",
debug=settings.DEBUG,
default_response_class=UTCJSONResponse,
)
# CORS middleware - origins configured via CORS_ORIGINS environment variable