File size: 4,333 Bytes
9dd9a58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import React from 'react';
import { useAuth } from '../../hooks/useAuth';
import { 
  PencilSquareIcon, 
  FolderOpenIcon, 
  CpuChipIcon, 
  CogIcon,
  UserCircleIcon,
  ShieldCheckIcon
} from '@heroicons/react/24/outline';

interface SidebarProps {
  activeSection: string;
  onSectionChange: (section: string) => void;
}

const Sidebar: React.FC<SidebarProps> = ({ activeSection, onSectionChange }) => {
  const { user, signOut } = useAuth();

  const menuItems = [
    {
      id: 'creation',
      label: '创作中心',
      icon: PencilSquareIcon,
      description: 'AI驱动的小说创作'
    },
    {
      id: 'projects',
      label: '作品管理',
      icon: FolderOpenIcon,
      description: '管理您的小说项目'
    },
    {
      id: 'ai-models',
      label: 'AI模型',
      icon: CpuChipIcon,
      description: '配置和管理AI模型'
    },
    {
      id: 'settings',
      label: '系统设置',
      icon: CogIcon,
      description: '个人设置和系统配置'
    }
  ];

  // 管理员菜单项
  if (user?.role === 'admin') {
    menuItems.push({
      id: 'admin',
      label: '管理控制台',
      icon: ShieldCheckIcon,
      description: '系统管理和监控'
    });
  }

  return (
    <div className="w-80 bg-secondary-bg backdrop-blur-lg border-r border-border-color h-screen fixed z-10 overflow-y-auto">
      {/* 头部 Logo */}
      <div className="p-6 border-b border-border-color">
        <div className="text-center">
          <div className="text-4xl mb-3 logo-glow">
            📚
          </div>
          <h1 className="text-2xl font-logo font-bold text-text-highlight">
            NovelForge
          </h1>
          <p className="text-accent-cyan text-sm font-logo">
            Sentinel Pro
          </p>
        </div>
      </div>

      {/* 导航菜单 */}
      <div className="py-4">
        {menuItems.map((item) => {
          const Icon = item.icon;
          return (
            <button
              key={item.id}
              onClick={() => onSectionChange(item.id)}
              className={`
                nav-item w-full text-left group
                ${activeSection === item.id ? 'active' : ''}
              `}
            >
              <Icon className="w-6 h-6 text-accent-cyan mr-4 flex-shrink-0" />
              <div className="flex-1">
                <div className="font-medium text-text-primary group-hover:text-text-highlight transition-colors">
                  {item.label}
                </div>
                <div className="text-xs text-text-secondary group-hover:text-text-primary/70 transition-colors">
                  {item.description}
                </div>
              </div>
            </button>
          );
        })}
      </div>

      {/* 底部用户信息 */}
      <div className="absolute bottom-0 w-full border-t border-border-color bg-panel-bg">
        <div className="p-4">
          {/* 用户信息 */}
          <div className="flex items-center mb-4">
            <div className="w-10 h-10 bg-gradient-to-r from-accent-cyan to-accent-blue rounded-full flex items-center justify-center mr-3 shadow-glow-sm">
              <UserCircleIcon className="w-6 h-6 text-primary-bg" />
            </div>
            <div className="flex-1">
              <div className="font-medium text-text-highlight">
                {user?.full_name || user?.username || '用户'}
              </div>
              <div className="text-sm text-success-green">
                {user?.role === 'admin' ? '管理员' : '已认证'}
              </div>
            </div>
          </div>

          {/* 安全状态 */}
          <div className="flex items-center justify-between mb-4">
            <div className="flex items-center">
              <div className="status-indicator active mr-2"></div>
              <span className="text-sm text-text-secondary">设备已绑定</span>
            </div>
            <div className="text-xs text-success-green">
              安全
            </div>
          </div>

          {/* 退出按钮 */}
          <button
            onClick={signOut}
            className="w-full cyber-btn cyber-btn-secondary py-2 text-sm"
          >
            退出登录
          </button>
        </div>
      </div>
    </div>
  );
};

export default Sidebar;