Browse Source

refactor: 将相对路径导入替换为 @ 别名,并修复 LoginPage 中的类型错误

web
hyh 3 months ago
parent
commit
d18b2bb245
  1. 2
      src/CellularManagement.WebUI/src/components/auth/LoginForm.tsx
  2. 8
      src/CellularManagement.WebUI/src/components/layout/Header.tsx
  3. 2
      src/CellularManagement.WebUI/src/components/layout/NotificationDrawer.tsx
  4. 4
      src/CellularManagement.WebUI/src/components/layout/Sidebar.tsx
  5. 13
      src/CellularManagement.WebUI/src/pages/auth/LoginPage.tsx
  6. 8
      src/CellularManagement.WebUI/src/routes/AppRouter.tsx

2
src/CellularManagement.WebUI/src/components/auth/LoginForm.tsx

@ -1,5 +1,5 @@
import { useState } from 'react';
import { DEFAULT_CREDENTIALS } from '../../constants/auth';
import { DEFAULT_CREDENTIALS } from '@/constants/auth';
interface LoginFormProps {
onSubmit: (username: string, password: string) => void;

8
src/CellularManagement.WebUI/src/components/layout/Header.tsx

@ -1,10 +1,10 @@
import { SearchInput } from '../ui/SearchInput';
import { UserAvatarMenu } from '../ui/UserAvatarMenu';
import { NotificationDrawer } from './NotificationDrawer';
import { SearchInput } from '@/components/ui/SearchInput';
import { UserAvatarMenu } from '@/components/ui/UserAvatarMenu';
import { NotificationDrawer } from '@/components/layout/NotificationDrawer';
import { useDrawer } from '@/hooks/useDrawer';
import { useSidebarToggle } from '@/hooks/useSidebarToggle';
import { cn } from '@/lib/utils';
import { SidebarToggleButton } from '../ui/SidebarToggleButton';
import { SidebarToggleButton } from '@/components/ui/SidebarToggleButton';
export function Header() {
const { isOpen: isNotificationOpen, toggle: toggleNotification } = useDrawer();

2
src/CellularManagement.WebUI/src/components/layout/NotificationDrawer.tsx

@ -1,5 +1,5 @@
import { Dialog, DialogContent } from '@radix-ui/react-dialog';
import { NotificationItem } from '../ui/NotificationItem';
import { NotificationItem } from '@/components/ui/NotificationItem';
interface NotificationDrawerProps {
isOpen: boolean;

4
src/CellularManagement.WebUI/src/components/layout/Sidebar.tsx

@ -1,7 +1,7 @@
import { useState } from 'react';
import { cn } from '@/lib/utils';
import { SidebarMenuItem } from '../ui/SidebarMenuItem';
import { SidebarToggleButton } from '../ui/SidebarToggleButton';
import { SidebarMenuItem } from '@/components/ui/SidebarMenuItem';
import { SidebarToggleButton } from '@/components/ui/SidebarToggleButton';
import { useSidebarToggle } from '@/hooks/useSidebarToggle';
import { menuItems, hasPermission, Permission, MenuItem } from '@/constants/menuConfig';
import { useAuth } from '@/hooks/useAuth'; // 假设你有一个useAuth hook来获取用户权限

13
src/CellularManagement.WebUI/src/pages/auth/LoginPage.tsx

@ -1,7 +1,8 @@
import { useNavigate, useLocation } from 'react-router-dom';
import { LoginForm } from '../../components/auth/LoginForm';
import { DEFAULT_CREDENTIALS } from '../../constants/auth';
import { LoginForm } from '@/components/auth/LoginForm';
import { DEFAULT_CREDENTIALS } from '@/constants/auth';
import { useAuth } from '@/hooks/useAuth';
import { Permission } from '@/constants/menuConfig';
export function LoginPage() {
const navigate = useNavigate();
@ -19,7 +20,13 @@ export function LoginPage() {
id: '1',
name: username,
email: `${username}@example.com`,
permissions: ['dashboard.view', 'users.view', 'roles.view', 'permissions.view', 'settings.view']
permissions: [
'dashboard.view',
'users.view',
'roles.view',
'permissions.view',
'settings.view'
] as Permission[]
};
// 保存用户数据到 localStorage

8
src/CellularManagement.WebUI/src/routes/AppRouter.tsx

@ -1,11 +1,11 @@
import { Routes, Route, Navigate } from 'react-router-dom';
import { Suspense, lazy } from 'react';
import { DashboardLayout } from '../components/layout/DashboardLayout';
import { ProtectedRoute } from '../components/auth/ProtectedRoute';
import { DashboardLayout } from '@/components/layout/DashboardLayout';
import { ProtectedRoute } from '@/components/auth/ProtectedRoute';
// 使用 lazy 加载组件
const LoginPage = lazy(() => import('../pages/auth/LoginPage').then(module => ({ default: module.LoginPage })));
const DashboardHome = lazy(() => import('../pages/dashboard/DashboardHome').then(module => ({ default: module.DashboardHome })));
const LoginPage = lazy(() => import('@/pages/auth/LoginPage').then(module => ({ default: module.LoginPage })));
const DashboardHome = lazy(() => import('@/pages/dashboard/DashboardHome').then(module => ({ default: module.DashboardHome })));
const ForbiddenPage = lazy(() => import('@/pages/auth/ForbiddenPage').then(module => ({ default: module.default })));
// 加载中的占位组件

Loading…
Cancel
Save