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