完善前端页面

This commit is contained in:
2026-03-27 02:55:06 +08:00
parent d494e78f70
commit 332f0f636d
42 changed files with 833 additions and 268 deletions

View File

@@ -144,12 +144,19 @@ class RedisDB:
Returns: Returns:
是否成功 是否成功
""" """
key = f"task:{task_id}" if not self._connected or not self.client:
data = { logger.warning(f"Redis未连接跳过任务状态更新: {task_id}")
"status": status, return False
"meta": meta or {}, try:
} key = f"task:{task_id}"
return await self.set_json(key, data, expire) data = {
"status": status,
"meta": meta or {},
}
return await self.set_json(key, data, expire)
except Exception as e:
logger.warning(f"设置任务状态失败: {task_id}, error: {e}")
return False
async def get_task_status(self, task_id: str) -> Optional[Dict[str, Any]]: async def get_task_status(self, task_id: str) -> Optional[Dict[str, Any]]:
""" """
@@ -161,8 +168,15 @@ class RedisDB:
Returns: Returns:
状态信息 状态信息
""" """
key = f"task:{task_id}" if not self._connected or not self.client:
return await self.get_json(key) logger.warning(f"Redis未连接无法获取任务状态: {task_id}")
return None
try:
key = f"task:{task_id}"
return await self.get_json(key)
except Exception as e:
logger.warning(f"获取任务状态失败: {task_id}, error: {e}")
return None
async def update_task_progress( async def update_task_progress(
self, self,
@@ -181,14 +195,21 @@ class RedisDB:
Returns: Returns:
是否成功 是否成功
""" """
data = await self.get_task_status(task_id) if not self._connected or not self.client:
if data: logger.warning(f"Redis未连接跳过任务进度更新: {task_id}")
data["meta"]["progress"] = progress return False
if message: try:
data["meta"]["message"] = message data = await self.get_task_status(task_id)
key = f"task:{task_id}" if data:
return await self.set_json(key, data, expire=86400) data["meta"]["progress"] = progress
return False if message:
data["meta"]["message"] = message
key = f"task:{task_id}"
return await self.set_json(key, data, expire=86400)
return False
except Exception as e:
logger.warning(f"更新任务进度失败: {task_id}, error: {e}")
return False
# ==================== 缓存操作 ==================== # ==================== 缓存操作 ====================

View File

@@ -1,39 +1,29 @@
import React from 'react'; import React from 'react';
import { Link, useLocation, Outlet, useNavigate } from 'react-router-dom'; import { Link, useLocation, Outlet } from 'react-router-dom';
import { import {
LayoutDashboard, LayoutDashboard,
FileText, FileText,
TableProperties, TableProperties,
MessageSquareCode, MessageSquareCode,
LogOut,
Menu, Menu,
X,
ChevronRight, ChevronRight,
User, Sparkles,
Sparkles Clock
} from 'lucide-react'; } from 'lucide-react';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { useAuth } from '@/context/AuthContext';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet'; import { Sheet, SheetContent, SheetTrigger } from '@/components/ui/sheet';
const navItems = [ const navItems = [
{ name: '控制台', path: '/', icon: LayoutDashboard }, { name: '控制台', path: '/', icon: LayoutDashboard },
{ name: '文档中心', path: '/documents', icon: FileText }, { name: '文档中心', path: '/documents', icon: FileText },
{ name: 'Excel 解析', path: '/excel-parse', icon: Sparkles },
{ name: '智能填表', path: '/form-fill', icon: TableProperties }, { name: '智能填表', path: '/form-fill', icon: TableProperties },
{ name: '智能助手', path: '/assistant', icon: MessageSquareCode }, { name: '智能助手', path: '/assistant', icon: MessageSquareCode },
{ name: '任务历史', path: '/task-history', icon: Clock },
]; ];
const MainLayout: React.FC = () => { const MainLayout: React.FC = () => {
const { user, profile, signOut } = useAuth();
const location = useLocation(); const location = useLocation();
const navigate = useNavigate();
const handleSignOut = async () => {
await signOut();
navigate('/login');
};
const SidebarContent = () => ( const SidebarContent = () => (
<div className="flex flex-col h-full bg-sidebar py-6 border-r border-sidebar-border"> <div className="flex flex-col h-full bg-sidebar py-6 border-r border-sidebar-border">
@@ -70,25 +60,17 @@ const MainLayout: React.FC = () => {
</nav> </nav>
<div className="px-4 mt-auto"> <div className="px-4 mt-auto">
<div className="bg-sidebar-accent/50 rounded-2xl p-4 mb-4 border border-sidebar-border/50"> <div className="bg-sidebar-accent/50 rounded-2xl p-4 border border-sidebar-border/50">
<div className="flex items-center gap-3"> <div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-full bg-secondary flex items-center justify-center border-2 border-primary/10"> <div className="w-10 h-10 rounded-full bg-secondary flex items-center justify-center border-2 border-primary/10">
<User size={20} className="text-primary" /> <Sparkles size={20} className="text-primary" />
</div> </div>
<div className="flex flex-col overflow-hidden"> <div className="flex flex-col overflow-hidden">
<span className="font-semibold text-sm truncate">{((profile as any)?.email) || '用户'}</span> <span className="font-semibold text-sm truncate"></span>
<span className="text-[10px] uppercase tracking-wider text-muted-foreground">{((profile as any)?.role) || 'User'}</span> <span className="text-[10px] uppercase tracking-wider text-muted-foreground"></span>
</div> </div>
</div> </div>
</div> </div>
<Button
variant="outline"
className="w-full justify-start gap-3 border-none hover:bg-destructive/10 hover:text-destructive group rounded-xl"
onClick={handleSignOut}
>
<LogOut size={18} className="group-hover:rotate-180 transition-transform duration-300" />
<span>退</span>
</Button>
</div> </div>
</div> </div>
); );

File diff suppressed because it is too large Load Diff

View File

@@ -1,17 +1,12 @@
import { createBrowserRouter, Navigate } from 'react-router-dom'; import { createBrowserRouter, Navigate } from 'react-router-dom';
import Login from '@/pages/Login';
import Dashboard from '@/pages/Dashboard'; import Dashboard from '@/pages/Dashboard';
import Documents from '@/pages/Documents'; import Documents from '@/pages/Documents';
import FormFill from '@/pages/FormFill'; import TemplateFill from '@/pages/TemplateFill';
import Assistant from '@/pages/Assistant'; import InstructionChat from '@/pages/InstructionChat';
import ExcelParse from '@/pages/ExcelParse'; import TaskHistory from '@/pages/TaskHistory';
import MainLayout from '@/components/layouts/MainLayout'; import MainLayout from '@/components/layouts/MainLayout';
export const routes = [ export const routes = [
{
path: '/login',
element: <Login />,
},
{ {
path: '/', path: '/',
element: <MainLayout />, element: <MainLayout />,
@@ -26,15 +21,15 @@ export const routes = [
}, },
{ {
path: '/form-fill', path: '/form-fill',
element: <FormFill />, element: <TemplateFill />,
}, },
{ {
path: '/assistant', path: '/assistant',
element: <Assistant />, element: <InstructionChat />,
}, },
{ {
path: '/excel-parse', path: '/task-history',
element: <ExcelParse />, element: <TaskHistory />,
}, },
], ],
}, },