+
-
{t('header.changePassword')}
-
{t('header.changePasswordDesc')}
+
{t('header.changePassword')}
+
{t('header.changePasswordDesc')}
diff --git a/web/src/components/Header/index.tsx b/web/src/components/Header/index.tsx
index fac432f5..b58f157b 100644
--- a/web/src/components/Header/index.tsx
+++ b/web/src/components/Header/index.tsx
@@ -1,16 +1,36 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:07:49
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:07:49
+ */
+/**
+ * AppHeader Component
+ *
+ * The main application header that displays breadcrumb navigation and user menu.
+ * Supports different breadcrumb sources based on the current route.
+ *
+ * @component
+ */
+
import { type FC, useRef } from 'react';
-import { Layout, Dropdown, Space, Breadcrumb } from 'antd';
+import { Layout, Dropdown, Breadcrumb } from 'antd';
import type { MenuProps, BreadcrumbProps } from 'antd';
import { UserOutlined, LogoutOutlined, SettingOutlined } from '@ant-design/icons';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
+
import { useUser } from '@/store/user';
import { useMenu } from '@/store/menu';
import styles from './index.module.css'
import SettingModal, { type SettingModalRef } from './SettingModal'
import UserInfoModal, { type UserInfoModalRef } from './UserInfoModal'
+
const { Header } = Layout;
+/**
+ * @param source - Breadcrumb source type ('space' or 'manage'), defaults to 'manage'
+ */
const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
const { t } = useTranslation();
const location = useLocation();
@@ -20,21 +40,26 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
const { user, logout } = useUser();
const { allBreadcrumbs } = useMenu();
- // 根据当前路由动态选择面包屑源
+ /**
+ * Dynamically select breadcrumb source based on current route
+ * - Knowledge base list: uses 'space' breadcrumb
+ * - Knowledge base detail: uses 'space-detail' breadcrumb
+ * - Other pages: uses the passed source prop
+ */
const getBreadcrumbSource = () => {
const pathname = location.pathname;
- // 知识库列表页面使用默认的 space 面包屑
+ // Knowledge base list page uses default space breadcrumb
if (pathname === '/knowledge-base') {
return 'space';
}
- // 知识库详情相关页面使用独立的面包屑
+ // Knowledge base detail pages use independent breadcrumb
if (pathname.includes('/knowledge-base/') && pathname !== '/knowledge-base') {
return 'space-detail';
}
- // 其他页面使用传入的 source
+ // Other pages use the passed source
return source;
};
@@ -42,13 +67,12 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
const breadcrumbs = allBreadcrumbs[breadcrumbSource] || [];
-
- // 处理退出登录
+ /** Handle user logout */
const handleLogout = () => {
logout()
};
- // 用户下拉菜单配置
+ /** User dropdown menu configuration with profile, settings, and logout options */
const userMenuItems: MenuProps['items'] = [
{
key: '1',
@@ -89,18 +113,25 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
onClick: handleLogout,
},
];
+
+ /**
+ * Format breadcrumb items with proper titles, paths, and click handlers
+ * - Translates i18n keys to display text
+ * - Handles custom onClick events
+ * - Disables navigation for the last breadcrumb item
+ */
const formatBreadcrumbNames = () => {
return breadcrumbs.map((menu, index) => {
const item: any = {
title: menu.i18nKey ? t(menu.i18nKey) : menu.label,
};
- // 如果是最后一项,不设置 path
+ // If it's the last item, don't set path
if (index === breadcrumbs.length - 1) {
return item;
}
- // 如果有自定义 onClick,使用 onClick 并设置 href 为 '#' 以显示手型光标
+ // If has custom onClick, use onClick and set href to '#' to show pointer cursor
if ((menu as any).onClick) {
item.onClick = (e: React.MouseEvent) => {
e.preventDefault();
@@ -108,35 +139,26 @@ const AppHeader: FC<{source?: 'space' | 'manage';}> = ({source = 'manage'}) => {
};
item.href = '#';
} else if (menu.path && menu.path !== '#') {
- // 只有当 path 不是 '#' 时才设置 path
+ // Only set path when path is not '#'
item.path = menu.path;
}
return item;
});
}
+
return (
+ {/* Breadcrumb navigation */}
- {/* 语言切换和主题切换按钮 */}
-
- {/* */}
-
- {/* 用户信息下拉菜单 */}
-
- {user.username}
-
-
+ {/* User info dropdown menu */}
+
+ {user.username}
+
diff --git a/web/src/components/Layout/AuthLayout.tsx b/web/src/components/Layout/AuthLayout.tsx
index a969298d..356f4678 100644
--- a/web/src/components/Layout/AuthLayout.tsx
+++ b/web/src/components/Layout/AuthLayout.tsx
@@ -1,6 +1,25 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:11:02
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:11:02
+ */
+/**
+ * AuthLayout Component
+ *
+ * The main authenticated layout wrapper that provides:
+ * - Route authentication and permission checks
+ * - Automatic breadcrumb navigation updates
+ * - Sidebar navigation and header
+ * - Token-based authentication validation
+ *
+ * @component
+ */
+
import { Outlet } from 'react-router-dom';
import { useEffect, type FC } from 'react';
import { Layout } from 'antd';
+
import useRouteGuard from '@/hooks/useRouteGuard';
import { useNavigationBreadcrumbs } from '@/hooks/useNavigationBreadcrumbs';
import AppHeader from '@/components/Header';
@@ -11,13 +30,20 @@ import { cookieUtils } from '@/utils/request';
const { Content } = Layout;
-// 认证布局组件,使用useRouteGuard hook进行路由鉴权
+/**
+ * Authentication layout component that wraps all authenticated pages.
+ * Handles route guards, breadcrumb navigation, and user authentication.
+ */
const AuthLayout: FC = () => {
const { getUserInfo } = useUser();
- // 使用路由守卫hook处理认证和权限检查
+
+ // Use route guard hook to handle authentication and permission checks
useRouteGuard('manage');
- // 自动更新面包屑导航
+
+ // Automatically update breadcrumb navigation based on current route
useNavigationBreadcrumbs('manage');
+
+ // Check authentication token and fetch user info on mount
useEffect(() => {
const authToken = cookieUtils.get('authToken')
if (!authToken && !window.location.hash.includes('#/login')) {
@@ -29,9 +55,12 @@ const AuthLayout: FC = () => {
return (
+ {/* Sidebar navigation */}
+ {/* Header with breadcrumbs and user menu */}
+ {/* Main content area - renders child routes */}
diff --git a/web/src/components/Layout/AuthSpaceLayout.tsx b/web/src/components/Layout/AuthSpaceLayout.tsx
index 17ee0bac..d47f13f2 100644
--- a/web/src/components/Layout/AuthSpaceLayout.tsx
+++ b/web/src/components/Layout/AuthSpaceLayout.tsx
@@ -1,6 +1,26 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:11:43
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:11:43
+ */
+/**
+ * AuthSpaceLayout Component
+ *
+ * The authenticated layout wrapper for knowledge base (space) pages that provides:
+ * - Route authentication and permission checks for space context
+ * - Automatic breadcrumb navigation updates
+ * - Sidebar navigation and header configured for space mode
+ * - Token-based authentication validation
+ * - Storage type initialization
+ *
+ * @component
+ */
+
import { Outlet } from 'react-router-dom';
import { useEffect, type FC } from 'react';
import { Layout } from 'antd';
+
import useRouteGuard from '@/hooks/useRouteGuard';
import { useNavigationBreadcrumbs } from '@/hooks/useNavigationBreadcrumbs';
import AppHeader from '@/components/Header';
@@ -11,28 +31,38 @@ import { cookieUtils } from '@/utils/request';
const { Content } = Layout;
-// 认证布局组件,使用useRouteGuard hook进行路由鉴权
+/**
+ * Authentication layout component for knowledge base (space) pages.
+ * Similar to AuthLayout but configured for space context with storage type management.
+ */
const AuthSpaceLayout: FC = () => {
const { getUserInfo, getStorageType } = useUser();
- // 使用路由守卫hook处理认证和权限检查
+
+ // Use route guard hook to handle authentication and permission checks for space context
useRouteGuard('space');
- // 自动更新面包屑导航
+
+ // Automatically update breadcrumb navigation based on current route in space context
useNavigationBreadcrumbs('space');
+
+ // Check authentication token, fetch user info and storage type on mount
useEffect(() => {
const authToken = cookieUtils.get('authToken')
if (!authToken && !window.location.hash.includes('#/login')) {
window.location.href = `/#/login`;
} else {
getUserInfo()
- getStorageType()
+ getStorageType() // Fetch storage type for knowledge base operations
}
}, []);
return (
+ {/* Sidebar navigation configured for space mode */}
+ {/* Header with breadcrumbs and user menu configured for space mode */}
+ {/* Main content area for knowledge base pages - renders child routes */}
diff --git a/web/src/components/Layout/BasicLayout.tsx b/web/src/components/Layout/BasicLayout.tsx
index 6b3d2904..cadcafb2 100644
--- a/web/src/components/Layout/BasicLayout.tsx
+++ b/web/src/components/Layout/BasicLayout.tsx
@@ -1,12 +1,35 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:12:42
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:12:42
+ */
+/**
+ * BasicLayout Component
+ *
+ * A minimal layout wrapper that provides:
+ * - User information initialization
+ * - Storage type initialization
+ * - Simple container for child routes without navigation UI
+ *
+ * Used for pages that don't require sidebar/header (e.g., login, public pages).
+ *
+ * @component
+ */
+
import { Outlet } from 'react-router-dom';
import { useEffect, type FC } from 'react';
+
import { useUser } from '@/store/user';
-// 基础布局组件,用于展示内容并保留用户信息获取功能
+/**
+ * Basic layout component for pages without navigation UI.
+ * Fetches user info and storage type on mount, then renders child routes.
+ */
const BasicLayout: FC = () => {
const { getUserInfo, getStorageType } = useUser();
- // 获取用户信息
+ // Fetch user information and storage type on component mount
useEffect(() => {
getUserInfo();
getStorageType()
@@ -14,6 +37,7 @@ const BasicLayout: FC = () => {
return (
+ {/* Render child routes without additional UI */}
)
diff --git a/web/src/components/Layout/LayoutBg.tsx b/web/src/components/Layout/LayoutBg.tsx
index 2cddfb62..ec76f196 100644
--- a/web/src/components/Layout/LayoutBg.tsx
+++ b/web/src/components/Layout/LayoutBg.tsx
@@ -1,13 +1,37 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:13:20
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:13:20
+ */
+/**
+ * LayoutBg Component
+ *
+ * A decorative background component that displays styled background elements.
+ * Provides visual aesthetics with positioned decorative shapes.
+ *
+ * @component
+ */
+
import { type FC } from 'react';
import clsx from 'clsx';
+
import styles from './layout.module.css';
+/**
+ * Background layout component with decorative elements.
+ * Renders a fixed full-screen background with styled shapes.
+ */
const LayoutBg: FC = () => {
return (
-
+ {/* Top section with decorative background shapes */}
+
+ {/* Left decorative element 1 */}
+ {/* Left decorative element 2 */}
+ {/* Right decorative element */}
diff --git a/web/src/components/Layout/LoginLayout.tsx b/web/src/components/Layout/LoginLayout.tsx
index ee49e98f..b3c3b8e6 100644
--- a/web/src/components/Layout/LoginLayout.tsx
+++ b/web/src/components/Layout/LoginLayout.tsx
@@ -1,11 +1,30 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:13:38
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:13:38
+ */
+/**
+ * LoginLayout Component
+ *
+ * A minimal layout wrapper for authentication pages (login, register, etc.).
+ * Provides a simple container without navigation UI or authentication checks.
+ *
+ * @component
+ */
+
import { Outlet } from 'react-router-dom';
import { type FC } from 'react';
-// 基础布局组件,用于展示内容并保留用户信息获取功能
+/**
+ * Login layout component for unauthenticated pages.
+ * Renders child routes in a simple full-size container.
+ */
const LoginLayout: FC = () => {
return (
+ {/* Render authentication pages (login, register, etc.) */}
)
diff --git a/web/src/components/Layout/NoAuthLayout.tsx b/web/src/components/Layout/NoAuthLayout.tsx
index a2e6f274..2e6154cf 100644
--- a/web/src/components/Layout/NoAuthLayout.tsx
+++ b/web/src/components/Layout/NoAuthLayout.tsx
@@ -1,11 +1,30 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:13:55
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:52:17
+ */
+/**
+ * NoAuthLayout Component
+ *
+ * A minimal layout wrapper for public pages that don't require authentication.
+ * Provides a simple container without navigation UI or authentication checks.
+ *
+ * @component
+ */
+
import { Outlet } from 'react-router-dom';
import { type FC } from 'react';
-// 基础布局组件,用于展示内容并保留用户信息获取功能
+/**
+ * No-authentication layout component for public pages.
+ * Renders child routes in a simple full-size container without any auth requirements.
+ */
const NoAuthLayout: FC = () => {
return (
+ {/* Render public pages without authentication */}
)
diff --git a/web/src/components/Markdown/AudioBlock.tsx b/web/src/components/Markdown/AudioBlock.tsx
index bd638816..75039d61 100644
--- a/web/src/components/Markdown/AudioBlock.tsx
+++ b/web/src/components/Markdown/AudioBlock.tsx
@@ -1,15 +1,31 @@
-import { memo } from 'react'
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:14:59
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:14:59
+ */
+/**
+ * AudioBlock Component
+ *
+ * Renders audio elements from markdown nodes.
+ * Extracts audio source URLs and creates HTML audio players with controls.
+ *
+ * @component
+ */
-import type { FC } from 'react'
+import { memo, type FC } from 'react'
+/** Props interface for AudioBlock component */
interface AudioBlockProps {
node: {
children: { properties: { src: string } }[]
}
}
+
+/** Audio block component that renders audio elements from markdown nodes */
const AudioBlock: FC
= (props) => {
- // console.log('AudioBlock', props)
const { children } = props.node;
+ /** Extract audio source URLs from node children and filter out empty values */
const srcs = children.map(item => item.properties?.src).filter(item => item)
return (
diff --git a/web/src/components/Markdown/Code.tsx b/web/src/components/Markdown/Code.tsx
index de60d0de..9aecd977 100644
--- a/web/src/components/Markdown/Code.tsx
+++ b/web/src/components/Markdown/Code.tsx
@@ -1,22 +1,45 @@
+/*
+ * @Author: ZhaoYing
+ * @Date: 2026-02-02 15:15:05
+ * @Last Modified by: ZhaoYing
+ * @Last Modified time: 2026-02-02 15:15:05
+ */
+/**
+ * Code Component
+ *
+ * A versatile code rendering component that supports:
+ * - Syntax-highlighted code blocks
+ * - ECharts visualizations
+ * - SVG rendering
+ * - Mermaid diagrams
+ * - Inline code snippets
+ *
+ * @component
+ */
+
import { type FC, useMemo } from 'react'
import SyntaxHighlighter from 'react-syntax-highlighter';
import { atelierHeathLight } from 'react-syntax-highlighter/dist/esm/styles/hljs';
-import CopyBtn from './CopyBtn';
import ReactEcharts from 'echarts-for-react';
+
+import CopyBtn from './CopyBtn';
import Svg from './Svg'
import MermaidChart from './MermaidChart'
-
+/** Props interface for Code component */
type ICodeProps = {
children: string;
className: string;
}
+/** Code block component that renders syntax-highlighted code or special visualizations */
const Code: FC = (props) => {
const { children, className } = props;
+ /** Extract language from className (e.g., 'language-javascript' -> 'javascript') */
const language = className?.split('-')[1]
console.log('Code', props)
+ // Parse ECharts configuration from code content
const charData = useMemo(() => {
if (language !== 'echarts') return null;
try {
@@ -27,6 +50,7 @@ const Code: FC = (props) => {
}
}, [language, children])
+ // Render ECharts visualization
if (language === 'echarts') {
return (
= (props) => {
)
}
+ // Render SVG content
if (language === 'svg') {
return (