seeder-st2110-components 1.0.0 → 1.0.1
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 +35 -43
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +35 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -332,68 +332,60 @@ const useUpgrade = _ref => {
|
|
|
332
332
|
const hideLoader = () => setIsSpinning(false);
|
|
333
333
|
|
|
334
334
|
// 构建菜单项 - 确保至少包含download和upload
|
|
335
|
+
// 构建菜单项 - 最终完美版本
|
|
335
336
|
const finalMenuItems = react.useMemo(() => {
|
|
336
337
|
const hasDownload = menuItems.some(item => item.key === 'download');
|
|
337
338
|
const hasUpload = menuItems.some(item => item.key === 'upload');
|
|
338
|
-
|
|
339
|
-
// 如果都已经存在,直接返回
|
|
340
339
|
if (hasDownload && hasUpload) {
|
|
341
340
|
return menuItems;
|
|
342
341
|
}
|
|
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 = [];
|
|
342
|
+
const licenseIndex = menuItems.findIndex(item => item.key === 'license');
|
|
368
343
|
|
|
369
|
-
//
|
|
370
|
-
if (
|
|
371
|
-
|
|
344
|
+
// 如果没有license,在末尾添加
|
|
345
|
+
if (licenseIndex === -1) {
|
|
346
|
+
const itemsToAdd = [];
|
|
347
|
+
if (menuItems.length > 0) itemsToAdd.push({
|
|
348
|
+
type: 'divider'
|
|
349
|
+
});
|
|
350
|
+
if (!hasDownload) itemsToAdd.push({
|
|
372
351
|
key: "download",
|
|
373
352
|
label: "Download Config File"
|
|
374
353
|
});
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
// 添加缺少的upload项
|
|
378
|
-
if (!hasUpload) {
|
|
379
|
-
itemsToInsert.push({
|
|
354
|
+
if (!hasUpload) itemsToAdd.push({
|
|
380
355
|
key: "upload",
|
|
381
356
|
label: "Software Update"
|
|
382
357
|
});
|
|
358
|
+
return [...menuItems, ...itemsToAdd];
|
|
383
359
|
}
|
|
384
360
|
|
|
385
|
-
//
|
|
386
|
-
|
|
387
|
-
|
|
361
|
+
// 有license,在license前面插入
|
|
362
|
+
const beforeLicense = menuItems.slice(0, licenseIndex);
|
|
363
|
+
const licenseItem = menuItems[licenseIndex];
|
|
364
|
+
const afterLicense = menuItems.slice(licenseIndex + 1);
|
|
365
|
+
const itemsToInsert = [];
|
|
366
|
+
|
|
367
|
+
// 1. 前面的分隔符(如果beforeLicense不为空且最后一项不是分隔符)
|
|
368
|
+
if (beforeLicense.length > 0 && beforeLicense[beforeLicense.length - 1].type !== 'divider') {
|
|
369
|
+
itemsToInsert.push({
|
|
388
370
|
type: 'divider'
|
|
389
371
|
});
|
|
390
372
|
}
|
|
391
373
|
|
|
392
|
-
//
|
|
393
|
-
if (itemsToInsert.
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
374
|
+
// 2. 添加缺少的项
|
|
375
|
+
if (!hasDownload) itemsToInsert.push({
|
|
376
|
+
key: "download",
|
|
377
|
+
label: "Download Config File"
|
|
378
|
+
});
|
|
379
|
+
if (!hasUpload) itemsToInsert.push({
|
|
380
|
+
key: "upload",
|
|
381
|
+
label: "Software Update"
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
// 3. 后面的分隔符(与license之间)
|
|
385
|
+
itemsToInsert.push({
|
|
386
|
+
type: 'divider'
|
|
387
|
+
});
|
|
388
|
+
return [...beforeLicense, ...itemsToInsert, licenseItem, ...afterLicense];
|
|
397
389
|
}, [menuItems]);
|
|
398
390
|
const handleMenuClick = _ref2 => {
|
|
399
391
|
let {
|