seeder-st2110-components 1.0.0 → 1.0.2
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 +43 -48
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +43 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -54,14 +54,15 @@ const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
|
54
54
|
iconClass,
|
|
55
55
|
text,
|
|
56
56
|
children,
|
|
57
|
-
|
|
57
|
+
showRam,
|
|
58
|
+
ramValue
|
|
58
59
|
} = _ref;
|
|
59
60
|
const tooltipContent = useMemo(() => /*#__PURE__*/jsx(Tooltip, {
|
|
60
61
|
title: /*#__PURE__*/jsxs(Fragment, {
|
|
61
62
|
children: [/*#__PURE__*/jsx("div", {
|
|
62
63
|
children: text
|
|
63
|
-
}),
|
|
64
|
-
children: ["Total Memory: ",
|
|
64
|
+
}), showRam && /*#__PURE__*/jsxs("div", {
|
|
65
|
+
children: ["Total Memory: ", ramValue, "GB"]
|
|
65
66
|
})]
|
|
66
67
|
}),
|
|
67
68
|
destroyOnHidden: false,
|
|
@@ -86,7 +87,8 @@ const UsageItem = /*#__PURE__*/memo(_ref => {
|
|
|
86
87
|
const getTemperature = (supermicro, sensors) => {
|
|
87
88
|
return supermicro?.cpu_temperature ?? sensors?.temperatures?.coretemp?.[0]?.current;
|
|
88
89
|
};
|
|
89
|
-
const useHardwareUsage = ps_status
|
|
90
|
+
const useHardwareUsage = function (ps_status) {
|
|
91
|
+
let showRam = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
90
92
|
return useMemo(() => {
|
|
91
93
|
if (!ps_status || typeof ps_status !== 'object') return null;
|
|
92
94
|
const {
|
|
@@ -109,7 +111,8 @@ const useHardwareUsage = ps_status => {
|
|
|
109
111
|
}), mem && /*#__PURE__*/jsxs(UsageItem, {
|
|
110
112
|
text: "Memory Usage",
|
|
111
113
|
iconClass: "icon-shiyongshuai",
|
|
112
|
-
|
|
114
|
+
showRam: showRam,
|
|
115
|
+
ramValue: (mem.total / (1024 * 1024 * 1024)).toFixed(1),
|
|
113
116
|
children: [mem.percent, "%"]
|
|
114
117
|
}), supermicro?.nic_temperature && /*#__PURE__*/jsxs(UsageItem, {
|
|
115
118
|
text: "NIC Temperature",
|
|
@@ -330,68 +333,60 @@ const useUpgrade = _ref => {
|
|
|
330
333
|
const hideLoader = () => setIsSpinning(false);
|
|
331
334
|
|
|
332
335
|
// 构建菜单项 - 确保至少包含download和upload
|
|
336
|
+
// 构建菜单项 - 最终完美版本
|
|
333
337
|
const finalMenuItems = useMemo(() => {
|
|
334
338
|
const hasDownload = menuItems.some(item => item.key === 'download');
|
|
335
339
|
const hasUpload = menuItems.some(item => item.key === 'upload');
|
|
336
|
-
|
|
337
|
-
// 如果都已经存在,直接返回
|
|
338
340
|
if (hasDownload && hasUpload) {
|
|
339
341
|
return menuItems;
|
|
340
342
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// 查找license项的位置
|
|
344
|
-
const licenseIndex = finalItems.findIndex(item => item.key === 'license');
|
|
345
|
-
|
|
346
|
-
// 查找最后一个分隔符的位置(在license之前)
|
|
347
|
-
let insertIndex = finalItems.length;
|
|
348
|
-
let hasPrecedingDivider = false;
|
|
349
|
-
if (licenseIndex !== -1) {
|
|
350
|
-
// 如果找到license,在其前面插入
|
|
351
|
-
insertIndex = licenseIndex;
|
|
352
|
-
|
|
353
|
-
// 检查license前面是否有分隔符
|
|
354
|
-
if (licenseIndex > 0 && finalItems[licenseIndex - 1].type === 'divider') {
|
|
355
|
-
hasPrecedingDivider = true;
|
|
356
|
-
insertIndex = licenseIndex - 1; // 在分隔符前面插入
|
|
357
|
-
}
|
|
358
|
-
} else {
|
|
359
|
-
// 如果没有license,查找最后一个分隔符
|
|
360
|
-
const lastDividerIndex = finalItems.map((item, idx) => item.type === 'divider' ? idx : -1).filter(idx => idx !== -1).pop();
|
|
361
|
-
if (lastDividerIndex !== undefined) {
|
|
362
|
-
insertIndex = lastDividerIndex + 1;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
const itemsToInsert = [];
|
|
343
|
+
const licenseIndex = menuItems.findIndex(item => item.key === 'license');
|
|
366
344
|
|
|
367
|
-
//
|
|
368
|
-
if (
|
|
369
|
-
|
|
345
|
+
// 如果没有license,在末尾添加
|
|
346
|
+
if (licenseIndex === -1) {
|
|
347
|
+
const itemsToAdd = [];
|
|
348
|
+
if (menuItems.length > 0) itemsToAdd.push({
|
|
349
|
+
type: 'divider'
|
|
350
|
+
});
|
|
351
|
+
if (!hasDownload) itemsToAdd.push({
|
|
370
352
|
key: "download",
|
|
371
353
|
label: "Download Config File"
|
|
372
354
|
});
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
// 添加缺少的upload项
|
|
376
|
-
if (!hasUpload) {
|
|
377
|
-
itemsToInsert.push({
|
|
355
|
+
if (!hasUpload) itemsToAdd.push({
|
|
378
356
|
key: "upload",
|
|
379
357
|
label: "Software Update"
|
|
380
358
|
});
|
|
359
|
+
return [...menuItems, ...itemsToAdd];
|
|
381
360
|
}
|
|
382
361
|
|
|
383
|
-
//
|
|
384
|
-
|
|
385
|
-
|
|
362
|
+
// 有license,在license前面插入
|
|
363
|
+
const beforeLicense = menuItems.slice(0, licenseIndex);
|
|
364
|
+
const licenseItem = menuItems[licenseIndex];
|
|
365
|
+
const afterLicense = menuItems.slice(licenseIndex + 1);
|
|
366
|
+
const itemsToInsert = [];
|
|
367
|
+
|
|
368
|
+
// 1. 前面的分隔符(如果beforeLicense不为空且最后一项不是分隔符)
|
|
369
|
+
if (beforeLicense.length > 0 && beforeLicense[beforeLicense.length - 1].type !== 'divider') {
|
|
370
|
+
itemsToInsert.push({
|
|
386
371
|
type: 'divider'
|
|
387
372
|
});
|
|
388
373
|
}
|
|
389
374
|
|
|
390
|
-
//
|
|
391
|
-
if (itemsToInsert.
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
375
|
+
// 2. 添加缺少的项
|
|
376
|
+
if (!hasDownload) itemsToInsert.push({
|
|
377
|
+
key: "download",
|
|
378
|
+
label: "Download Config File"
|
|
379
|
+
});
|
|
380
|
+
if (!hasUpload) itemsToInsert.push({
|
|
381
|
+
key: "upload",
|
|
382
|
+
label: "Software Update"
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// 3. 后面的分隔符(与license之间)
|
|
386
|
+
itemsToInsert.push({
|
|
387
|
+
type: 'divider'
|
|
388
|
+
});
|
|
389
|
+
return [...beforeLicense, ...itemsToInsert, licenseItem, ...afterLicense];
|
|
395
390
|
}, [menuItems]);
|
|
396
391
|
const handleMenuClick = _ref2 => {
|
|
397
392
|
let {
|