diff --git a/apps/web/src/pages/admin/Analytics.tsx b/apps/web/src/pages/admin/Analytics.tsx deleted file mode 100644 index 186e6e67a..000000000 --- a/apps/web/src/pages/admin/Analytics.tsx +++ /dev/null @@ -1,245 +0,0 @@ -/** - * Admin Analytics 数据分析页面 - */ -import React from 'react'; -import { Card, Row, Col, Statistic, Table, DatePicker, Space } from 'antd'; -import { - LineChart, - Line, - BarChart, - Bar, - PieChart, - Pie, - Cell, - XAxis, - YAxis, - CartesianGrid, - Tooltip, - Legend, - ResponsiveContainer, -} from 'recharts'; -import { - ArrowUpOutlined, - UserAddOutlined, - DollarOutlined, - ProjectOutlined, -} from '@ant-design/icons'; -import './Admin.css'; - -const { RangePicker } = DatePicker; - -// V21 配色 -const V21_COLORS = { - primary: '#4f46e5', - primaryLight: '#6366f1', - success: '#10b981', - successLight: '#34d399', - warning: '#f59e0b', - warningLight: '#fbbf24', - purple: '#8b5cf6', - purpleLight: '#a78bfa', -}; - -const Analytics: React.FC = () => { - // 模拟用户增长数据 - const userGrowthData = [ - { month: '1月', users: 120, paid: 15 }, - { month: '2月', users: 180, paid: 28 }, - { month: '3月', users: 240, paid: 42 }, - { month: '4月', users: 320, paid: 58 }, - { month: '5月', users: 450, paid: 89 }, - { month: '6月', users: 620, paid: 135 }, - ]; - - // 模拟营收数据 - const revenueData = [ - { month: '1月', revenue: 1480 }, - { month: '2月', revenue: 2770 }, - { month: '3月', revenue: 4160 }, - { month: '4月', revenue: 5740 }, - { month: '5月', revenue: 8810 }, - { month: '6月', revenue: 13365 }, - ]; - - // 订阅计划分布 - const planDistribution = [ - { name: 'Free', value: 485, color: '#a78bfa' }, - { name: 'Pro', value: 120, color: '#34d399' }, - { name: 'Enterprise', value: 15, color: '#fbbf24' }, - ]; - - // 活跃度统计 - const activityStats = [ - { metric: '日活跃用户 (DAU)', value: 892, growth: '+12.5%', icon: , colorClass: 'primary' }, - { metric: '月活跃用户 (MAU)', value: 3456, growth: '+8.3%', icon: , colorClass: 'success' }, - { metric: '本月收入', value: 13365, prefix: '¥', growth: '+51.6%', icon: , colorClass: 'warning' }, - { metric: '活跃项目数', value: 2341, growth: '+18.2%', icon: , colorClass: 'purple' }, - ]; - - // 用户留存表格 - const retentionData = [ - { cohort: '2024-01', day1: '100%', day7: '68%', day30: '45%', day90: '28%' }, - { cohort: '2024-02', day1: '100%', day7: '72%', day30: '48%', day90: '31%' }, - { cohort: '2024-03', day1: '100%', day7: '75%', day30: '52%', day90: '-' }, - { cohort: '2024-04', day1: '100%', day7: '78%', day30: '55%', day90: '-' }, - { cohort: '2024-05', day1: '100%', day7: '80%', day30: '-', day90: '-' }, - ]; - - const retentionColumns = [ - { title: 'Cohort', dataIndex: 'cohort', key: 'cohort' }, - { title: 'Day 1', dataIndex: 'day1', key: 'day1' }, - { title: 'Day 7', dataIndex: 'day7', key: 'day7' }, - { title: 'Day 30', dataIndex: 'day30', key: 'day30' }, - { title: 'Day 90', dataIndex: 'day90', key: 'day90' }, - ]; - - const colorMap: Record = { - primary: '#4f46e5', - success: '#10b981', - warning: '#f59e0b', - purple: '#8b5cf6', - }; - - return ( -
-
-
-

数据分析

-

用户增长、营收趋势与留存分析

-
-
- - - -
-
- - {/* 关键指标 */} - - {activityStats.map((stat, index) => ( - -
-
-
- {stat.icon} -
-
-
{stat.metric}
-
- {stat.prefix}{stat.value.toLocaleString()} -
-
- {stat.growth} vs 上月 -
-
- - ))} -
- - {/* 图表区域 */} - - {/* 用户增长趋势 */} - -
- - - - - - - - - - - - - -
- - - {/* 订阅计划分布 */} - -
- - - - `${entry.name}: ${entry.value}`} - outerRadius={80} - fill="#8884d8" - dataKey="value" - > - {planDistribution.map((entry, index) => ( - - ))} - - - - - -
- -
- - {/* 营收趋势 */} - - -
- - - - - - - - - - - - -
- -
- - {/* 用户留存表 */} -
- - - - - - ); -}; - -export default Analytics; - -export const Component = Analytics; diff --git a/apps/web/src/pages/admin/Dashboard.tsx b/apps/web/src/pages/admin/Dashboard.tsx deleted file mode 100644 index 469b6c2d7..000000000 --- a/apps/web/src/pages/admin/Dashboard.tsx +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Admin Dashboard 仪表盘 - */ -import React from 'react'; -import { Card, Row, Col, Statistic, Table } from 'antd'; -import { - UserOutlined, - CrownOutlined, - DollarOutlined, - RiseOutlined, -} from '@ant-design/icons'; -import './Admin.css'; - -const Dashboard: React.FC = () => { - // 模拟数据 - const stats = [ - { title: '总用户数', value: 1234, icon: , colorClass: 'primary' }, - { title: '付费用户', value: 156, icon: , colorClass: 'success' }, - { title: '月收入', value: 15444, prefix: '¥', icon: , colorClass: 'warning' }, - { title: '活跃用户', value: 892, icon: , colorClass: 'purple' }, - ]; - - const recentUsers = [ - { id: '1', username: 'user1', email: 'user1@example.com', created_at: '2024-06-17' }, - { id: '2', username: 'user2', email: 'user2@example.com', created_at: '2024-06-16' }, - { id: '3', username: 'user3', email: 'user3@example.com', created_at: '2024-06-15' }, - ]; - - const columns = [ - { title: '用户名', dataIndex: 'username', key: 'username' }, - { title: '邮箱', dataIndex: 'email', key: 'email' }, - { title: '注册时间', dataIndex: 'created_at', key: 'created_at' }, - ]; - - const colorMap: Record = { - primary: '#4f46e5', - success: '#10b981', - warning: '#f59e0b', - purple: '#8b5cf6', - }; - - return ( -
-
-

Dashboard

-

系统数据总览与关键指标

-
- - - {stats.map((stat, index) => ( -
-
-
-
- {stat.icon} -
-
-
{stat.title}
-
- {stat.prefix}{stat.value.toLocaleString()} -
-
- - ))} - - -
- -
- - - - ); -}; - -export default Dashboard; - -export const Component = Dashboard; diff --git a/apps/web/src/pages/admin/LogViewer.tsx b/apps/web/src/pages/admin/LogViewer.tsx deleted file mode 100644 index 4744a0957..000000000 --- a/apps/web/src/pages/admin/LogViewer.tsx +++ /dev/null @@ -1,344 +0,0 @@ -/** - * 日志查看器 - */ -import React, { useState } from 'react'; -import { Card, Table, Tag, Input, Select, DatePicker, Space, Button, Drawer } from 'antd'; -import { - SearchOutlined, - FilterOutlined, - DownloadOutlined, - EyeOutlined, -} from '@ant-design/icons'; -import type { ColumnsType } from 'antd/es/table'; -import './Admin.css'; - -const { Search } = Input; -const { RangePicker } = DatePicker; -const { Option } = Select; - -interface LogEntry { - id: string; - timestamp: string; - level: 'INFO' | 'WARN' | 'ERROR' | 'DEBUG'; - service: string; - user?: string; - action: string; - details: string; - ip?: string; - request_id?: string; -} - -const LogViewer: React.FC = () => { - const [selectedLog, setSelectedLog] = useState(null); - const [drawerVisible, setDrawerVisible] = useState(false); - const [filterLevel, setFilterLevel] = useState('all'); - const [filterService, setFilterService] = useState('all'); - - // 模拟日志数据 - const logs: LogEntry[] = [ - { - id: '1', - timestamp: '2024-06-17 17:15:32', - level: 'INFO', - service: 'API', - user: 'user@example.com', - action: 'User Login', - details: 'User successfully logged in', - ip: '192.168.1.100', - request_id: 'req_abc123', - }, - { - id: '2', - timestamp: '2024-06-17 17:14:28', - level: 'WARN', - service: 'API', - user: 'admin@example.com', - action: 'Failed Login Attempt', - details: 'Invalid password provided (attempt 2/5)', - ip: '192.168.1.101', - request_id: 'req_def456', - }, - { - id: '3', - timestamp: '2024-06-17 17:12:45', - level: 'ERROR', - service: 'Database', - action: 'Connection Timeout', - details: 'PostgreSQL connection pool exhausted, timeout after 5s', - request_id: 'req_ghi789', - }, - { - id: '4', - timestamp: '2024-06-17 17:10:15', - level: 'INFO', - service: 'Celery', - action: 'Task Completed', - details: 'Video processing task completed successfully', - request_id: 'task_jkl012', - }, - { - id: '5', - timestamp: '2024-06-17 17:08:52', - level: 'WARN', - service: 'ObjectStorage', - action: 'Slow Upload', - details: 'File upload took 3.2s (>1s threshold)', - ip: '192.168.1.102', - request_id: 'req_mno345', - }, - { - id: '6', - timestamp: '2024-06-17 17:05:33', - level: 'ERROR', - service: 'API', - user: 'user2@example.com', - action: 'Permission Denied', - details: 'User attempted to access admin endpoint without permission', - ip: '192.168.1.103', - request_id: 'req_pqr678', - }, - { - id: '7', - timestamp: '2024-06-17 17:03:21', - level: 'INFO', - service: 'API', - user: 'user3@example.com', - action: 'Project Created', details: 'New project "My Project" created', - ip: '192.168.1.104', - request_id: 'req_stu901', - }, - { - id: '8', - timestamp: '2024-06-17 17:01:08', - level: 'DEBUG', - service: 'Redis', - action: 'Cache Miss', - details: 'Cache key "project:123" not found, fetching from DB', - request_id: 'req_vwx234', - }, - ]; - - const getLevelTagClass = (level: string) => { - const classes: Record = { - INFO: 'xx-tag info', - WARN: 'xx-tag warning', - ERROR: 'xx-tag error', - DEBUG: 'xx-tag debug', - }; - return classes[level] || 'xx-tag debug'; - }; - - const handleViewDetails = (log: LogEntry) => { - setSelectedLog(log); - setDrawerVisible(true); - }; - - const columns: ColumnsType = [ - { - title: '时间', - dataIndex: 'timestamp', - key: 'timestamp', - width: 180, - sorter: (a, b) => a.timestamp.localeCompare(b.timestamp), - }, - { - title: '级别', - dataIndex: 'level', - key: 'level', - width: 100, - render: (level: string) => {level}, - filters: [ - { text: 'INFO', value: 'INFO' }, - { text: 'WARN', value: 'WARN' }, - { text: 'ERROR', value: 'ERROR' }, - { text: 'DEBUG', value: 'DEBUG' }, - ], - onFilter: (value, record) => record.level === value, - }, - { - title: '服务', - dataIndex: 'service', - key: 'service', - width: 120, - filters: [ - { text: 'API', value: 'API' }, - { text: 'Database', value: 'Database' }, - { text: 'Celery', value: 'Celery' }, - { text: 'ObjectStorage', value: 'ObjectStorage' }, - { text: 'Redis', value: 'Redis' }, - ], - onFilter: (value, record) => record.service === value, - }, - { - title: '用户', - dataIndex: 'user', - key: 'user', - width: 180, - render: (user?: string) => user || '-', - }, - { - title: '操作', - dataIndex: 'action', - key: 'action', - width: 200, - }, - { - title: '详情', - dataIndex: 'details', - key: 'details', - ellipsis: true, - }, - { - title: '操作', - key: 'actions', - width: 100, - render: (_, record) => ( - - ), - }, - ]; - - return ( -
-
-

日志查看器

-

系统日志查询与监控

-
- -
- } - className="xx-search-input" - style={{ width: 280 }} - /> - - - - - - - - - -
- -
-
`共 ${total} 条日志`, - }} - scroll={{ x: 1200 }} - /> - - - {/* 日志详情抽屉 */} - setDrawerVisible(false)} - className="xx-drawer" - > - {selectedLog && ( -
-
-
时间
-
{selectedLog.timestamp}
-
- -
-
级别
-
- {selectedLog.level} -
-
- -
-
服务
-
{selectedLog.service}
-
- - {selectedLog.user && ( -
-
用户
-
{selectedLog.user}
-
- )} - -
-
操作
-
{selectedLog.action}
-
- -
-
详细信息
-
{selectedLog.details}
-
- - {selectedLog.ip && ( -
-
IP 地址
-
{selectedLog.ip}
-
- )} - - {selectedLog.request_id && ( -
-
Request ID
-
{selectedLog.request_id}
-
- )} -
- )} -
- - ); -}; - -export default LogViewer; - -export const Component = LogViewer; diff --git a/apps/web/src/pages/admin/SystemMonitor.tsx b/apps/web/src/pages/admin/SystemMonitor.tsx deleted file mode 100644 index bc20279f7..000000000 --- a/apps/web/src/pages/admin/SystemMonitor.tsx +++ /dev/null @@ -1,224 +0,0 @@ -/** - * 系统监控页面 - */ -import React, { useState, useEffect } from 'react'; -import { Card, Row, Col, Progress, Badge, Table, Tag, Button, Space } from 'antd'; -import { - CheckCircleOutlined, - CloseCircleOutlined, - SyncOutlined, - ReloadOutlined, - DatabaseOutlined, - ApiOutlined, - CloudServerOutlined, - ThunderboltOutlined, -} from '@ant-design/icons'; -import './Admin.css'; - -const SystemMonitor: React.FC = () => { - const [refreshTime, setRefreshTime] = useState(new Date()); - - // 模拟实时数据 - const [systemMetrics, setSystemMetrics] = useState({ - cpu: 35, - memory: 62, - disk: 48, - network: 28, - }); - - // 服务健康状态 - const services = [ - { name: 'API 服务', status: 'healthy', uptime: '99.98%', responseTime: '45ms' }, - { name: 'PostgreSQL', status: 'healthy', uptime: '99.99%', responseTime: '8ms' }, - { name: 'Redis', status: 'healthy', uptime: '99.97%', responseTime: '2ms' }, - { name: 'Celery Worker', status: 'healthy', uptime: '99.95%', responseTime: '-' }, - { name: 'Object Storage', status: 'warning', uptime: '99.85%', responseTime: '120ms' }, - ]; - - // API 请求统计 - const apiStats = [ - { endpoint: 'POST /api/v1/auth/login', requests: 15420, avgTime: '48ms', errors: 12 }, - { endpoint: 'GET /api/v1/projects', requests: 89340, avgTime: '32ms', errors: 5 }, - { endpoint: 'POST /api/v1/projects', requests: 6780, avgTime: '156ms', errors: 8 }, - { endpoint: 'GET /api/v1/assets', requests: 124560, avgTime: '68ms', errors: 23 }, - { endpoint: 'POST /api/v1/subscriptions/subscribe', requests: 234, avgTime: '890ms', errors: 2 }, - ]; - - // 错误日志 - const recentErrors = [ - { time: '2024-06-17 16:45:32', level: 'ERROR', service: 'API', message: 'Database connection timeout' }, - { time: '2024-06-17 16:42:15', level: 'WARN', service: 'Object Storage', message: 'Slow response detected (>1s)' }, - { time: '2024-06-17 16:38:41', level: 'ERROR', service: 'Celery', message: 'Task retry limit exceeded' }, - ]; - - const serviceColumns = [ - { - title: '服务名称', - dataIndex: 'name', - key: 'name', - render: (text: string) => <> {text}, - }, - { - title: '状态', - dataIndex: 'status', - key: 'status', - render: (status: string) => { - const config: Record = { - healthy: { color: 'success', icon: , text: '正常' }, - warning: { color: 'warning', icon: , text: '警告' }, - error: { color: 'error', icon: , text: '故障' }, - }; - const { color, text } = config[status] || config.healthy; - return ; - }, - }, - { title: '可用性', dataIndex: 'uptime', key: 'uptime' }, - { title: '响应时间', dataIndex: 'responseTime', key: 'responseTime' }, - ]; - - const apiColumns = [ - { title: 'API 端点', dataIndex: 'endpoint', key: 'endpoint' }, - { title: '请求数', dataIndex: 'requests', key: 'requests', sorter: (a: any, b: any) => a.requests - b.requests }, - { title: '平均响应时间', dataIndex: 'avgTime', key: 'avgTime' }, - { - title: '错误数', - dataIndex: 'errors', - key: 'errors', - render: (errors: number) => ( - 10 ? 'xx-tag error' : errors > 5 ? 'xx-tag warning' : 'xx-tag success'}>{errors} - ), - }, - ]; - - const errorColumns = [ - { title: '时间', dataIndex: 'time', key: 'time', width: 180 }, - { - title: '级别', - dataIndex: 'level', - key: 'level', - width: 100, - render: (level: string) => ( - {level} - ), - }, - { title: '服务', dataIndex: 'service', key: 'service', width: 120 }, - { title: '错误信息', dataIndex: 'message', key: 'message' }, - ]; - - const refreshMetrics = () => { - setSystemMetrics({ - cpu: Math.floor(Math.random() * 30) + 30, - memory: Math.floor(Math.random() * 20) + 55, - disk: Math.floor(Math.random() * 10) + 45, - network: Math.floor(Math.random() * 40) + 20, - }); - setRefreshTime(new Date()); - }; - - // 模拟实时更新 - useEffect(() => { - const interval = setInterval(refreshMetrics, 5000); - return () => clearInterval(interval); - }, []); - - const getProgressColor = (value: number) => { - if (value > 80) return '#ef4444'; - if (value > 60) return '#f59e0b'; - return '#10b981'; - }; - - const getProgressClass = (value: number) => { - if (value > 80) return 'xx-progress-warning'; - if (value > 60) return 'xx-progress-warning'; - return 'xx-progress-success'; - }; - - const resourceMetrics = [ - { key: 'cpu', label: 'CPU 使用率', value: systemMetrics.cpu, icon: , bg: 'linear-gradient(135deg, #6366f1, #4f46e5)' }, - { key: 'memory', label: '内存使用率', value: systemMetrics.memory, icon: , bg: 'linear-gradient(135deg, #34d399, #10b981)' }, - { key: 'disk', label: '磁盘使用率', value: systemMetrics.disk, icon: , bg: 'linear-gradient(135deg, #fbbf24, #f59e0b)' }, - { key: 'network', label: '网络使用率', value: systemMetrics.network, icon: , bg: 'linear-gradient(135deg, #a78bfa, #8b5cf6)' }, - ]; - - return ( -
-
-
-

系统监控

-

服务器资源、服务健康与 API 统计

-
-
- - 上次更新: {refreshTime.toLocaleTimeString()} - - -
-
- - {/* 系统资源监控 */} - - {resourceMetrics.map((metric) => ( -
-
-
- {metric.icon} -
-
{metric.label}
- -
- - ))} - - - {/* 服务健康状态 */} -
- -
- - - - {/* API 请求统计 */} -
- -
- - - - {/* 最近错误 */} -
- -
- - - - ); -}; - -export default SystemMonitor; - -export const Component = SystemMonitor; diff --git a/apps/web/src/pages/admin/UserManagement.tsx b/apps/web/src/pages/admin/UserManagement.tsx deleted file mode 100644 index 18d3ac53b..000000000 --- a/apps/web/src/pages/admin/UserManagement.tsx +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Admin 用户管理页面 - */ -import React from 'react'; -import { Table, Button, Space, Tag, Input, Card } from 'antd'; -import { SearchOutlined, LockOutlined, UnlockOutlined } from '@ant-design/icons'; -import './Admin.css'; - -const { Search } = Input; - -const UserManagement: React.FC = () => { - // 模拟数据 - const users = [ - { - id: '1', - username: 'user1', - email: 'user1@example.com', - is_email_verified: true, - status: 'active', - created_at: '2024-01-15', - }, - { - id: '2', - username: 'user2', - email: 'user2@example.com', - is_email_verified: false, - status: 'active', - created_at: '2024-02-20', - }, - ]; - - const columns = [ - { - title: '用户名', - dataIndex: 'username', - key: 'username', - }, - { - title: '邮箱', - dataIndex: 'email', - key: 'email', - }, - { - title: '邮箱验证', - dataIndex: 'is_email_verified', - key: 'is_email_verified', - render: (verified: boolean) => ( - - {verified ? '已验证' : '未验证'} - - ), - }, - { - title: '状态', - dataIndex: 'status', - key: 'status', - render: (status: string) => ( - - {status === 'active' ? '正常' : '已封禁'} - - ), - }, - { - title: '注册时间', - dataIndex: 'created_at', - key: 'created_at', - }, - { - title: '操作', - key: 'action', - render: (_: any, record: any) => ( - - - - - ), - }, - ]; - - return ( -
-
-

用户管理

-

管理系统用户与账户状态

-
- -
- -
- } - className="xx-search-input" - style={{ width: 320 }} - /> -
-
- - - - ); -}; - -export default UserManagement; - -export const Component = UserManagement; diff --git a/apps/web/src/pages/profile/AccountSecurity.tsx b/apps/web/src/pages/profile/AccountSecurity.tsx deleted file mode 100644 index 416f975e2..000000000 --- a/apps/web/src/pages/profile/AccountSecurity.tsx +++ /dev/null @@ -1,111 +0,0 @@ -/** - * 账号安全设置页面 - */ -import React from 'react'; -import { Form, Input, Button, Alert } from 'antd'; -import { LockOutlined, MailOutlined } from '@ant-design/icons'; -import './ProfileSettings.css'; - -const AccountSecurity: React.FC = () => { - const [passwordForm] = Form.useForm(); - const [emailForm] = Form.useForm(); - - const onPasswordSubmit = () => undefined; - - const onEmailSubmit = () => undefined; - - - return ( -
-
-

修改密码

- -
- - } /> - - - - } /> - - - ({ - validator(_, value) { - if (!value || getFieldValue('newPassword') === value) { - return Promise.resolve(); - } - return Promise.reject(new Error('两次输入的密码不一致')); - }, - }), - ]} - > - } /> - - - - - - -
- -
-

修改邮箱

-
- - } /> - - - - } /> - - - - - - -
-
- ); -}; - -export default AccountSecurity; - -export const Component = AccountSecurity; diff --git a/apps/web/src/pages/profile/NotificationSettings.tsx b/apps/web/src/pages/profile/NotificationSettings.tsx deleted file mode 100644 index ddf52ccec..000000000 --- a/apps/web/src/pages/profile/NotificationSettings.tsx +++ /dev/null @@ -1,96 +0,0 @@ -/** - * 通知设置页面 - */ -import React from 'react'; -import { Form, Switch, Button, Divider, Alert } from 'antd'; -import './ProfileSettings.css'; - - -const NotificationSettings: React.FC = () => { - const [form] = Form.useForm(); - - const onFinish = () => undefined; - - - return ( -
-
- -
-

邮件通知

- - - - - - -

通知类型

- - - - - - - - - - - - - - -

营销

- - - - - - - - -
-
- ); -}; - -export default NotificationSettings; - -export const Component = NotificationSettings; diff --git a/apps/web/src/pages/profile/SessionManagement.tsx b/apps/web/src/pages/profile/SessionManagement.tsx deleted file mode 100644 index 03b39126a..000000000 --- a/apps/web/src/pages/profile/SessionManagement.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import { Result } from 'antd'; -import './ProfileSettings.css'; - -const SessionManagement: React.FC = () => { - return ( -
-
- -
-
- ); -}; - -export default SessionManagement; - -export const Component = SessionManagement; diff --git a/apps/web/src/pages/workspace/WorkspaceDetail.tsx b/apps/web/src/pages/workspace/WorkspaceDetail.tsx deleted file mode 100644 index c69efc974..000000000 --- a/apps/web/src/pages/workspace/WorkspaceDetail.tsx +++ /dev/null @@ -1,196 +0,0 @@ -/** - * 工作空间详情页面 - */ -import React, { useState } from 'react'; -import { useParams, useNavigate } from 'react-router-dom'; -import { Tabs, Button, Descriptions, Card, List, Modal, Form, Input, message, Alert } from 'antd'; -import { PlusOutlined, TeamOutlined } from '@ant-design/icons'; -import { useWorkspace } from '@/hooks/useWorkspace'; -import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { createProject, getProjects } from '@/api/projects'; -import MemberList from '@/components/business/MemberList'; -import InviteMemberModal from '@/components/business/InviteMemberModal'; -import PermissionMatrix from '@/components/business/PermissionMatrix'; - -const WorkspaceDetail: React.FC = () => { - const { id } = useParams<{ id: string }>(); - const navigate = useNavigate(); - const { data: workspace, isLoading } = useWorkspace(id!); - const queryClient = useQueryClient(); - const [inviteModalOpen, setInviteModalOpen] = useState(false); - const [createProjectOpen, setCreateProjectOpen] = useState(false); - const [projectForm] = Form.useForm<{ name: string; description?: string }>(); - - const projectsQuery = useQuery({ - queryKey: ['projects', id], - queryFn: () => getProjects(), - enabled: !!id, - }); - - const createProjectMutation = useMutation({ - mutationFn: createProject, - onSuccess: (project) => { - message.success('项目创建成功'); - setCreateProjectOpen(false); - projectForm.resetFields(); - queryClient.invalidateQueries({ queryKey: ['projects', id] }); - navigate(`/projects/${project.id}/assets`, { state: { workspaceId: id } }); - }, - onError: (error: any) => { - message.error(error.response?.data?.detail || '项目创建失败,请稍后重试'); - }, - }); - - const handleCreateProject = async () => { - const values = await projectForm.validateFields(); - createProjectMutation.mutate({ - name: values.name, - description: values.description || '', - }); - }; - - if (isLoading) return
加载中...
; - if (!workspace) return
工作空间不存在
; - - const items = [ - { - key: 'overview', - label: '概览', - children: ( -
- setCreateProjectOpen(true)}> - 创建项目 - - } - > - - {workspace.name} - {workspace.subscription_plan} - {workspace.subscription_status} - - {workspace.created_at - ? new Date(workspace.created_at).toLocaleDateString() - : '暂未返回'} - - - - - - {projectsQuery.isError && ( - - )} - ( - navigate(`/projects/${project.id}/assets`, { state: { workspaceId: id } })}> - 素材管理 - , - , - , - , - , - ]} - > - - - )} - /> - - - -
- ), - }, - { - key: 'members', - label: ( - <> - 成员管理 - - ), - children: ( -
-
- -
- -
- -
-
- ), - }, - { - key: 'settings', - label: '设置', - children:
工作空间设置(待开发)
, - }, - ]; - - return ( -
-

{workspace.name}

- - setCreateProjectOpen(false)} - > -
- - - - - - - -
- setInviteModalOpen(false)} - /> -
- ); -}; - -export default WorkspaceDetail; -export const Component = WorkspaceDetail; diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 00cd71085..0bd7d8a4a 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -17,8 +17,8 @@ /* Linting */ "strict": true, - "noUnusedLocals": false, - "noUnusedParameters": false, + "noUnusedLocals": true, + "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, /* Path alias */ diff --git a/apps/worker/worker_app/tasks/generation.py b/apps/worker/worker_app/tasks/generation.py index 7dd822a2a..5bf7e4fb0 100755 --- a/apps/worker/worker_app/tasks/generation.py +++ b/apps/worker/worker_app/tasks/generation.py @@ -138,17 +138,9 @@ def _download_library_assets( # 导入模型和会话 try: from packages.adapters.sqlalchemy_impl.models import AssetModel - from sqlalchemy import create_engine - from sqlalchemy.orm import sessionmaker + from worker_app.db import SessionLocal - db_url = os.getenv("DATABASE_URL") - if not db_url: - logger.warning("DATABASE_URL not set, cannot fetch assets") - return [] - - engine = create_engine(db_url) - Session = sessionmaker(bind=engine) - session = Session() + session = SessionLocal() try: # 查询素材库中的视频素材