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