diff --git a/web/src/App.tsx b/web/src/App.tsx index 8e3140d9..1abbc2cc 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -30,15 +30,12 @@ import 'dayjs/plugin/utc' import { cookieUtils } from './utils/request'; - - - function App() { const { t } = useTranslation(); const { locale, language, timeZone } = useI18n() useEffect(() => { const authToken = cookieUtils.get('authToken') - if (!authToken && !window.location.hash.includes('#/login')) { + if (!authToken && !window.location.hash.includes('#/login') && !window.location.hash.includes('#/conversation/')) { window.location.href = `/#/login`; } }, []) diff --git a/web/src/components/Layout/NoAuthLayout.tsx b/web/src/components/Layout/NoAuthLayout.tsx new file mode 100644 index 00000000..a2e6f274 --- /dev/null +++ b/web/src/components/Layout/NoAuthLayout.tsx @@ -0,0 +1,14 @@ +import { Outlet } from 'react-router-dom'; +import { type FC } from 'react'; + +// 基础布局组件,用于展示内容并保留用户信息获取功能 +const NoAuthLayout: FC = () => { + + return ( +
+ +
+ ) +}; + +export default NoAuthLayout; \ No newline at end of file diff --git a/web/src/routes/index.tsx b/web/src/routes/index.tsx index 5c302565..7189dc9c 100644 --- a/web/src/routes/index.tsx +++ b/web/src/routes/index.tsx @@ -34,6 +34,7 @@ const componentMap: Record>> = AuthSpaceLayout: lazy(() => import('@/components/Layout/AuthSpaceLayout')), BasicLayout: lazy(() => import('@/components/Layout/BasicLayout')), LoginLayout: lazy(() => import('@/components/Layout/LoginLayout')), + NoAuthLayout: lazy(() => import('@/components/Layout/NoAuthLayout')), // 视图组件 Index: lazy(() => import('@/views/Index')), Home: lazy(() => import('@/views/Home')), diff --git a/web/src/routes/routes.json b/web/src/routes/routes.json index db0c1b7d..1c317033 100644 --- a/web/src/routes/routes.json +++ b/web/src/routes/routes.json @@ -42,12 +42,17 @@ "element": "BasicLayout", "children": [ { "path": "/application/config/:id", "element": "ApplicationConfig" }, - { "path": "/conversation/:token", "element": "Conversation" }, { "path": "/user-memory/neo4j/:id", "element": "Neo4jUserMemoryDetail" }, { "path": "/statement/:id", "element": "StatementDetail" }, { "path": "/user-memory/detail/:id/:type", "element": "MemoryNodeDetail" } ] }, + { + "element": "NoAuthLayout", + "children": [ + { "path": "/conversation/:token", "element": "Conversation" } + ] + }, { "element": "LoginLayout", "children": [