refactor: 重构项目结构并优化类型定义

- 移除extension模块,将功能迁移至node-agent
- 修复类型导出问题,使用export type明确类型导出
- 统一数据库连接方式,从直接导入改为使用config/database
- 更新文档中的项目结构描述
- 添加多个服务的实用方法,如getForecast、getBalances等
- 修复类型错误和TS1205警告
- 优化RedisService调用方式
- 添加新的实体类型定义
- 更新审计日志格式,统一字段命名
This commit is contained in:
2026-03-21 15:04:06 +08:00
parent 888d3844f3
commit 15ee1758f5
286 changed files with 9110 additions and 21453 deletions

View File

@@ -28,18 +28,12 @@ import {
ThunderboltOutlined,
} from '@ant-design/icons';
import { Link, useLocation, useNavigate, Outlet } from 'react-router-dom';
import type { MenuProps } from 'antd';
const { Header, Sider, Content } = Layout;
const { Title, Text } = Typography;
// 菜单项类型定义
interface MenuItem {
key: string;
icon?: React.ReactNode;
label: React.ReactNode;
children?: MenuItem[];
type?: 'divider';
}
type MenuItem = MenuProps['items'][number];
// 菜单项配置
const menuItems: MenuItem[] = [
@@ -194,6 +188,7 @@ const userMenuItems: MenuItem[] = [
label: '账号设置',
},
{
key: 'divider-1',
type: 'divider',
},
{
@@ -211,49 +206,22 @@ const MainLayout: React.FC = () => {
// 根据当前路径设置选中的菜单项
useEffect(() => {
const pathname = location.pathname;
// 找到匹配的菜单项
let matchedKey: string | undefined;
// 递归查找匹配的菜单项
const findMatchedItem = (items: MenuItem[]): boolean => {
const findKey = (items: MenuItem[]): string | undefined => {
for (const item of items) {
if (item.type === 'divider') continue;
if (item.children) {
// 检查子菜单项
for (const child of item.children) {
if (child.type === 'divider') continue;
if (child.key === '/') {
if (pathname === '/') {
matchedKey = child.key;
return true;
}
} else if (pathname.startsWith(child.key)) {
matchedKey = child.key;
return true;
}
if (item && 'key' in item && typeof item.key === 'string') {
if (item.key.startsWith('/') && pathname.startsWith(item.key)) {
return item.key;
}
// 递归检查子菜单
if (findMatchedItem(item.children)) {
return true;
}
} else {
// 检查当前菜单项
if (item.key === '/') {
if (pathname === '/') {
matchedKey = item.key;
return true;
}
} else if (pathname.startsWith(item.key)) {
matchedKey = item.key;
return true;
if ('children' in item && Array.isArray(item.children)) {
const found = findKey(item.children as MenuItem[]);
if (found) return found;
}
}
}
return false;
return undefined;
};
findMatchedItem(menuItems);
const matchedKey = findKey(menuItems);
if (matchedKey) {
setSelectedKeys([matchedKey]);
}