migrate frontend

This commit is contained in:
ryan
2026-06-18 18:34:20 +08:00
parent 75140fc3bb
commit 48421c12de
113 changed files with 116 additions and 152 deletions
@@ -42,7 +42,7 @@ export function LoginPage() {
const resolveRedirectTarget = useCallback(() => {
const callbackUrl = searchParams.get('callbackUrl')
const storedRedirect = sessionStorage.getItem('redirect_after_login')
const target = callbackUrl || storedRedirect || '/home'
const target = callbackUrl || storedRedirect || '/'
if (storedRedirect) {
sessionStorage.removeItem('redirect_after_login')
@@ -24,7 +24,7 @@ function getRedirectTarget(searchParams: ReturnType<typeof useSearchParams>) {
typeof window === "undefined"
? null
: sessionStorage.getItem("redirect_after_login")
return safeRedirectTarget(callbackUrl || storedRedirect || "/home")
return safeRedirectTarget(callbackUrl || storedRedirect || "/")
}
@@ -116,7 +116,7 @@ export function HomeMain() {
className="bg-indigo-600 hover:bg-indigo-700 text-xs font-semibold px-4 shadow-sm h-7"
asChild
>
<Link href="/home">开始使用</Link>
<Link href="/">开始使用</Link>
</Button>
<Button
size="sm"
@@ -42,8 +42,7 @@ const MENU_GROUPS: MenuGroup[] = [
{
name: "基础菜单",
items: [
{ path: "/home", label: "首页", description: "系统控制台/个人首页", icon: Home },
{ path: "/files", label: "我的文件", description: "用户个人文件管理与上传", icon: FolderOpen },
{ path: "/", label: "总览", description: "OpenFlare 控制台总览", icon: Home },
]
},
{
@@ -35,7 +35,7 @@ export const FooterSection = React.memo(function FooterSection({ className }: Fo
<div className="lg:col-span-1">
<h3 className="font-semibold text-foreground mb-6">产品</h3>
<ul className="space-y-4 text-sm text-muted-foreground">
<li><FooterLink href="/home">仪表盘</FooterLink></li>
<li><FooterLink href="/">仪表盘</FooterLink></li>
<li><FooterLink href="/settings">个人设置</FooterLink></li>
</ul>
</div>
@@ -62,7 +62,7 @@ export const HeroSection = React.memo(function HeroSection({ className }: HeroSe
transition={{ duration: 0.6, delay: 0.3, ease: [0.16, 1, 0.3, 1] }}
className="flex flex-col sm:flex-row items-center gap-4"
>
<Link href="/home" className="w-full sm:w-auto">
<Link href="/" className="w-full sm:w-auto">
<Button
size="lg"
className="w-full rounded-full bg-primary hover:bg-primary/90 font-medium transition-all active:scale-95"
@@ -4,7 +4,7 @@ import {useState} from 'react';
import {useQuery} from '@tanstack/react-query';
import {usePathname} from 'next/navigation';
import {VersionUpgradeDialog} from '@/app/(main)/openflare/components/version-upgrade-dialog';
import {VersionUpgradeDialog} from '@/app/(main)/components/version-upgrade-dialog';
import {Badge} from '@/components/ui/badge';
import {Button} from '@/components/ui/button';
import {useUser} from '@/contexts/user-context';
@@ -12,6 +12,7 @@ import {
openflareLatestReleaseQueryKey,
openflarePublicStatusQueryKey,
} from '@/lib/hooks/use-openflare-server-upgrade';
import {isOpenFlareConsoleRoute} from '@/lib/navigation/openflare-nav';
import {StatusService, UpdateService} from '@/lib/services/openflare';
export function OpenFlareVersionEntry() {
@@ -19,7 +20,7 @@ export function OpenFlareVersionEntry() {
const {user} = useUser();
const [dialogOpen, setDialogOpen] = useState(false);
const isOpenFlareRoute = pathname.startsWith('/openflare');
const isOpenFlareRoute = isOpenFlareConsoleRoute(pathname);
const canUpgrade = Boolean(user?.is_admin);
const statusQuery = useQuery({
+3 -39
View File
@@ -53,7 +53,6 @@ import {
FileQuestionMark,
FileText,
FolderOpen,
Home,
Layers,
LogOut,
Settings,
@@ -68,10 +67,6 @@ import {openflareNavItems} from "@/lib/navigation/openflare-nav"
/* 导航数据 */
const data = {
navMain: [
{ title: "首页", url: "/home", icon: Home },
{ title: "我的文件", url: "/files", icon: FolderOpen },
],
admin: [
{ title: "用户管理", url: "/admin/users", icon: UserRound },
{ title: "任务管理", url: "/admin/tasks", icon: Layers },
@@ -166,11 +161,6 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
}
}
const navMainFiltered = React.useMemo(() => {
const displayConfig = parseMenuDisplayConfig(config?.menu_display_config)
return data.navMain.filter((item) => displayConfig[item.url] !== false)
}, [config])
const adminFiltered = React.useMemo(() => {
const displayConfig = parseMenuDisplayConfig(config?.menu_display_config)
return data.admin.filter((item) => displayConfig[item.url] !== false)
@@ -304,34 +294,8 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
</DropdownMenu>
</SidebarHeader>
<SidebarContent className="group-data-[collapsible=icon]">
{navMainFiltered.length > 0 && (
<SidebarGroup className="py-0">
<SidebarGroupContent className="py-1">
<SidebarMenu className="gap-1">
{navMainFiltered.map((item) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton
tooltip={item.title}
isActive={pathname === item.url}
asChild
>
<Link href={item.url} onClick={handleCloseSidebar}>
{item.icon && <item.icon />}
<span>{item.title}</span>
</Link>
</SidebarMenuButton>
</SidebarMenuItem>
))}
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
)}
{openflareNavItems.length > 0 && (
<SidebarGroup className="py-0 pt-4">
<SidebarGroupLabel className="text-xs font-normal text-muted-foreground">
OpenFlare
</SidebarGroupLabel>
<SidebarGroup className="py-0">
<SidebarGroupContent className="py-1">
<SidebarMenu className="gap-1">
{openflareNavItems.map((item) => (
@@ -339,8 +303,8 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
<SidebarMenuButton
tooltip={item.title}
isActive={
item.url === "/openflare"
? pathname === "/openflare"
item.url === "/"
? pathname === "/"
: pathname === item.url || pathname.startsWith(`${item.url}/`)
}
asChild
@@ -23,10 +23,8 @@ export function SiteTitleUpdater() {
suffix = " - 注册"
} else if (pathname.startsWith("/admin")) {
suffix = " - 后台管理"
} else if (pathname === "/home") {
suffix = " - 控制台"
} else if (pathname === "/") {
suffix = ""
suffix = " - 总览"
}
document.title = `${siteName}${suffix}`