refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
This commit is contained in:
@@ -6,7 +6,7 @@ const AnimatedCounter = ({ value, duration = 1500 }) => {
|
||||
const startTimeRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const animate = (currentTime) => {
|
||||
const animate = currentTime => {
|
||||
if (!startTimeRef.current) {
|
||||
startTimeRef.current = currentTime;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { designTokens } from '../../config/theme';
|
||||
|
||||
const DeviceTrendChart = ({ data }) => {
|
||||
const maxValue = Math.max(...data.map((d) => d.value));
|
||||
const maxValue = Math.max(...data.map(d => d.value));
|
||||
const chartHeight = 120;
|
||||
|
||||
return (
|
||||
|
||||
@@ -72,7 +72,7 @@ const createNavButtonStyle = (color, isHovered) => ({
|
||||
minWidth: 0,
|
||||
});
|
||||
|
||||
const createNavIconContainer = (color) => ({
|
||||
const createNavIconContainer = color => ({
|
||||
width: 'clamp(44px, 10vw, 60px)',
|
||||
height: 'clamp(44px, 10vw, 60px)',
|
||||
borderRadius: designTokens.borderRadius.medium,
|
||||
@@ -117,7 +117,7 @@ const NavigationGrid = ({ hoveredCard, onHover }) => {
|
||||
className="nav-button"
|
||||
style={{
|
||||
...createNavButtonStyle(color, isHovered),
|
||||
animationDelay: `${NAV_BUTTONS_DATA.findIndex((b) => b.key === key) * 0.1}s`,
|
||||
animationDelay: `${NAV_BUTTONS_DATA.findIndex(b => b.key === key) * 0.1}s`,
|
||||
}}
|
||||
onMouseEnter={() => onHover(`nav-${key}`)}
|
||||
onMouseLeave={() => onHover(null)}
|
||||
|
||||
@@ -17,9 +17,8 @@ const quickStatItemStyle = {
|
||||
};
|
||||
|
||||
const QuickStats = ({ onlineRate, powerUsage, totalMaxPower }) => {
|
||||
const powerUsagePercent = totalMaxPower > 0
|
||||
? ((powerUsage / totalMaxPower) * 100).toFixed(1)
|
||||
: '0.0';
|
||||
const powerUsagePercent =
|
||||
totalMaxPower > 0 ? ((powerUsage / totalMaxPower) * 100).toFixed(1) : '0.0';
|
||||
|
||||
const quickStats = [
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ArrowUpOutlined, ArrowDownOutlined } from '@ant-design/icons';
|
||||
import { designTokens } from '../../config/theme';
|
||||
import AnimatedCounter from './AnimatedCounter';
|
||||
|
||||
const createStatCardStyle = (color) => ({
|
||||
const createStatCardStyle = color => ({
|
||||
borderRadius: designTokens.borderRadius.large,
|
||||
border: 'none',
|
||||
boxShadow: designTokens.shadows.medium,
|
||||
@@ -17,7 +17,7 @@ const createStatCardStyle = (color) => ({
|
||||
borderLeft: `4px solid ${color}`,
|
||||
});
|
||||
|
||||
const createStatIconContainer = (color) => ({
|
||||
const createStatIconContainer = color => ({
|
||||
width: 'clamp(40px, 8vw, 64px)',
|
||||
height: 'clamp(40px, 8vw, 64px)',
|
||||
borderRadius: designTokens.borderRadius.medium,
|
||||
@@ -30,14 +30,7 @@ const createStatIconContainer = (color) => ({
|
||||
background: `linear-gradient(135deg, ${color}20 0%, ${color}10 100%)`,
|
||||
});
|
||||
|
||||
const StatCard = ({
|
||||
config,
|
||||
stats,
|
||||
loading,
|
||||
animatedKey,
|
||||
hoveredCard,
|
||||
onHover,
|
||||
}) => {
|
||||
const StatCard = ({ config, stats, loading, animatedKey, hoveredCard, onHover }) => {
|
||||
const {
|
||||
icon: Icon,
|
||||
color,
|
||||
@@ -143,7 +136,8 @@ const StatCard = ({
|
||||
alignItems: 'center',
|
||||
fontSize: 'clamp(0.7rem, 1.8vw, 0.875rem)',
|
||||
fontWeight: '500',
|
||||
color: trend > 0 ? designTokens.colors.success.main : designTokens.colors.error.main,
|
||||
color:
|
||||
trend > 0 ? designTokens.colors.success.main : designTokens.colors.error.main,
|
||||
flexWrap: 'wrap',
|
||||
gap: '4px',
|
||||
}}
|
||||
|
||||
@@ -6,10 +6,26 @@ const { Text } = Typography;
|
||||
|
||||
const StatusLegend = ({ deviceStatusPercentages }) => {
|
||||
const legends = [
|
||||
{ color: designTokens.colors.success.main, label: '运行中', percent: deviceStatusPercentages?.running ?? 0 },
|
||||
{ color: designTokens.colors.warning.main, label: '维护中', percent: deviceStatusPercentages?.maintenance ?? 0 },
|
||||
{ color: designTokens.colors.error.main, label: '故障', percent: deviceStatusPercentages?.fault ?? 0 },
|
||||
{ color: designTokens.colors.primary.main, label: '离线', percent: deviceStatusPercentages?.offline ?? 0 },
|
||||
{
|
||||
color: designTokens.colors.success.main,
|
||||
label: '运行中',
|
||||
percent: deviceStatusPercentages?.running ?? 0,
|
||||
},
|
||||
{
|
||||
color: designTokens.colors.warning.main,
|
||||
label: '维护中',
|
||||
percent: deviceStatusPercentages?.maintenance ?? 0,
|
||||
},
|
||||
{
|
||||
color: designTokens.colors.error.main,
|
||||
label: '故障',
|
||||
percent: deviceStatusPercentages?.fault ?? 0,
|
||||
},
|
||||
{
|
||||
color: designTokens.colors.primary.main,
|
||||
label: '离线',
|
||||
percent: deviceStatusPercentages?.offline ?? 0,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user