Skip to content

Commit 91f3e8d

Browse files
committed
⭐️ Add pages to Navigation
1 parent c8a9a29 commit 91f3e8d

File tree

4 files changed

+76
-31
lines changed

4 files changed

+76
-31
lines changed

frontend/app/[locale]/models/ModelsContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import React, {useEffect, useRef, useState} from "react";
3+
import React, {useRef, useState} from "react";
44
import {App} from "antd";
55
import {motion} from "framer-motion";
66

frontend/app/[locale]/setup/page.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export default function SetupPage() {
147147
return (
148148
<NavigationLayout
149149
contentMode="scrollable"
150-
showFooter={true}
150+
showFooter={false}
151151
topNavbarLeftContent={
152152
<SetupHeaderLeftContent
153153
title={t("setup.header.title")}
@@ -173,11 +173,9 @@ export default function SetupPage() {
173173
nextText={t("setup.navigation.button.next")}
174174
completeText={t("setup.navigation.button.complete")}
175175
>
176-
177176
{/* Render content based on current step */}
178177
{currentStep === "models" && isAdmin && (
179178
<ModelsContent
180-
showNavigation={true}
181179
onNext={handleNext}
182180
connectionStatus={connectionStatus}
183181
isCheckingConnection={isCheckingConnection}
@@ -187,10 +185,6 @@ export default function SetupPage() {
187185

188186
{currentStep === "knowledges" && (
189187
<KnowledgesContent
190-
showNavigation={true}
191-
onBack={handleBack}
192-
onNext={isAdmin ? handleNext : undefined}
193-
onComplete={!isAdmin ? handleComplete : undefined}
194188
isSaving={isSaving}
195189
connectionStatus={connectionStatus}
196190
isCheckingConnection={isCheckingConnection}
@@ -201,9 +195,6 @@ export default function SetupPage() {
201195

202196
{currentStep === "agents" && isAdmin && (
203197
<AgentsContent
204-
showNavigation={true}
205-
onBack={handleBack}
206-
onComplete={handleComplete}
207198
isSaving={isSaving}
208199
connectionStatus={connectionStatus}
209200
isCheckingConnection={isCheckingConnection}

frontend/components/homepage/HomepageContent.tsx

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,35 +65,59 @@ export function HomepageContent({
6565
transition={{ duration: 0.8, delay: 0.4 }}
6666
className="flex flex-col sm:flex-row gap-4"
6767
>
68-
<Link
69-
href={isSpeedMode || user ? "/chat" : "#"}
70-
onClick={onAuthRequired}
71-
>
72-
<Button className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group">
68+
{/* Start Chat Button */}
69+
{isSpeedMode || user ? (
70+
<Link href="/chat">
71+
<Button className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group">
72+
<Bot className="mr-2 h-5 w-5 group-hover:animate-pulse" />
73+
{t("page.startChat")}
74+
</Button>
75+
</Link>
76+
) : (
77+
<Button
78+
onClick={onAuthRequired}
79+
className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group"
80+
>
7381
<Bot className="mr-2 h-5 w-5 group-hover:animate-pulse" />
7482
{t("page.startChat")}
7583
</Button>
76-
</Link>
84+
)}
7785

78-
<Link
79-
href={isSpeedMode || user?.role === "admin" ? "/setup" : "#"}
80-
onClick={onAdminRequired}
81-
>
82-
<Button className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group">
86+
{/* Quick Config Button */}
87+
{isSpeedMode || user?.role === "admin" ? (
88+
<Link href="/setup">
89+
<Button className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group">
90+
<Zap className="mr-2 h-5 w-5 group-hover:animate-pulse" />
91+
{t("page.quickConfig")}
92+
</Button>
93+
</Link>
94+
) : (
95+
<Button
96+
onClick={onAdminRequired}
97+
className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group"
98+
>
8399
<Zap className="mr-2 h-5 w-5 group-hover:animate-pulse" />
84100
{t("page.quickConfig")}
85101
</Button>
86-
</Link>
102+
)}
87103

88-
<Link
89-
href={isSpeedMode || user ? "/space" : "#"}
90-
onClick={onAuthRequired}
91-
>
92-
<Button className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group">
104+
{/* Agent Space Button */}
105+
{isSpeedMode || user ? (
106+
<Link href="/space">
107+
<Button className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group">
108+
<Globe className="mr-2 h-5 w-5 group-hover:animate-pulse" />
109+
{t("page.agentSpace")}
110+
</Button>
111+
</Link>
112+
) : (
113+
<Button
114+
onClick={onAuthRequired}
115+
className="bg-blue-600 hover:bg-blue-700 text-white px-8 py-6 rounded-full text-lg font-medium shadow-lg hover:shadow-xl transition-all duration-300 group"
116+
>
93117
<Globe className="mr-2 h-5 w-5 group-hover:animate-pulse" />
94118
{t("page.agentSpace")}
95119
</Button>
96-
</Link>
120+
)}
97121
</motion.div>
98122

99123
{/* Data protection notice - only shown in full version */}

frontend/components/navigation/SideNavigation.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use client";
22

3-
import { useState } from "react";
3+
import { useState, useEffect } from "react";
44
import { useTranslation } from "react-i18next";
5+
import { usePathname } from "next/navigation";
56
import { Layout, Menu, ConfigProvider, Button } from "antd";
67
import {
78
Bot,
@@ -28,6 +29,28 @@ interface SideNavigationProps {
2829
onAdminRequired?: () => void;
2930
}
3031

32+
/**
33+
* Get menu key based on current pathname
34+
*/
35+
function getMenuKeyFromPathname(pathname: string): string {
36+
// Remove locale prefix (e.g., /zh/, /en/)
37+
const segments = pathname.split('/').filter(Boolean);
38+
const pathWithoutLocale = segments.length > 1 ? segments[1] : '';
39+
40+
// Map paths to menu keys
41+
const pathToKeyMap: Record<string, string> = {
42+
'': '0', // Home page
43+
'chat': '1', // Start chat
44+
'setup': '2', // Quick config
45+
'space': '3', // Agent space
46+
'agents': '5', // Agent dev
47+
'knowledges': '6', // Knowledge base
48+
'models': '7', // Model management
49+
};
50+
51+
return pathToKeyMap[pathWithoutLocale] || '0';
52+
}
53+
3154
/**
3255
* Side navigation component with collapsible menu
3356
* Displays main navigation items for the application
@@ -38,8 +61,15 @@ export function SideNavigation({
3861
}: SideNavigationProps) {
3962
const { t } = useTranslation("common");
4063
const { user, isSpeedMode } = useAuth();
64+
const pathname = usePathname();
4165
const [collapsed, setCollapsed] = useState(false);
42-
const [selectedKey, setSelectedKey] = useState("1");
66+
const [selectedKey, setSelectedKey] = useState("0");
67+
68+
// Update selected key when pathname changes
69+
useEffect(() => {
70+
const key = getMenuKeyFromPathname(pathname);
71+
setSelectedKey(key);
72+
}, [pathname]);
4373

4474
// Menu items configuration
4575
const menuItems: MenuProps["items"] = [

0 commit comments

Comments
 (0)