refactor: 统一代码风格并迁移至 ESLint 新配置

style(backend): 格式化模型文件代码
style(frontend): 调整组件代码格式
chore: 删除旧 ESLint 配置并添加新配置
refactor(backend): 重构模型定义语法
style: 统一箭头函数和对象属性简写
This commit is contained in:
zhang1106
2026-03-27 19:12:16 +08:00
parent 6a8d4144ff
commit 63f0cb570e
166 changed files with 15483 additions and 11170 deletions
+17 -6
View File
@@ -34,7 +34,7 @@ export const useDangerousOperation = () => {
const entityLabel = ENTITY_LABELS[entityType] || entityType;
const operationLabel = OPERATION_LABELS[operationType] || operationType;
return new Promise((resolve) => {
return new Promise(resolve => {
const modalKey = `dangerous-${Date.now()}`;
const handleOk = () => {
@@ -74,14 +74,21 @@ export const useDangerousOperation = () => {
}
description={
<Paragraph style={{ marginBottom: 0 }}>
{description || `您即将${operationLabel} ${itemCount > 1 ? `${itemCount}` : '1 个'}${entityLabel}`}
{description ||
`您即将${operationLabel} ${itemCount > 1 ? `${itemCount}` : '1 个'}${entityLabel}`}
<br />
<Text type="secondary" style={{ fontSize: 12 }}>
此操作不可逆一旦删除将无法恢复
</Text>
</Paragraph>
}
type={riskLevel === RISK_LEVEL.EXTREME ? 'error' : riskLevel === RISK_LEVEL.HIGH ? 'warning' : 'info'}
type={
riskLevel === RISK_LEVEL.EXTREME
? 'error'
: riskLevel === RISK_LEVEL.HIGH
? 'warning'
: 'info'
}
style={{
backgroundColor: config.bgColor,
borderColor: config.borderColor,
@@ -106,7 +113,11 @@ export const useDangerousOperation = () => {
<Alert
message={
<Text>
为确认此操作请输入 <Text code strong>CONFIRM</Text>
为确认此操作请输入{' '}
<Text code strong>
CONFIRM
</Text>
</Text>
}
type="error"
@@ -115,7 +126,7 @@ export const useDangerousOperation = () => {
<Input
id={`keyword-input-${modalKey}`}
placeholder="请输入 CONFIRM"
onChange={(e) => {
onChange={e => {
const inputValue = e.target.value;
const okButton = document.querySelector('.ant-modal-confirm .ant-btn-primary');
if (okButton) {
@@ -212,7 +223,7 @@ export const useDangerousOperation = () => {
return { confirm, logOperation };
};
export const confirmDangerousOperation = async (options) => {
export const confirmDangerousOperation = async options => {
const hook = useDangerousOperation();
return hook.confirm(options);
};
+1 -9
View File
@@ -119,15 +119,7 @@ const useIdleTimeout = ({
}
// 定义需要监听的事件
const events = [
'mousedown',
'mousemove',
'keydown',
'scroll',
'touchstart',
'click',
'wheel',
];
const events = ['mousedown', 'mousemove', 'keydown', 'scroll', 'touchstart', 'click', 'wheel'];
// 事件处理函数
const handleActivity = () => {
+3 -3
View File
@@ -16,7 +16,7 @@ export const SCREEN_SIZES = {
xl: 'xl',
};
const getScreenSize = (width) => {
const getScreenSize = width => {
if (width >= BREAKPOINTS.xl) return SCREEN_SIZES.xl;
if (width >= BREAKPOINTS.lg) return SCREEN_SIZES.lg;
if (width >= BREAKPOINTS.md) return SCREEN_SIZES.md;
@@ -24,7 +24,7 @@ const getScreenSize = (width) => {
return SCREEN_SIZES.xs;
};
const getScreenSizeConfig = (screenSize) => {
const getScreenSizeConfig = screenSize => {
const configs = {
xs: {
showFullButtonLabels: false,
@@ -100,4 +100,4 @@ export const useResponsiveLayout = () => {
};
};
export default useResponsiveLayout;
export default useResponsiveLayout;
+14 -11
View File
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
const extractNumberFromString = (str) => {
const extractNumberFromString = str => {
if (!str) return 0;
const match = str.match(/\d+/);
return match ? parseInt(match[0], 10) : 0;
@@ -13,7 +13,7 @@ const naturalSort = (a, b) => {
return String(a).localeCompare(String(b), 'zh-CN');
};
const sortRooms = (rooms) => {
const sortRooms = rooms => {
return [...rooms].sort((a, b) => {
const sortOrderA = a.sortOrder ?? a.sort_order ?? 0;
const sortOrderB = b.sortOrder ?? b.sort_order ?? 0;
@@ -24,7 +24,7 @@ const sortRooms = (rooms) => {
});
};
const sortRacksInRoom = (racks) => {
const sortRacksInRoom = racks => {
return [...racks].sort((a, b) => {
const sortOrderA = a.sortOrder ?? a.sort_order ?? 0;
const sortOrderB = b.sortOrder ?? b.sort_order ?? 0;
@@ -38,7 +38,7 @@ const sortRacksInRoom = (racks) => {
});
};
export const useSortedRacks = (racks) => {
export const useSortedRacks = racks => {
return useMemo(() => {
if (!racks || !Array.isArray(racks) || racks.length === 0) {
return [];
@@ -46,7 +46,7 @@ export const useSortedRacks = (racks) => {
const roomMap = new Map();
racks.forEach((rack) => {
racks.forEach(rack => {
if (!rack || !rack.Room) return;
const roomKey = rack.Room.roomId || rack.Room.id || rack.Room.name;
@@ -65,10 +65,13 @@ export const useSortedRacks = (racks) => {
const sortedRooms = sortRooms(Array.from(roomMap.values()));
sortedRooms.forEach((room) => {
sortedRooms.forEach(room => {
room.racks = sortRacksInRoom(room.racks);
room.rackCount = room.racks.length;
room.totalDevices = room.racks.reduce((sum, r) => sum + (r._count?.Devices || r.deviceCount || 0), 0);
room.totalDevices = room.racks.reduce(
(sum, r) => sum + (r._count?.Devices || r.deviceCount || 0),
0
);
});
return sortedRooms;
@@ -83,11 +86,11 @@ export const filterRoomsBySearch = (rooms, searchText) => {
const lowerSearch = searchText.toLowerCase().trim();
return rooms
.map((room) => {
.map(room => {
const roomNameMatch = room.name?.toLowerCase().includes(lowerSearch);
const roomIdMatch = room.roomId?.toLowerCase().includes(lowerSearch);
const filteredRacks = room.racks.filter((rack) => {
const filteredRacks = room.racks.filter(rack => {
const rackNameMatch = rack.name?.toLowerCase().includes(lowerSearch);
const rackIdMatch = rack.rackId?.toLowerCase().includes(lowerSearch);
return roomNameMatch || roomIdMatch || rackNameMatch || rackIdMatch;
@@ -103,7 +106,7 @@ export const filterRoomsBySearch = (rooms, searchText) => {
return null;
})
.filter((room) => room !== null);
.filter(room => room !== null);
};
export const getRackStats = (rack, devices = []) => {
@@ -123,4 +126,4 @@ export const getRackStats = (rack, devices = []) => {
};
};
export default useSortedRacks;
export default useSortedRacks;