seeder-st2110-components 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +101 -52
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +101 -52
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.esm.js
CHANGED
|
@@ -50,20 +50,28 @@ const useHardwareWebSocket = socketUrl => {
|
|
|
50
50
|
};
|
|
51
51
|
var useHardwareWebSocket$1 = useHardwareWebSocket;
|
|
52
52
|
|
|
53
|
+
const formatBytes = function (bytes) {
|
|
54
|
+
let decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
55
|
+
if (bytes === 0 || !bytes) return '0 Bytes';
|
|
56
|
+
const k = 1024;
|
|
57
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
58
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
|
59
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
60
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
61
|
+
};
|
|
53
62
|
const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
54
63
|
let {
|
|
64
|
+
title,
|
|
55
65
|
iconClass,
|
|
56
|
-
text,
|
|
57
66
|
children,
|
|
58
|
-
|
|
59
|
-
ramValue
|
|
67
|
+
memTotal
|
|
60
68
|
} = _ref;
|
|
61
|
-
|
|
69
|
+
return /*#__PURE__*/jsx(Tooltip, {
|
|
62
70
|
title: /*#__PURE__*/jsxs(Fragment, {
|
|
63
71
|
children: [/*#__PURE__*/jsx("div", {
|
|
64
|
-
children:
|
|
65
|
-
}),
|
|
66
|
-
children: ["Total Memory: ",
|
|
72
|
+
children: title
|
|
73
|
+
}), title === 'Memory Usage' && memTotal !== undefined && /*#__PURE__*/jsxs("div", {
|
|
74
|
+
children: ["Total Memory: ", formatBytes(memTotal)]
|
|
67
75
|
})]
|
|
68
76
|
}),
|
|
69
77
|
destroyOnHidden: false,
|
|
@@ -76,59 +84,100 @@ const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
|
76
84
|
children: children
|
|
77
85
|
})]
|
|
78
86
|
})
|
|
79
|
-
}), [text, iconClass, children]);
|
|
80
|
-
return /*#__PURE__*/jsxs(Flex, {
|
|
81
|
-
align: "center",
|
|
82
|
-
children: [tooltipContent, /*#__PURE__*/jsx(Divider, {
|
|
83
|
-
type: "vertical"
|
|
84
|
-
})]
|
|
85
87
|
});
|
|
86
88
|
});
|
|
87
89
|
var UsageItem$1 = UsageItem;
|
|
88
90
|
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
+
const getMaxNicTemp = function (sensors) {
|
|
92
|
+
let priorityFields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ["i350bb", "r8169_0_8300:00"];
|
|
93
|
+
const temps = priorityFields.flatMap(field => sensors?.[field]?.map(item => item.current) || []).filter(temp => typeof temp === 'number');
|
|
94
|
+
return temps.length ? Math.max(...temps) : null;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// 获取数组类型传感器最高温度(如内存、硬盘)
|
|
98
|
+
const getMaxSensorTemp = sensorData => {
|
|
99
|
+
const temps = (sensorData || []).map(item => item.current).filter(temp => typeof temp === 'number');
|
|
100
|
+
return temps.length ? Math.max(...temps) : null;
|
|
101
|
+
};
|
|
102
|
+
const getDetail = function () {
|
|
103
|
+
let status = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
104
|
+
const {
|
|
105
|
+
cpu_percent,
|
|
106
|
+
mem,
|
|
107
|
+
sensors_temperatures,
|
|
108
|
+
gpu_stats
|
|
109
|
+
} = status;
|
|
110
|
+
return {
|
|
111
|
+
cpu_usage: cpu_percent ?? null,
|
|
112
|
+
cpu_temp: sensors_temperatures?.coretemp?.[0]?.current ?? null,
|
|
113
|
+
mem_total: mem?.total ?? null,
|
|
114
|
+
mem_usage: mem?.percent ?? null,
|
|
115
|
+
mem_temp: getMaxSensorTemp(sensors_temperatures?.spd5118),
|
|
116
|
+
nic_temp: getMaxNicTemp(sensors_temperatures) ?? null,
|
|
117
|
+
hd_temp: getMaxSensorTemp(sensors_temperatures?.nvme),
|
|
118
|
+
gpu_usage: gpu_stats?.[0]?.["utilization.gpu"] ?? null,
|
|
119
|
+
gpu_temp: gpu_stats?.[0]?.["temperature.gpu"] ?? null
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// 提取公共逻辑
|
|
124
|
+
const createMetricItem = (title, iconClass, value, unit) => {
|
|
125
|
+
const numValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
126
|
+
return {
|
|
127
|
+
title,
|
|
128
|
+
iconClass,
|
|
129
|
+
valueString: `${numValue}${unit}`,
|
|
130
|
+
value: numValue
|
|
131
|
+
};
|
|
91
132
|
};
|
|
92
|
-
const
|
|
93
|
-
|
|
133
|
+
const getItems = details => {
|
|
134
|
+
const items = [];
|
|
135
|
+
if (details.cpu_usage !== null && details.cpu_usage !== undefined) {
|
|
136
|
+
items.push(createMetricItem('CPU Usage', 'icon-CPU', details.cpu_usage, '%'));
|
|
137
|
+
}
|
|
138
|
+
if (details.cpu_temp !== null && details.cpu_temp !== undefined) {
|
|
139
|
+
items.push(createMetricItem('CPU Temperature', 'icon-CPUwendu', details.cpu_temp, '℃'));
|
|
140
|
+
}
|
|
141
|
+
if (details.mem_usage !== null && details.mem_usage !== undefined) {
|
|
142
|
+
items.push({
|
|
143
|
+
...createMetricItem('Memory Usage', 'icon-shiyongshuai', details.mem_usage, '%'),
|
|
144
|
+
memTotal: details.mem_total
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
if (details.mem_temp !== null && details.mem_temp !== undefined) {
|
|
148
|
+
items.push(createMetricItem('Memory Temperature', 'icon-wendu', details.mem_temp, '℃'));
|
|
149
|
+
}
|
|
150
|
+
if (details.nic_temp !== null && details.nic_temp !== undefined) {
|
|
151
|
+
items.push(createMetricItem('NIC Temperature', 'icon-wuliwangka', details.nic_temp, '℃'));
|
|
152
|
+
}
|
|
153
|
+
if (details.hd_temp !== null && details.hd_temp !== undefined) {
|
|
154
|
+
items.push(createMetricItem('HD Temperature', 'icon-yingpan', details.hd_temp, '℃'));
|
|
155
|
+
}
|
|
156
|
+
if (details.gpu_usage !== null && details.gpu_usage !== undefined) {
|
|
157
|
+
items.push(createMetricItem('GPU Usage', 'icon-gpufuwu', details.gpu_usage, '%'));
|
|
158
|
+
}
|
|
159
|
+
if (details.gpu_temp !== null && details.gpu_temp !== undefined) {
|
|
160
|
+
items.push(createMetricItem('GPU Temperature', 'icon-CPUwendu', details.gpu_temp, '℃'));
|
|
161
|
+
}
|
|
162
|
+
return items;
|
|
163
|
+
};
|
|
164
|
+
const useHardwareUsage = ps_status => {
|
|
94
165
|
return useMemo(() => {
|
|
95
166
|
if (!ps_status || typeof ps_status !== 'object') return null;
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
sensors_temperatures,
|
|
99
|
-
mem,
|
|
100
|
-
gpu_stats,
|
|
101
|
-
supermicro
|
|
102
|
-
} = ps_status;
|
|
103
|
-
return /*#__PURE__*/jsxs("div", {
|
|
167
|
+
const statusItems = getItems(getDetail(ps_status));
|
|
168
|
+
return /*#__PURE__*/jsx("div", {
|
|
104
169
|
className: "flex",
|
|
105
|
-
children:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
showRam: showRam,
|
|
117
|
-
ramValue: (mem.total / (1024 * 1024 * 1024)).toFixed(1),
|
|
118
|
-
children: [mem.percent, "%"]
|
|
119
|
-
}), supermicro?.nic_temperature && /*#__PURE__*/jsxs(UsageItem$1, {
|
|
120
|
-
text: "NIC Temperature",
|
|
121
|
-
iconClass: "icon-wuliwangka",
|
|
122
|
-
children: [supermicro.nic_temperature, "\u2103"]
|
|
123
|
-
}), gpu_stats?.length > 0 && /*#__PURE__*/jsx(UsageItem$1, {
|
|
124
|
-
text: "GPU Usage",
|
|
125
|
-
iconClass: "icon-gpufuwu",
|
|
126
|
-
children: gpu_stats[0]["utilization.gpu"]
|
|
127
|
-
}), supermicro?.gpu_temperature && /*#__PURE__*/jsxs(UsageItem$1, {
|
|
128
|
-
text: "GPU Temperature",
|
|
129
|
-
iconClass: "icon-wendu",
|
|
130
|
-
children: [supermicro.gpu_temperature, "\u2103"]
|
|
131
|
-
})]
|
|
170
|
+
children: statusItems.map((item, index) => /*#__PURE__*/jsxs(Flex, {
|
|
171
|
+
align: "center",
|
|
172
|
+
children: [/*#__PURE__*/jsx(UsageItem$1, {
|
|
173
|
+
title: item.title,
|
|
174
|
+
iconClass: item.iconClass,
|
|
175
|
+
memTotal: item.memTotal,
|
|
176
|
+
children: item.valueString
|
|
177
|
+
}), index < statusItems.length - 1 && /*#__PURE__*/jsx(Divider, {
|
|
178
|
+
type: "vertical"
|
|
179
|
+
})]
|
|
180
|
+
}, item.title))
|
|
132
181
|
});
|
|
133
182
|
}, [ps_status]);
|
|
134
183
|
};
|